@abstractframework/continuum 0.5.0 → 0.6.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 (67) hide show
  1. package/README.md +11 -4
  2. package/dist/assets/{abnfDiagram-VRR7QNED-E9lbmtBV.js → abnfDiagram-VRR7QNED-DUoj6rgR.js} +2 -2
  3. package/dist/assets/{arc-XVGGKtJ-.js → arc-I6yCEc-n.js} +2 -2
  4. package/dist/assets/{architectureDiagram-ZJ3FMSHR-GRV2Ej0c.js → architectureDiagram-ZJ3FMSHR-DJYsy6Ke.js} +2 -2
  5. package/dist/assets/{blockDiagram-677ZJIJ3-Dz8wPMHC.js → blockDiagram-677ZJIJ3-BjB9Abvu.js} +2 -2
  6. package/dist/assets/{c4Diagram-LMCZKHZV-CAHne5Am.js → c4Diagram-LMCZKHZV-DiukFpvk.js} +2 -2
  7. package/dist/assets/channel-CsGWNVeB.js +2 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-DFXMgoy3.js → chunk-2Q5K7J3B-Bzj3nCUE.js} +2 -2
  9. package/dist/assets/{chunk-32BRIVSS-D9T7Whin.js → chunk-32BRIVSS-P-cd15lV.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-D8jr-VV1.js → chunk-5VM5RSS4-C926qres.js} +2 -2
  11. package/dist/assets/{chunk-EX3LRPZG-BSkCDWzU.js → chunk-EX3LRPZG-D-8MH237.js} +2 -2
  12. package/dist/assets/{chunk-JWPE2WC7-iYmSeuV1.js → chunk-JWPE2WC7-xesmSJf_.js} +2 -2
  13. package/dist/assets/{chunk-MOJQB5TN-BxgBSbz5.js → chunk-MOJQB5TN-Cur1aPrT.js} +2 -2
  14. package/dist/assets/{chunk-RYQCIY6F-D5JkyQAc.js → chunk-RYQCIY6F-BVTILQCf.js} +2 -2
  15. package/dist/assets/{chunk-V7JOEXUC-B_6OmmFi.js → chunk-V7JOEXUC-DH8DqqLP.js} +2 -2
  16. package/dist/assets/{chunk-VR4S4FIN-BsoDEIUS.js → chunk-VR4S4FIN-DONA5ZQE.js} +2 -2
  17. package/dist/assets/{chunk-XXDRQBXY-DG-goPoO.js → chunk-XXDRQBXY-Cj5h3H9W.js} +2 -2
  18. package/dist/assets/classDiagram-OUVF2IWQ-BRgLg1Zt.js +2 -0
  19. package/dist/assets/classDiagram-v2-EOCWNBFH-BRgLg1Zt.js +2 -0
  20. package/dist/assets/{cose-bilkent-JH36ORCC-C95YoC9P.js → cose-bilkent-JH36ORCC-DPp5nz7X.js} +2 -2
  21. package/dist/assets/{cynefin-VYW2F7L2-A7Vh09t2.js → cynefin-VYW2F7L2-Cb1VDqjx.js} +2 -2
  22. package/dist/assets/{cynefinDiagram-TSTJHNR4-BI8-04G-.js → cynefinDiagram-TSTJHNR4-BkVCVAKN.js} +2 -2
  23. package/dist/assets/{dagre-VKFMJZFB-owAzFOdh.js → dagre-VKFMJZFB-C69yqHLO.js} +2 -2
  24. package/dist/assets/{diagram-FQU43EPY-B8FPxd72.js → diagram-FQU43EPY-Cu2AB9_p.js} +2 -2
  25. package/dist/assets/{diagram-G47NLZAW-CwooMJF9.js → diagram-G47NLZAW-CxoS06le.js} +2 -2
  26. package/dist/assets/{diagram-NH7WQ7WH-Cr-bMH-G.js → diagram-NH7WQ7WH-BfWvQlGK.js} +2 -2
  27. package/dist/assets/{diagram-OA4YK3LP-3rHTMgXR.js → diagram-OA4YK3LP-BT4lqaBM.js} +2 -2
  28. package/dist/assets/{diagram-WEI45ONY-BG4PjrBn.js → diagram-WEI45ONY-DzN57p-J.js} +2 -2
  29. package/dist/assets/{ebnfDiagram-CCIWWBDH-B6uukG4X.js → ebnfDiagram-CCIWWBDH-DENI1vQm.js} +2 -2
  30. package/dist/assets/{erDiagram-Q63AITRT-D3OgqYHT.js → erDiagram-Q63AITRT-D0Xg--j1.js} +2 -2
  31. package/dist/assets/{flowDiagram-23GEKE2U-CxTaDERr.js → flowDiagram-23GEKE2U-V_z3dBhe.js} +2 -2
  32. package/dist/assets/{ganttDiagram-NO4QXBWP-CN7iAeQh.js → ganttDiagram-NO4QXBWP-9QKS4cRZ.js} +2 -2
  33. package/dist/assets/{gitGraphDiagram-IHSO6WYX-DbvcWmmM.js → gitGraphDiagram-IHSO6WYX-DfBBOfgk.js} +2 -2
  34. package/dist/assets/index-C_TjOHlB.css +1 -0
  35. package/dist/assets/index-SU9S3HCp.js +122 -0
  36. package/dist/assets/{infoDiagram-FWYZ7A6U-DX4NPNgR.js → infoDiagram-FWYZ7A6U-2PxB9AEr.js} +2 -2
  37. package/dist/assets/{ishikawaDiagram-FXEZZL3T-DtL3v287.js → ishikawaDiagram-FXEZZL3T-BPs88htZ.js} +2 -2
  38. package/dist/assets/{journeyDiagram-5HDEW3XC-CtAZFiGl.js → journeyDiagram-5HDEW3XC-D59tgM9D.js} +2 -2
  39. package/dist/assets/{kanban-definition-HUTT4EX6-CvrCkrKt.js → kanban-definition-HUTT4EX6-MfmvVLTi.js} +2 -2
  40. package/dist/assets/{linear-CbLBdTPp.js → linear-DUi9ti0c.js} +2 -2
  41. package/dist/assets/{mermaid.core-zt0bcQ8D.js → mermaid.core-i20J3FaS.js} +5 -5
  42. package/dist/assets/{mindmap-definition-LN4V7U3C-DU-r_mE6.js → mindmap-definition-LN4V7U3C-D2Q7oe5w.js} +2 -2
  43. package/dist/assets/{pegDiagram-2B236MQR-CoiPuGzc.js → pegDiagram-2B236MQR-CNmY3KTl.js} +2 -2
  44. package/dist/assets/{pieDiagram-ENE6RG2P-ClUZORQg.js → pieDiagram-ENE6RG2P-Ch2esIfg.js} +2 -2
  45. package/dist/assets/{quadrantDiagram-ABIIQ3AL-D0i0p2xo.js → quadrantDiagram-ABIIQ3AL-CJHDjhnh.js} +2 -2
  46. package/dist/assets/{railroadDiagram-RFXS5EU6-wI6Hdpa5.js → railroadDiagram-RFXS5EU6-C_mgIhjT.js} +2 -2
  47. package/dist/assets/{requirementDiagram-TGXJPOKE-Bm4qvEra.js → requirementDiagram-TGXJPOKE-C-tQSD22.js} +2 -2
  48. package/dist/assets/{sankeyDiagram-HTMAVEWB-DX8is9uB.js → sankeyDiagram-HTMAVEWB-D2zvcJ4r.js} +2 -2
  49. package/dist/assets/{sequenceDiagram-DBY2YBRQ-5RpIQiJh.js → sequenceDiagram-DBY2YBRQ-CI0liPpW.js} +2 -2
  50. package/dist/assets/{sizeCapture-X5ZJPWSS-ChX6cFSk.js → sizeCapture-X5ZJPWSS-8-Z0Kdmg.js} +2 -2
  51. package/dist/assets/{stateDiagram-2N3HPSRC-Tea20pcW.js → stateDiagram-2N3HPSRC-D335WS9r.js} +2 -2
  52. package/dist/assets/stateDiagram-v2-6OUMAXLB-DnoX14wc.js +2 -0
  53. package/dist/assets/{swimlanes-5IMT3BWC-BY7gSBH7.js → swimlanes-5IMT3BWC-BO-KsJgL.js} +3 -3
  54. package/dist/assets/swimlanesDiagram-G3AALYLV-DIwiFP1r.js +9 -0
  55. package/dist/assets/{timeline-definition-FHXFAJF6-Bq52M8-r.js → timeline-definition-FHXFAJF6-BuN-EhNZ.js} +2 -2
  56. package/dist/assets/{vennDiagram-L72KCM5P-BGBcMmhw.js → vennDiagram-L72KCM5P-CeZevnKl.js} +2 -2
  57. package/dist/assets/{wardleyDiagram-EHGQE667-T3JqsmMn.js → wardleyDiagram-EHGQE667-D7kBjKl4.js} +2 -2
  58. package/dist/assets/{xychartDiagram-FW5EYKEG-B0yTh8-d.js → xychartDiagram-FW5EYKEG-D7uR7Ic7.js} +2 -2
  59. package/dist/index.html +2 -2
  60. package/package.json +3 -3
  61. package/dist/assets/channel-BbrZydfX.js +0 -2
  62. package/dist/assets/classDiagram-OUVF2IWQ-BvV49U6G.js +0 -2
  63. package/dist/assets/classDiagram-v2-EOCWNBFH-BvV49U6G.js +0 -2
  64. package/dist/assets/index-Ca1Qebcu.js +0 -121
  65. package/dist/assets/index-fh60G2KG.css +0 -1
  66. package/dist/assets/stateDiagram-v2-6OUMAXLB-CCBRDLbX.js +0 -2
  67. package/dist/assets/swimlanesDiagram-G3AALYLV-Dtz4rZCK.js +0 -9
@@ -1,121 +0,0 @@
1
- var Cp=Object.defineProperty;var $p=(a,s,r)=>s in a?Cp(a,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[s]=r;var Rr=(a,s,r)=>$p(a,typeof s!="symbol"?s+"":s,r);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&l(h)}).observe(document,{childList:!0,subtree:!0});function r(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(c){if(c.ep)return;c.ep=!0;const d=r(c);fetch(c.href,d)}})();function Ep(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var vu={exports:{}},kl={},yu={exports:{}},ft={};/**
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 Vm;function Tp(){if(Vm)return ft;Vm=1;var a=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),h=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),x=Symbol.iterator;function N(w){return w===null||typeof w!="object"?null:(w=x&&w[x]||w["@@iterator"],typeof w=="function"?w:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},I=Object.assign,C={};function M(w,L,X){this.props=w,this.context=L,this.refs=C,this.updater=X||E}M.prototype.isReactComponent={},M.prototype.setState=function(w,L){if(typeof w!="object"&&typeof w!="function"&&w!=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,w,L,"setState")},M.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function O(){}O.prototype=M.prototype;function D(w,L,X){this.props=w,this.context=L,this.refs=C,this.updater=X||E}var F=D.prototype=new O;F.constructor=D,I(F,M.prototype),F.isPureReactComponent=!0;var H=Array.isArray,$=Object.prototype.hasOwnProperty,ae={current:null},fe={key:!0,ref:!0,__self:!0,__source:!0};function oe(w,L,X){var ge,de={},P=null,je=null;if(L!=null)for(ge in L.ref!==void 0&&(je=L.ref),L.key!==void 0&&(P=""+L.key),L)$.call(L,ge)&&!fe.hasOwnProperty(ge)&&(de[ge]=L[ge]);var Ae=arguments.length-2;if(Ae===1)de.children=X;else if(1<Ae){for(var Fe=Array(Ae),Ve=0;Ve<Ae;Ve++)Fe[Ve]=arguments[Ve+2];de.children=Fe}if(w&&w.defaultProps)for(ge in Ae=w.defaultProps,Ae)de[ge]===void 0&&(de[ge]=Ae[ge]);return{$$typeof:a,type:w,key:P,ref:je,props:de,_owner:ae.current}}function Ne(w,L){return{$$typeof:a,type:w.type,key:L,ref:w.ref,props:w.props,_owner:w._owner}}function Me(w){return typeof w=="object"&&w!==null&&w.$$typeof===a}function be(w){var L={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(X){return L[X]})}var ye=/\/+/g;function ue(w,L){return typeof w=="object"&&w!==null&&w.key!=null?be(""+w.key):L.toString(36)}function q(w,L,X,ge,de){var P=typeof w;(P==="undefined"||P==="boolean")&&(w=null);var je=!1;if(w===null)je=!0;else switch(P){case"string":case"number":je=!0;break;case"object":switch(w.$$typeof){case a:case s:je=!0}}if(je)return je=w,de=de(je),w=ge===""?"."+ue(je,0):ge,H(de)?(X="",w!=null&&(X=w.replace(ye,"$&/")+"/"),q(de,L,X,"",function(Ve){return Ve})):de!=null&&(Me(de)&&(de=Ne(de,X+(!de.key||je&&je.key===de.key?"":(""+de.key).replace(ye,"$&/")+"/")+w)),L.push(de)),1;if(je=0,ge=ge===""?".":ge+":",H(w))for(var Ae=0;Ae<w.length;Ae++){P=w[Ae];var Fe=ge+ue(P,Ae);je+=q(P,L,X,Fe,de)}else if(Fe=N(w),typeof Fe=="function")for(w=Fe.call(w),Ae=0;!(P=w.next()).done;)P=P.value,Fe=ge+ue(P,Ae++),je+=q(P,L,X,Fe,de);else if(P==="object")throw L=String(w),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.");return je}function R(w,L,X){if(w==null)return w;var ge=[],de=0;return q(w,ge,"","",function(P){return L.call(X,P,de++)}),ge}function V(w){if(w._status===-1){var L=w._result;L=L(),L.then(function(X){(w._status===0||w._status===-1)&&(w._status=1,w._result=X)},function(X){(w._status===0||w._status===-1)&&(w._status=2,w._result=X)}),w._status===-1&&(w._status=0,w._result=L)}if(w._status===1)return w._result.default;throw w._result}var ne={current:null},Y={transition:null},me={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:Y,ReactCurrentOwner:ae};function A(){throw Error("act(...) is not supported in production builds of React.")}return ft.Children={map:R,forEach:function(w,L,X){R(w,function(){L.apply(this,arguments)},X)},count:function(w){var L=0;return R(w,function(){L++}),L},toArray:function(w){return R(w,function(L){return L})||[]},only:function(w){if(!Me(w))throw Error("React.Children.only expected to receive a single React element child.");return w}},ft.Component=M,ft.Fragment=r,ft.Profiler=c,ft.PureComponent=D,ft.StrictMode=l,ft.Suspense=_,ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=me,ft.act=A,ft.cloneElement=function(w,L,X){if(w==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+w+".");var ge=I({},w.props),de=w.key,P=w.ref,je=w._owner;if(L!=null){if(L.ref!==void 0&&(P=L.ref,je=ae.current),L.key!==void 0&&(de=""+L.key),w.type&&w.type.defaultProps)var Ae=w.type.defaultProps;for(Fe in L)$.call(L,Fe)&&!fe.hasOwnProperty(Fe)&&(ge[Fe]=L[Fe]===void 0&&Ae!==void 0?Ae[Fe]:L[Fe])}var Fe=arguments.length-2;if(Fe===1)ge.children=X;else if(1<Fe){Ae=Array(Fe);for(var Ve=0;Ve<Fe;Ve++)Ae[Ve]=arguments[Ve+2];ge.children=Ae}return{$$typeof:a,type:w.type,key:de,ref:P,props:ge,_owner:je}},ft.createContext=function(w){return w={$$typeof:h,_currentValue:w,_currentValue2:w,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},w.Provider={$$typeof:d,_context:w},w.Consumer=w},ft.createElement=oe,ft.createFactory=function(w){var L=oe.bind(null,w);return L.type=w,L},ft.createRef=function(){return{current:null}},ft.forwardRef=function(w){return{$$typeof:p,render:w}},ft.isValidElement=Me,ft.lazy=function(w){return{$$typeof:b,_payload:{_status:-1,_result:w},_init:V}},ft.memo=function(w,L){return{$$typeof:y,type:w,compare:L===void 0?null:L}},ft.startTransition=function(w){var L=Y.transition;Y.transition={};try{w()}finally{Y.transition=L}},ft.unstable_act=A,ft.useCallback=function(w,L){return ne.current.useCallback(w,L)},ft.useContext=function(w){return ne.current.useContext(w)},ft.useDebugValue=function(){},ft.useDeferredValue=function(w){return ne.current.useDeferredValue(w)},ft.useEffect=function(w,L){return ne.current.useEffect(w,L)},ft.useId=function(){return ne.current.useId()},ft.useImperativeHandle=function(w,L,X){return ne.current.useImperativeHandle(w,L,X)},ft.useInsertionEffect=function(w,L){return ne.current.useInsertionEffect(w,L)},ft.useLayoutEffect=function(w,L){return ne.current.useLayoutEffect(w,L)},ft.useMemo=function(w,L){return ne.current.useMemo(w,L)},ft.useReducer=function(w,L,X){return ne.current.useReducer(w,L,X)},ft.useRef=function(w){return ne.current.useRef(w)},ft.useState=function(w){return ne.current.useState(w)},ft.useSyncExternalStore=function(w,L,X){return ne.current.useSyncExternalStore(w,L,X)},ft.useTransition=function(){return ne.current.useTransition()},ft.version="18.3.1",ft}var Gm;function ld(){return Gm||(Gm=1,yu.exports=Tp()),yu.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 Km;function Ap(){if(Km)return kl;Km=1;var a=ld(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function h(p,_,y){var b,x={},N=null,E=null;y!==void 0&&(N=""+y),_.key!==void 0&&(N=""+_.key),_.ref!==void 0&&(E=_.ref);for(b in _)l.call(_,b)&&!d.hasOwnProperty(b)&&(x[b]=_[b]);if(p&&p.defaultProps)for(b in _=p.defaultProps,_)x[b]===void 0&&(x[b]=_[b]);return{$$typeof:s,type:p,key:N,ref:E,props:x,_owner:c.current}}return kl.Fragment=r,kl.jsx=h,kl.jsxs=h,kl}var Qm;function Rp(){return Qm||(Qm=1,vu.exports=Ap()),vu.exports}var e=Rp(),f=ld();const Wt=Ep(f);var Go={},xu={exports:{}},Wn={},bu={exports:{}},wu={};/**
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 Jm;function Lp(){return Jm||(Jm=1,(function(a){function s(Y,me){var A=Y.length;Y.push(me);e:for(;0<A;){var w=A-1>>>1,L=Y[w];if(0<c(L,me))Y[w]=me,Y[A]=L,A=w;else break e}}function r(Y){return Y.length===0?null:Y[0]}function l(Y){if(Y.length===0)return null;var me=Y[0],A=Y.pop();if(A!==me){Y[0]=A;e:for(var w=0,L=Y.length,X=L>>>1;w<X;){var ge=2*(w+1)-1,de=Y[ge],P=ge+1,je=Y[P];if(0>c(de,A))P<L&&0>c(je,de)?(Y[w]=je,Y[P]=A,w=P):(Y[w]=de,Y[ge]=A,w=ge);else if(P<L&&0>c(je,A))Y[w]=je,Y[P]=A,w=P;else break e}}return me}function c(Y,me){var A=Y.sortIndex-me.sortIndex;return A!==0?A:Y.id-me.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;a.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();a.unstable_now=function(){return h.now()-p}}var _=[],y=[],b=1,x=null,N=3,E=!1,I=!1,C=!1,M=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function F(Y){for(var me=r(y);me!==null;){if(me.callback===null)l(y);else if(me.startTime<=Y)l(y),me.sortIndex=me.expirationTime,s(_,me);else break;me=r(y)}}function H(Y){if(C=!1,F(Y),!I)if(r(_)!==null)I=!0,V($);else{var me=r(y);me!==null&&ne(H,me.startTime-Y)}}function $(Y,me){I=!1,C&&(C=!1,O(oe),oe=-1),E=!0;var A=N;try{for(F(me),x=r(_);x!==null&&(!(x.expirationTime>me)||Y&&!be());){var w=x.callback;if(typeof w=="function"){x.callback=null,N=x.priorityLevel;var L=w(x.expirationTime<=me);me=a.unstable_now(),typeof L=="function"?x.callback=L:x===r(_)&&l(_),F(me)}else l(_);x=r(_)}if(x!==null)var X=!0;else{var ge=r(y);ge!==null&&ne(H,ge.startTime-me),X=!1}return X}finally{x=null,N=A,E=!1}}var ae=!1,fe=null,oe=-1,Ne=5,Me=-1;function be(){return!(a.unstable_now()-Me<Ne)}function ye(){if(fe!==null){var Y=a.unstable_now();Me=Y;var me=!0;try{me=fe(!0,Y)}finally{me?ue():(ae=!1,fe=null)}}else ae=!1}var ue;if(typeof D=="function")ue=function(){D(ye)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=ye,ue=function(){R.postMessage(null)}}else ue=function(){M(ye,0)};function V(Y){fe=Y,ae||(ae=!0,ue())}function ne(Y,me){oe=M(function(){Y(a.unstable_now())},me)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(Y){Y.callback=null},a.unstable_continueExecution=function(){I||E||(I=!0,V($))},a.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Ne=0<Y?Math.floor(1e3/Y):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_getFirstCallbackNode=function(){return r(_)},a.unstable_next=function(Y){switch(N){case 1:case 2:case 3:var me=3;break;default:me=N}var A=N;N=me;try{return Y()}finally{N=A}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(Y,me){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var A=N;N=Y;try{return me()}finally{N=A}},a.unstable_scheduleCallback=function(Y,me,A){var w=a.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?w+A:w):A=w,Y){case 1:var L=-1;break;case 2:L=250;break;case 5:L=1073741823;break;case 4:L=1e4;break;default:L=5e3}return L=A+L,Y={id:b++,callback:me,priorityLevel:Y,startTime:A,expirationTime:L,sortIndex:-1},A>w?(Y.sortIndex=A,s(y,Y),r(_)===null&&Y===r(y)&&(C?(O(oe),oe=-1):C=!0,ne(H,A-w))):(Y.sortIndex=L,s(_,Y),I||E||(I=!0,V($))),Y},a.unstable_shouldYield=be,a.unstable_wrapCallback=function(Y){var me=N;return function(){var A=N;N=me;try{return Y.apply(this,arguments)}finally{N=A}}}})(wu)),wu}var Ym;function Mp(){return Ym||(Ym=1,bu.exports=Lp()),bu.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 Xm;function zp(){if(Xm)return Wn;Xm=1;var a=ld(),s=Mp();function r(t){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)n+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,c={};function d(t,n){h(t,n),h(t+"Capture",n)}function h(t,n){for(c[t]=n,t=0;t<n.length;t++)l.add(n[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_=Object.prototype.hasOwnProperty,y=/^[: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]*$/,b={},x={};function N(t){return _.call(x,t)?!0:_.call(b,t)?!1:y.test(t)?x[t]=!0:(b[t]=!0,!1)}function E(t,n,i,o){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return o?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function I(t,n,i,o){if(n===null||typeof n>"u"||E(t,n,i,o))return!0;if(o)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function C(t,n,i,o,m,g,j){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=o,this.attributeNamespace=m,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=g,this.removeEmptyString=j}var M={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){M[t]=new C(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];M[n]=new C(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){M[t]=new C(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){M[t]=new C(t,2,!1,t,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(t){M[t]=new C(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){M[t]=new C(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){M[t]=new C(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){M[t]=new C(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){M[t]=new C(t,5,!1,t.toLowerCase(),null,!1,!1)});var O=/[\-:]([a-z])/g;function D(t){return t[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(t){var n=t.replace(O,D);M[n]=new C(n,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var n=t.replace(O,D);M[n]=new C(n,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var n=t.replace(O,D);M[n]=new C(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){M[t]=new C(t,1,!1,t.toLowerCase(),null,!1,!1)}),M.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){M[t]=new C(t,1,!1,t.toLowerCase(),null,!0,!0)});function F(t,n,i,o){var m=M.hasOwnProperty(n)?M[n]:null;(m!==null?m.type!==0:o||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(I(n,i,m,o)&&(i=null),o||m===null?N(n)&&(i===null?t.removeAttribute(n):t.setAttribute(n,""+i)):m.mustUseProperty?t[m.propertyName]=i===null?m.type===3?!1:"":i:(n=m.attributeName,o=m.attributeNamespace,i===null?t.removeAttribute(n):(m=m.type,i=m===3||m===4&&i===!0?"":""+i,o?t.setAttributeNS(o,n,i):t.setAttribute(n,i))))}var H=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),ae=Symbol.for("react.portal"),fe=Symbol.for("react.fragment"),oe=Symbol.for("react.strict_mode"),Ne=Symbol.for("react.profiler"),Me=Symbol.for("react.provider"),be=Symbol.for("react.context"),ye=Symbol.for("react.forward_ref"),ue=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),Y=Symbol.iterator;function me(t){return t===null||typeof t!="object"?null:(t=Y&&t[Y]||t["@@iterator"],typeof t=="function"?t:null)}var A=Object.assign,w;function L(t){if(w===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);w=n&&n[1]||""}return`
34
- `+w+t}var X=!1;function ge(t,n){if(!t||X)return"";X=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(he){var o=he}Reflect.construct(t,[],n)}else{try{n.call()}catch(he){o=he}t.call(n.prototype)}else{try{throw Error()}catch(he){o=he}t()}}catch(he){if(he&&o&&typeof he.stack=="string"){for(var m=he.stack.split(`
35
- `),g=o.stack.split(`
36
- `),j=m.length-1,z=g.length-1;1<=j&&0<=z&&m[j]!==g[z];)z--;for(;1<=j&&0<=z;j--,z--)if(m[j]!==g[z]){if(j!==1||z!==1)do if(j--,z--,0>z||m[j]!==g[z]){var W=`
37
- `+m[j].replace(" at new "," at ");return t.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",t.displayName)),W}while(1<=j&&0<=z);break}}}finally{X=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?L(t):""}function de(t){switch(t.tag){case 5:return L(t.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return t=ge(t.type,!1),t;case 11:return t=ge(t.type.render,!1),t;case 1:return t=ge(t.type,!0),t;default:return""}}function P(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case fe:return"Fragment";case ae:return"Portal";case Ne:return"Profiler";case oe:return"StrictMode";case ue:return"Suspense";case q:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case be:return(t.displayName||"Context")+".Consumer";case Me:return(t._context.displayName||"Context")+".Provider";case ye:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case R:return n=t.displayName||null,n!==null?n:P(t.type)||"Memo";case V:n=t._payload,t=t._init;try{return P(t(n))}catch{}}return null}function je(t){var n=t.type;switch(t.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=n.render,t=t.displayName||t.name||"",n.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return P(n);case 8:return n===oe?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Ae(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Fe(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ve(t){var n=Fe(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,n),o=""+t[n];if(!t.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var m=i.get,g=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return m.call(this)},set:function(j){o=""+j,g.call(this,j)}}),Object.defineProperty(t,n,{enumerable:i.enumerable}),{getValue:function(){return o},setValue:function(j){o=""+j},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function lt(t){t._valueTracker||(t._valueTracker=Ve(t))}function pe(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),o="";return t&&(o=Fe(t)?t.checked?"true":"false":t.value),t=o,t!==i?(n.setValue(t),!0):!1}function Ie(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function ke(t,n){var i=n.checked;return A({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function Z(t,n){var i=n.defaultValue==null?"":n.defaultValue,o=n.checked!=null?n.checked:n.defaultChecked;i=Ae(n.value!=null?n.value:i),t._wrapperState={initialChecked:o,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function K(t,n){n=n.checked,n!=null&&F(t,"checked",n,!1)}function xe(t,n){K(t,n);var i=Ae(n.value),o=n.type;if(i!=null)o==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(o==="submit"||o==="reset"){t.removeAttribute("value");return}n.hasOwnProperty("value")?De(t,n.type,i):n.hasOwnProperty("defaultValue")&&De(t,n.type,Ae(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function Ee(t,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var o=n.type;if(!(o!=="submit"&&o!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+t._wrapperState.initialValue,i||n===t.value||(t.value=n),t.defaultValue=n}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function De(t,n,i){(n!=="number"||Ie(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var te=Array.isArray;function J(t,n,i,o){if(t=t.options,n){n={};for(var m=0;m<i.length;m++)n["$"+i[m]]=!0;for(i=0;i<t.length;i++)m=n.hasOwnProperty("$"+t[i].value),t[i].selected!==m&&(t[i].selected=m),m&&o&&(t[i].defaultSelected=!0)}else{for(i=""+Ae(i),n=null,m=0;m<t.length;m++){if(t[m].value===i){t[m].selected=!0,o&&(t[m].defaultSelected=!0);return}n!==null||t[m].disabled||(n=t[m])}n!==null&&(n.selected=!0)}}function ve(t,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return A({},n,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function G(t,n){var i=n.value;if(i==null){if(i=n.children,n=n.defaultValue,i!=null){if(n!=null)throw Error(r(92));if(te(i)){if(1<i.length)throw Error(r(93));i=i[0]}n=i}n==null&&(n=""),i=n}t._wrapperState={initialValue:Ae(i)}}function Se(t,n){var i=Ae(n.value),o=Ae(n.defaultValue);i!=null&&(i=""+i,i!==t.value&&(t.value=i),n.defaultValue==null&&t.defaultValue!==i&&(t.defaultValue=i)),o!=null&&(t.defaultValue=""+o)}function Ge(t){var n=t.textContent;n===t._wrapperState.initialValue&&n!==""&&n!==null&&(t.value=n)}function ze(t){switch(t){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 Qe(t,n){return t==null||t==="http://www.w3.org/1999/xhtml"?ze(n):t==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var ee,U=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,o,m){MSApp.execUnsafeLocalFunction(function(){return t(n,i,o,m)})}:t})(function(t,n){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=n;else{for(ee=ee||document.createElement("div"),ee.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=ee.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function se(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var le={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},Ue=["Webkit","ms","Moz","O"];Object.keys(le).forEach(function(t){Ue.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),le[n]=le[t]})});function ut(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||le.hasOwnProperty(t)&&le[t]?(""+n).trim():n+"px"}function mt(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var o=i.indexOf("--")===0,m=ut(i,n[i],o);i==="float"&&(i="cssFloat"),o?t.setProperty(i,m):t[i]=m}}var ot=A({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 dt(t,n){if(n){if(ot[t]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(r(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(r(61))}if(n.style!=null&&typeof n.style!="object")throw Error(r(62))}}function bt(t,n){if(t.indexOf("-")===-1)return typeof n.is=="string";switch(t){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 rt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var vt=null,zt=null,wt=null;function tn(t){if(t=jr(t)){if(typeof vt!="function")throw Error(r(280));var n=t.stateNode;n&&(n=ci(n),vt(t.stateNode,t.type,n))}}function _e(t){zt?wt?wt.push(t):wt=[t]:zt=t}function Ce(){if(zt){var t=zt,n=wt;if(wt=zt=null,tn(t),n)for(t=0;t<n.length;t++)tn(n[t])}}function Ye(t,n){return t(n)}function _t(){}var ht=!1;function jt(t,n,i){if(ht)return t(n,i);ht=!0;try{return Ye(t,n,i)}finally{ht=!1,(zt!==null||wt!==null)&&(_t(),Ce())}}function st(t,n){var i=t.stateNode;if(i===null)return null;var o=ci(i);if(o===null)return null;i=o[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(t=t.type,o=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!o;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(r(231,n,typeof i));return i}var Cn=!1;if(p)try{var Cs={};Object.defineProperty(Cs,"passive",{get:function(){Cn=!0}}),window.addEventListener("test",Cs,Cs),window.removeEventListener("test",Cs,Cs)}catch{Cn=!1}function Xa(t,n,i,o,m,g,j,z,W){var he=Array.prototype.slice.call(arguments,3);try{n.apply(i,he)}catch(Te){this.onError(Te)}}var $s=!1,os=null,nn=!1,Vs=null,Gs={onError:function(t){$s=!0,os=t}};function Es(t,n,i,o,m,g,j,z,W){$s=!1,os=null,Xa.apply(Gs,arguments)}function $i(t,n,i,o,m,g,j,z,W){if(Es.apply(this,arguments),$s){if($s){var he=os;$s=!1,os=null}else throw Error(r(198));nn||(nn=!0,Vs=he)}}function Ts(t){var n=t,i=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(i=n.return),t=n.return;while(t)}return n.tag===3?i:null}function Or(t){if(t.tag===13){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function ct(t){if(Ts(t)!==t)throw Error(r(188))}function Ht(t){var n=t.alternate;if(!n){if(n=Ts(t),n===null)throw Error(r(188));return n!==t?null:t}for(var i=t,o=n;;){var m=i.return;if(m===null)break;var g=m.alternate;if(g===null){if(o=m.return,o!==null){i=o;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===i)return ct(m),t;if(g===o)return ct(m),n;g=g.sibling}throw Error(r(188))}if(i.return!==o.return)i=m,o=g;else{for(var j=!1,z=m.child;z;){if(z===i){j=!0,i=m,o=g;break}if(z===o){j=!0,o=m,i=g;break}z=z.sibling}if(!j){for(z=g.child;z;){if(z===i){j=!0,i=g,o=m;break}if(z===o){j=!0,o=g,i=m;break}z=z.sibling}if(!j)throw Error(r(189))}}if(i.alternate!==o)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?t:n}function Za(t){return t=Ht(t),t!==null?Mt(t):null}function Mt(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var n=Mt(t);if(n!==null)return n;t=t.sibling}return null}var er=s.unstable_scheduleCallback,Ei=s.unstable_cancelCallback,Bl=s.unstable_shouldYield,Ti=s.unstable_requestPaint,It=s.unstable_now,Dr=s.unstable_getCurrentPriorityLevel,Fr=s.unstable_ImmediatePriority,tr=s.unstable_UserBlockingPriority,Ks=s.unstable_NormalPriority,Ul=s.unstable_LowPriority,qr=s.unstable_IdlePriority,cs=null,hn=null;function Br(t){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot(cs,t,void 0,(t.current.flags&128)===128)}catch{}}var pn=Math.clz32?Math.clz32:Hl,Wl=Math.log,pa=Math.LN2;function Hl(t){return t>>>=0,t===0?32:31-(Wl(t)/pa|0)|0}var _a=64,Ur=4194304;function nr(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function bn(t,n){var i=t.pendingLanes;if(i===0)return 0;var o=0,m=t.suspendedLanes,g=t.pingedLanes,j=i&268435455;if(j!==0){var z=j&~m;z!==0?o=nr(z):(g&=j,g!==0&&(o=nr(g)))}else j=i&~m,j!==0?o=nr(j):g!==0&&(o=nr(g));if(o===0)return 0;if(n!==0&&n!==o&&(n&m)===0&&(m=o&-o,g=n&-n,m>=g||m===16&&(g&4194240)!==0))return n;if((o&4)!==0&&(o|=i&16),n=t.entangledLanes,n!==0)for(t=t.entanglements,n&=o;0<n;)i=31-pn(n),m=1<<i,o|=t[i],n&=~m;return o}function Qs(t,n){switch(t){case 1:case 2:case 4:return n+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 n+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 Wr(t,n){for(var i=t.suspendedLanes,o=t.pingedLanes,m=t.expirationTimes,g=t.pendingLanes;0<g;){var j=31-pn(g),z=1<<j,W=m[j];W===-1?((z&i)===0||(z&o)!==0)&&(m[j]=Qs(z,n)):W<=n&&(t.expiredLanes|=z),g&=~z}}function As(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Vt(){var t=_a;return _a<<=1,(_a&4194240)===0&&(_a=64),t}function Xt(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function Rs(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-pn(n),t[n]=i}function ga(t,n){var i=t.pendingLanes&~n;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=n,t.mutableReadLanes&=n,t.entangledLanes&=n,n=t.entanglements;var o=t.eventTimes;for(t=t.expirationTimes;0<i;){var m=31-pn(i),g=1<<m;n[m]=0,o[m]=-1,t[m]=-1,i&=~g}}function Ls(t,n){var i=t.entangledLanes|=n;for(t=t.entanglements;i;){var o=31-pn(i),m=1<<o;m&n|t[o]&n&&(t[o]|=n),i&=~m}}var kt=0;function Gt(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var us,Hr,zn,Vr,Ai,sr=!1,ar=[],ds=null,Kn=null,$n=null,Ms=new Map,on=new Map,_n=[],lc="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 va(t,n){switch(t){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":Ms.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":on.delete(n.pointerId)}}function Et(t,n,i,o,m,g){return t===null||t.nativeEvent!==g?(t={blockedOn:n,domEventName:i,eventSystemFlags:o,nativeEvent:g,targetContainers:[m]},n!==null&&(n=jr(n),n!==null&&Hr(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,m!==null&&n.indexOf(m)===-1&&n.push(m),t)}function Qn(t,n,i,o,m){switch(n){case"focusin":return ds=Et(ds,t,n,i,o,m),!0;case"dragenter":return Kn=Et(Kn,t,n,i,o,m),!0;case"mouseover":return $n=Et($n,t,n,i,o,m),!0;case"pointerover":var g=m.pointerId;return Ms.set(g,Et(Ms.get(g)||null,t,n,i,o,m)),!0;case"gotpointercapture":return g=m.pointerId,on.set(g,Et(on.get(g)||null,t,n,i,o,m)),!0}return!1}function Pn(t){var n=ys(t.target);if(n!==null){var i=Ts(n);if(i!==null){if(n=i.tag,n===13){if(n=Or(i),n!==null){t.blockedOn=n,Ai(t.priority,function(){zn(i)});return}}else if(n===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ya(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var i=or(t.domEventName,t.eventSystemFlags,n[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var o=new i.constructor(i.type,i);Re=o,i.target.dispatchEvent(o),Re=null}else return n=jr(i),n!==null&&Hr(n),t.blockedOn=i,!1;n.shift()}return!0}function Gr(t,n,i){ya(t)&&i.delete(n)}function Vl(){sr=!1,ds!==null&&ya(ds)&&(ds=null),Kn!==null&&ya(Kn)&&(Kn=null),$n!==null&&ya($n)&&($n=null),Ms.forEach(Gr),on.forEach(Gr)}function wn(t,n){t.blockedOn===n&&(t.blockedOn=null,sr||(sr=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Vl)))}function xa(t){function n(m){return wn(m,t)}if(0<ar.length){wn(ar[0],t);for(var i=1;i<ar.length;i++){var o=ar[i];o.blockedOn===t&&(o.blockedOn=null)}}for(ds!==null&&wn(ds,t),Kn!==null&&wn(Kn,t),$n!==null&&wn($n,t),Ms.forEach(n),on.forEach(n),i=0;i<_n.length;i++)o=_n[i],o.blockedOn===t&&(o.blockedOn=null);for(;0<_n.length&&(i=_n[0],i.blockedOn===null);)Pn(i),i.blockedOn===null&&_n.shift()}var ms=H.ReactCurrentBatchConfig,rr=!0;function Ri(t,n,i,o){var m=kt,g=ms.transition;ms.transition=null;try{kt=1,Kr(t,n,i,o)}finally{kt=m,ms.transition=g}}function ir(t,n,i,o){var m=kt,g=ms.transition;ms.transition=null;try{kt=4,Kr(t,n,i,o)}finally{kt=m,ms.transition=g}}function Kr(t,n,i,o){if(rr){var m=or(t,n,i,o);if(m===null)yr(t,n,o,lr,i),va(t,o);else if(Qn(m,t,n,i,o))o.stopPropagation();else if(va(t,o),n&4&&-1<lc.indexOf(t)){for(;m!==null;){var g=jr(m);if(g!==null&&us(g),g=or(t,n,i,o),g===null&&yr(t,n,o,lr,i),g===m)break;m=g}m!==null&&o.stopPropagation()}else yr(t,n,o,null,i)}}var lr=null;function or(t,n,i,o){if(lr=null,t=rt(o),t=ys(t),t!==null)if(n=Ts(t),n===null)t=null;else if(i=n.tag,i===13){if(t=Or(n),t!==null)return t;t=null}else if(i===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;t=null}else n!==t&&(t=null);return lr=t,null}function Li(t){switch(t){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(Dr()){case Fr:return 1;case tr:return 4;case Ks:case Ul:return 16;case qr:return 536870912;default:return 16}default:return 16}}var In=null,fs=null,Js=null;function Qr(){if(Js)return Js;var t,n=fs,i=n.length,o,m="value"in In?In.value:In.textContent,g=m.length;for(t=0;t<i&&n[t]===m[t];t++);var j=i-t;for(o=1;o<=j&&n[i-o]===m[g-o];o++);return Js=m.slice(t,1<o?1-o:void 0)}function ba(t){var n=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&n===13&&(t=13)):t=n,t===10&&(t=13),32<=t||t===13?t:0}function wa(){return!0}function Ys(){return!1}function sn(t){function n(i,o,m,g,j){this._reactName=i,this._targetInst=m,this.type=o,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var z in t)t.hasOwnProperty(z)&&(i=t[z],this[z]=i?i(g):g[z]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?wa:Ys,this.isPropagationStopped=Ys,this}return A(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=wa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=wa)},persist:function(){},isPersistent:wa}),n}var ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kt=sn(ja),zs=A({},ja,{view:0,detail:0}),Mi=sn(zs),Jr,cr,Xs,ka=A({},zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ur,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Xs&&(Xs&&t.type==="mousemove"?(Jr=t.screenX-Xs.screenX,cr=t.screenY-Xs.screenY):cr=Jr=0,Xs=t),Jr)},movementY:function(t){return"movementY"in t?t.movementY:cr}}),zi=sn(ka),Pi=A({},ka,{dataTransfer:0}),Gl=sn(Pi),Kl=A({},zs,{relatedTarget:0}),Yr=sn(Kl),Ql=A({},ja,{animationName:0,elapsedTime:0,pseudoElement:0}),Ii=sn(Ql),Jl=A({},ja,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Oi=sn(Jl),Di=A({},ja,{data:0}),Fi=sn(Di),On={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ps={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"},Is={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qi(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=Is[t])?!!n[t]:!1}function ur(){return qi}var Bi=A({},zs,{key:function(t){if(t.key){var n=On[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=ba(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Ps[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ur,charCode:function(t){return t.type==="keypress"?ba(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ba(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),oc=sn(Bi),Sa=A({},ka,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Na=sn(Sa),hs=A({},zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ur}),Zs=sn(hs),Yl=A({},ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xl=sn(Yl),Zl=A({},ka,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),cc=sn(Zl),uc=[9,13,27,32],dr=p&&"CompositionEvent"in window,ns=null;p&&"documentMode"in document&&(ns=document.documentMode);var Ui=p&&"TextEvent"in window&&!ns,Wi=p&&(!dr||ns&&8<ns&&11>=ns),Xr=" ",Hi=!1;function ea(t,n){switch(t){case"keyup":return uc.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ca=!1;function mr(t,n){switch(t){case"compositionend":return Zr(n);case"keypress":return n.which!==32?null:(Hi=!0,Xr);case"textInput":return t=n.data,t===Xr&&Hi?null:t;default:return null}}function Vi(t,n){if(Ca)return t==="compositionend"||!dr&&ea(t,n)?(t=Qr(),Js=fs=In=null,Ca=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Wi&&n.locale!=="ko"?null:n.data;default:return null}}var eo={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 Gi(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!eo[t.type]:n==="textarea"}function Ki(t,n,i,o){_e(o),n=li(n,"onChange"),0<n.length&&(i=new Kt("onChange","change",null,i,o),t.push({event:i,listeners:n}))}var fr=null,Jn=null;function hr(t){Ea(t,0)}function ei(t){var n=Pa(t);if(pe(n))return t}function ti(t,n){if(t==="change")return n}var ni=!1;if(p){var Qi;if(p){var $a="oninput"in document;if(!$a){var pr=document.createElement("div");pr.setAttribute("oninput","return;"),$a=typeof pr.oninput=="function"}Qi=$a}else Qi=!1;ni=Qi&&(!document.documentMode||9<document.documentMode)}function to(){fr&&(fr.detachEvent("onpropertychange",no),Jn=fr=null)}function no(t){if(t.propertyName==="value"&&ei(Jn)){var n=[];Ki(n,Jn,t,rt(t)),jt(hr,n)}}function dc(t,n,i){t==="focusin"?(to(),fr=n,Jn=i,fr.attachEvent("onpropertychange",no)):t==="focusout"&&to()}function so(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ei(Jn)}function mc(t,n){if(t==="click")return ei(n)}function ao(t,n){if(t==="input"||t==="change")return ei(n)}function fc(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var Yn=typeof Object.is=="function"?Object.is:fc;function ta(t,n){if(Yn(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;var i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;for(o=0;o<i.length;o++){var m=i[o];if(!_.call(n,m)||!Yn(t[m],n[m]))return!1}return!0}function ro(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Ji(t,n){var i=ro(t);t=0;for(var o;i;){if(i.nodeType===3){if(o=t+i.textContent.length,t<=n&&o>=n)return{node:i,offset:n-t};t=o}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ro(i)}}function Yi(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Yi(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function io(){for(var t=window,n=Ie();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Ie(t.document)}return n}function si(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}function ai(t){var n=io(),i=t.focusedElem,o=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&Yi(i.ownerDocument.documentElement,i)){if(o!==null&&si(i)){if(n=o.start,t=o.end,t===void 0&&(t=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(t,i.value.length);else if(t=(n=i.ownerDocument||document)&&n.defaultView||window,t.getSelection){t=t.getSelection();var m=i.textContent.length,g=Math.min(o.start,m);o=o.end===void 0?g:Math.min(o.end,m),!t.extend&&g>o&&(m=o,o=g,g=m),m=Ji(i,g);var j=Ji(i,o);m&&j&&(t.rangeCount!==1||t.anchorNode!==m.node||t.anchorOffset!==m.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(n=n.createRange(),n.setStart(m.node,m.offset),t.removeAllRanges(),g>o?(t.addRange(n),t.extend(j.node,j.offset)):(n.setEnd(j.node,j.offset),t.addRange(n)))}}for(n=[],t=i;t=t.parentNode;)t.nodeType===1&&n.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<n.length;i++)t=n[i],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var lo=p&&"documentMode"in document&&11>=document.documentMode,ps=null,ri=null,_r=null,Xi=!1;function Zi(t,n,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Xi||ps==null||ps!==Ie(o)||(o=ps,"selectionStart"in o&&si(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),_r&&ta(_r,o)||(_r=o,o=li(ri,"onSelect"),0<o.length&&(n=new Kt("onSelect","select",null,n,i),t.push({event:n,listeners:o}),n.target=ps)))}function ii(t,n){var i={};return i[t.toLowerCase()]=n.toLowerCase(),i["Webkit"+t]="webkit"+n,i["Moz"+t]="moz"+n,i}var na={animationend:ii("Animation","AnimationEnd"),animationiteration:ii("Animation","AnimationIteration"),animationstart:ii("Animation","AnimationStart"),transitionend:ii("Transition","TransitionEnd")},el={},tl={};p&&(tl=document.createElement("div").style,"AnimationEvent"in window||(delete na.animationend.animation,delete na.animationiteration.animation,delete na.animationstart.animation),"TransitionEvent"in window||delete na.transitionend.transition);function gr(t){if(el[t])return el[t];if(!na[t])return t;var n=na[t],i;for(i in n)if(n.hasOwnProperty(i)&&i in tl)return el[t]=n[i];return t}var oo=gr("animationend"),co=gr("animationiteration"),nl=gr("animationstart"),sl=gr("transitionend"),uo=new Map,En="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 gt(t,n){uo.set(t,n),d(n,[t])}for(var Qt=0;Qt<En.length;Qt++){var vr=En[Qt],hc=vr.toLowerCase(),Os=vr[0].toUpperCase()+vr.slice(1);gt(hc,"on"+Os)}gt(oo,"onAnimationEnd"),gt(co,"onAnimationIteration"),gt(nl,"onAnimationStart"),gt("dblclick","onDoubleClick"),gt("focusin","onFocus"),gt("focusout","onBlur"),gt(sl,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dn="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(" "),_s=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dn));function sa(t,n,i){var o=t.type||"unknown-event";t.currentTarget=i,$i(o,n,void 0,t),t.currentTarget=null}function Ea(t,n){n=(n&4)!==0;for(var i=0;i<t.length;i++){var o=t[i],m=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var j=o.length-1;0<=j;j--){var z=o[j],W=z.instance,he=z.currentTarget;if(z=z.listener,W!==g&&m.isPropagationStopped())break e;sa(m,z,he),g=W}else for(j=0;j<o.length;j++){if(z=o[j],W=z.instance,he=z.currentTarget,z=z.listener,W!==g&&m.isPropagationStopped())break e;sa(m,z,he),g=W}}}if(nn)throw t=Vs,nn=!1,Vs=null,t}function Ct(t,n){var i=n[ol];i===void 0&&(i=n[ol]=new Set);var o=t+"__bubble";i.has(o)||(al(n,t,2,!1),i.add(o))}function aa(t,n,i){var o=0;n&&(o|=4),al(i,t,o,n)}var Ta="_reactListening"+Math.random().toString(36).slice(2);function Aa(t){if(!t[Ta]){t[Ta]=!0,l.forEach(function(i){i!=="selectionchange"&&(_s.has(i)||aa(i,!1,t),aa(i,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[Ta]||(n[Ta]=!0,aa("selectionchange",!1,n))}}function al(t,n,i,o){switch(Li(n)){case 1:var m=Ri;break;case 4:m=ir;break;default:m=Kr}i=m.bind(null,n,i,t),m=void 0,!Cn||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(m=!0),o?m!==void 0?t.addEventListener(n,i,{capture:!0,passive:m}):t.addEventListener(n,i,!0):m!==void 0?t.addEventListener(n,i,{passive:m}):t.addEventListener(n,i,!1)}function yr(t,n,i,o,m){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var j=o.tag;if(j===3||j===4){var z=o.stateNode.containerInfo;if(z===m||z.nodeType===8&&z.parentNode===m)break;if(j===4)for(j=o.return;j!==null;){var W=j.tag;if((W===3||W===4)&&(W=j.stateNode.containerInfo,W===m||W.nodeType===8&&W.parentNode===m))return;j=j.return}for(;z!==null;){if(j=ys(z),j===null)return;if(W=j.tag,W===5||W===6){o=g=j;continue e}z=z.parentNode}}o=o.return}jt(function(){var he=g,Te=rt(i),Le=[];e:{var $e=uo.get(t);if($e!==void 0){var We=Kt,Je=t;switch(t){case"keypress":if(ba(i)===0)break e;case"keydown":case"keyup":We=oc;break;case"focusin":Je="focus",We=Yr;break;case"focusout":Je="blur",We=Yr;break;case"beforeblur":case"afterblur":We=Yr;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":We=zi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":We=Gl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":We=Zs;break;case oo:case co:case nl:We=Ii;break;case sl:We=Xl;break;case"scroll":We=Mi;break;case"wheel":We=cc;break;case"copy":case"cut":case"paste":We=Oi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":We=Na}var Xe=(n&4)!==0,Yt=!Xe&&t==="scroll",ie=Xe?$e!==null?$e+"Capture":null:$e;Xe=[];for(var Q=he,ce;Q!==null;){ce=Q;var Oe=ce.stateNode;if(ce.tag===5&&Oe!==null&&(ce=Oe,ie!==null&&(Oe=st(Q,ie),Oe!=null&&Xe.push(xr(Q,Oe,ce)))),Yt)break;Q=Q.return}0<Xe.length&&($e=new We($e,Je,null,i,Te),Le.push({event:$e,listeners:Xe}))}}if((n&7)===0){e:{if($e=t==="mouseover"||t==="pointerover",We=t==="mouseout"||t==="pointerout",$e&&i!==Re&&(Je=i.relatedTarget||i.fromElement)&&(ys(Je)||Je[vs]))break e;if((We||$e)&&($e=Te.window===Te?Te:($e=Te.ownerDocument)?$e.defaultView||$e.parentWindow:window,We?(Je=i.relatedTarget||i.toElement,We=he,Je=Je?ys(Je):null,Je!==null&&(Yt=Ts(Je),Je!==Yt||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(We=null,Je=he),We!==Je)){if(Xe=zi,Oe="onMouseLeave",ie="onMouseEnter",Q="mouse",(t==="pointerout"||t==="pointerover")&&(Xe=Na,Oe="onPointerLeave",ie="onPointerEnter",Q="pointer"),Yt=We==null?$e:Pa(We),ce=Je==null?$e:Pa(Je),$e=new Xe(Oe,Q+"leave",We,i,Te),$e.target=Yt,$e.relatedTarget=ce,Oe=null,ys(Te)===he&&(Xe=new Xe(ie,Q+"enter",Je,i,Te),Xe.target=ce,Xe.relatedTarget=Yt,Oe=Xe),Yt=Oe,We&&Je)t:{for(Xe=We,ie=Je,Q=0,ce=Xe;ce;ce=ra(ce))Q++;for(ce=0,Oe=ie;Oe;Oe=ra(Oe))ce++;for(;0<Q-ce;)Xe=ra(Xe),Q--;for(;0<ce-Q;)ie=ra(ie),ce--;for(;Q--;){if(Xe===ie||ie!==null&&Xe===ie.alternate)break t;Xe=ra(Xe),ie=ra(ie)}Xe=null}else Xe=null;We!==null&&rl(Le,$e,We,Xe,!1),Je!==null&&Yt!==null&&rl(Le,Yt,Je,Xe,!0)}}e:{if($e=he?Pa(he):window,We=$e.nodeName&&$e.nodeName.toLowerCase(),We==="select"||We==="input"&&$e.type==="file")var Ze=ti;else if(Gi($e))if(ni)Ze=ao;else{Ze=so;var tt=dc}else(We=$e.nodeName)&&We.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(Ze=mc);if(Ze&&(Ze=Ze(t,he))){Ki(Le,Ze,i,Te);break e}tt&&tt(t,$e,he),t==="focusout"&&(tt=$e._wrapperState)&&tt.controlled&&$e.type==="number"&&De($e,"number",$e.value)}switch(tt=he?Pa(he):window,t){case"focusin":(Gi(tt)||tt.contentEditable==="true")&&(ps=tt,ri=he,_r=null);break;case"focusout":_r=ri=ps=null;break;case"mousedown":Xi=!0;break;case"contextmenu":case"mouseup":case"dragend":Xi=!1,Zi(Le,i,Te);break;case"selectionchange":if(lo)break;case"keydown":case"keyup":Zi(Le,i,Te)}var nt;if(dr)e:{switch(t){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else Ca?ea(t,i)&&(it="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(it="onCompositionStart");it&&(Wi&&i.locale!=="ko"&&(Ca||it!=="onCompositionStart"?it==="onCompositionEnd"&&Ca&&(nt=Qr()):(In=Te,fs="value"in In?In.value:In.textContent,Ca=!0)),tt=li(he,it),0<tt.length&&(it=new Fi(it,t,null,i,Te),Le.push({event:it,listeners:tt}),nt?it.data=nt:(nt=Zr(i),nt!==null&&(it.data=nt)))),(nt=Ui?mr(t,i):Vi(t,i))&&(he=li(he,"onBeforeInput"),0<he.length&&(Te=new Fi("onBeforeInput","beforeinput",null,i,Te),Le.push({event:Te,listeners:he}),Te.data=nt))}Ea(Le,n)})}function xr(t,n,i){return{instance:t,listener:n,currentTarget:i}}function li(t,n){for(var i=n+"Capture",o=[];t!==null;){var m=t,g=m.stateNode;m.tag===5&&g!==null&&(m=g,g=st(t,i),g!=null&&o.unshift(xr(t,g,m)),g=st(t,n),g!=null&&o.push(xr(t,g,m))),t=t.return}return o}function ra(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function rl(t,n,i,o,m){for(var g=n._reactName,j=[];i!==null&&i!==o;){var z=i,W=z.alternate,he=z.stateNode;if(W!==null&&W===o)break;z.tag===5&&he!==null&&(z=he,m?(W=st(i,g),W!=null&&j.unshift(xr(i,W,z))):m||(W=st(i,g),W!=null&&j.push(xr(i,W,z)))),i=i.return}j.length!==0&&t.push({event:n,listeners:j})}var Ra=/\r\n?/g,pc=/\u0000|\uFFFD/g;function Tn(t){return(typeof t=="string"?t:""+t).replace(Ra,`
38
- `).replace(pc,"")}function La(t,n,i){if(n=Tn(n),Tn(t)!==n&&i)throw Error(r(425))}function An(){}var Ma=null,br=null;function Xn(t,n){return t==="textarea"||t==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Fn=typeof setTimeout=="function"?setTimeout:void 0,oi=typeof clearTimeout=="function"?clearTimeout:void 0,mo=typeof Promise=="function"?Promise:void 0,il=typeof queueMicrotask=="function"?queueMicrotask:typeof mo<"u"?function(t){return mo.resolve(null).then(t).catch(_c)}:Fn;function _c(t){setTimeout(function(){throw t})}function ll(t,n){var i=n,o=0;do{var m=i.nextSibling;if(t.removeChild(i),m&&m.nodeType===8)if(i=m.data,i==="/$"){if(o===0){t.removeChild(m),xa(n);return}o--}else i!=="$"&&i!=="$?"&&i!=="$!"||o++;i=m}while(i);xa(n)}function gs(t){for(;t!=null;t=t.nextSibling){var n=t.nodeType;if(n===1||n===3)break;if(n===8){if(n=t.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return t}function fo(t){t=t.previousSibling;for(var n=0;t;){if(t.nodeType===8){var i=t.data;if(i==="$"||i==="$!"||i==="$?"){if(n===0)return t;n--}else i==="/$"&&n++}t=t.previousSibling}return null}var za=Math.random().toString(36).slice(2),Zn="__reactFiber$"+za,wr="__reactProps$"+za,vs="__reactContainer$"+za,ol="__reactEvents$"+za,gc="__reactListeners$"+za,vc="__reactHandles$"+za;function ys(t){var n=t[Zn];if(n)return n;for(var i=t.parentNode;i;){if(n=i[vs]||i[Zn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(t=fo(t);t!==null;){if(i=t[Zn])return i;t=fo(t)}return n}t=i,i=t.parentNode}return null}function jr(t){return t=t[Zn]||t[vs],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Pa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function ci(t){return t[wr]||null}var cl=[],ia=-1;function xs(t){return{current:t}}function At(t){0>ia||(t.current=cl[ia],cl[ia]=null,ia--)}function Tt(t,n){ia++,cl[ia]=t.current,t.current=n}var bs={},an=xs(bs),gn=xs(!1),Ds=bs;function la(t,n){var i=t.type.contextTypes;if(!i)return bs;var o=t.stateNode;if(o&&o.__reactInternalMemoizedUnmaskedChildContext===n)return o.__reactInternalMemoizedMaskedChildContext;var m={},g;for(g in i)m[g]=n[g];return o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=m),m}function u(t){return t=t.childContextTypes,t!=null}function v(){At(gn),At(an)}function S(t,n,i){if(an.current!==bs)throw Error(r(168));Tt(an,n),Tt(gn,i)}function k(t,n,i){var o=t.stateNode;if(n=n.childContextTypes,typeof o.getChildContext!="function")return i;o=o.getChildContext();for(var m in o)if(!(m in n))throw Error(r(108,je(t)||"Unknown",m));return A({},i,o)}function T(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bs,Ds=an.current,Tt(an,t),Tt(gn,gn.current),!0}function re(t,n,i){var o=t.stateNode;if(!o)throw Error(r(169));i?(t=k(t,n,Ds),o.__reactInternalMemoizedMergedChildContext=t,At(gn),At(an),Tt(an,t)):At(gn),Tt(gn,i)}var B=null,we=!1,Pe=!1;function qe(t){B===null?B=[t]:B.push(t)}function He(t){we=!0,qe(t)}function $t(){if(!Pe&&B!==null){Pe=!0;var t=0,n=kt;try{var i=B;for(kt=1;t<i.length;t++){var o=i[t];do o=o(!0);while(o!==null)}B=null,we=!1}catch(m){throw B!==null&&(B=B.slice(t+1)),er(Fr,$t),m}finally{kt=n,Pe=!1}}return null}var Pt=[],jn=0,yt=null,at=0,Rt=[],pt=0,Be=null,St=1,Dt="";function Bt(t,n){Pt[jn++]=at,Pt[jn++]=yt,yt=t,at=n}function Zt(t,n,i){Rt[pt++]=St,Rt[pt++]=Dt,Rt[pt++]=Be,Be=t;var o=St;t=Dt;var m=32-pn(o)-1;o&=~(1<<m),i+=1;var g=32-pn(n)+m;if(30<g){var j=m-m%5;g=(o&(1<<j)-1).toString(32),o>>=j,m-=j,St=1<<32-pn(n)+m|i<<m|o,Dt=g+t}else St=1<<g|i<<m|o,Dt=t}function Lt(t){t.return!==null&&(Bt(t,1),Zt(t,1,0))}function Jt(t){for(;t===yt;)yt=Pt[--jn],Pt[jn]=null,at=Pt[--jn],Pt[jn]=null;for(;t===Be;)Be=Rt[--pt],Rt[pt]=null,Dt=Rt[--pt],Rt[pt]=null,St=Rt[--pt],Rt[pt]=null}var cn=null,es=null,Ot=!1,ws=null;function yd(t,n){var i=is(5,null,null,0);i.elementType="DELETED",i.stateNode=n,i.return=t,n=t.deletions,n===null?(t.deletions=[i],t.flags|=16):n.push(i)}function xd(t,n){switch(t.tag){case 5:var i=t.type;return n=n.nodeType!==1||i.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(t.stateNode=n,cn=t,es=gs(n.firstChild),!0):!1;case 6:return n=t.pendingProps===""||n.nodeType!==3?null:n,n!==null?(t.stateNode=n,cn=t,es=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=Be!==null?{id:St,overflow:Dt}:null,t.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=is(18,null,null,0),i.stateNode=n,i.return=t,t.child=i,cn=t,es=null,!0):!1;default:return!1}}function yc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function xc(t){if(Ot){var n=es;if(n){var i=n;if(!xd(t,n)){if(yc(t))throw Error(r(418));n=gs(i.nextSibling);var o=cn;n&&xd(t,n)?yd(o,i):(t.flags=t.flags&-4097|2,Ot=!1,cn=t)}}else{if(yc(t))throw Error(r(418));t.flags=t.flags&-4097|2,Ot=!1,cn=t}}}function bd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;cn=t}function ho(t){if(t!==cn)return!1;if(!Ot)return bd(t),Ot=!0,!1;var n;if((n=t.tag!==3)&&!(n=t.tag!==5)&&(n=t.type,n=n!=="head"&&n!=="body"&&!Xn(t.type,t.memoizedProps)),n&&(n=es)){if(yc(t))throw wd(),Error(r(418));for(;n;)yd(t,n),n=gs(n.nextSibling)}if(bd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,n=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(n===0){es=gs(t.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}t=t.nextSibling}es=null}}else es=cn?gs(t.stateNode.nextSibling):null;return!0}function wd(){for(var t=es;t;)t=gs(t.nextSibling)}function ui(){es=cn=null,Ot=!1}function bc(t){ws===null?ws=[t]:ws.push(t)}var Gh=H.ReactCurrentBatchConfig;function ul(t,n,i){if(t=i.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(r(309));var o=i.stateNode}if(!o)throw Error(r(147,t));var m=o,g=""+t;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===g?n.ref:(n=function(j){var z=m.refs;j===null?delete z[g]:z[g]=j},n._stringRef=g,n)}if(typeof t!="string")throw Error(r(284));if(!i._owner)throw Error(r(290,t))}return t}function po(t,n){throw t=Object.prototype.toString.call(n),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t))}function jd(t){var n=t._init;return n(t._payload)}function kd(t){function n(ie,Q){if(t){var ce=ie.deletions;ce===null?(ie.deletions=[Q],ie.flags|=16):ce.push(Q)}}function i(ie,Q){if(!t)return null;for(;Q!==null;)n(ie,Q),Q=Q.sibling;return null}function o(ie,Q){for(ie=new Map;Q!==null;)Q.key!==null?ie.set(Q.key,Q):ie.set(Q.index,Q),Q=Q.sibling;return ie}function m(ie,Q){return ie=Wa(ie,Q),ie.index=0,ie.sibling=null,ie}function g(ie,Q,ce){return ie.index=ce,t?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<Q?(ie.flags|=2,Q):ce):(ie.flags|=2,Q)):(ie.flags|=1048576,Q)}function j(ie){return t&&ie.alternate===null&&(ie.flags|=2),ie}function z(ie,Q,ce,Oe){return Q===null||Q.tag!==6?(Q=mu(ce,ie.mode,Oe),Q.return=ie,Q):(Q=m(Q,ce),Q.return=ie,Q)}function W(ie,Q,ce,Oe){var Ze=ce.type;return Ze===fe?Te(ie,Q,ce.props.children,Oe,ce.key):Q!==null&&(Q.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===V&&jd(Ze)===Q.type)?(Oe=m(Q,ce.props),Oe.ref=ul(ie,Q,ce),Oe.return=ie,Oe):(Oe=Do(ce.type,ce.key,ce.props,null,ie.mode,Oe),Oe.ref=ul(ie,Q,ce),Oe.return=ie,Oe)}function he(ie,Q,ce,Oe){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ce.containerInfo||Q.stateNode.implementation!==ce.implementation?(Q=fu(ce,ie.mode,Oe),Q.return=ie,Q):(Q=m(Q,ce.children||[]),Q.return=ie,Q)}function Te(ie,Q,ce,Oe,Ze){return Q===null||Q.tag!==7?(Q=Ar(ce,ie.mode,Oe,Ze),Q.return=ie,Q):(Q=m(Q,ce),Q.return=ie,Q)}function Le(ie,Q,ce){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=mu(""+Q,ie.mode,ce),Q.return=ie,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case $:return ce=Do(Q.type,Q.key,Q.props,null,ie.mode,ce),ce.ref=ul(ie,null,Q),ce.return=ie,ce;case ae:return Q=fu(Q,ie.mode,ce),Q.return=ie,Q;case V:var Oe=Q._init;return Le(ie,Oe(Q._payload),ce)}if(te(Q)||me(Q))return Q=Ar(Q,ie.mode,ce,null),Q.return=ie,Q;po(ie,Q)}return null}function $e(ie,Q,ce,Oe){var Ze=Q!==null?Q.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return Ze!==null?null:z(ie,Q,""+ce,Oe);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===Ze?W(ie,Q,ce,Oe):null;case ae:return ce.key===Ze?he(ie,Q,ce,Oe):null;case V:return Ze=ce._init,$e(ie,Q,Ze(ce._payload),Oe)}if(te(ce)||me(ce))return Ze!==null?null:Te(ie,Q,ce,Oe,null);po(ie,ce)}return null}function We(ie,Q,ce,Oe,Ze){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return ie=ie.get(ce)||null,z(Q,ie,""+Oe,Ze);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case $:return ie=ie.get(Oe.key===null?ce:Oe.key)||null,W(Q,ie,Oe,Ze);case ae:return ie=ie.get(Oe.key===null?ce:Oe.key)||null,he(Q,ie,Oe,Ze);case V:var tt=Oe._init;return We(ie,Q,ce,tt(Oe._payload),Ze)}if(te(Oe)||me(Oe))return ie=ie.get(ce)||null,Te(Q,ie,Oe,Ze,null);po(Q,Oe)}return null}function Je(ie,Q,ce,Oe){for(var Ze=null,tt=null,nt=Q,it=Q=0,mn=null;nt!==null&&it<ce.length;it++){nt.index>it?(mn=nt,nt=null):mn=nt.sibling;var Nt=$e(ie,nt,ce[it],Oe);if(Nt===null){nt===null&&(nt=mn);break}t&&nt&&Nt.alternate===null&&n(ie,nt),Q=g(Nt,Q,it),tt===null?Ze=Nt:tt.sibling=Nt,tt=Nt,nt=mn}if(it===ce.length)return i(ie,nt),Ot&&Bt(ie,it),Ze;if(nt===null){for(;it<ce.length;it++)nt=Le(ie,ce[it],Oe),nt!==null&&(Q=g(nt,Q,it),tt===null?Ze=nt:tt.sibling=nt,tt=nt);return Ot&&Bt(ie,it),Ze}for(nt=o(ie,nt);it<ce.length;it++)mn=We(nt,ie,it,ce[it],Oe),mn!==null&&(t&&mn.alternate!==null&&nt.delete(mn.key===null?it:mn.key),Q=g(mn,Q,it),tt===null?Ze=mn:tt.sibling=mn,tt=mn);return t&&nt.forEach(function(Ha){return n(ie,Ha)}),Ot&&Bt(ie,it),Ze}function Xe(ie,Q,ce,Oe){var Ze=me(ce);if(typeof Ze!="function")throw Error(r(150));if(ce=Ze.call(ce),ce==null)throw Error(r(151));for(var tt=Ze=null,nt=Q,it=Q=0,mn=null,Nt=ce.next();nt!==null&&!Nt.done;it++,Nt=ce.next()){nt.index>it?(mn=nt,nt=null):mn=nt.sibling;var Ha=$e(ie,nt,Nt.value,Oe);if(Ha===null){nt===null&&(nt=mn);break}t&&nt&&Ha.alternate===null&&n(ie,nt),Q=g(Ha,Q,it),tt===null?Ze=Ha:tt.sibling=Ha,tt=Ha,nt=mn}if(Nt.done)return i(ie,nt),Ot&&Bt(ie,it),Ze;if(nt===null){for(;!Nt.done;it++,Nt=ce.next())Nt=Le(ie,Nt.value,Oe),Nt!==null&&(Q=g(Nt,Q,it),tt===null?Ze=Nt:tt.sibling=Nt,tt=Nt);return Ot&&Bt(ie,it),Ze}for(nt=o(ie,nt);!Nt.done;it++,Nt=ce.next())Nt=We(nt,ie,it,Nt.value,Oe),Nt!==null&&(t&&Nt.alternate!==null&&nt.delete(Nt.key===null?it:Nt.key),Q=g(Nt,Q,it),tt===null?Ze=Nt:tt.sibling=Nt,tt=Nt);return t&&nt.forEach(function(Np){return n(ie,Np)}),Ot&&Bt(ie,it),Ze}function Yt(ie,Q,ce,Oe){if(typeof ce=="object"&&ce!==null&&ce.type===fe&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var Ze=ce.key,tt=Q;tt!==null;){if(tt.key===Ze){if(Ze=ce.type,Ze===fe){if(tt.tag===7){i(ie,tt.sibling),Q=m(tt,ce.props.children),Q.return=ie,ie=Q;break e}}else if(tt.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===V&&jd(Ze)===tt.type){i(ie,tt.sibling),Q=m(tt,ce.props),Q.ref=ul(ie,tt,ce),Q.return=ie,ie=Q;break e}i(ie,tt);break}else n(ie,tt);tt=tt.sibling}ce.type===fe?(Q=Ar(ce.props.children,ie.mode,Oe,ce.key),Q.return=ie,ie=Q):(Oe=Do(ce.type,ce.key,ce.props,null,ie.mode,Oe),Oe.ref=ul(ie,Q,ce),Oe.return=ie,ie=Oe)}return j(ie);case ae:e:{for(tt=ce.key;Q!==null;){if(Q.key===tt)if(Q.tag===4&&Q.stateNode.containerInfo===ce.containerInfo&&Q.stateNode.implementation===ce.implementation){i(ie,Q.sibling),Q=m(Q,ce.children||[]),Q.return=ie,ie=Q;break e}else{i(ie,Q);break}else n(ie,Q);Q=Q.sibling}Q=fu(ce,ie.mode,Oe),Q.return=ie,ie=Q}return j(ie);case V:return tt=ce._init,Yt(ie,Q,tt(ce._payload),Oe)}if(te(ce))return Je(ie,Q,ce,Oe);if(me(ce))return Xe(ie,Q,ce,Oe);po(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,Q!==null&&Q.tag===6?(i(ie,Q.sibling),Q=m(Q,ce),Q.return=ie,ie=Q):(i(ie,Q),Q=mu(ce,ie.mode,Oe),Q.return=ie,ie=Q),j(ie)):i(ie,Q)}return Yt}var di=kd(!0),Sd=kd(!1),_o=xs(null),go=null,mi=null,wc=null;function jc(){wc=mi=go=null}function kc(t){var n=_o.current;At(_o),t._currentValue=n}function Sc(t,n,i){for(;t!==null;){var o=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),t===i)break;t=t.return}}function fi(t,n){go=t,wc=mi=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&(qn=!0),t.firstContext=null)}function ss(t){var n=t._currentValue;if(wc!==t)if(t={context:t,memoizedValue:n,next:null},mi===null){if(go===null)throw Error(r(308));mi=t,go.dependencies={lanes:0,firstContext:t}}else mi=mi.next=t;return n}var kr=null;function Nc(t){kr===null?kr=[t]:kr.push(t)}function Nd(t,n,i,o){var m=n.interleaved;return m===null?(i.next=i,Nc(n)):(i.next=m.next,m.next=i),n.interleaved=i,oa(t,o)}function oa(t,n){t.lanes|=n;var i=t.alternate;for(i!==null&&(i.lanes|=n),i=t,t=t.return;t!==null;)t.childLanes|=n,i=t.alternate,i!==null&&(i.childLanes|=n),i=t,t=t.return;return i.tag===3?i.stateNode:null}var Ia=!1;function Cc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cd(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ca(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function Oa(t,n,i){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(xt&2)!==0){var m=o.pending;return m===null?n.next=n:(n.next=m.next,m.next=n),o.pending=n,oa(t,i)}return m=o.interleaved,m===null?(n.next=n,Nc(o)):(n.next=m.next,m.next=n),o.interleaved=n,oa(t,i)}function vo(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,Ls(t,i)}}function $d(t,n){var i=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var m=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var j={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?m=g=j:g=g.next=j,i=i.next}while(i!==null);g===null?m=g=n:g=g.next=n}else m=g=n;i={baseState:o.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:o.shared,effects:o.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}function yo(t,n,i,o){var m=t.updateQueue;Ia=!1;var g=m.firstBaseUpdate,j=m.lastBaseUpdate,z=m.shared.pending;if(z!==null){m.shared.pending=null;var W=z,he=W.next;W.next=null,j===null?g=he:j.next=he,j=W;var Te=t.alternate;Te!==null&&(Te=Te.updateQueue,z=Te.lastBaseUpdate,z!==j&&(z===null?Te.firstBaseUpdate=he:z.next=he,Te.lastBaseUpdate=W))}if(g!==null){var Le=m.baseState;j=0,Te=he=W=null,z=g;do{var $e=z.lane,We=z.eventTime;if((o&$e)===$e){Te!==null&&(Te=Te.next={eventTime:We,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Je=t,Xe=z;switch($e=n,We=i,Xe.tag){case 1:if(Je=Xe.payload,typeof Je=="function"){Le=Je.call(We,Le,$e);break e}Le=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Xe.payload,$e=typeof Je=="function"?Je.call(We,Le,$e):Je,$e==null)break e;Le=A({},Le,$e);break e;case 2:Ia=!0}}z.callback!==null&&z.lane!==0&&(t.flags|=64,$e=m.effects,$e===null?m.effects=[z]:$e.push(z))}else We={eventTime:We,lane:$e,tag:z.tag,payload:z.payload,callback:z.callback,next:null},Te===null?(he=Te=We,W=Le):Te=Te.next=We,j|=$e;if(z=z.next,z===null){if(z=m.shared.pending,z===null)break;$e=z,z=$e.next,$e.next=null,m.lastBaseUpdate=$e,m.shared.pending=null}}while(!0);if(Te===null&&(W=Le),m.baseState=W,m.firstBaseUpdate=he,m.lastBaseUpdate=Te,n=m.shared.interleaved,n!==null){m=n;do j|=m.lane,m=m.next;while(m!==n)}else g===null&&(m.shared.lanes=0);Cr|=j,t.lanes=j,t.memoizedState=Le}}function Ed(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;n<t.length;n++){var o=t[n],m=o.callback;if(m!==null){if(o.callback=null,o=i,typeof m!="function")throw Error(r(191,m));m.call(o)}}}var dl={},Fs=xs(dl),ml=xs(dl),fl=xs(dl);function Sr(t){if(t===dl)throw Error(r(174));return t}function $c(t,n){switch(Tt(fl,n),Tt(ml,t),Tt(Fs,dl),t=n.nodeType,t){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:Qe(null,"");break;default:t=t===8?n.parentNode:n,n=t.namespaceURI||null,t=t.tagName,n=Qe(n,t)}At(Fs),Tt(Fs,n)}function hi(){At(Fs),At(ml),At(fl)}function Td(t){Sr(fl.current);var n=Sr(Fs.current),i=Qe(n,t.type);n!==i&&(Tt(ml,t),Tt(Fs,i))}function Ec(t){ml.current===t&&(At(Fs),At(ml))}var Ft=xs(0);function xo(t){for(var n=t;n!==null;){if(n.tag===13){var i=n.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Tc=[];function Ac(){for(var t=0;t<Tc.length;t++)Tc[t]._workInProgressVersionPrimary=null;Tc.length=0}var bo=H.ReactCurrentDispatcher,Rc=H.ReactCurrentBatchConfig,Nr=0,qt=null,rn=null,un=null,wo=!1,hl=!1,pl=0,Kh=0;function kn(){throw Error(r(321))}function Lc(t,n){if(n===null)return!1;for(var i=0;i<n.length&&i<t.length;i++)if(!Yn(t[i],n[i]))return!1;return!0}function Mc(t,n,i,o,m,g){if(Nr=g,qt=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,bo.current=t===null||t.memoizedState===null?Xh:Zh,t=i(o,m),hl){g=0;do{if(hl=!1,pl=0,25<=g)throw Error(r(301));g+=1,un=rn=null,n.updateQueue=null,bo.current=ep,t=i(o,m)}while(hl)}if(bo.current=So,n=rn!==null&&rn.next!==null,Nr=0,un=rn=qt=null,wo=!1,n)throw Error(r(300));return t}function zc(){var t=pl!==0;return pl=0,t}function qs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return un===null?qt.memoizedState=un=t:un=un.next=t,un}function as(){if(rn===null){var t=qt.alternate;t=t!==null?t.memoizedState:null}else t=rn.next;var n=un===null?qt.memoizedState:un.next;if(n!==null)un=n,rn=t;else{if(t===null)throw Error(r(310));rn=t,t={memoizedState:rn.memoizedState,baseState:rn.baseState,baseQueue:rn.baseQueue,queue:rn.queue,next:null},un===null?qt.memoizedState=un=t:un=un.next=t}return un}function _l(t,n){return typeof n=="function"?n(t):n}function Pc(t){var n=as(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=rn,m=o.baseQueue,g=i.pending;if(g!==null){if(m!==null){var j=m.next;m.next=g.next,g.next=j}o.baseQueue=m=g,i.pending=null}if(m!==null){g=m.next,o=o.baseState;var z=j=null,W=null,he=g;do{var Te=he.lane;if((Nr&Te)===Te)W!==null&&(W=W.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),o=he.hasEagerState?he.eagerState:t(o,he.action);else{var Le={lane:Te,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};W===null?(z=W=Le,j=o):W=W.next=Le,qt.lanes|=Te,Cr|=Te}he=he.next}while(he!==null&&he!==g);W===null?j=o:W.next=z,Yn(o,n.memoizedState)||(qn=!0),n.memoizedState=o,n.baseState=j,n.baseQueue=W,i.lastRenderedState=o}if(t=i.interleaved,t!==null){m=t;do g=m.lane,qt.lanes|=g,Cr|=g,m=m.next;while(m!==t)}else m===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Ic(t){var n=as(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=i.dispatch,m=i.pending,g=n.memoizedState;if(m!==null){i.pending=null;var j=m=m.next;do g=t(g,j.action),j=j.next;while(j!==m);Yn(g,n.memoizedState)||(qn=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),i.lastRenderedState=g}return[g,o]}function Ad(){}function Rd(t,n){var i=qt,o=as(),m=n(),g=!Yn(o.memoizedState,m);if(g&&(o.memoizedState=m,qn=!0),o=o.queue,Oc(zd.bind(null,i,o,t),[t]),o.getSnapshot!==n||g||un!==null&&un.memoizedState.tag&1){if(i.flags|=2048,gl(9,Md.bind(null,i,o,m,n),void 0,null),dn===null)throw Error(r(349));(Nr&30)!==0||Ld(i,n,m)}return m}function Ld(t,n,i){t.flags|=16384,t={getSnapshot:n,value:i},n=qt.updateQueue,n===null?(n={lastEffect:null,stores:null},qt.updateQueue=n,n.stores=[t]):(i=n.stores,i===null?n.stores=[t]:i.push(t))}function Md(t,n,i,o){n.value=i,n.getSnapshot=o,Pd(n)&&Id(t)}function zd(t,n,i){return i(function(){Pd(n)&&Id(t)})}function Pd(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!Yn(t,i)}catch{return!0}}function Id(t){var n=oa(t,1);n!==null&&Ns(n,t,1,-1)}function Od(t){var n=qs();return typeof t=="function"&&(t=t()),n.memoizedState=n.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:t},n.queue=t,t=t.dispatch=Yh.bind(null,qt,t),[n.memoizedState,t]}function gl(t,n,i,o){return t={tag:t,create:n,destroy:i,deps:o,next:null},n=qt.updateQueue,n===null?(n={lastEffect:null,stores:null},qt.updateQueue=n,n.lastEffect=t.next=t):(i=n.lastEffect,i===null?n.lastEffect=t.next=t:(o=i.next,i.next=t,t.next=o,n.lastEffect=t)),t}function Dd(){return as().memoizedState}function jo(t,n,i,o){var m=qs();qt.flags|=t,m.memoizedState=gl(1|n,i,void 0,o===void 0?null:o)}function ko(t,n,i,o){var m=as();o=o===void 0?null:o;var g=void 0;if(rn!==null){var j=rn.memoizedState;if(g=j.destroy,o!==null&&Lc(o,j.deps)){m.memoizedState=gl(n,i,g,o);return}}qt.flags|=t,m.memoizedState=gl(1|n,i,g,o)}function Fd(t,n){return jo(8390656,8,t,n)}function Oc(t,n){return ko(2048,8,t,n)}function qd(t,n){return ko(4,2,t,n)}function Bd(t,n){return ko(4,4,t,n)}function Ud(t,n){if(typeof n=="function")return t=t(),n(t),function(){n(null)};if(n!=null)return t=t(),n.current=t,function(){n.current=null}}function Wd(t,n,i){return i=i!=null?i.concat([t]):null,ko(4,4,Ud.bind(null,n,t),i)}function Dc(){}function Hd(t,n){var i=as();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Lc(n,o[1])?o[0]:(i.memoizedState=[t,n],t)}function Vd(t,n){var i=as();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Lc(n,o[1])?o[0]:(t=t(),i.memoizedState=[t,n],t)}function Gd(t,n,i){return(Nr&21)===0?(t.baseState&&(t.baseState=!1,qn=!0),t.memoizedState=i):(Yn(i,n)||(i=Vt(),qt.lanes|=i,Cr|=i,t.baseState=!0),n)}function Qh(t,n){var i=kt;kt=i!==0&&4>i?i:4,t(!0);var o=Rc.transition;Rc.transition={};try{t(!1),n()}finally{kt=i,Rc.transition=o}}function Kd(){return as().memoizedState}function Jh(t,n,i){var o=Ba(t);if(i={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(t))Jd(n,i);else if(i=Nd(t,n,i,o),i!==null){var m=Ln();Ns(i,t,o,m),Yd(i,n,o)}}function Yh(t,n,i){var o=Ba(t),m={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(t))Jd(n,m);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var j=n.lastRenderedState,z=g(j,i);if(m.hasEagerState=!0,m.eagerState=z,Yn(z,j)){var W=n.interleaved;W===null?(m.next=m,Nc(n)):(m.next=W.next,W.next=m),n.interleaved=m;return}}catch{}finally{}i=Nd(t,n,m,o),i!==null&&(m=Ln(),Ns(i,t,o,m),Yd(i,n,o))}}function Qd(t){var n=t.alternate;return t===qt||n!==null&&n===qt}function Jd(t,n){hl=wo=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function Yd(t,n,i){if((i&4194240)!==0){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,Ls(t,i)}}var So={readContext:ss,useCallback:kn,useContext:kn,useEffect:kn,useImperativeHandle:kn,useInsertionEffect:kn,useLayoutEffect:kn,useMemo:kn,useReducer:kn,useRef:kn,useState:kn,useDebugValue:kn,useDeferredValue:kn,useTransition:kn,useMutableSource:kn,useSyncExternalStore:kn,useId:kn,unstable_isNewReconciler:!1},Xh={readContext:ss,useCallback:function(t,n){return qs().memoizedState=[t,n===void 0?null:n],t},useContext:ss,useEffect:Fd,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,jo(4194308,4,Ud.bind(null,n,t),i)},useLayoutEffect:function(t,n){return jo(4194308,4,t,n)},useInsertionEffect:function(t,n){return jo(4,2,t,n)},useMemo:function(t,n){var i=qs();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var o=qs();return n=i!==void 0?i(n):n,o.memoizedState=o.baseState=n,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},o.queue=t,t=t.dispatch=Jh.bind(null,qt,t),[o.memoizedState,t]},useRef:function(t){var n=qs();return t={current:t},n.memoizedState=t},useState:Od,useDebugValue:Dc,useDeferredValue:function(t){return qs().memoizedState=t},useTransition:function(){var t=Od(!1),n=t[0];return t=Qh.bind(null,t[1]),qs().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var o=qt,m=qs();if(Ot){if(i===void 0)throw Error(r(407));i=i()}else{if(i=n(),dn===null)throw Error(r(349));(Nr&30)!==0||Ld(o,n,i)}m.memoizedState=i;var g={value:i,getSnapshot:n};return m.queue=g,Fd(zd.bind(null,o,g,t),[t]),o.flags|=2048,gl(9,Md.bind(null,o,g,i,n),void 0,null),i},useId:function(){var t=qs(),n=dn.identifierPrefix;if(Ot){var i=Dt,o=St;i=(o&~(1<<32-pn(o)-1)).toString(32)+i,n=":"+n+"R"+i,i=pl++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=Kh++,n=":"+n+"r"+i.toString(32)+":";return t.memoizedState=n},unstable_isNewReconciler:!1},Zh={readContext:ss,useCallback:Hd,useContext:ss,useEffect:Oc,useImperativeHandle:Wd,useInsertionEffect:qd,useLayoutEffect:Bd,useMemo:Vd,useReducer:Pc,useRef:Dd,useState:function(){return Pc(_l)},useDebugValue:Dc,useDeferredValue:function(t){var n=as();return Gd(n,rn.memoizedState,t)},useTransition:function(){var t=Pc(_l)[0],n=as().memoizedState;return[t,n]},useMutableSource:Ad,useSyncExternalStore:Rd,useId:Kd,unstable_isNewReconciler:!1},ep={readContext:ss,useCallback:Hd,useContext:ss,useEffect:Oc,useImperativeHandle:Wd,useInsertionEffect:qd,useLayoutEffect:Bd,useMemo:Vd,useReducer:Ic,useRef:Dd,useState:function(){return Ic(_l)},useDebugValue:Dc,useDeferredValue:function(t){var n=as();return rn===null?n.memoizedState=t:Gd(n,rn.memoizedState,t)},useTransition:function(){var t=Ic(_l)[0],n=as().memoizedState;return[t,n]},useMutableSource:Ad,useSyncExternalStore:Rd,useId:Kd,unstable_isNewReconciler:!1};function js(t,n){if(t&&t.defaultProps){n=A({},n),t=t.defaultProps;for(var i in t)n[i]===void 0&&(n[i]=t[i]);return n}return n}function Fc(t,n,i,o){n=t.memoizedState,i=i(o,n),i=i==null?n:A({},n,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var No={isMounted:function(t){return(t=t._reactInternals)?Ts(t)===t:!1},enqueueSetState:function(t,n,i){t=t._reactInternals;var o=Ln(),m=Ba(t),g=ca(o,m);g.payload=n,i!=null&&(g.callback=i),n=Oa(t,g,m),n!==null&&(Ns(n,t,m,o),vo(n,t,m))},enqueueReplaceState:function(t,n,i){t=t._reactInternals;var o=Ln(),m=Ba(t),g=ca(o,m);g.tag=1,g.payload=n,i!=null&&(g.callback=i),n=Oa(t,g,m),n!==null&&(Ns(n,t,m,o),vo(n,t,m))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var i=Ln(),o=Ba(t),m=ca(i,o);m.tag=2,n!=null&&(m.callback=n),n=Oa(t,m,o),n!==null&&(Ns(n,t,o,i),vo(n,t,o))}};function Xd(t,n,i,o,m,g,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,g,j):n.prototype&&n.prototype.isPureReactComponent?!ta(i,o)||!ta(m,g):!0}function Zd(t,n,i){var o=!1,m=bs,g=n.contextType;return typeof g=="object"&&g!==null?g=ss(g):(m=u(n)?Ds:an.current,o=n.contextTypes,g=(o=o!=null)?la(t,m):bs),n=new n(i,g),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=No,t.stateNode=n,n._reactInternals=t,o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=m,t.__reactInternalMemoizedMaskedChildContext=g),n}function em(t,n,i,o){t=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(i,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(i,o),n.state!==t&&No.enqueueReplaceState(n,n.state,null)}function qc(t,n,i,o){var m=t.stateNode;m.props=i,m.state=t.memoizedState,m.refs={},Cc(t);var g=n.contextType;typeof g=="object"&&g!==null?m.context=ss(g):(g=u(n)?Ds:an.current,m.context=la(t,g)),m.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(Fc(t,n,g,i),m.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(n=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),n!==m.state&&No.enqueueReplaceState(m,m.state,null),yo(t,i,m,o),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308)}function pi(t,n){try{var i="",o=n;do i+=de(o),o=o.return;while(o);var m=i}catch(g){m=`
39
- Error generating stack: `+g.message+`
40
- `+g.stack}return{value:t,source:n,stack:m,digest:null}}function Bc(t,n,i){return{value:t,source:null,stack:i??null,digest:n??null}}function Uc(t,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var tp=typeof WeakMap=="function"?WeakMap:Map;function tm(t,n,i){i=ca(-1,i),i.tag=3,i.payload={element:null};var o=n.value;return i.callback=function(){Lo||(Lo=!0,au=o),Uc(t,n)},i}function nm(t,n,i){i=ca(-1,i),i.tag=3;var o=t.type.getDerivedStateFromError;if(typeof o=="function"){var m=n.value;i.payload=function(){return o(m)},i.callback=function(){Uc(t,n)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){Uc(t,n),typeof o!="function"&&(Fa===null?Fa=new Set([this]):Fa.add(this));var j=n.stack;this.componentDidCatch(n.value,{componentStack:j!==null?j:""})}),i}function sm(t,n,i){var o=t.pingCache;if(o===null){o=t.pingCache=new tp;var m=new Set;o.set(n,m)}else m=o.get(n),m===void 0&&(m=new Set,o.set(n,m));m.has(i)||(m.add(i),t=pp.bind(null,t,n,i),n.then(t,t))}function am(t){do{var n;if((n=t.tag===13)&&(n=t.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return t;t=t.return}while(t!==null);return null}function rm(t,n,i,o,m){return(t.mode&1)===0?(t===n?t.flags|=65536:(t.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=ca(-1,1),n.tag=2,Oa(i,n,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=m,t)}var np=H.ReactCurrentOwner,qn=!1;function Rn(t,n,i,o){n.child=t===null?Sd(n,null,i,o):di(n,t.child,i,o)}function im(t,n,i,o,m){i=i.render;var g=n.ref;return fi(n,m),o=Mc(t,n,i,o,g,m),i=zc(),t!==null&&!qn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~m,ua(t,n,m)):(Ot&&i&&Lt(n),n.flags|=1,Rn(t,n,o,m),n.child)}function lm(t,n,i,o,m){if(t===null){var g=i.type;return typeof g=="function"&&!du(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,om(t,n,g,o,m)):(t=Do(i.type,null,o,n,n.mode,m),t.ref=n.ref,t.return=n,n.child=t)}if(g=t.child,(t.lanes&m)===0){var j=g.memoizedProps;if(i=i.compare,i=i!==null?i:ta,i(j,o)&&t.ref===n.ref)return ua(t,n,m)}return n.flags|=1,t=Wa(g,o),t.ref=n.ref,t.return=n,n.child=t}function om(t,n,i,o,m){if(t!==null){var g=t.memoizedProps;if(ta(g,o)&&t.ref===n.ref)if(qn=!1,n.pendingProps=o=g,(t.lanes&m)!==0)(t.flags&131072)!==0&&(qn=!0);else return n.lanes=t.lanes,ua(t,n,m)}return Wc(t,n,i,o,m)}function cm(t,n,i){var o=n.pendingProps,m=o.children,g=t!==null?t.memoizedState:null;if(o.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tt(gi,ts),ts|=i;else{if((i&1073741824)===0)return t=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:t,cachePool:null,transitions:null},n.updateQueue=null,Tt(gi,ts),ts|=t,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},o=g!==null?g.baseLanes:i,Tt(gi,ts),ts|=o}else g!==null?(o=g.baseLanes|i,n.memoizedState=null):o=i,Tt(gi,ts),ts|=o;return Rn(t,n,m,i),n.child}function um(t,n){var i=n.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Wc(t,n,i,o,m){var g=u(i)?Ds:an.current;return g=la(n,g),fi(n,m),i=Mc(t,n,i,o,g,m),o=zc(),t!==null&&!qn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~m,ua(t,n,m)):(Ot&&o&&Lt(n),n.flags|=1,Rn(t,n,i,m),n.child)}function dm(t,n,i,o,m){if(u(i)){var g=!0;T(n)}else g=!1;if(fi(n,m),n.stateNode===null)$o(t,n),Zd(n,i,o),qc(n,i,o,m),o=!0;else if(t===null){var j=n.stateNode,z=n.memoizedProps;j.props=z;var W=j.context,he=i.contextType;typeof he=="object"&&he!==null?he=ss(he):(he=u(i)?Ds:an.current,he=la(n,he));var Te=i.getDerivedStateFromProps,Le=typeof Te=="function"||typeof j.getSnapshotBeforeUpdate=="function";Le||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(z!==o||W!==he)&&em(n,j,o,he),Ia=!1;var $e=n.memoizedState;j.state=$e,yo(n,o,j,m),W=n.memoizedState,z!==o||$e!==W||gn.current||Ia?(typeof Te=="function"&&(Fc(n,i,Te,o),W=n.memoizedState),(z=Ia||Xd(n,i,z,o,$e,W,he))?(Le||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(n.flags|=4194308)):(typeof j.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=W),j.props=o,j.state=W,j.context=he,o=z):(typeof j.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{j=n.stateNode,Cd(t,n),z=n.memoizedProps,he=n.type===n.elementType?z:js(n.type,z),j.props=he,Le=n.pendingProps,$e=j.context,W=i.contextType,typeof W=="object"&&W!==null?W=ss(W):(W=u(i)?Ds:an.current,W=la(n,W));var We=i.getDerivedStateFromProps;(Te=typeof We=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(z!==Le||$e!==W)&&em(n,j,o,W),Ia=!1,$e=n.memoizedState,j.state=$e,yo(n,o,j,m);var Je=n.memoizedState;z!==Le||$e!==Je||gn.current||Ia?(typeof We=="function"&&(Fc(n,i,We,o),Je=n.memoizedState),(he=Ia||Xd(n,i,he,o,$e,Je,W)||!1)?(Te||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(o,Je,W),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(o,Je,W)),typeof j.componentDidUpdate=="function"&&(n.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof j.componentDidUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=Je),j.props=o,j.state=Je,j.context=W,o=he):(typeof j.componentDidUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=1024),o=!1)}return Hc(t,n,i,o,g,m)}function Hc(t,n,i,o,m,g){um(t,n);var j=(n.flags&128)!==0;if(!o&&!j)return m&&re(n,i,!1),ua(t,n,g);o=n.stateNode,np.current=n;var z=j&&typeof i.getDerivedStateFromError!="function"?null:o.render();return n.flags|=1,t!==null&&j?(n.child=di(n,t.child,null,g),n.child=di(n,null,z,g)):Rn(t,n,z,g),n.memoizedState=o.state,m&&re(n,i,!0),n.child}function mm(t){var n=t.stateNode;n.pendingContext?S(t,n.pendingContext,n.pendingContext!==n.context):n.context&&S(t,n.context,!1),$c(t,n.containerInfo)}function fm(t,n,i,o,m){return ui(),bc(m),n.flags|=256,Rn(t,n,i,o),n.child}var Vc={dehydrated:null,treeContext:null,retryLane:0};function Gc(t){return{baseLanes:t,cachePool:null,transitions:null}}function hm(t,n,i){var o=n.pendingProps,m=Ft.current,g=!1,j=(n.flags&128)!==0,z;if((z=j)||(z=t!==null&&t.memoizedState===null?!1:(m&2)!==0),z?(g=!0,n.flags&=-129):(t===null||t.memoizedState!==null)&&(m|=1),Tt(Ft,m&1),t===null)return xc(n),t=n.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((n.mode&1)===0?n.lanes=1:t.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(j=o.children,t=o.fallback,g?(o=n.mode,g=n.child,j={mode:"hidden",children:j},(o&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=j):g=Fo(j,o,0,null),t=Ar(t,o,i,null),g.return=n,t.return=n,g.sibling=t,n.child=g,n.child.memoizedState=Gc(i),n.memoizedState=Vc,t):Kc(n,j));if(m=t.memoizedState,m!==null&&(z=m.dehydrated,z!==null))return sp(t,n,j,o,z,m,i);if(g){g=o.fallback,j=n.mode,m=t.child,z=m.sibling;var W={mode:"hidden",children:o.children};return(j&1)===0&&n.child!==m?(o=n.child,o.childLanes=0,o.pendingProps=W,n.deletions=null):(o=Wa(m,W),o.subtreeFlags=m.subtreeFlags&14680064),z!==null?g=Wa(z,g):(g=Ar(g,j,i,null),g.flags|=2),g.return=n,o.return=n,o.sibling=g,n.child=o,o=g,g=n.child,j=t.child.memoizedState,j=j===null?Gc(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},g.memoizedState=j,g.childLanes=t.childLanes&~i,n.memoizedState=Vc,o}return g=t.child,t=g.sibling,o=Wa(g,{mode:"visible",children:o.children}),(n.mode&1)===0&&(o.lanes=i),o.return=n,o.sibling=null,t!==null&&(i=n.deletions,i===null?(n.deletions=[t],n.flags|=16):i.push(t)),n.child=o,n.memoizedState=null,o}function Kc(t,n){return n=Fo({mode:"visible",children:n},t.mode,0,null),n.return=t,t.child=n}function Co(t,n,i,o){return o!==null&&bc(o),di(n,t.child,null,i),t=Kc(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function sp(t,n,i,o,m,g,j){if(i)return n.flags&256?(n.flags&=-257,o=Bc(Error(r(422))),Co(t,n,j,o)):n.memoizedState!==null?(n.child=t.child,n.flags|=128,null):(g=o.fallback,m=n.mode,o=Fo({mode:"visible",children:o.children},m,0,null),g=Ar(g,m,j,null),g.flags|=2,o.return=n,g.return=n,o.sibling=g,n.child=o,(n.mode&1)!==0&&di(n,t.child,null,j),n.child.memoizedState=Gc(j),n.memoizedState=Vc,g);if((n.mode&1)===0)return Co(t,n,j,null);if(m.data==="$!"){if(o=m.nextSibling&&m.nextSibling.dataset,o)var z=o.dgst;return o=z,g=Error(r(419)),o=Bc(g,o,void 0),Co(t,n,j,o)}if(z=(j&t.childLanes)!==0,qn||z){if(o=dn,o!==null){switch(j&-j){case 4:m=2;break;case 16:m=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:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(o.suspendedLanes|j))!==0?0:m,m!==0&&m!==g.retryLane&&(g.retryLane=m,oa(t,m),Ns(o,t,m,-1))}return uu(),o=Bc(Error(r(421))),Co(t,n,j,o)}return m.data==="$?"?(n.flags|=128,n.child=t.child,n=_p.bind(null,t),m._reactRetry=n,null):(t=g.treeContext,es=gs(m.nextSibling),cn=n,Ot=!0,ws=null,t!==null&&(Rt[pt++]=St,Rt[pt++]=Dt,Rt[pt++]=Be,St=t.id,Dt=t.overflow,Be=n),n=Kc(n,o.children),n.flags|=4096,n)}function pm(t,n,i){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),Sc(t.return,n,i)}function Qc(t,n,i,o,m){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:m}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=o,g.tail=i,g.tailMode=m)}function _m(t,n,i){var o=n.pendingProps,m=o.revealOrder,g=o.tail;if(Rn(t,n,o.children,i),o=Ft.current,(o&2)!==0)o=o&1|2,n.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=n.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&pm(t,i,n);else if(t.tag===19)pm(t,i,n);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break e;for(;t.sibling===null;){if(t.return===null||t.return===n)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}o&=1}if(Tt(Ft,o),(n.mode&1)===0)n.memoizedState=null;else switch(m){case"forwards":for(i=n.child,m=null;i!==null;)t=i.alternate,t!==null&&xo(t)===null&&(m=i),i=i.sibling;i=m,i===null?(m=n.child,n.child=null):(m=i.sibling,i.sibling=null),Qc(n,!1,m,i,g);break;case"backwards":for(i=null,m=n.child,n.child=null;m!==null;){if(t=m.alternate,t!==null&&xo(t)===null){n.child=m;break}t=m.sibling,m.sibling=i,i=m,m=t}Qc(n,!0,i,null,g);break;case"together":Qc(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function $o(t,n){(n.mode&1)===0&&t!==null&&(t.alternate=null,n.alternate=null,n.flags|=2)}function ua(t,n,i){if(t!==null&&(n.dependencies=t.dependencies),Cr|=n.lanes,(i&n.childLanes)===0)return null;if(t!==null&&n.child!==t.child)throw Error(r(153));if(n.child!==null){for(t=n.child,i=Wa(t,t.pendingProps),n.child=i,i.return=n;t.sibling!==null;)t=t.sibling,i=i.sibling=Wa(t,t.pendingProps),i.return=n;i.sibling=null}return n.child}function ap(t,n,i){switch(n.tag){case 3:mm(n),ui();break;case 5:Td(n);break;case 1:u(n.type)&&T(n);break;case 4:$c(n,n.stateNode.containerInfo);break;case 10:var o=n.type._context,m=n.memoizedProps.value;Tt(_o,o._currentValue),o._currentValue=m;break;case 13:if(o=n.memoizedState,o!==null)return o.dehydrated!==null?(Tt(Ft,Ft.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?hm(t,n,i):(Tt(Ft,Ft.current&1),t=ua(t,n,i),t!==null?t.sibling:null);Tt(Ft,Ft.current&1);break;case 19:if(o=(i&n.childLanes)!==0,(t.flags&128)!==0){if(o)return _m(t,n,i);n.flags|=128}if(m=n.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Tt(Ft,Ft.current),o)break;return null;case 22:case 23:return n.lanes=0,cm(t,n,i)}return ua(t,n,i)}var gm,Jc,vm,ym;gm=function(t,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Jc=function(){},vm=function(t,n,i,o){var m=t.memoizedProps;if(m!==o){t=n.stateNode,Sr(Fs.current);var g=null;switch(i){case"input":m=ke(t,m),o=ke(t,o),g=[];break;case"select":m=A({},m,{value:void 0}),o=A({},o,{value:void 0}),g=[];break;case"textarea":m=ve(t,m),o=ve(t,o),g=[];break;default:typeof m.onClick!="function"&&typeof o.onClick=="function"&&(t.onclick=An)}dt(i,o);var j;i=null;for(he in m)if(!o.hasOwnProperty(he)&&m.hasOwnProperty(he)&&m[he]!=null)if(he==="style"){var z=m[he];for(j in z)z.hasOwnProperty(j)&&(i||(i={}),i[j]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(c.hasOwnProperty(he)?g||(g=[]):(g=g||[]).push(he,null));for(he in o){var W=o[he];if(z=m!=null?m[he]:void 0,o.hasOwnProperty(he)&&W!==z&&(W!=null||z!=null))if(he==="style")if(z){for(j in z)!z.hasOwnProperty(j)||W&&W.hasOwnProperty(j)||(i||(i={}),i[j]="");for(j in W)W.hasOwnProperty(j)&&z[j]!==W[j]&&(i||(i={}),i[j]=W[j])}else i||(g||(g=[]),g.push(he,i)),i=W;else he==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,z=z?z.__html:void 0,W!=null&&z!==W&&(g=g||[]).push(he,W)):he==="children"?typeof W!="string"&&typeof W!="number"||(g=g||[]).push(he,""+W):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(c.hasOwnProperty(he)?(W!=null&&he==="onScroll"&&Ct("scroll",t),g||z===W||(g=[])):(g=g||[]).push(he,W))}i&&(g=g||[]).push("style",i);var he=g;(n.updateQueue=he)&&(n.flags|=4)}},ym=function(t,n,i,o){i!==o&&(n.flags|=4)};function vl(t,n){if(!Ot)switch(t.tailMode){case"hidden":n=t.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?t.tail=null:i.sibling=null;break;case"collapsed":i=t.tail;for(var o=null;i!==null;)i.alternate!==null&&(o=i),i=i.sibling;o===null?n||t.tail===null?t.tail=null:t.tail.sibling=null:o.sibling=null}}function Sn(t){var n=t.alternate!==null&&t.alternate.child===t.child,i=0,o=0;if(n)for(var m=t.child;m!==null;)i|=m.lanes|m.childLanes,o|=m.subtreeFlags&14680064,o|=m.flags&14680064,m.return=t,m=m.sibling;else for(m=t.child;m!==null;)i|=m.lanes|m.childLanes,o|=m.subtreeFlags,o|=m.flags,m.return=t,m=m.sibling;return t.subtreeFlags|=o,t.childLanes=i,n}function rp(t,n,i){var o=n.pendingProps;switch(Jt(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(n),null;case 1:return u(n.type)&&v(),Sn(n),null;case 3:return o=n.stateNode,hi(),At(gn),At(an),Ac(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(t===null||t.child===null)&&(ho(n)?n.flags|=4:t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ws!==null&&(lu(ws),ws=null))),Jc(t,n),Sn(n),null;case 5:Ec(n);var m=Sr(fl.current);if(i=n.type,t!==null&&n.stateNode!=null)vm(t,n,i,o,m),t.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!o){if(n.stateNode===null)throw Error(r(166));return Sn(n),null}if(t=Sr(Fs.current),ho(n)){o=n.stateNode,i=n.type;var g=n.memoizedProps;switch(o[Zn]=n,o[wr]=g,t=(n.mode&1)!==0,i){case"dialog":Ct("cancel",o),Ct("close",o);break;case"iframe":case"object":case"embed":Ct("load",o);break;case"video":case"audio":for(m=0;m<Dn.length;m++)Ct(Dn[m],o);break;case"source":Ct("error",o);break;case"img":case"image":case"link":Ct("error",o),Ct("load",o);break;case"details":Ct("toggle",o);break;case"input":Z(o,g),Ct("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!g.multiple},Ct("invalid",o);break;case"textarea":G(o,g),Ct("invalid",o)}dt(i,g),m=null;for(var j in g)if(g.hasOwnProperty(j)){var z=g[j];j==="children"?typeof z=="string"?o.textContent!==z&&(g.suppressHydrationWarning!==!0&&La(o.textContent,z,t),m=["children",z]):typeof z=="number"&&o.textContent!==""+z&&(g.suppressHydrationWarning!==!0&&La(o.textContent,z,t),m=["children",""+z]):c.hasOwnProperty(j)&&z!=null&&j==="onScroll"&&Ct("scroll",o)}switch(i){case"input":lt(o),Ee(o,g,!0);break;case"textarea":lt(o),Ge(o);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(o.onclick=An)}o=m,n.updateQueue=o,o!==null&&(n.flags|=4)}else{j=m.nodeType===9?m:m.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=ze(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof o.is=="string"?t=j.createElement(i,{is:o.is}):(t=j.createElement(i),i==="select"&&(j=t,o.multiple?j.multiple=!0:o.size&&(j.size=o.size))):t=j.createElementNS(t,i),t[Zn]=n,t[wr]=o,gm(t,n,!1,!1),n.stateNode=t;e:{switch(j=bt(i,o),i){case"dialog":Ct("cancel",t),Ct("close",t),m=o;break;case"iframe":case"object":case"embed":Ct("load",t),m=o;break;case"video":case"audio":for(m=0;m<Dn.length;m++)Ct(Dn[m],t);m=o;break;case"source":Ct("error",t),m=o;break;case"img":case"image":case"link":Ct("error",t),Ct("load",t),m=o;break;case"details":Ct("toggle",t),m=o;break;case"input":Z(t,o),m=ke(t,o),Ct("invalid",t);break;case"option":m=o;break;case"select":t._wrapperState={wasMultiple:!!o.multiple},m=A({},o,{value:void 0}),Ct("invalid",t);break;case"textarea":G(t,o),m=ve(t,o),Ct("invalid",t);break;default:m=o}dt(i,m),z=m;for(g in z)if(z.hasOwnProperty(g)){var W=z[g];g==="style"?mt(t,W):g==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,W!=null&&U(t,W)):g==="children"?typeof W=="string"?(i!=="textarea"||W!=="")&&se(t,W):typeof W=="number"&&se(t,""+W):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(c.hasOwnProperty(g)?W!=null&&g==="onScroll"&&Ct("scroll",t):W!=null&&F(t,g,W,j))}switch(i){case"input":lt(t),Ee(t,o,!1);break;case"textarea":lt(t),Ge(t);break;case"option":o.value!=null&&t.setAttribute("value",""+Ae(o.value));break;case"select":t.multiple=!!o.multiple,g=o.value,g!=null?J(t,!!o.multiple,g,!1):o.defaultValue!=null&&J(t,!!o.multiple,o.defaultValue,!0);break;default:typeof m.onClick=="function"&&(t.onclick=An)}switch(i){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return Sn(n),null;case 6:if(t&&n.stateNode!=null)ym(t,n,t.memoizedProps,o);else{if(typeof o!="string"&&n.stateNode===null)throw Error(r(166));if(i=Sr(fl.current),Sr(Fs.current),ho(n)){if(o=n.stateNode,i=n.memoizedProps,o[Zn]=n,(g=o.nodeValue!==i)&&(t=cn,t!==null))switch(t.tag){case 3:La(o.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&La(o.nodeValue,i,(t.mode&1)!==0)}g&&(n.flags|=4)}else o=(i.nodeType===9?i:i.ownerDocument).createTextNode(o),o[Zn]=n,n.stateNode=o}return Sn(n),null;case 13:if(At(Ft),o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Ot&&es!==null&&(n.mode&1)!==0&&(n.flags&128)===0)wd(),ui(),n.flags|=98560,g=!1;else if(g=ho(n),o!==null&&o.dehydrated!==null){if(t===null){if(!g)throw Error(r(318));if(g=n.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[Zn]=n}else ui(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Sn(n),g=!1}else ws!==null&&(lu(ws),ws=null),g=!0;if(!g)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=i,n):(o=o!==null,o!==(t!==null&&t.memoizedState!==null)&&o&&(n.child.flags|=8192,(n.mode&1)!==0&&(t===null||(Ft.current&1)!==0?ln===0&&(ln=3):uu())),n.updateQueue!==null&&(n.flags|=4),Sn(n),null);case 4:return hi(),Jc(t,n),t===null&&Aa(n.stateNode.containerInfo),Sn(n),null;case 10:return kc(n.type._context),Sn(n),null;case 17:return u(n.type)&&v(),Sn(n),null;case 19:if(At(Ft),g=n.memoizedState,g===null)return Sn(n),null;if(o=(n.flags&128)!==0,j=g.rendering,j===null)if(o)vl(g,!1);else{if(ln!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(j=xo(t),j!==null){for(n.flags|=128,vl(g,!1),o=j.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),n.subtreeFlags=0,o=i,i=n.child;i!==null;)g=i,t=o,g.flags&=14680066,j=g.alternate,j===null?(g.childLanes=0,g.lanes=t,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=j.childLanes,g.lanes=j.lanes,g.child=j.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=j.memoizedProps,g.memoizedState=j.memoizedState,g.updateQueue=j.updateQueue,g.type=j.type,t=j.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return Tt(Ft,Ft.current&1|2),n.child}t=t.sibling}g.tail!==null&&It()>vi&&(n.flags|=128,o=!0,vl(g,!1),n.lanes=4194304)}else{if(!o)if(t=xo(j),t!==null){if(n.flags|=128,o=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),vl(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!Ot)return Sn(n),null}else 2*It()-g.renderingStartTime>vi&&i!==1073741824&&(n.flags|=128,o=!0,vl(g,!1),n.lanes=4194304);g.isBackwards?(j.sibling=n.child,n.child=j):(i=g.last,i!==null?i.sibling=j:n.child=j,g.last=j)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=It(),n.sibling=null,i=Ft.current,Tt(Ft,o?i&1|2:i&1),n):(Sn(n),null);case 22:case 23:return cu(),o=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==o&&(n.flags|=8192),o&&(n.mode&1)!==0?(ts&1073741824)!==0&&(Sn(n),n.subtreeFlags&6&&(n.flags|=8192)):Sn(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function ip(t,n){switch(Jt(n),n.tag){case 1:return u(n.type)&&v(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return hi(),At(gn),At(an),Ac(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return Ec(n),null;case 13:if(At(Ft),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(r(340));ui()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return At(Ft),null;case 4:return hi(),null;case 10:return kc(n.type._context),null;case 22:case 23:return cu(),null;case 24:return null;default:return null}}var Eo=!1,Nn=!1,lp=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function _i(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(o){Ut(t,n,o)}else i.current=null}function Yc(t,n,i){try{i()}catch(o){Ut(t,n,o)}}var xm=!1;function op(t,n){if(Ma=rr,t=io(),si(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var o=i.getSelection&&i.getSelection();if(o&&o.rangeCount!==0){i=o.anchorNode;var m=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var j=0,z=-1,W=-1,he=0,Te=0,Le=t,$e=null;t:for(;;){for(var We;Le!==i||m!==0&&Le.nodeType!==3||(z=j+m),Le!==g||o!==0&&Le.nodeType!==3||(W=j+o),Le.nodeType===3&&(j+=Le.nodeValue.length),(We=Le.firstChild)!==null;)$e=Le,Le=We;for(;;){if(Le===t)break t;if($e===i&&++he===m&&(z=j),$e===g&&++Te===o&&(W=j),(We=Le.nextSibling)!==null)break;Le=$e,$e=Le.parentNode}Le=We}i=z===-1||W===-1?null:{start:z,end:W}}else i=null}i=i||{start:0,end:0}}else i=null;for(br={focusedElem:t,selectionRange:i},rr=!1,Ke=n;Ke!==null;)if(n=Ke,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Ke=t;else for(;Ke!==null;){n=Ke;try{var Je=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Xe=Je.memoizedProps,Yt=Je.memoizedState,ie=n.stateNode,Q=ie.getSnapshotBeforeUpdate(n.elementType===n.type?Xe:js(n.type,Xe),Yt);ie.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var ce=n.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Oe){Ut(n,n.return,Oe)}if(t=n.sibling,t!==null){t.return=n.return,Ke=t;break}Ke=n.return}return Je=xm,xm=!1,Je}function yl(t,n,i){var o=n.updateQueue;if(o=o!==null?o.lastEffect:null,o!==null){var m=o=o.next;do{if((m.tag&t)===t){var g=m.destroy;m.destroy=void 0,g!==void 0&&Yc(n,i,g)}m=m.next}while(m!==o)}}function To(t,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var o=i.create;i.destroy=o()}i=i.next}while(i!==n)}}function Xc(t){var n=t.ref;if(n!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof n=="function"?n(t):n.current=t}}function bm(t){var n=t.alternate;n!==null&&(t.alternate=null,bm(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[Zn],delete n[wr],delete n[ol],delete n[gc],delete n[vc])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function wm(t){return t.tag===5||t.tag===3||t.tag===4}function jm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||wm(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Zc(t,n,i){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(t,n):i.insertBefore(t,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(t,i)):(n=i,n.appendChild(t)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=An));else if(o!==4&&(t=t.child,t!==null))for(Zc(t,n,i),t=t.sibling;t!==null;)Zc(t,n,i),t=t.sibling}function eu(t,n,i){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(o!==4&&(t=t.child,t!==null))for(eu(t,n,i),t=t.sibling;t!==null;)eu(t,n,i),t=t.sibling}var vn=null,ks=!1;function Da(t,n,i){for(i=i.child;i!==null;)km(t,n,i),i=i.sibling}function km(t,n,i){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(cs,i)}catch{}switch(i.tag){case 5:Nn||_i(i,n);case 6:var o=vn,m=ks;vn=null,Da(t,n,i),vn=o,ks=m,vn!==null&&(ks?(t=vn,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):vn.removeChild(i.stateNode));break;case 18:vn!==null&&(ks?(t=vn,i=i.stateNode,t.nodeType===8?ll(t.parentNode,i):t.nodeType===1&&ll(t,i),xa(t)):ll(vn,i.stateNode));break;case 4:o=vn,m=ks,vn=i.stateNode.containerInfo,ks=!0,Da(t,n,i),vn=o,ks=m;break;case 0:case 11:case 14:case 15:if(!Nn&&(o=i.updateQueue,o!==null&&(o=o.lastEffect,o!==null))){m=o=o.next;do{var g=m,j=g.destroy;g=g.tag,j!==void 0&&((g&2)!==0||(g&4)!==0)&&Yc(i,n,j),m=m.next}while(m!==o)}Da(t,n,i);break;case 1:if(!Nn&&(_i(i,n),o=i.stateNode,typeof o.componentWillUnmount=="function"))try{o.props=i.memoizedProps,o.state=i.memoizedState,o.componentWillUnmount()}catch(z){Ut(i,n,z)}Da(t,n,i);break;case 21:Da(t,n,i);break;case 22:i.mode&1?(Nn=(o=Nn)||i.memoizedState!==null,Da(t,n,i),Nn=o):Da(t,n,i);break;default:Da(t,n,i)}}function Sm(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new lp),n.forEach(function(o){var m=gp.bind(null,t,o);i.has(o)||(i.add(o),o.then(m,m))})}}function Ss(t,n){var i=n.deletions;if(i!==null)for(var o=0;o<i.length;o++){var m=i[o];try{var g=t,j=n,z=j;e:for(;z!==null;){switch(z.tag){case 5:vn=z.stateNode,ks=!1;break e;case 3:vn=z.stateNode.containerInfo,ks=!0;break e;case 4:vn=z.stateNode.containerInfo,ks=!0;break e}z=z.return}if(vn===null)throw Error(r(160));km(g,j,m),vn=null,ks=!1;var W=m.alternate;W!==null&&(W.return=null),m.return=null}catch(he){Ut(m,n,he)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Nm(n,t),n=n.sibling}function Nm(t,n){var i=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Ss(n,t),Bs(t),o&4){try{yl(3,t,t.return),To(3,t)}catch(Xe){Ut(t,t.return,Xe)}try{yl(5,t,t.return)}catch(Xe){Ut(t,t.return,Xe)}}break;case 1:Ss(n,t),Bs(t),o&512&&i!==null&&_i(i,i.return);break;case 5:if(Ss(n,t),Bs(t),o&512&&i!==null&&_i(i,i.return),t.flags&32){var m=t.stateNode;try{se(m,"")}catch(Xe){Ut(t,t.return,Xe)}}if(o&4&&(m=t.stateNode,m!=null)){var g=t.memoizedProps,j=i!==null?i.memoizedProps:g,z=t.type,W=t.updateQueue;if(t.updateQueue=null,W!==null)try{z==="input"&&g.type==="radio"&&g.name!=null&&K(m,g),bt(z,j);var he=bt(z,g);for(j=0;j<W.length;j+=2){var Te=W[j],Le=W[j+1];Te==="style"?mt(m,Le):Te==="dangerouslySetInnerHTML"?U(m,Le):Te==="children"?se(m,Le):F(m,Te,Le,he)}switch(z){case"input":xe(m,g);break;case"textarea":Se(m,g);break;case"select":var $e=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!g.multiple;var We=g.value;We!=null?J(m,!!g.multiple,We,!1):$e!==!!g.multiple&&(g.defaultValue!=null?J(m,!!g.multiple,g.defaultValue,!0):J(m,!!g.multiple,g.multiple?[]:"",!1))}m[wr]=g}catch(Xe){Ut(t,t.return,Xe)}}break;case 6:if(Ss(n,t),Bs(t),o&4){if(t.stateNode===null)throw Error(r(162));m=t.stateNode,g=t.memoizedProps;try{m.nodeValue=g}catch(Xe){Ut(t,t.return,Xe)}}break;case 3:if(Ss(n,t),Bs(t),o&4&&i!==null&&i.memoizedState.isDehydrated)try{xa(n.containerInfo)}catch(Xe){Ut(t,t.return,Xe)}break;case 4:Ss(n,t),Bs(t);break;case 13:Ss(n,t),Bs(t),m=t.child,m.flags&8192&&(g=m.memoizedState!==null,m.stateNode.isHidden=g,!g||m.alternate!==null&&m.alternate.memoizedState!==null||(su=It())),o&4&&Sm(t);break;case 22:if(Te=i!==null&&i.memoizedState!==null,t.mode&1?(Nn=(he=Nn)||Te,Ss(n,t),Nn=he):Ss(n,t),Bs(t),o&8192){if(he=t.memoizedState!==null,(t.stateNode.isHidden=he)&&!Te&&(t.mode&1)!==0)for(Ke=t,Te=t.child;Te!==null;){for(Le=Ke=Te;Ke!==null;){switch($e=Ke,We=$e.child,$e.tag){case 0:case 11:case 14:case 15:yl(4,$e,$e.return);break;case 1:_i($e,$e.return);var Je=$e.stateNode;if(typeof Je.componentWillUnmount=="function"){o=$e,i=$e.return;try{n=o,Je.props=n.memoizedProps,Je.state=n.memoizedState,Je.componentWillUnmount()}catch(Xe){Ut(o,i,Xe)}}break;case 5:_i($e,$e.return);break;case 22:if($e.memoizedState!==null){Em(Le);continue}}We!==null?(We.return=$e,Ke=We):Em(Le)}Te=Te.sibling}e:for(Te=null,Le=t;;){if(Le.tag===5){if(Te===null){Te=Le;try{m=Le.stateNode,he?(g=m.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(z=Le.stateNode,W=Le.memoizedProps.style,j=W!=null&&W.hasOwnProperty("display")?W.display:null,z.style.display=ut("display",j))}catch(Xe){Ut(t,t.return,Xe)}}}else if(Le.tag===6){if(Te===null)try{Le.stateNode.nodeValue=he?"":Le.memoizedProps}catch(Xe){Ut(t,t.return,Xe)}}else if((Le.tag!==22&&Le.tag!==23||Le.memoizedState===null||Le===t)&&Le.child!==null){Le.child.return=Le,Le=Le.child;continue}if(Le===t)break e;for(;Le.sibling===null;){if(Le.return===null||Le.return===t)break e;Te===Le&&(Te=null),Le=Le.return}Te===Le&&(Te=null),Le.sibling.return=Le.return,Le=Le.sibling}}break;case 19:Ss(n,t),Bs(t),o&4&&Sm(t);break;case 21:break;default:Ss(n,t),Bs(t)}}function Bs(t){var n=t.flags;if(n&2){try{e:{for(var i=t.return;i!==null;){if(wm(i)){var o=i;break e}i=i.return}throw Error(r(160))}switch(o.tag){case 5:var m=o.stateNode;o.flags&32&&(se(m,""),o.flags&=-33);var g=jm(t);eu(t,g,m);break;case 3:case 4:var j=o.stateNode.containerInfo,z=jm(t);Zc(t,z,j);break;default:throw Error(r(161))}}catch(W){Ut(t,t.return,W)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function cp(t,n,i){Ke=t,Cm(t)}function Cm(t,n,i){for(var o=(t.mode&1)!==0;Ke!==null;){var m=Ke,g=m.child;if(m.tag===22&&o){var j=m.memoizedState!==null||Eo;if(!j){var z=m.alternate,W=z!==null&&z.memoizedState!==null||Nn;z=Eo;var he=Nn;if(Eo=j,(Nn=W)&&!he)for(Ke=m;Ke!==null;)j=Ke,W=j.child,j.tag===22&&j.memoizedState!==null?Tm(m):W!==null?(W.return=j,Ke=W):Tm(m);for(;g!==null;)Ke=g,Cm(g),g=g.sibling;Ke=m,Eo=z,Nn=he}$m(t)}else(m.subtreeFlags&8772)!==0&&g!==null?(g.return=m,Ke=g):$m(t)}}function $m(t){for(;Ke!==null;){var n=Ke;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:Nn||To(5,n);break;case 1:var o=n.stateNode;if(n.flags&4&&!Nn)if(i===null)o.componentDidMount();else{var m=n.elementType===n.type?i.memoizedProps:js(n.type,i.memoizedProps);o.componentDidUpdate(m,i.memoizedState,o.__reactInternalSnapshotBeforeUpdate)}var g=n.updateQueue;g!==null&&Ed(n,g,o);break;case 3:var j=n.updateQueue;if(j!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}Ed(n,j,i)}break;case 5:var z=n.stateNode;if(i===null&&n.flags&4){i=z;var W=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":W.autoFocus&&i.focus();break;case"img":W.src&&(i.src=W.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var he=n.alternate;if(he!==null){var Te=he.memoizedState;if(Te!==null){var Le=Te.dehydrated;Le!==null&&xa(Le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Nn||n.flags&512&&Xc(n)}catch($e){Ut(n,n.return,$e)}}if(n===t){Ke=null;break}if(i=n.sibling,i!==null){i.return=n.return,Ke=i;break}Ke=n.return}}function Em(t){for(;Ke!==null;){var n=Ke;if(n===t){Ke=null;break}var i=n.sibling;if(i!==null){i.return=n.return,Ke=i;break}Ke=n.return}}function Tm(t){for(;Ke!==null;){var n=Ke;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{To(4,n)}catch(W){Ut(n,i,W)}break;case 1:var o=n.stateNode;if(typeof o.componentDidMount=="function"){var m=n.return;try{o.componentDidMount()}catch(W){Ut(n,m,W)}}var g=n.return;try{Xc(n)}catch(W){Ut(n,g,W)}break;case 5:var j=n.return;try{Xc(n)}catch(W){Ut(n,j,W)}}}catch(W){Ut(n,n.return,W)}if(n===t){Ke=null;break}var z=n.sibling;if(z!==null){z.return=n.return,Ke=z;break}Ke=n.return}}var up=Math.ceil,Ao=H.ReactCurrentDispatcher,tu=H.ReactCurrentOwner,rs=H.ReactCurrentBatchConfig,xt=0,dn=null,en=null,yn=0,ts=0,gi=xs(0),ln=0,xl=null,Cr=0,Ro=0,nu=0,bl=null,Bn=null,su=0,vi=1/0,da=null,Lo=!1,au=null,Fa=null,Mo=!1,qa=null,zo=0,wl=0,ru=null,Po=-1,Io=0;function Ln(){return(xt&6)!==0?It():Po!==-1?Po:Po=It()}function Ba(t){return(t.mode&1)===0?1:(xt&2)!==0&&yn!==0?yn&-yn:Gh.transition!==null?(Io===0&&(Io=Vt()),Io):(t=kt,t!==0||(t=window.event,t=t===void 0?16:Li(t.type)),t)}function Ns(t,n,i,o){if(50<wl)throw wl=0,ru=null,Error(r(185));Rs(t,i,o),((xt&2)===0||t!==dn)&&(t===dn&&((xt&2)===0&&(Ro|=i),ln===4&&Ua(t,yn)),Un(t,o),i===1&&xt===0&&(n.mode&1)===0&&(vi=It()+500,we&&$t()))}function Un(t,n){var i=t.callbackNode;Wr(t,n);var o=bn(t,t===dn?yn:0);if(o===0)i!==null&&Ei(i),t.callbackNode=null,t.callbackPriority=0;else if(n=o&-o,t.callbackPriority!==n){if(i!=null&&Ei(i),n===1)t.tag===0?He(Rm.bind(null,t)):qe(Rm.bind(null,t)),il(function(){(xt&6)===0&&$t()}),i=null;else{switch(Gt(o)){case 1:i=Fr;break;case 4:i=tr;break;case 16:i=Ks;break;case 536870912:i=qr;break;default:i=Ks}i=Fm(i,Am.bind(null,t))}t.callbackPriority=n,t.callbackNode=i}}function Am(t,n){if(Po=-1,Io=0,(xt&6)!==0)throw Error(r(327));var i=t.callbackNode;if(yi()&&t.callbackNode!==i)return null;var o=bn(t,t===dn?yn:0);if(o===0)return null;if((o&30)!==0||(o&t.expiredLanes)!==0||n)n=Oo(t,o);else{n=o;var m=xt;xt|=2;var g=Mm();(dn!==t||yn!==n)&&(da=null,vi=It()+500,Er(t,n));do try{fp();break}catch(z){Lm(t,z)}while(!0);jc(),Ao.current=g,xt=m,en!==null?n=0:(dn=null,yn=0,n=ln)}if(n!==0){if(n===2&&(m=As(t),m!==0&&(o=m,n=iu(t,m))),n===1)throw i=xl,Er(t,0),Ua(t,o),Un(t,It()),i;if(n===6)Ua(t,o);else{if(m=t.current.alternate,(o&30)===0&&!dp(m)&&(n=Oo(t,o),n===2&&(g=As(t),g!==0&&(o=g,n=iu(t,g))),n===1))throw i=xl,Er(t,0),Ua(t,o),Un(t,It()),i;switch(t.finishedWork=m,t.finishedLanes=o,n){case 0:case 1:throw Error(r(345));case 2:Tr(t,Bn,da);break;case 3:if(Ua(t,o),(o&130023424)===o&&(n=su+500-It(),10<n)){if(bn(t,0)!==0)break;if(m=t.suspendedLanes,(m&o)!==o){Ln(),t.pingedLanes|=t.suspendedLanes&m;break}t.timeoutHandle=Fn(Tr.bind(null,t,Bn,da),n);break}Tr(t,Bn,da);break;case 4:if(Ua(t,o),(o&4194240)===o)break;for(n=t.eventTimes,m=-1;0<o;){var j=31-pn(o);g=1<<j,j=n[j],j>m&&(m=j),o&=~g}if(o=m,o=It()-o,o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*up(o/1960))-o,10<o){t.timeoutHandle=Fn(Tr.bind(null,t,Bn,da),o);break}Tr(t,Bn,da);break;case 5:Tr(t,Bn,da);break;default:throw Error(r(329))}}}return Un(t,It()),t.callbackNode===i?Am.bind(null,t):null}function iu(t,n){var i=bl;return t.current.memoizedState.isDehydrated&&(Er(t,n).flags|=256),t=Oo(t,n),t!==2&&(n=Bn,Bn=i,n!==null&&lu(n)),t}function lu(t){Bn===null?Bn=t:Bn.push.apply(Bn,t)}function dp(t){for(var n=t;;){if(n.flags&16384){var i=n.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var o=0;o<i.length;o++){var m=i[o],g=m.getSnapshot;m=m.value;try{if(!Yn(g(),m))return!1}catch{return!1}}}if(i=n.child,n.subtreeFlags&16384&&i!==null)i.return=n,n=i;else{if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Ua(t,n){for(n&=~nu,n&=~Ro,t.suspendedLanes|=n,t.pingedLanes&=~n,t=t.expirationTimes;0<n;){var i=31-pn(n),o=1<<i;t[i]=-1,n&=~o}}function Rm(t){if((xt&6)!==0)throw Error(r(327));yi();var n=bn(t,0);if((n&1)===0)return Un(t,It()),null;var i=Oo(t,n);if(t.tag!==0&&i===2){var o=As(t);o!==0&&(n=o,i=iu(t,o))}if(i===1)throw i=xl,Er(t,0),Ua(t,n),Un(t,It()),i;if(i===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=n,Tr(t,Bn,da),Un(t,It()),null}function ou(t,n){var i=xt;xt|=1;try{return t(n)}finally{xt=i,xt===0&&(vi=It()+500,we&&$t())}}function $r(t){qa!==null&&qa.tag===0&&(xt&6)===0&&yi();var n=xt;xt|=1;var i=rs.transition,o=kt;try{if(rs.transition=null,kt=1,t)return t()}finally{kt=o,rs.transition=i,xt=n,(xt&6)===0&&$t()}}function cu(){ts=gi.current,At(gi)}function Er(t,n){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,oi(i)),en!==null)for(i=en.return;i!==null;){var o=i;switch(Jt(o),o.tag){case 1:o=o.type.childContextTypes,o!=null&&v();break;case 3:hi(),At(gn),At(an),Ac();break;case 5:Ec(o);break;case 4:hi();break;case 13:At(Ft);break;case 19:At(Ft);break;case 10:kc(o.type._context);break;case 22:case 23:cu()}i=i.return}if(dn=t,en=t=Wa(t.current,null),yn=ts=n,ln=0,xl=null,nu=Ro=Cr=0,Bn=bl=null,kr!==null){for(n=0;n<kr.length;n++)if(i=kr[n],o=i.interleaved,o!==null){i.interleaved=null;var m=o.next,g=i.pending;if(g!==null){var j=g.next;g.next=m,o.next=j}i.pending=o}kr=null}return t}function Lm(t,n){do{var i=en;try{if(jc(),bo.current=So,wo){for(var o=qt.memoizedState;o!==null;){var m=o.queue;m!==null&&(m.pending=null),o=o.next}wo=!1}if(Nr=0,un=rn=qt=null,hl=!1,pl=0,tu.current=null,i===null||i.return===null){ln=1,xl=n,en=null;break}e:{var g=t,j=i.return,z=i,W=n;if(n=yn,z.flags|=32768,W!==null&&typeof W=="object"&&typeof W.then=="function"){var he=W,Te=z,Le=Te.tag;if((Te.mode&1)===0&&(Le===0||Le===11||Le===15)){var $e=Te.alternate;$e?(Te.updateQueue=$e.updateQueue,Te.memoizedState=$e.memoizedState,Te.lanes=$e.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var We=am(j);if(We!==null){We.flags&=-257,rm(We,j,z,g,n),We.mode&1&&sm(g,he,n),n=We,W=he;var Je=n.updateQueue;if(Je===null){var Xe=new Set;Xe.add(W),n.updateQueue=Xe}else Je.add(W);break e}else{if((n&1)===0){sm(g,he,n),uu();break e}W=Error(r(426))}}else if(Ot&&z.mode&1){var Yt=am(j);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),rm(Yt,j,z,g,n),bc(pi(W,z));break e}}g=W=pi(W,z),ln!==4&&(ln=2),bl===null?bl=[g]:bl.push(g),g=j;do{switch(g.tag){case 3:g.flags|=65536,n&=-n,g.lanes|=n;var ie=tm(g,W,n);$d(g,ie);break e;case 1:z=W;var Q=g.type,ce=g.stateNode;if((g.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Fa===null||!Fa.has(ce)))){g.flags|=65536,n&=-n,g.lanes|=n;var Oe=nm(g,z,n);$d(g,Oe);break e}}g=g.return}while(g!==null)}Pm(i)}catch(Ze){n=Ze,en===i&&i!==null&&(en=i=i.return);continue}break}while(!0)}function Mm(){var t=Ao.current;return Ao.current=So,t===null?So:t}function uu(){(ln===0||ln===3||ln===2)&&(ln=4),dn===null||(Cr&268435455)===0&&(Ro&268435455)===0||Ua(dn,yn)}function Oo(t,n){var i=xt;xt|=2;var o=Mm();(dn!==t||yn!==n)&&(da=null,Er(t,n));do try{mp();break}catch(m){Lm(t,m)}while(!0);if(jc(),xt=i,Ao.current=o,en!==null)throw Error(r(261));return dn=null,yn=0,ln}function mp(){for(;en!==null;)zm(en)}function fp(){for(;en!==null&&!Bl();)zm(en)}function zm(t){var n=Dm(t.alternate,t,ts);t.memoizedProps=t.pendingProps,n===null?Pm(t):en=n,tu.current=null}function Pm(t){var n=t;do{var i=n.alternate;if(t=n.return,(n.flags&32768)===0){if(i=rp(i,n,ts),i!==null){en=i;return}}else{if(i=ip(i,n),i!==null){i.flags&=32767,en=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{ln=6,en=null;return}}if(n=n.sibling,n!==null){en=n;return}en=n=t}while(n!==null);ln===0&&(ln=5)}function Tr(t,n,i){var o=kt,m=rs.transition;try{rs.transition=null,kt=1,hp(t,n,i,o)}finally{rs.transition=m,kt=o}return null}function hp(t,n,i,o){do yi();while(qa!==null);if((xt&6)!==0)throw Error(r(327));i=t.finishedWork;var m=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var g=i.lanes|i.childLanes;if(ga(t,g),t===dn&&(en=dn=null,yn=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Mo||(Mo=!0,Fm(Ks,function(){return yi(),null})),g=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||g){g=rs.transition,rs.transition=null;var j=kt;kt=1;var z=xt;xt|=4,tu.current=null,op(t,i),Nm(i,t),ai(br),rr=!!Ma,br=Ma=null,t.current=i,cp(i),Ti(),xt=z,kt=j,rs.transition=g}else t.current=i;if(Mo&&(Mo=!1,qa=t,zo=m),g=t.pendingLanes,g===0&&(Fa=null),Br(i.stateNode),Un(t,It()),n!==null)for(o=t.onRecoverableError,i=0;i<n.length;i++)m=n[i],o(m.value,{componentStack:m.stack,digest:m.digest});if(Lo)throw Lo=!1,t=au,au=null,t;return(zo&1)!==0&&t.tag!==0&&yi(),g=t.pendingLanes,(g&1)!==0?t===ru?wl++:(wl=0,ru=t):wl=0,$t(),null}function yi(){if(qa!==null){var t=Gt(zo),n=rs.transition,i=kt;try{if(rs.transition=null,kt=16>t?16:t,qa===null)var o=!1;else{if(t=qa,qa=null,zo=0,(xt&6)!==0)throw Error(r(331));var m=xt;for(xt|=4,Ke=t.current;Ke!==null;){var g=Ke,j=g.child;if((Ke.flags&16)!==0){var z=g.deletions;if(z!==null){for(var W=0;W<z.length;W++){var he=z[W];for(Ke=he;Ke!==null;){var Te=Ke;switch(Te.tag){case 0:case 11:case 15:yl(8,Te,g)}var Le=Te.child;if(Le!==null)Le.return=Te,Ke=Le;else for(;Ke!==null;){Te=Ke;var $e=Te.sibling,We=Te.return;if(bm(Te),Te===he){Ke=null;break}if($e!==null){$e.return=We,Ke=$e;break}Ke=We}}}var Je=g.alternate;if(Je!==null){var Xe=Je.child;if(Xe!==null){Je.child=null;do{var Yt=Xe.sibling;Xe.sibling=null,Xe=Yt}while(Xe!==null)}}Ke=g}}if((g.subtreeFlags&2064)!==0&&j!==null)j.return=g,Ke=j;else e:for(;Ke!==null;){if(g=Ke,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:yl(9,g,g.return)}var ie=g.sibling;if(ie!==null){ie.return=g.return,Ke=ie;break e}Ke=g.return}}var Q=t.current;for(Ke=Q;Ke!==null;){j=Ke;var ce=j.child;if((j.subtreeFlags&2064)!==0&&ce!==null)ce.return=j,Ke=ce;else e:for(j=Q;Ke!==null;){if(z=Ke,(z.flags&2048)!==0)try{switch(z.tag){case 0:case 11:case 15:To(9,z)}}catch(Ze){Ut(z,z.return,Ze)}if(z===j){Ke=null;break e}var Oe=z.sibling;if(Oe!==null){Oe.return=z.return,Ke=Oe;break e}Ke=z.return}}if(xt=m,$t(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(cs,t)}catch{}o=!0}return o}finally{kt=i,rs.transition=n}}return!1}function Im(t,n,i){n=pi(i,n),n=tm(t,n,1),t=Oa(t,n,1),n=Ln(),t!==null&&(Rs(t,1,n),Un(t,n))}function Ut(t,n,i){if(t.tag===3)Im(t,t,i);else for(;n!==null;){if(n.tag===3){Im(n,t,i);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Fa===null||!Fa.has(o))){t=pi(i,t),t=nm(n,t,1),n=Oa(n,t,1),t=Ln(),n!==null&&(Rs(n,1,t),Un(n,t));break}}n=n.return}}function pp(t,n,i){var o=t.pingCache;o!==null&&o.delete(n),n=Ln(),t.pingedLanes|=t.suspendedLanes&i,dn===t&&(yn&i)===i&&(ln===4||ln===3&&(yn&130023424)===yn&&500>It()-su?Er(t,0):nu|=i),Un(t,n)}function Om(t,n){n===0&&((t.mode&1)===0?n=1:(n=Ur,Ur<<=1,(Ur&130023424)===0&&(Ur=4194304)));var i=Ln();t=oa(t,n),t!==null&&(Rs(t,n,i),Un(t,i))}function _p(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Om(t,i)}function gp(t,n){var i=0;switch(t.tag){case 13:var o=t.stateNode,m=t.memoizedState;m!==null&&(i=m.retryLane);break;case 19:o=t.stateNode;break;default:throw Error(r(314))}o!==null&&o.delete(n),Om(t,i)}var Dm;Dm=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||gn.current)qn=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return qn=!1,ap(t,n,i);qn=(t.flags&131072)!==0}else qn=!1,Ot&&(n.flags&1048576)!==0&&Zt(n,at,n.index);switch(n.lanes=0,n.tag){case 2:var o=n.type;$o(t,n),t=n.pendingProps;var m=la(n,an.current);fi(n,i),m=Mc(null,n,o,t,m,i);var g=zc();return n.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,u(o)?(g=!0,T(n)):g=!1,n.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,Cc(n),m.updater=No,n.stateNode=m,m._reactInternals=n,qc(n,o,t,i),n=Hc(null,n,o,!0,g,i)):(n.tag=0,Ot&&g&&Lt(n),Rn(null,n,m,i),n=n.child),n;case 16:o=n.elementType;e:{switch($o(t,n),t=n.pendingProps,m=o._init,o=m(o._payload),n.type=o,m=n.tag=yp(o),t=js(o,t),m){case 0:n=Wc(null,n,o,t,i);break e;case 1:n=dm(null,n,o,t,i);break e;case 11:n=im(null,n,o,t,i);break e;case 14:n=lm(null,n,o,js(o.type,t),i);break e}throw Error(r(306,o,""))}return n;case 0:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:js(o,m),Wc(t,n,o,m,i);case 1:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:js(o,m),dm(t,n,o,m,i);case 3:e:{if(mm(n),t===null)throw Error(r(387));o=n.pendingProps,g=n.memoizedState,m=g.element,Cd(t,n),yo(n,o,null,i);var j=n.memoizedState;if(o=j.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){m=pi(Error(r(423)),n),n=fm(t,n,o,i,m);break e}else if(o!==m){m=pi(Error(r(424)),n),n=fm(t,n,o,i,m);break e}else for(es=gs(n.stateNode.containerInfo.firstChild),cn=n,Ot=!0,ws=null,i=Sd(n,null,o,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ui(),o===m){n=ua(t,n,i);break e}Rn(t,n,o,i)}n=n.child}return n;case 5:return Td(n),t===null&&xc(n),o=n.type,m=n.pendingProps,g=t!==null?t.memoizedProps:null,j=m.children,Xn(o,m)?j=null:g!==null&&Xn(o,g)&&(n.flags|=32),um(t,n),Rn(t,n,j,i),n.child;case 6:return t===null&&xc(n),null;case 13:return hm(t,n,i);case 4:return $c(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=di(n,null,o,i):Rn(t,n,o,i),n.child;case 11:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:js(o,m),im(t,n,o,m,i);case 7:return Rn(t,n,n.pendingProps,i),n.child;case 8:return Rn(t,n,n.pendingProps.children,i),n.child;case 12:return Rn(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(o=n.type._context,m=n.pendingProps,g=n.memoizedProps,j=m.value,Tt(_o,o._currentValue),o._currentValue=j,g!==null)if(Yn(g.value,j)){if(g.children===m.children&&!gn.current){n=ua(t,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var z=g.dependencies;if(z!==null){j=g.child;for(var W=z.firstContext;W!==null;){if(W.context===o){if(g.tag===1){W=ca(-1,i&-i),W.tag=2;var he=g.updateQueue;if(he!==null){he=he.shared;var Te=he.pending;Te===null?W.next=W:(W.next=Te.next,Te.next=W),he.pending=W}}g.lanes|=i,W=g.alternate,W!==null&&(W.lanes|=i),Sc(g.return,i,n),z.lanes|=i;break}W=W.next}}else if(g.tag===10)j=g.type===n.type?null:g.child;else if(g.tag===18){if(j=g.return,j===null)throw Error(r(341));j.lanes|=i,z=j.alternate,z!==null&&(z.lanes|=i),Sc(j,i,n),j=g.sibling}else j=g.child;if(j!==null)j.return=g;else for(j=g;j!==null;){if(j===n){j=null;break}if(g=j.sibling,g!==null){g.return=j.return,j=g;break}j=j.return}g=j}Rn(t,n,m.children,i),n=n.child}return n;case 9:return m=n.type,o=n.pendingProps.children,fi(n,i),m=ss(m),o=o(m),n.flags|=1,Rn(t,n,o,i),n.child;case 14:return o=n.type,m=js(o,n.pendingProps),m=js(o.type,m),lm(t,n,o,m,i);case 15:return om(t,n,n.type,n.pendingProps,i);case 17:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:js(o,m),$o(t,n),n.tag=1,u(o)?(t=!0,T(n)):t=!1,fi(n,i),Zd(n,o,m),qc(n,o,m,i),Hc(null,n,o,!0,t,i);case 19:return _m(t,n,i);case 22:return cm(t,n,i)}throw Error(r(156,n.tag))};function Fm(t,n){return er(t,n)}function vp(t,n,i,o){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function is(t,n,i,o){return new vp(t,n,i,o)}function du(t){return t=t.prototype,!(!t||!t.isReactComponent)}function yp(t){if(typeof t=="function")return du(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ye)return 11;if(t===R)return 14}return 2}function Wa(t,n){var i=t.alternate;return i===null?(i=is(t.tag,n,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=n,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,n=t.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function Do(t,n,i,o,m,g){var j=2;if(o=t,typeof t=="function")du(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case fe:return Ar(i.children,m,g,n);case oe:j=8,m|=8;break;case Ne:return t=is(12,i,n,m|2),t.elementType=Ne,t.lanes=g,t;case ue:return t=is(13,i,n,m),t.elementType=ue,t.lanes=g,t;case q:return t=is(19,i,n,m),t.elementType=q,t.lanes=g,t;case ne:return Fo(i,m,g,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Me:j=10;break e;case be:j=9;break e;case ye:j=11;break e;case R:j=14;break e;case V:j=16,o=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return n=is(j,i,n,m),n.elementType=t,n.type=o,n.lanes=g,n}function Ar(t,n,i,o){return t=is(7,t,o,n),t.lanes=i,t}function Fo(t,n,i,o){return t=is(22,t,o,n),t.elementType=ne,t.lanes=i,t.stateNode={isHidden:!1},t}function mu(t,n,i){return t=is(6,t,null,n),t.lanes=i,t}function fu(t,n,i){return n=is(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function xp(t,n,i,o,m){this.tag=n,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xt(0),this.expirationTimes=Xt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.identifierPrefix=o,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function hu(t,n,i,o,m,g,j,z,W){return t=new xp(t,n,i,z,W),n===1?(n=1,g===!0&&(n|=8)):n=0,g=is(3,null,null,n),t.current=g,g.stateNode=t,g.memoizedState={element:o,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Cc(g),t}function bp(t,n,i){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ae,key:o==null?null:""+o,children:t,containerInfo:n,implementation:i}}function qm(t){if(!t)return bs;t=t._reactInternals;e:{if(Ts(t)!==t||t.tag!==1)throw Error(r(170));var n=t;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(u(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(r(171))}if(t.tag===1){var i=t.type;if(u(i))return k(t,i,n)}return n}function Bm(t,n,i,o,m,g,j,z,W){return t=hu(i,o,!0,t,m,g,j,z,W),t.context=qm(null),i=t.current,o=Ln(),m=Ba(i),g=ca(o,m),g.callback=n??null,Oa(i,g,m),t.current.lanes=m,Rs(t,m,o),Un(t,o),t}function qo(t,n,i,o){var m=n.current,g=Ln(),j=Ba(m);return i=qm(i),n.context===null?n.context=i:n.pendingContext=i,n=ca(g,j),n.payload={element:t},o=o===void 0?null:o,o!==null&&(n.callback=o),t=Oa(m,n,j),t!==null&&(Ns(t,m,j,g),vo(t,m,j)),j}function Bo(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Um(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<n?i:n}}function pu(t,n){Um(t,n),(t=t.alternate)&&Um(t,n)}function wp(){return null}var Wm=typeof reportError=="function"?reportError:function(t){console.error(t)};function _u(t){this._internalRoot=t}Uo.prototype.render=_u.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(r(409));qo(t,n,null,null)},Uo.prototype.unmount=_u.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;$r(function(){qo(null,t,null,null)}),n[vs]=null}};function Uo(t){this._internalRoot=t}Uo.prototype.unstable_scheduleHydration=function(t){if(t){var n=Vr();t={blockedOn:null,target:t,priority:n};for(var i=0;i<_n.length&&n!==0&&n<_n[i].priority;i++);_n.splice(i,0,t),i===0&&Pn(t)}};function gu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Wo(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Hm(){}function jp(t,n,i,o,m){if(m){if(typeof o=="function"){var g=o;o=function(){var he=Bo(j);g.call(he)}}var j=Bm(n,o,t,0,null,!1,!1,"",Hm);return t._reactRootContainer=j,t[vs]=j.current,Aa(t.nodeType===8?t.parentNode:t),$r(),j}for(;m=t.lastChild;)t.removeChild(m);if(typeof o=="function"){var z=o;o=function(){var he=Bo(W);z.call(he)}}var W=hu(t,0,!1,null,null,!1,!1,"",Hm);return t._reactRootContainer=W,t[vs]=W.current,Aa(t.nodeType===8?t.parentNode:t),$r(function(){qo(n,W,i,o)}),W}function Ho(t,n,i,o,m){var g=i._reactRootContainer;if(g){var j=g;if(typeof m=="function"){var z=m;m=function(){var W=Bo(j);z.call(W)}}qo(n,j,t,m)}else j=jp(i,n,t,m,o);return Bo(j)}us=function(t){switch(t.tag){case 3:var n=t.stateNode;if(n.current.memoizedState.isDehydrated){var i=nr(n.pendingLanes);i!==0&&(Ls(n,i|1),Un(n,It()),(xt&6)===0&&(vi=It()+500,$t()))}break;case 13:$r(function(){var o=oa(t,1);if(o!==null){var m=Ln();Ns(o,t,1,m)}}),pu(t,1)}},Hr=function(t){if(t.tag===13){var n=oa(t,134217728);if(n!==null){var i=Ln();Ns(n,t,134217728,i)}pu(t,134217728)}},zn=function(t){if(t.tag===13){var n=Ba(t),i=oa(t,n);if(i!==null){var o=Ln();Ns(i,t,n,o)}pu(t,n)}},Vr=function(){return kt},Ai=function(t,n){var i=kt;try{return kt=t,n()}finally{kt=i}},vt=function(t,n,i){switch(n){case"input":if(xe(t,i),n=i.name,i.type==="radio"&&n!=null){for(i=t;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<i.length;n++){var o=i[n];if(o!==t&&o.form===t.form){var m=ci(o);if(!m)throw Error(r(90));pe(o),xe(o,m)}}}break;case"textarea":Se(t,i);break;case"select":n=i.value,n!=null&&J(t,!!i.multiple,n,!1)}},Ye=ou,_t=$r;var kp={usingClientEntryPoint:!1,Events:[jr,Pa,ci,_e,Ce,ou]},jl={findFiberByHostInstance:ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Sp={bundleType:jl.bundleType,version:jl.version,rendererPackageName:jl.rendererPackageName,rendererConfig:jl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:H.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Za(t),t===null?null:t.stateNode},findFiberByHostInstance:jl.findFiberByHostInstance||wp,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 Vo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vo.isDisabled&&Vo.supportsFiber)try{cs=Vo.inject(Sp),hn=Vo}catch{}}return Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kp,Wn.createPortal=function(t,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gu(n))throw Error(r(200));return bp(t,n,null,i)},Wn.createRoot=function(t,n){if(!gu(t))throw Error(r(299));var i=!1,o="",m=Wm;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(m=n.onRecoverableError)),n=hu(t,1,!1,null,null,i,!1,o,m),t[vs]=n.current,Aa(t.nodeType===8?t.parentNode:t),new _u(n)},Wn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var n=t._reactInternals;if(n===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=Za(n),t=t===null?null:t.stateNode,t},Wn.flushSync=function(t){return $r(t)},Wn.hydrate=function(t,n,i){if(!Wo(n))throw Error(r(200));return Ho(null,t,n,!0,i)},Wn.hydrateRoot=function(t,n,i){if(!gu(t))throw Error(r(405));var o=i!=null&&i.hydratedSources||null,m=!1,g="",j=Wm;if(i!=null&&(i.unstable_strictMode===!0&&(m=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),n=Bm(n,null,t,1,i??null,m,!1,g,j),t[vs]=n.current,Aa(t),o)for(t=0;t<o.length;t++)i=o[t],m=i._getVersion,m=m(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,m]:n.mutableSourceEagerHydrationData.push(i,m);return new Uo(n)},Wn.render=function(t,n,i){if(!Wo(n))throw Error(r(200));return Ho(null,t,n,!1,i)},Wn.unmountComponentAtNode=function(t){if(!Wo(t))throw Error(r(40));return t._reactRootContainer?($r(function(){Ho(null,null,t,!1,function(){t._reactRootContainer=null,t[vs]=null})}),!0):!1},Wn.unstable_batchedUpdates=ou,Wn.unstable_renderSubtreeIntoContainer=function(t,n,i,o){if(!Wo(i))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Ho(t,n,i,!1,o)},Wn.version="18.3.1-next-f1338f8080-20240426",Wn}var Zm;function eh(){if(Zm)return xu.exports;Zm=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(s){console.error(s)}}return a(),xu.exports=zp(),xu.exports}var ef;function Pp(){if(ef)return Go;ef=1;var a=eh();return Go.createRoot=a.createRoot,Go.hydrateRoot=a.hydrateRoot,Go}var Ip=Pp();const th=[{id:"dark",label:"Dark (Abstract)",group:"dark",swatches:["#1a1a2e","#16213e","#0f3460","#e94560","#60a5fa","#27ae60"]},{id:"observer-night",label:"Observer Night",group:"dark",swatches:["#0b0f14","#10161e","#161e28","#e8a54a","#6ea8d8","#7bc98c"]},{id:"catppuccin-mocha",label:"Catppuccin Mocha",group:"dark",swatches:["#1e1e2e","#181825","#313244","#cba6f7","#89b4fa","#a6e3a1"]},{id:"catppuccin-macchiato",label:"Catppuccin Macchiato",group:"dark",swatches:["#24273a","#1e2030","#363a4f","#c6a0f6","#8aadf4","#a6da95"]},{id:"catppuccin-frappe",label:"Catppuccin Frappe",group:"dark",swatches:["#303446","#292c3c","#414559","#ca9ee6","#8caaee","#a6d189"]},{id:"rose-pine",label:"Rose Pine",group:"dark",swatches:["#191724","#1f1d2e","#26233a","#c4a7e7","#31748f","#9ccfd8"]},{id:"rose-pine-moon",label:"Rose Pine Moon",group:"dark",swatches:["#232136","#2a273f","#393552","#c4a7e7","#3e8fb0","#9ccfd8"]},{id:"tokyo-night",label:"Tokyo Night",group:"dark",swatches:["#1a1b26","#24283b","#414868","#7aa2f7","#2ac3de","#9ece6a"]},{id:"nord",label:"Nord",group:"dark",swatches:["#2e3440","#3b4252","#434c5e","#88c0d0","#5e81ac","#a3be8c"]},{id:"one-dark",label:"One Dark",group:"dark",swatches:["#282c34","#21252b","#3a3f4b","#61afef","#c678dd","#98c379"]},{id:"dracula",label:"Dracula",group:"dark",swatches:["#282a36","#343746","#44475a","#ff79c6","#8be9fd","#50fa7b"]},{id:"monokai",label:"Monokai",group:"dark",swatches:["#272822","#2d2e27","#3e3d32","#66d9ef","#a1efe4","#a6e22e"]},{id:"gruvbox",label:"Gruvbox",group:"dark",swatches:["#282828","#3c3836","#504945","#fe8019","#83a598","#b8bb26"]},{id:"solarized-dark",label:"Solarized Dark",group:"dark",swatches:["#002b36","#073642","#0b4b5a","#268bd2","#2aa198","#859900"]},{id:"everforest-dark",label:"Everforest Dark",group:"dark",swatches:["#2b3339","#323c41","#3a464c","#a7c080","#7fbbb3","#a7c080"]},{id:"catppuccin-latte",label:"Catppuccin Latte",group:"light",swatches:["#eff1f5","#e6e9ef","#ccd0da","#8839ef","#1e66f5","#40a02b"]},{id:"rose-pine-dawn",label:"Rose Pine Dawn",group:"light",swatches:["#faf4ed","#fffaf3","#f2e9e1","#907aa9","#56949f","#286983"]},{id:"one-light",label:"One Light",group:"light",swatches:["#fafafa","#ffffff","#e5e5e6","#4078f2","#a626a4","#50a14f"]},{id:"everforest-light",label:"Everforest Light",group:"light",swatches:["#fdf6e3","#fffbef","#e8e0cc","#4f8f5a","#3a94c5","#4f8f5a"]},{id:"solarized-light",label:"Solarized Light",group:"light",swatches:["#fdf6e3","#eee8d5","#e3ddc9","#268bd2","#2aa198","#859900"]},{id:"light",label:"Light",group:"light",swatches:["#f7f7fb","#ffffff","#e6e8f0","#e94560","#2563eb","#16a34a"]}];th.map(a=>({id:a.id,label:a.label}));function Op(a){return`theme-${String(a||"").trim()||"dark"}`}function tf(a){try{const s=document.documentElement,r=Array.from(s.classList).filter(l=>l.startsWith("theme-"));for(const l of r)s.classList.remove(l);s.classList.add(Op(a))}catch{}}const Wu=[{id:"sm",label:"Small",scale:.9},{id:"md",label:"Medium",scale:1},{id:"lg",label:"Large",scale:1.1},{id:"xl",label:"Extra Large",scale:1.2}],Hu=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Dp(a){const s=String(a).trim();return Wu.find(r=>r.id===s)||Wu[1]}function Fp(a){const s=String(a).trim();return Hu.find(r=>r.id===s)||Hu[1]}function nf(a){try{const s=document.documentElement,r=Dp(a.font_scale||"md"),l=Fp(a.header_density||"standard");s.style.setProperty("--font-scale",String(r.scale)),s.style.setProperty("--header-density",String(l.density))}catch{}}function qp(a){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(a).matches}catch{return!1}}function Bp(a){const[s,r]=f.useState(()=>qp(a));return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(a),c=()=>r(l.matches);return c(),typeof l.addEventListener=="function"?l.addEventListener("change",c):l.addListener(c),()=>{typeof l.removeEventListener=="function"?l.removeEventListener("change",c):l.removeListener(c)}},[a]),s}let Sl=null;function Up(a,s){const r=Math.max(0,Math.round(a));if(!(s.scale<=1.01))return{vvHeight:r,keyboardInset:0};const l=Math.max(0,Math.min(r,Math.round(s.height))),c=Math.max(0,Math.round(a-s.height-Math.max(0,s.offsetTop)));return{vvHeight:l,keyboardInset:c}}function Wp(){if(Sl)return Sl;if(typeof window>"u"||typeof document>"u")return()=>{};const a=window.visualViewport;if(!a)return()=>{};const s=document.documentElement;let r=0;const l=()=>{r=0;const{vvHeight:d,keyboardInset:h}=Up(window.innerHeight,{height:a.height,offsetTop:a.offsetTop,scale:a.scale||1});s.style.setProperty("--vv-height",`${d}px`),s.style.setProperty("--keyboard-inset",`${h}px`)},c=()=>{r||(r=window.requestAnimationFrame(l))};return l(),a.addEventListener("resize",c),a.addEventListener("scroll",c),window.addEventListener("orientationchange",c),Sl=()=>{a.removeEventListener("resize",c),a.removeEventListener("scroll",c),window.removeEventListener("orientationchange",c),r&&window.cancelAnimationFrame(r),s.style.removeProperty("--vv-height"),s.style.removeProperty("--keyboard-inset"),Sl=null},Sl}var nh=eh();function xi(...a){return a.filter(Boolean).join(" ")}function Ir({value:a,options:s,placeholder:r="Select…",disabled:l=!1,loading:c=!1,searchable:d=!0,searchPlaceholder:h="Search…",allowCustom:p=!1,clearable:_=!1,minPopoverWidth:y=240,variant:b="panel",className:x,triggerClassName:N,ariaLabel:E,id:I,includeValueOption:C=!1,onOpen:M,customOptionLabel:O,validateCustomValue:D,onChange:F,renderOption:H,renderValue:$}){const ae=f.useRef(null),fe=f.useRef(null),oe=f.useRef(null),Ne=f.useRef(M),Me=f.useId(),be=I||`af-select-${Me.replace(/[^a-zA-Z0-9_-]/g,"")}`,ye=`${be}-listbox`,[ue,q]=f.useState(!1),[R,V]=f.useState(""),[ne,Y]=f.useState(0),[me,A]=f.useState("bottom"),[w,L]=f.useState({left:0,top:0,width:0});f.useEffect(()=>{Ne.current=M},[M]);const X=f.useMemo(()=>{if(!C)return s;const te=String(a??"").trim();return!te||s.some(J=>J.value===te)?s:[...s,{value:te,label:te}]},[C,s,a]),ge=f.useMemo(()=>{const te=String(a??"");return X.find(J=>J.value===te)||null},[X,a]),de=f.useMemo(()=>(ge==null?void 0:ge.label)||String(a||"").trim()||"",[ge,a]),P=f.useMemo(()=>{const te=R.trim().toLowerCase();return te?X.filter(J=>J.label.toLowerCase().includes(te)||J.value.toLowerCase().includes(te)):X},[X,R]),je=f.useMemo(()=>{if(!p)return null;const te=R.trim();if(!te||X.some(G=>G.value===te))return null;const ve=(D==null?void 0:D(te,{options:X}))||"";return{value:te,label:O?O(te):`Use "${te}"`,disabled:!!ve,reason:ve}},[p,O,X,R,D]),Ae=f.useMemo(()=>{const te=je?[je,...P]:P;if(te.length>0)return te;const J=String(a??"").trim();return c&&J?[{value:J,label:de||J}]:te},[je,P,c,de,a]),Fe=f.useCallback(()=>{const te=ae.current;if(!te)return;const J=te.getBoundingClientRect(),ve=Math.max(J.width,y),G=Math.max(8,Math.min(J.left,window.innerWidth-ve-8)),Se=window.innerHeight-J.bottom,Ge=J.top,ze=Se>=220||Se>=Ge?"bottom":"top";A(ze);const Qe=ze==="bottom"?J.bottom+6:J.top-6;L({left:G,top:Qe,width:ve})},[y]),Ve=f.useCallback(()=>{q(!1),V("")},[]);f.useEffect(()=>{var te;ue&&((te=Ne.current)==null||te.call(Ne))},[ue]),f.useEffect(()=>{if(!ue)return;Fe();const te=()=>Fe();return window.addEventListener("resize",te),window.addEventListener("scroll",te,!0),()=>{window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0)}},[ue,Fe]),f.useEffect(()=>{if(!ue)return;const te=J=>{var G,Se;const ve=J.target;ve&&((G=ae.current)!=null&&G.contains(ve)||(Se=fe.current)!=null&&Se.contains(ve)||Ve())};return document.addEventListener("mousedown",te,!0),()=>document.removeEventListener("mousedown",te,!0)},[ue,Ve]),f.useEffect(()=>{if(!ue)return;const te=Math.max(0,Ae.findIndex(J=>J.value===a));Y(te===-1?0:te),d&&setTimeout(()=>{var J;return(J=oe.current)==null?void 0:J.focus()},0)},[ue,d,a,Ae]);const lt=te=>{var ve;const J=Ae.find(G=>G.value===te);J!=null&&J.disabled||(F(te),Ve(),(ve=ae.current)==null||ve.focus())},pe=te=>{var J,ve;if(te.key==="Escape")return te.preventDefault(),Ve(),(J=ae.current)==null||J.focus(),!0;if(te.key==="Tab")return Ve(),(ve=ae.current)==null||ve.focus(),!1;if(te.key==="ArrowDown")return te.preventDefault(),Y(G=>Math.min(G+1,Math.max(0,Ae.length-1))),!0;if(te.key==="ArrowUp")return te.preventDefault(),Y(G=>Math.max(G-1,0)),!0;if(te.key==="Home")return te.preventDefault(),Y(0),!0;if(te.key==="End")return te.preventDefault(),Y(Math.max(0,Ae.length-1)),!0;if(te.key==="Enter"){te.preventDefault();const G=Ae[ne];return G&&lt(G.value),!0}return!1},Ie=te=>{if(!l){if(ue){if(pe(te))return;if(te.key===" "&&!d){te.preventDefault();const J=Ae[ne];J&&lt(J.value)}return}(te.key==="Enter"||te.key===" "||te.key==="ArrowDown"||te.key==="ArrowUp")&&(te.preventDefault(),q(!0))}},ke=!!String(a||"").trim(),Z=ke?de:r,K=je!=null&&je.disabled?je.reason||"Unavailable":"",xe=ue&&Ae.length>0?`${be}-opt-${ne}`:void 0,Ee=e.jsx("span",{className:xi("af-select-value",!ke&&"af-select-value--placeholder"),children:c&&!ke?"Loading…":Z}),De=$?$(ge,String(a||"")):Ee;return e.jsxs("span",{className:xi("af-select",b==="pin"?"af-select--pin":"af-select--panel",x),children:[e.jsxs("button",{ref:ae,id:be,type:"button",className:xi("af-select-trigger",_&&ke&&"af-select-trigger--clearable",N),disabled:l,onMouseDown:te=>te.stopPropagation(),onClick:te=>{te.stopPropagation(),!l&&q(J=>!J)},onKeyDown:Ie,role:d?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":ue,"aria-controls":ue?ye:void 0,"aria-activedescendant":d?void 0:xe,"aria-label":E,children:[De,e.jsx("span",{className:xi("af-select-caret",ue&&"af-select-caret--open"),children:"▾"})]}),_&&ke?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:l,onMouseDown:te=>{te.preventDefault(),te.stopPropagation()},onClick:te=>{var J;te.preventDefault(),te.stopPropagation(),F(""),Ve(),(J=ae.current)==null||J.focus()},title:"Clear",children:"×"}):null,ue?nh.createPortal(e.jsxs("div",{ref:fe,className:xi("af-select-popover",me==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`},onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),onWheel:te=>te.stopPropagation(),onKeyDown:pe,tabIndex:-1,children:[d?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:oe,className:"af-select-search-input",value:R,onChange:te=>V(te.target.value),placeholder:h,onKeyDown:pe,role:"combobox","aria-expanded":!0,"aria-controls":ye,"aria-activedescendant":xe,"aria-invalid":!!K,"aria-describedby":K?`${be}-custom-error`:void 0}),K?e.jsx("div",{id:`${be}-custom-error`,className:"af-select-custom-error",role:"alert",children:K}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:ye,"aria-label":E,children:c&&Ae.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):Ae.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):Ae.map((te,J)=>{var Qe;const ve=te.value===a,G=J===ne,Se=String(te.group||"").trim(),Ge=J>0?String(((Qe=Ae[J-1])==null?void 0:Qe.group)||"").trim():"",ze=!!Se&&Se!==Ge;return e.jsxs(Wt.Fragment,{children:[ze?e.jsx("div",{className:"af-select-group",role:"presentation",children:Se}):null,e.jsx("div",{id:`${be}-opt-${J}`,role:"option","aria-selected":ve,className:xi("af-select-option",ve&&"af-select-option--selected",G&&"af-select-option--highlighted",te.disabled&&"af-select-option--disabled"),title:te.disabled?te.reason||"Unavailable":void 0,onMouseEnter:()=>Y(J),onMouseDown:ee=>{ee.preventDefault(),ee.stopPropagation()},onClick:()=>lt(te.value),"aria-disabled":te.disabled?!0:void 0,children:H?H(te,{selected:ve,highlighted:G}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:te.label}),te.reason?e.jsx("small",{className:"af-select-option-reason",children:te.reason}):null]}),ve?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},te.value)})})]}),document.body):null]})}function Hp(a){const s=new Set,r=[];for(const l of a||[]){if(!l||typeof l!="object")continue;const c=String(l.name||"").trim();!c||s.has(c)||(s.add(c),r.push({name:c,display_name:typeof l.display_name=="string"?l.display_name:void 0}))}return r.sort((l,c)=>l.name.localeCompare(c.name)),r}function Vp(a){const s=new Set,r=[];for(const l of a||[]){const c=String(l||"").trim();!c||s.has(c)||(s.add(c),r.push(c))}return r.sort(),r}function Gp(a){const s=a.disabled===!0,r=a.layout||"stack",l=a.allowGatewayDefault!==!1,c=String(a.gatewayDefaultLabel||"(gateway default)"),d=String(a.providerLabel||"Provider"),h=String(a.modelLabel||"Model"),p=String(a.providerPlaceholder||"(select)"),_=String(a.modelPlaceholder||"(select)"),y=String(a.provider||"").trim(),b=String(a.model||"").trim(),x=Hp(a.providers),N=Vp(a.models),E=s||!!a.loadingProviders,I=s||!!a.loadingModels,C=[...l?[{value:"",label:c}]:[],...x.map(O=>({value:O.name,label:O.display_name?`${O.display_name} (${O.name})`:O.name}))],M=[...l?[{value:"",label:c}]:[],...N.map(O=>({value:O,label:O}))];return e.jsxs("div",{className:a.className,style:r==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:d}),e.jsx(Ir,{value:y,options:C,placeholder:l?c:p,disabled:E,loading:!!a.loadingProviders,searchable:!0,allowCustom:a.allowCustomProvider===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:d,onChange:O=>a.onChange({provider:String(O||"").trim(),model:""})}),a.loadingProviders?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,a.providerError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:a.providerError}):null]}),e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:h}),e.jsx(Ir,{value:b,options:M,placeholder:l?c:_,disabled:I,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:h,onChange:O=>a.onChange({provider:y,model:String(O||"").trim()})}),a.loadingModels?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,a.modelError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:a.modelError}):null]})]})}function Kp(a){if(a===!1||a&&typeof a=="object"&&a.mode==="off")return!1;if(!a||typeof a!="object")return;const s=a;if(!(s.mode!=="native_mtp"||!Number.isInteger(s.num_draft_tokens)||Number(s.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(s.num_draft_tokens),require_acceleration:!0}}function Qp(a){var r;const s=(r=a==null?void 0:a.execution)==null?void 0:r.speculation;return!s||typeof s.supported!="boolean"?null:{supported:s.supported,ready:typeof s.ready=="boolean"?s.ready:null,reason:typeof s.reason=="string"?s.reason:null,supported_depths:s.supported&&Array.isArray(s.supported_depths)?[...new Set(s.supported_depths.filter(l=>typeof l=="number"&&Number.isInteger(l)&&l>0))]:[],default:Object.prototype.hasOwnProperty.call(s,"effective_default")?s.effective_default:s.default,requires_reload:typeof s.requires_reload=="boolean"?s.requires_reload:null}}function sf(a){const s=Kp(a);return s===!1?"off":s?String(s.num_draft_tokens):""}function Jp(a){if(a==="off")return!1;if(!(!/^\d+$/.test(a)||Number(a)<1))return{mode:"native_mtp",num_draft_tokens:Number(a),require_acceleration:!0}}function Yp(a){const s=Qp(a.capabilities),r=sf(a.value),l=(s==null?void 0:s.supported_depths.map(String))||[],c=sf(s==null?void 0:s.default),d=a.inheritLabel||"Workflow / Gateway default",h=c?`${d} (${c==="off"?"Off":`depth ${c}`})`:d,p=a.error||(a.loading?"Checking MTP capability…":s?s.reason||(s.requires_reload?"Model reload required before MTP can run.":s.ready===!1?"MTP is supported but not ready on this instance.":s.ready===null&&s.supported?"MTP support verified; loaded-instance readiness is unknown.":s.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return e.jsxs("div",{className:"af-pmp__speculation",children:[e.jsx("label",{children:"MTP depth"}),e.jsx(Ir,{ariaLabel:"MTP depth",value:r,placeholder:h,disabled:a.disabled||a.loading,options:[{value:"",label:h},{value:"off",label:"Off"},...l.map(_=>({value:_,label:`Depth ${_}`})),...r&&r!=="off"&&!l.includes(r)?[{value:r,label:`Depth ${r} (saved; not available)`}]:[]],onChange:_=>a.onChange(Jp(_))}),p?e.jsx("div",{role:"status",className:"af-pmp__hint",children:p}):null]})}function Xp(a){var Y,me;const s=a.disabled===!0,r=a.value||{provider:"",model:""},l=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[c,d]=f.useState(!l),h=l&&!c,p=f.useRef(l);f.useEffect(()=>{l&&!p.current&&d(!1),p.current=l},[l]);const[_,y]=f.useState([]),[b,x]=f.useState(!1),[N,E]=f.useState(""),[I,C]=f.useState([]),[M,O]=f.useState(!1),[D,F]=f.useState(""),H=f.useRef(a);H.current=a,f.useEffect(()=>{if(h||s)return;let A=!0;return x(!0),(async()=>{try{const w=await H.current.fetchProviders();if(!A)return;y(Array.isArray(w)?w:[]),E("")}catch(w){if(!A)return;y([]),E(`#FALLBACK provider discovery failed: ${String((w==null?void 0:w.message)||w)}`)}finally{A&&x(!1)}})(),()=>{A=!1}},[h,s]);const $=String(r.provider||"").trim();f.useEffect(()=>{if(!$||s){C([]),F(""),O(!1);return}let A=!0;return C([]),O(!0),F(""),(async()=>{try{const w=await H.current.fetchModels($);if(!A)return;C(Array.isArray(w)?w:[])}catch(w){if(!A)return;C([]),F(`#FALLBACK model discovery failed: ${String((w==null?void 0:w.message)||w)}`)}finally{A&&O(!1)}})(),()=>{A=!1}},[$,s]);const ae=f.useMemo(()=>{const A=[..._];return $&&!A.some(w=>w.name===$)&&A.unshift({name:$}),A},[_,$]),fe=String(r.model||"").trim(),oe=f.useMemo(()=>{const A=[...I];return fe&&!A.includes(fe)&&A.unshift(fe),A},[I,fe]),Ne=a.defaultModeLabel||"Gateway default",Me=a.customModeLabel||"Custom",be=$||((Y=a.effectiveDefault)==null?void 0:Y.provider)||"",ye=fe||($?"":(me=a.effectiveDefault)==null?void 0:me.model)||"",[ue,q]=f.useState({levels:[],error:"",loading:!1}),R=!!a.fetchModelCapabilities,[V,ne]=f.useState();return f.useEffect(()=>{let A=!0;if(ne(void 0),q({levels:[],error:"",loading:R&&!!ye}),!(!R||!ye||s))return H.current.fetchModelCapabilities(ye,be).then(w=>{var de;if(!A)return;if(w!=null&&w.error)throw new Error(String(w.error));ne(w);const L=(w==null?void 0:w.capabilities)||w||{},X=L.reasoning_levels||L.thinking_levels,ge=Array.isArray(X)?[...new Set(X.filter(P=>typeof P=="string"&&!!P.trim()))]:[];!ge.length&&L.thinking_support===!0&&((de=L.thinking_control)!=null&&de.prompt_disable_token)&&ge.push("off","auto"),q({levels:ge,error:"",loading:!1})}).catch(w=>{A&&q({levels:[],error:`Reasoning options unavailable: ${String((w==null?void 0:w.message)||w)}`,loading:!1})}),()=>{A=!1}},[be,ye,R,s]),e.jsxs("div",{className:`af-pmp${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":h,className:`af-pmp__seg-btn${h?" is-active":""}`,onClick:()=>{d(!1),a.onChange({...r,provider:"",model:"",...R?{reasoning:""}:{}})},disabled:s,children:Ne}),e.jsx("button",{type:"button",role:"tab","aria-selected":!h,className:`af-pmp__seg-btn${h?"":" is-active"}`,onClick:()=>{d(!0)},disabled:s,children:Me})]}),h?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(Gp,{provider:$,model:fe,providers:ae,models:oe,disabled:s,loadingProviders:b,loadingModels:M,providerError:N||void 0,modelError:D||void 0,providerLabel:a.providerLabel,modelLabel:a.modelLabel,allowGatewayDefault:!1,allowCustomProvider:a.allowCustom!==!1,allowCustomModel:a.allowCustom!==!1,onChange:A=>a.onChange({...r,provider:A.provider,model:A.model,...R?{reasoning:""}:{}})}),R&&(ue.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx(Ir,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:r.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...ue.levels.map(A=>({value:A,label:A})),...r.reasoning&&!ue.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:s||ue.loading,onChange:A=>a.onChange({...r,reasoning:A})})]}):null,ue.error?e.jsx("div",{role:"status",className:"af-pmp__hint",children:ue.error}):null,a.enableSpeculation?e.jsx(Yp,{value:r.speculation,onChange:A=>a.onChange({...r,speculation:A}),capabilities:V,disabled:s,loading:ue.loading,error:ue.error?ue.error.replace("Reasoning options","MTP options"):void 0}):null]})}function af(...a){return a.filter(Boolean).join(" ")}function Zp({kicker:a="AbstractGateway connection",title:s="Connect to AbstractGateway",description:r="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:l="Gateway token missing",statusTone:c="warn",tokenSourceLabel:d="token: missing",showGatewayUrl:h=!1,gatewayUrl:p="",gatewayUrlPlaceholder:_="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:b,userPlaceholder:x="admin",onUserIdChange:N,token:E,tokenPlaceholder:I="Paste Gateway user token",showToken:C=!1,onTokenChange:M,onShowTokenChange:O,remember:D=!1,rememberLabel:F="Remember this browser",onRememberChange:H,loading:$=!1,submitting:ae=!1,submitDisabled:fe=!1,submitLabel:oe="Sign in",submittingLabel:Ne="Signing in...",closeLabel:Me="Close",signOutLabel:be="Sign out",showClose:ye=!1,showSignOut:ue=!1,error:q,message:R,className:V,onSubmit:ne,onClose:Y,onSignOut:me}){const A=$||ae,w=A||fe||!String(b||"").trim()||!String(E||"").trim(),L=X=>{X.preventDefault(),!w&&ne()};return e.jsxs("form",{className:af("af-gateway-signin",V),onSubmit:L,children:[e.jsxs("div",{className:"af-gateway-signin__hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"af-gateway-signin__kicker",children:a}),e.jsx("h2",{children:s}),r?e.jsx("p",{children:r}):null]}),e.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),e.jsxs("div",{className:"af-gateway-signin__status-row",children:[e.jsx("span",{className:af("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:l}),d?e.jsx("span",{className:"af-gateway-signin__source",children:d}):null]}),e.jsxs("div",{className:"af-gateway-signin__form",children:[h?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),e.jsx("input",{id:"gateway-session-url",value:p,onChange:X=>y==null?void 0:y(X.target.value),placeholder:_,autoComplete:"url",disabled:A})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:b,onChange:X=>N(X.target.value),placeholder:x,autoComplete:"username",disabled:A}),e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),e.jsxs("div",{className:"af-gateway-signin__token-input",children:[e.jsx("input",{id:"gateway-session-token",type:C?"text":"password",value:E,onChange:X=>M(X.target.value),placeholder:I,autoComplete:"current-password",disabled:A}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>O==null?void 0:O(!C),disabled:A,children:C?"Hide":"Show"})]}),e.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!D,onChange:X=>H==null?void 0:H(X.target.checked),disabled:A}),F]})]}),q?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:q}):null,!q&&R?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:R}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[ye?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:Y,disabled:A,children:Me}):null,ue?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(me==null?void 0:me()),disabled:A,children:be}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:w,children:ae?Ne:oe})]})]})}function e_(a){return a==="light"?"Light":"Dark"}function t_(a){const s=a.themes&&a.themes.length?a.themes:th,r=a.showSwatches!==!1,l=a.variant||"panel",c=f.useMemo(()=>{const h={};for(const p of s)h[p.id]=p;return h},[s]),d=f.useMemo(()=>s.map(h=>({value:h.id,label:h.label,group:e_(h.group)})),[s]);return e.jsx(Ir,{value:a.value,options:d,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:l,className:a.className,triggerClassName:a.triggerClassName,onChange:h=>a.onChange(String(h||"").trim()),renderValue:(h,p)=>{const _=String(p||"").trim(),y=c[_],b=(y==null?void 0:y.label)||_||a.placeholder||"Select theme…",x=(y==null?void 0:y.swatches)||null,N=!_;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${N?"af-theme-label--placeholder":""}`.trim(),children:b}),r&&x?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:x.map((E,I)=>e.jsx("span",{className:"af-theme-swatch",style:{background:E}},`${_}:${I}`))}):null]})},renderOption:(h,p)=>{const _=String(h.value||"").trim(),y=c[_],b=(y==null?void 0:y.swatches)||null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"af-theme-option-label",children:h.label}),e.jsxs("span",{className:"af-theme-option-right",children:[r&&b?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:b.map((x,N)=>e.jsx("span",{className:"af-theme-swatch",style:{background:x}},`${_}:${N}`))}):null,p.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function n_(a){const s=a.scales&&a.scales.length?a.scales:Wu,r=a.variant||"panel",l=f.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Ir,{value:a.value,options:l,placeholder:a.placeholder||"Font size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:c=>a.onChange(String(c||"").trim())})}function s_(a){const s=a.densities&&a.densities.length?a.densities:Hu,r=a.variant||"panel",l=f.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Ir,{value:a.value,options:l,placeholder:a.placeholder||"Header size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:c=>a.onChange(String(c||"").trim())})}const a_=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function r_(a){switch(a){case"chat":return e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"});case"plus":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]});case"history":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),e.jsx("path",{d:"M3 3v5h5"}),e.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),e.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("circle",{cx:"8",cy:"6",r:"2"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("circle",{cx:"16",cy:"12",r:"2"}),e.jsx("path",{d:"M4 18h16"}),e.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2v3"}),e.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),e.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M9 17h6"})]});case"paperclip":return e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a5.5 5.5 0 0 1-7.78-7.78l9.19-9.19a3.5 3.5 0 0 1 4.95 4.95l-9.2 9.19a1.5 1.5 0 0 1-2.12-2.12l8.49-8.48"});case"mic":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),e.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),e.jsx("path",{d:"M12 18v4"}),e.jsx("path",{d:"M8 22h8"})]});case"speaker":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),e.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),e.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 9l3 3-3 3"}),e.jsx("path",{d:"M12 15h5"})]});case"edit":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]});case"download":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("path",{d:"M7 10l5 5 5-5"}),e.jsx("path",{d:"M12 15V3"})]});case"loader":return e.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l10 18H2L12 3z"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M15 9l-6 6"}),e.jsx("path",{d:"M9 9l6 6"})]});case"copy":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return e.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return e.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return e.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M6 6l1 16h10l1-16"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"})]});case"send":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2L11 13"}),e.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7"})]});case"thumbsDown":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17"})]});case"thumbsUpFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7z",fill:"currentColor",stroke:"none"})]});case"thumbsDownFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17z",fill:"currentColor",stroke:"none"})]});case"board":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),e.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),e.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),e.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),e.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),e.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),e.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),e.jsx("path",{d:"M8 4.5V2.2"}),e.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),e.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2.5 4h11"}),e.jsx("path",{d:"M2.5 8h11"}),e.jsx("path",{d:"M2.5 12h7"})]});case"gear":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),e.jsx("path",{d:"M8 1.6v2"}),e.jsx("path",{d:"M8 12.4v2"}),e.jsx("path",{d:"M1.6 8h2"}),e.jsx("path",{d:"M12.4 8h2"}),e.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),e.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),e.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),e.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),e.jsx("path",{d:"M18.5 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"})]});case"contrast":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("path",{d:"M16 17l5-5-5-5"}),e.jsx("path",{d:"M21 12H9"})]});case"play":return e.jsx("path",{d:"M7 4.5v15a1 1 0 0 0 1.5.86l12-7.5a1 1 0 0 0 0-1.72l-12-7.5A1 1 0 0 0 7 4.5z",fill:"currentColor",stroke:"none"});case"stop":return e.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2",fill:"currentColor",stroke:"none"});case"folder":return e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"});case"file":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("path",{d:"M14 2v6h6"})]});case"archive":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),e.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),e.jsx("path",{d:"M10 12h4"})]});case"clock":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6h4"})]});default:return null}}function et({name:a,size:s=16,className:r,title:l,...c}){const d=l?void 0:!0,h=a_.has(a);return e.jsxs("svg",{width:s,height:s,viewBox:h?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:h?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":d,role:l?"img":"presentation",...c,children:[l?e.jsx("title",{children:l}):null,r_(a)]})}const Ci="api/connection/gateway";function rf(a,s){const r=String(s||"");if(r.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(r)}.`);let l=String(a??"");for(;l.endsWith("/");)l=l.slice(0,-1);return l?`${l}/${r}`:r}const ju=1;function Ka(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const i_=["granted","denied","structurally_unavailable","trust_gated"],l_=["attachable","requires_review","blocked"],o_=["default","operator","structural"],c_=["grant","deny","clear"],u_=new Set(["__proto__","constructor","prototype"]);function d_(a,s){if(!Ka(a))return{ok:!1,reason:`${s}: cell is not an object`};const r=String(a.availability||"");if(!i_.includes(r))return{ok:!1,reason:`${s}: unknown availability "${r}"`};const l=String(a.provenance||"");if(!o_.includes(l))return{ok:!1,reason:`${s}: unknown provenance "${l}"`};let c;if(r==="trust_gated"){const d=String(a.trust_state||"");if(!l_.includes(d))return{ok:!1,reason:`${s}: trust_gated cell without a valid trust_state ("${d}")`};c=d}for(const d of["assigned","resolved_value","executable"]){const h=a[d];if(h!==void 0&&typeof h!="boolean")return{ok:!1,reason:`${s}: "${d}" is present but not a boolean`}}return{ok:!0,cell:{assigned:a.assigned===!0,resolved_value:a.resolved_value===!0,provenance:l,availability:r,executable:a.executable!==!1,reason:typeof a.reason=="string"?a.reason:void 0,trust_state:c}}}function sh(a){if(!Ka(a))return{ok:!1,reason:"payload is not an object"};const s=a.schema_version;if(typeof s!="number"||!Number.isFinite(s))return{ok:!1,reason:"payload has no numeric schema_version"};if(Math.floor(s)!==ju)return{ok:!1,reason:`unsupported schema_version ${s} (this build understands ${ju}); refusing to render grant state from an unknown schema`};if(!Array.isArray(a.phases)||a.phases.length===0)return{ok:!1,reason:"payload has no phases"};if(!Array.isArray(a.sections))return{ok:!1,reason:"payload has no sections"};const r=[],l=new Set;for(const h of a.phases){if(!Ka(h)||typeof h.id!="string"||!h.id.trim())return{ok:!1,reason:"phase without a string id"};const p=h.id.trim();if(u_.has(p))return{ok:!1,reason:`reserved phase id "${p}"`};if(l.has(p))return{ok:!1,reason:`duplicate phase id "${p}"`};l.add(p),r.push({id:p,label:typeof h.label=="string"?h.label:void 0,hint:typeof h.hint=="string"?h.hint:void 0})}const c=[],d=new Set;for(const h of a.sections){if(!Ka(h)||typeof h.id!="string"||!h.id.trim())return{ok:!1,reason:"section without a string id"};const p=h.id.trim();if(d.has(p))return{ok:!1,reason:`duplicate section id "${p}"`};if(d.add(p),!Array.isArray(h.items))return{ok:!1,reason:`section "${p}" has no items array`};const _=[],y=new Set;for(const b of h.items){if(!Ka(b)||typeof b.id!="string"||!b.id.trim())return{ok:!1,reason:`section "${p}": item without a string id`};const x=b.id.trim();if(y.has(x))return{ok:!1,reason:`section "${p}": duplicate item id "${x}"`};if(y.add(x),b.cells!==void 0&&!Ka(b.cells))return{ok:!1,reason:`section "${p}" item "${x}": cells is not an object`};const N=Object.create(null),E=Ka(b.cells)?b.cells:{};for(const[I,C]of Object.entries(E)){if(!l.has(I))return{ok:!1,reason:`section "${p}" item "${x}": cell for undeclared phase "${I}"`};const M=d_(C,`section "${p}" item "${x}" phase "${I}"`);if(!M.ok)return M;N[I]=M.cell}_.push({id:x,label:typeof b.label=="string"?b.label:void 0,description:typeof b.description=="string"?b.description:void 0,cells:N})}c.push({id:p,label:typeof h.label=="string"?h.label:void 0,items:_})}return{ok:!0,payload:{schema_version:ju,phases:r,sections:c}}}function m_(a,s,r,l){for(const c of a)if(c.section===s&&c.item===r&&c.phase===l)return c.op;return null}function od(a,s,r,l,c){const d=a.sections.find(I=>I.id===r),h=d==null?void 0:d.items.find(I=>I.id===l),p=h&&h.cells[c]||null,_=m_(s,r,l,c);if(!p)return{cell:null,pending:null,effective_value:!1,interactive:!1,approval_required:!1,standing_config:!1,reason:"not declared by the server for this phase",control:{kind:"absent"}};const y=p.availability==="structurally_unavailable"||p.availability==="trust_gated"&&p.trust_state==="blocked";let b=p.resolved_value;_==="grant"?b=!0:_==="deny"?b=!1:_==="clear"&&(b=p.provenance==="operator"?null:p.resolved_value);const x=p.availability==="trust_gated"&&p.trust_state==="requires_review",N=y?!1:b;let E;return y?E={kind:"blocked",blocked_kind:p.availability==="trust_gated"?"trust":"structural"}:x&&N!==!0?E={kind:"approval"}:E={kind:"tristate",options:["grant","clear","deny"],active_op:_!==null?_:p.assigned?p.resolved_value?"grant":"deny":"clear"},{cell:p,pending:_,effective_value:N,interactive:!y,approval_required:x,standing_config:!y&&p.executable===!1,reason:p.reason||(y?p.availability:null),control:E}}function f_(a,s,r){const l=od(a,s,r.section,r.item,r.phase);if(!l.cell||!l.interactive)return s;const c=s.filter(p=>!(p.section===r.section&&p.item===r.item&&p.phase===r.phase)),d=l.cell;return r.op==="clear"?d.assigned?[...c,r]:c:d.assigned&&d.provenance==="operator"&&d.resolved_value===(r.op==="grant")?c:[...c,r]}function h_(a,s){const r=new Set,l=[];for(const c of s){if(!Ka(c)||!c_.includes(c.op))continue;const d=`${c.section}\0${c.item}\0${c.phase}`;if(r.has(d))continue;r.add(d);const h=od(a,[],c.section,c.item,c.phase);!h.cell||!h.interactive||l.push(c)}return l}function p_(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function __(a){const{view:s,disabled:r}=a,l=s.control;if(l.kind==="absent")return e.jsx("div",{className:"af-matrix__cell is-absent",title:s.reason||void 0,children:e.jsx("span",{className:"af-matrix__cell-mark",children:"—"})});if(l.kind==="blocked")return e.jsxs("div",{className:`af-matrix__cell is-unavailable is-${l.blocked_kind}`,children:[e.jsx("span",{className:"af-matrix__cell-mark",children:"✕"}),e.jsx("span",{className:"af-matrix__cell-note",children:l.blocked_kind==="trust"?"blocked":"structural"}),s.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:s.reason}):null]});if(l.kind==="approval")return e.jsxs("div",{className:"af-matrix__cell is-review",children:[e.jsx("span",{className:"af-matrix__cell-note",children:"needs review"}),e.jsx("button",{type:"button",className:"af-matrix__approve-btn",disabled:r,onClick:()=>a.onAct("grant"),"aria-label":`Approve and enable: ${a.cellLabel}`,children:"Approve & enable"}),s.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:s.reason}):null]});const c=s.cell,d=s.effective_value===null?"server default (unknown until saved)":s.effective_value?"on":"off";return e.jsxs("div",{className:`af-matrix__cell ${s.effective_value===null?"is-indeterminate":s.effective_value?"is-on":"is-off"} ${s.pending?"is-pending":""}`.trim(),title:s.reason||void 0,children:[e.jsx("div",{className:"af-matrix__tristate",role:"group","aria-label":a.cellLabel,children:l.options.map(h=>e.jsx("button",{type:"button","aria-pressed":l.active_op===h,className:`af-matrix__tri-btn is-${h} ${l.active_op===h?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(h),children:p_(h)},h))}),e.jsxs("div",{className:"af-matrix__cell-meta",children:[e.jsx("span",{className:`af-matrix__prov is-${c.provenance}`,children:s.pending?"pending":c.provenance}),e.jsx("span",{className:"af-matrix__value-mark",children:d}),s.standing_config?e.jsx("span",{className:"af-matrix__standing",title:s.reason||"grant is stored; no executor consumes it yet",children:"standing config"}):null]})]})}function g_(a){const s=a.disabled===!0,r=f.useMemo(()=>sh(a.payload),[a.payload]),l=f.useMemo(()=>r.ok?h_(r.payload,a.patches):a.patches,[r,a.patches]);if(!r.ok)return e.jsxs("div",{className:`af-matrix af-matrix--refused ${a.className||""}`.trim(),children:[e.jsx("div",{className:"af-matrix__title",children:a.title||"Phase capabilities"}),e.jsxs("div",{className:"af-matrix__refusal",children:["Cannot render capability state: ",r.reason]})]});const c=r.payload,d=(h,p,_,y)=>{if(s)return;const b=f_(c,l,{section:h,item:p,phase:_,op:y});a.onPatchesChange(b)};return e.jsxs("div",{className:`af-matrix ${a.className||""}`.trim(),children:[e.jsxs("div",{className:"af-matrix__header",children:[e.jsx("div",{className:"af-matrix__title",children:a.title||"Phase capabilities"}),a.subtitle?e.jsx("div",{className:"af-matrix__subtitle",children:a.subtitle}):null,l.length>0?e.jsxs("div",{className:"af-matrix__pending-note",children:[l.length," unsaved change",l.length===1?"":"s"," (cell-scoped; untouched cells are never written)"]}):null]}),e.jsx("div",{className:"af-matrix__scroll",children:e.jsxs("table",{className:"af-matrix__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"af-matrix__corner"}),c.phases.map(h=>e.jsxs("th",{className:"af-matrix__phase",title:h.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:h.label||h.id}),h.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:h.hint}):null]},h.id))]})}),c.sections.map(h=>e.jsxs("tbody",{className:"af-matrix__section",children:[e.jsx("tr",{className:"af-matrix__section-row",children:e.jsx("th",{className:"af-matrix__section-label",colSpan:c.phases.length+1,children:h.label||h.id})}),h.items.map(p=>e.jsxs("tr",{className:"af-matrix__item-row",children:[e.jsx("th",{className:"af-matrix__item",title:p.description||void 0,children:e.jsx("span",{className:"af-matrix__item-name",children:p.label||p.id})}),c.phases.map(_=>{const y=od(c,l,h.id,p.id,_.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(__,{view:y,cellLabel:`${p.label||p.id} — ${_.label||_.id}`,disabled:s,onAct:b=>d(h.id,p.id,_.id,b)})},_.id)})]},p.id)),h.items.length===0?e.jsx("tr",{children:e.jsx("td",{className:"af-matrix__empty",colSpan:c.phases.length+1,children:"No entries in this section."})}):null]},h.id))]})})]})}async function Vu(a=Ci){const s=await fetch(a),r=await s.json().catch(()=>null);if(!s.ok){const l=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${s.status}`;throw new Error(l)}return r}async function v_(a,s=Ci){const r=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),l=await r.json().catch(()=>null);if(!r.ok){const c=l&&typeof l=="object"&&l.detail?String(l.detail):`HTTP ${r.status}`;throw new Error(c)}return l}async function ah(a=Ci){const s=await fetch(a,{method:"DELETE"});if(!s.ok){const r=await s.json().catch(()=>({})),l=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${s.status}`;throw new Error(l)}}function ku(a){let s=String(a||"").trim();for(let r=0;r<2&&s;r+=1){try{const d=JSON.parse(s);if(typeof d=="string"&&d!==s){s=d.trim();continue}}catch{}const l=s[0],c=s[s.length-1];if(l==='"'&&c==='"'||l==="'"&&c==="'"){s=s.slice(1,-1).trim();continue}break}return s.replace(/\/+$/,"")}function y_(a){var d,h;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const s=a.gateway||{},r=(d=s.principal)==null?void 0:d.user_id,l=(h=s.principal)==null?void 0:h.runtime_id;if(s.ok&&r)return{label:`Signed in as ${r}${l?` · runtime ${l}`:""}`,tone:"ok"};if(s.ok)return{label:"Signed in",tone:"ok"};const c=s.error||s.detail;return typeof c=="string"&&c.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function x_(a){const s=a.connectionPath||Ci,[r,l]=f.useState(!1),[c,d]=f.useState(!1),[h,p]=f.useState(null),[_,y]=f.useState(!1);f.useEffect(()=>{a.isOpen||y(!1)},[a.isOpen]);const[b,x]=f.useState(a.defaultGatewayUrl||"http://127.0.0.1:8080"),[N,E]=f.useState("admin"),[I,C]=f.useState(""),[M,O]=f.useState(!1),[D,F]=f.useState(!0),[H,$]=f.useState(""),[ae,fe]=f.useState(""),oe=f.useMemo(()=>y_(h),[h]),Ne=ue=>{var q;p(ue),(q=a.onStatusChange)==null||q.call(a,ue)},Me=f.useRef(!1);if(f.useEffect(()=>{var q;if(!a.isOpen)return;const ue=!Me.current;if(Me.current=!0,ue&&a.initialStatus!==void 0&&a.initialStatus!==null){const R=a.initialStatus;Ne(R),typeof R.gateway_url=="string"&&R.gateway_url.trim()&&x(ku(R.gateway_url));const V=(q=R.gateway)==null?void 0:q.principal;V!=null&&V.user_id&&E(V.user_id);return}l(!0),$(""),Vu(s).then(R=>{var ne;Ne(R),typeof R.gateway_url=="string"&&R.gateway_url.trim()&&x(ku(R.gateway_url));const V=(ne=R.gateway)==null?void 0:ne.principal;V!=null&&V.user_id&&E(V.user_id)}).catch(R=>$(`Failed to load connection status: ${String((R==null?void 0:R.message)||R)}`)).finally(()=>l(!1))},[a.isOpen]),f.useEffect(()=>{if(!a.isOpen)return;const ue=q=>{q.key==="Escape"&&!q.defaultPrevented&&!a.blocking&&(q.preventDefault(),a.onClose())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||_)return null;const be=async()=>{d(!0),$(""),fe("");try{const ue=ku(b);x(ue);const q=await v_({gateway_url:ue,gateway_user_id:N,gateway_token:I,persist:D},s);Ne(q),C(""),y(!0),a.onClose()}catch(ue){$(String((ue==null?void 0:ue.message)||ue))}finally{d(!1)}},ye=async()=>{d(!0),$(""),fe("");try{await ah(s),C("");const ue=await Vu(s).catch(()=>null);Ne(ue),fe("Signed out. This browser no longer holds a gateway session.")}catch(ue){$(String((ue==null?void 0:ue.message)||ue))}finally{d(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:ue=>{!a.blocking&&ue.target===ue.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Zp,{kicker:`${a.appName||"AbstractFramework"} connection`,title:"Connect this browser to AbstractGateway",description:"Sign in with a Gateway user token. The app exchanges it for an HTTP-only browser session and never stores the raw token.",statusLabel:oe.label,statusTone:oe.tone,tokenSourceLabel:h!=null&&h.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:b,onGatewayUrlChange:ue=>x(ue),userId:N,onUserIdChange:E,token:I,tokenPlaceholder:h!=null&&h.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:M,onTokenChange:C,onShowTokenChange:O,remember:D,rememberLabel:"Keep this browser signed in",onRememberChange:F,loading:r,submitting:c,submittingLabel:"Signing in...",showClose:!a.blocking,onClose:a.onClose,showSignOut:!a.blocking&&!!(h!=null&&h.has_session),onSignOut:ye,error:H,message:ae,onSubmit:be})})})}function b_(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function w_(a){const s=a||{},r=s.connectionPath||Ci,l=s.variant||"dismissable",c=f.useRef(s.onStatusChange);c.current=s.onStatusChange;const d=f.useRef(l);d.current=l;const h=f.useRef(!!s.autoOpenMidSession);h.current=!!s.autoOpenMidSession;const[p,_]=f.useState(null),[y,b]=f.useState("loading"),[x,N]=f.useState(!1),E=f.useRef(!1),I=f.useRef(!1),C=f.useRef("loading"),M=f.useRef("none"),O=f.useRef(!1),D=f.useRef(0),F=f.useCallback(q=>{var V;D.current+=1,_(q),(V=c.current)==null||V.call(c,q);const R=b_(q);if(R)b("connected"),C.current="connected",E.current=!1,M.current="none",I.current||N(!1);else if(q!==null){const ne=C.current;b("disconnected"),C.current="disconnected",ne!=="disconnected"&&(M.current=O.current?"signout":ne==="connected"?"mid":"boot");const Y=d.current==="blocking"||M.current!=="mid"||h.current;!E.current&&Y&&N(!0)}q!==null&&(I.current=R)},[]),H=f.useCallback(async()=>{const q=D.current;try{const R=await Vu(r);if(D.current!==q)return;F(R)}catch{if(D.current!==q)return;F(null)}},[r,F]),[$,ae]=f.useState(!1),[fe,oe]=f.useState(null),Ne=f.useCallback(async()=>{ae(!0),oe(null),D.current+=1;let q=null;try{await ah(r)}catch(R){q=String((R==null?void 0:R.message)||R||"Sign-out request failed")}O.current=!0;try{await H()}finally{O.current=!1}oe(q),ae(!1)},[r,H]),Me=f.useRef(!1);f.useEffect(()=>{Me.current||(Me.current=!0,H())},[H]);const be=f.useCallback(()=>{N(!0)},[]),ye=f.useCallback(()=>{const q=C.current;l==="blocking"&&q==="disconnected"||(q==="disconnected"&&(E.current=!0),N(!1))},[l]),ue=f.useMemo(()=>({isOpen:x,onClose:ye,blocking:l==="blocking"&&y!=="connected",appName:s.appName,connectionPath:r,defaultGatewayUrl:s.defaultGatewayUrl,initialStatus:p,onStatusChange:F}),[x,ye,l,y,s.appName,r,s.defaultGatewayUrl,p,F]);return{status:p,phase:y,connected:y==="connected",modalOpen:x,signingOut:$,signOutError:fe,openModal:be,refresh:H,signOut:Ne,modalProps:ue}}const Su={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},j_=/^var\(--[a-z0-9-]+\)$/i;function k_(a,s){const r=a||"neutral";if(r==="custom"){const l=String(s||"").trim();return j_.test(l)?l:Su.neutral}return Su[r]||Su.neutral}function S_(a,s,r){return[a,`${a}--${s.tone||"neutral"}`,s.size==="sm"?`${a}--sm`:"",r||"",s.className||""].filter(Boolean).join(" ")}function N_(a){return{"--af-chip-hue":k_(a.tone,a.hue)}}function Hn(a){return e.jsxs("span",{className:S_("af-chip",a,a.onRemove?"af-chip--removable":""),style:N_(a),title:a.title,children:[e.jsx("span",{className:"af-chip__label",children:a.children}),a.onRemove?e.jsx("button",{type:"button",className:"af-chip__remove","aria-label":a.removeLabel||"Remove",onClick:s=>{var r;s.stopPropagation(),(r=a.onRemove)==null||r.call(a)},children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}):null]})}function lf(a){const s=a.closeOnEscape!==!1,r=f.useRef(null);return f.useEffect(()=>{if(!a.open||!s)return;const l=c=>{c.key!=="Escape"||c.defaultPrevented||(c.preventDefault(),a.onClose())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[a.open,s,a.onClose]),f.useEffect(()=>{const l=r.current;l&&(a.open?l.removeAttribute("inert"):l.setAttribute("inert",""))},[a.open]),e.jsxs(e.Fragment,{children:[a.backdrop&&a.open?e.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:a.onClose,style:{top:a.topOffset||0}}):null,e.jsxs("div",{ref:r,className:`af-drawer${a.side==="left"?" af-drawer--left":""}${a.topOffset?" af-drawer--offset":""}${a.open?" af-drawer--open":""}${a.className?` ${a.className}`:""}`,style:{width:a.width||420,top:a.topOffset||0,display:a.open?void 0:"none"},role:"complementary","aria-label":a.label,"aria-hidden":a.open?void 0:!0,children:[a.title!==void 0?e.jsxs("div",{className:"af-drawer__header",children:[e.jsx("div",{className:"af-drawer__title",children:a.title}),e.jsxs("div",{className:"af-drawer__header-actions",children:[a.headerActions,e.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:a.onClose,children:"×"})]})]}):null,e.jsx("div",{className:"af-drawer__body",children:a.children})]})]})}const C_={name:"AbstractFramework",website:"https://abstractframework.ai",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},$_={abstractframework:{name:"AbstractFramework",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractFramework",docs:"https://github.com/lpalbou/AbstractFramework/tree/main/docs",issues:"https://github.com/lpalbou/AbstractFramework/issues",feedback:"https://github.com/lpalbou/AbstractFramework/issues/new?labels=feedback"},abstractgateway:{name:"AbstractGateway",website:"https://abstractframework.ai/gateway",repo:"https://github.com/lpalbou/AbstractGateway",docs:"https://www.lpalbou.info/AbstractGateway/",issues:"https://github.com/lpalbou/AbstractGateway/issues",feedback:"https://github.com/lpalbou/AbstractGateway/issues/new?labels=feedback"},abstractcode:{name:"AbstractCode",website:"https://abstractframework.ai/code",repo:"https://github.com/lpalbou/AbstractCode",docs:"https://github.com/lpalbou/AbstractCode/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCode/issues",feedback:"https://github.com/lpalbou/AbstractCode/issues/new?labels=feedback"},abstractassistant:{name:"AbstractAssistant",website:"https://abstractframework.ai/assistant",repo:"https://github.com/lpalbou/AbstractAssistant",docs:"https://github.com/lpalbou/AbstractAssistant/blob/main/docs/README.md",issues:"https://github.com/lpalbou/AbstractAssistant/issues",feedback:"https://github.com/lpalbou/AbstractAssistant/issues/new?labels=feedback"},abstractflow:{name:"AbstractFlow",website:"https://abstractframework.ai/flow",repo:"https://github.com/lpalbou/AbstractFlow",docs:"https://github.com/lpalbou/AbstractFlow#readme",issues:"https://github.com/lpalbou/AbstractFlow/issues",feedback:"https://github.com/lpalbou/AbstractFlow/issues/new?labels=feedback"},abstractcontinuum:{name:"AbstractContinuum",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractContinuum",docs:"https://github.com/lpalbou/AbstractContinuum/tree/main/docs",issues:"https://github.com/lpalbou/AbstractContinuum/issues",feedback:"https://github.com/lpalbou/AbstractContinuum/issues/new?labels=feedback"},abstractentity:{name:"AbstractEntity",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractEntity",docs:"https://github.com/lpalbou/AbstractEntity/tree/main/docs",issues:"https://github.com/lpalbou/AbstractEntity/issues",feedback:"https://github.com/lpalbou/AbstractEntity/issues/new?labels=feedback"},abstractobserver:{name:"AbstractObserver",website:"https://abstractframework.ai/observer",repo:"https://github.com/lpalbou/AbstractObserver",docs:"https://github.com/lpalbou/AbstractObserver#readme",issues:"https://github.com/lpalbou/AbstractObserver/issues",feedback:"https://github.com/lpalbou/AbstractObserver/issues/new?labels=feedback"},abstractcore:{name:"AbstractCore",website:"https://www.abstractcore.ai",repo:"https://github.com/lpalbou/AbstractCore",docs:"https://github.com/lpalbou/AbstractCore/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCore/issues",feedback:"https://github.com/lpalbou/AbstractCore/issues/new?labels=feedback"},abstractuic:{name:"AbstractUIC",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractUIC",docs:"https://github.com/lpalbou/AbstractUIC/tree/main/docs",issues:"https://github.com/lpalbou/AbstractUIC/issues",feedback:"https://github.com/lpalbou/AbstractUIC/issues/new?labels=feedback"}},E_={framework:C_,apps:$_},ac=E_;function T_(){return Object.keys(ac.apps).sort()}function A_(a,s){const r=Object.prototype.hasOwnProperty.call(ac.apps,a)?ac.apps[a]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${a}" (known: ${T_().join(", ")})`);return{id:a,name:r.name,version:s,website:r.website,repo:r.repo,docs:r.docs,issues:r.issues,feedback:r.feedback}}function R_(a,s){const r=ac.framework,l=[["Application",`${a.name} ${a.version}`],["Part of",`${r.name} — ${r.website}`],["Author",`${r.author} (${r.years})`],["Copyright",r.copyright],["Website",a.website],["Source",a.repo],["Documentation",a.docs],["Report an issue",a.issues],["Give feedback",a.feedback],["Contact",r.contact_email]];for(const[c,d]of s||[])l.push([String(c),String(d)]);return l}function Nu(a){return typeof a=="string"?a.trim():""}function of(a,s){if(s!=null)return[["Gateway",`unavailable (${String(s).trim()||"unknown error"})`]];const r=a&&typeof a=="object"&&!Array.isArray(a)?a:{},l=Nu(r.abstractgateway);if(!l)return[["Gateway","unavailable (the gateway did not report its version)"]];const c=Nu(r.abstractframework),d=[["Gateway",`AbstractGateway ${l}`],["Gateway framework",c?`AbstractFramework ${c}`:"not installed on the gateway host"]],h=r.packages&&typeof r.packages=="object"&&!Array.isArray(r.packages)?r.packages:{},p=Object.keys(h).filter(_=>_!=="abstractgateway"&&_!=="abstractframework").sort((_,y)=>_<y?-1:_>y?1:0);for(const _ of p){const y=Nu(h[_]);y&&d.push([`Gateway package ${_}`,y])}return d}const L_='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function M_(a,s,r){if(a.key!=="Tab"||!s)return;const l=Array.from(s.querySelectorAll(L_));if(l.length===0){a.preventDefault();return}const c=l[0],d=l[l.length-1],h=!!r&&s.contains(r);a.shiftKey?(r===c||!h)&&(a.preventDefault(),d.focus()):(r===d||!h)&&(a.preventDefault(),c.focus())}const z_=/https?:\/\/[^\s<>"]+/g;function P_(a,s){if(a==="Contact")return[{text:s,href:`mailto:${s}`}];const r=[];let l=0;for(const c of s.matchAll(z_)){const d=c.index??0;d>l&&r.push({text:s.slice(l,d)}),r.push({text:c[0],href:c[0]}),l=d+c[0].length}return(l<s.length||r.length===0)&&r.push({text:s.slice(l)}),r}function I_({label:a,value:s}){return e.jsx("span",{children:P_(a,s).map((r,l)=>r.href===void 0?e.jsx(Wt.Fragment,{children:r.text},l):r.href.startsWith("mailto:")?e.jsx("a",{className:"af-about__link",href:r.href,children:r.text},l):e.jsx("a",{className:"af-about__link",href:r.href,target:"_blank",rel:"noopener noreferrer",children:r.text},l))})}function O_(a){const s=f.useRef(null),r=f.useRef(null),l=f.useId(),c=f.useRef(a.onClose);if(c.current=a.onClose,f.useEffect(()=>{var y;if(!a.open)return;const p=document.activeElement;(y=s.current)==null||y.focus();const _=b=>{if(!b.defaultPrevented){if(b.key==="Escape"){b.preventDefault(),c.current();return}M_(b,r.current,document.activeElement)}};return window.addEventListener("keydown",_),()=>{window.removeEventListener("keydown",_),p&&typeof p.focus=="function"&&p.focus()}},[a.open]),!a.open)return null;const d=a.title||`About ${a.identity.name}`,h=R_(a.identity,a.extraRows);return e.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:a.onClose,role:"presentation",children:e.jsxs("div",{ref:r,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":l,onClick:p=>p.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",id:l,children:d}),e.jsx("dl",{className:"af-about__rows",children:h.map(([p,_],y)=>e.jsxs("div",{className:"af-about__row",children:[e.jsx("dt",{className:"af-about__label",children:p}),e.jsx("dd",{className:"af-about__value",children:e.jsx(I_,{label:p,value:_})})]},`${y}:${p}`))}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{ref:s,type:"button",className:"af-appearance__close",onClick:a.onClose,children:"Close"})})]})})}function D_(a){const{connection:s}=a,r=s.phase,l=s.signingOut===!0,[c,d]=f.useState(!1),h=a.about,p=l?"Signing out…":r==="connected"?"Disconnect":r==="loading"?"Connecting…":"Connect",_=r==="connected"?"Disconnect from gateway":r==="loading"?"Checking gateway session…":"Connect to gateway";return e.jsxs("div",{className:`af-topbar${a.className?` ${a.className}`:""}`,role:"group","aria-label":"App actions",children:[a.assistant?e.jsx("button",{type:"button",className:`af-topbar__btn${a.assistant.open?" is-active":""}`,"aria-pressed":a.assistant.open,"aria-label":a.assistant.label||"Open assistant",title:a.assistant.label||"Assistant",onClick:a.assistant.onToggle,children:e.jsx(et,{name:"sparkle",size:16})}):null,a.appearance?e.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":a.appearance.label||"Appearance (theme and typography)",title:a.appearance.label||"Appearance",onClick:a.appearance.onOpen,children:e.jsx(et,{name:"contrast",size:16})}):null,h?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":h.label||`About ${h.identity.name}`,title:h.label||"About","aria-haspopup":"dialog",onClick:()=>{var y;d(!0),(y=h.onOpen)==null||y.call(h)},children:e.jsx(et,{name:"info",size:16})}):null,a.extraActions,e.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${r}`,onClick:r==="connected"?s.onDisconnect:s.onConnect,disabled:l,title:_,"aria-label":_,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:p})]}),h?e.jsx(O_,{open:c,onClose:()=>d(!1),identity:h.identity,extraRows:h.extraRows}):null]})}const tc={theme:"dark",font_scale:"md",header_density:"standard"};function F_(a){const s=a&&typeof a=="object"?a:{};return{theme:typeof s.theme=="string"&&s.theme?s.theme:tc.theme,font_scale:typeof s.font_scale=="string"&&s.font_scale?s.font_scale:tc.font_scale,header_density:typeof s.header_density=="string"&&s.header_density?s.header_density:tc.header_density}}function q_(a){return`af_appearance_${a}_v1`}function B_(a,s){const r=q_(a),l=f.useMemo(()=>({...tc}),[JSON.stringify({})]),[c,d]=f.useState(()=>{let h=l;try{const p=localStorage.getItem(r)??(s!=null&&s.legacyKey?localStorage.getItem(s.legacyKey):null);p&&(h=F_({...l,...JSON.parse(p)}))}catch{}try{tf(h.theme),nf({font_scale:h.font_scale,header_density:h.header_density})}catch{}return h});return f.useEffect(()=>{tf(c.theme),nf({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(r,JSON.stringify(c))}catch{}},[r,c]),[c,d]}function U_(a){return f.useEffect(()=>{if(!a.open)return;const s=r=>{r.key!=="Escape"||r.defaultPrevented||(r.preventDefault(),a.onClose())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a.open,a.onClose]),a.open?e.jsx("div",{className:"af-appearance-overlay",onClick:a.onClose,role:"presentation",children:e.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":a.title||"Appearance",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",children:a.title||"Appearance"}),e.jsx("div",{className:"af-appearance__note",children:a.note||"Stored locally in this browser, per app."}),e.jsxs("div",{className:"af-appearance__grid",children:[e.jsx("label",{className:"af-appearance__label",children:"Theme"}),e.jsx(t_,{value:a.value.theme,onChange:s=>a.onChange({...a.value,theme:s})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(n_,{value:a.value.font_scale,onChange:s=>a.onChange({...a.value,font_scale:s})}),e.jsx("label",{className:"af-appearance__label",children:"Header size"}),e.jsx(s_,{value:a.value.header_density,onChange:s=>a.onChange({...a.value,header_density:s})})]}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{type:"button",className:"af-appearance__close",onClick:a.onClose,children:"Close"})})]})}):null}async function*W_(a){const s=new AbortController;try{const r=await fetch(a.path,{method:"POST",headers:{"Content-Type":"application/json",...a.csrfToken?{"x-abstract-csrf":a.csrfToken}:{},...a.headers||{}},body:JSON.stringify(a.body),signal:s.signal});if(!r.ok){const h=await r.json().catch(()=>null),p=h&&typeof h=="object"&&h.detail?String(h.detail):`HTTP ${r.status}`;throw new Error(p)}if(!r.body)throw new Error("TTS stream has no body");const l=r.body.getReader(),c=new TextDecoder;let d="";for(;;){const{done:h,value:p}=await l.read();if(h)break;d+=c.decode(p,{stream:!0});let _;for(;(_=d.indexOf(`
41
- `))>=0;){const y=d.slice(0,_).trim();if(d=d.slice(_+1),!y)continue;let b=null;try{b=JSON.parse(y)}catch{continue}if(b&&b.type==="error")throw new Error(String(b.error||"TTS stream error"));const x=b&&typeof b.audio_b64=="string"?b.audio_b64:"";if(x){const N=atob(x),E=new Uint8Array(N.length);for(let I=0;I<N.length;I+=1)E[I]=N.charCodeAt(I);yield E.buffer}if(b&&(b.type==="done"||b.type==="cancelled"))return}}}finally{s.abort()}}function H_(){var s;if(typeof window>"u")return!1;const a=navigator;return!!((s=a==null?void 0:a.mediaDevices)!=null&&s.getUserMedia)&&typeof window.MediaRecorder=="function"}function V_(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function G_(){const a=window.MediaRecorder,s=l=>{var c;try{return!!((c=a==null?void 0:a.isTypeSupported)!=null&&c.call(a,l))}catch{return!1}},r=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const l of r)if(s(l))return l;return""}async function Cu(a,s){var c;const r=s.slice(0),l=(c=a.decodeAudioData)==null?void 0:c.bind(a);if(typeof l!="function")throw new Error("decodeAudioData not available");try{const d=l(r);if(d&&typeof d.then=="function")return await d}catch{}return await new Promise((d,h)=>{try{l(r,d,h)}catch(p){h(p)}})}function K_(a){const s=new Uint8Array(a);if(s.length<44)return null;const r=d=>String.fromCharCode(s[d],s[d+1],s[d+2],s[d+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const l=new DataView(a);let c=12;for(;c+8<=s.length;){const d=r(c),h=l.getUint32(c+4,!0);if(d==="data")return s.slice(0,c+8);c+=8+h+h%2}return null}function Q_(a,s){const r=new Uint8Array(s),l=new Uint8Array(a.length+r.length);l.set(a,0),l.set(r,a.length);const c=new DataView(l.buffer);return c.setUint32(4,l.length-8,!0),c.setUint32(a.length-4,r.length,!0),l.buffer}function rh(a){const s=f.useRef(a);s.current=a;const r=pe=>{var Ie,ke;return(ke=(Ie=s.current).on_error)==null?void 0:ke.call(Ie,pe)},l=f.useMemo(()=>V_()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),c=f.useMemo(()=>H_()&&typeof a.transcribe=="function",[a.transcribe]),[d,h]=f.useState({key:"",status:"idle"}),p=f.useRef(d),_=f.useCallback(pe=>{p.current=pe,h(Ie=>Ie.key===pe.key&&Ie.status===pe.status?Ie:pe)},[]),y=f.useRef(""),b=f.useRef(""),x=f.useRef(null),N=f.useRef(null),E=f.useRef(null),I=f.useRef(null),C=f.useRef(0),M=f.useRef(0),O=f.useRef(0),D=f.useRef([]),F=f.useRef(0),H=f.useRef(!0),$=f.useRef(!1),ae=()=>{try{const pe=globalThis,Ie=(pe==null?void 0:pe.AudioContext)||(pe==null?void 0:pe.webkitAudioContext);if(!Ie)return null;if(!x.current){const K=new Ie,xe=K.createGain();xe.gain.value=1,xe.connect(K.destination),x.current=K,N.current=xe}const ke=x.current,Z=N.current;if(!ke||!Z)return null;try{ke.state==="suspended"&&ke.resume()}catch{}return{ctx:ke,gain:Z}}catch{return null}},fe=f.useCallback(()=>{const pe=E.current;if(E.current=null,!!pe){try{pe.onended=null}catch{}try{pe.stop()}catch{}try{pe.disconnect()}catch{}}},[]),oe=f.useCallback(()=>{fe(),O.current+=1,D.current=[],F.current=0,H.current=!0,$.current=!1,b.current="",y.current="",I.current=null,C.current=0,M.current=0,_({key:"",status:"idle"})},[fe,_]);f.useEffect(()=>()=>{var pe,Ie;oe();try{(pe=N.current)==null||pe.disconnect()}catch{}try{(Ie=x.current)==null||Ie.close()}catch{}x.current=null,N.current=null,I.current=null},[]);const Ne=async(pe,Ie,ke)=>{const Z=O.current,K=ae();if(!K)throw new Error("TTS playback is not supported in this browser");const{ctx:xe,gain:Ee}=K;try{xe.state==="suspended"&&await xe.resume()}catch{}if(Z!==O.current)return;fe();const De=xe.createBufferSource();De.buffer=Ie,De.connect(Ee);const te=Number.isFinite(Number(Ie.duration))?Number(Ie.duration):0,J=Math.max(0,Math.min(Number(ke||0),te>0?Math.max(0,te-.01):0));M.current=xe.currentTime-J,C.current=J,E.current=De,y.current=pe,De.onended=()=>{E.current===De&&(E.current=null,C.current=0,M.current=0,y.current="",_({key:"",status:"idle"}))},De.start(0,J),_({key:pe,status:"playing"})},Me=(pe,Ie)=>{if(Ie!==O.current)return;const ke=ae();if(!ke)return;const Z=D.current,K=F.current;if(K>=Z.length){H.current&&(y.current="",C.current=0,M.current=0,_({key:"",status:"idle"}));return}const xe=Z[K],{ctx:Ee,gain:De}=ke;fe();const te=Ee.createBufferSource();te.buffer=xe,te.connect(De);const J=Number.isFinite(Number(xe.duration))?Number(xe.duration):0,ve=Math.max(0,Math.min(Number(C.current||0),J>0?Math.max(0,J-.01):0));M.current=Ee.currentTime-ve,E.current=te,y.current=pe,te.onended=()=>{Ie===O.current&&E.current===te&&(E.current=null,F.current=K+1,C.current=0,Me(pe,Ie))};try{Ee.state==="suspended"&&Ee.resume()}catch{}te.start(0,ve),_({key:pe,status:"playing"})},be=async(pe,Ie,ke)=>{const Z=ae();if(!Z){r==null||r("TTS playback is not supported in this browser.");return}fe();const K=++O.current;D.current=[],F.current=0,H.current=!1,$.current=!1,I.current=null,C.current=0,M.current=0,y.current=pe,b.current=pe,_({key:pe,status:"loading"}),r==null||r("");let xe=null;try{for await(const Ee of ke(Ie)){if(K!==O.current)return;let De;try{De=await Cu(Z.ctx,Ee),xe||(xe=K_(Ee))}catch{if(!xe)continue;try{De=await Cu(Z.ctx,Q_(xe,Ee))}catch{continue}}if(K!==O.current)return;D.current.push(De),!E.current&&!$.current&&(b.current="",Me(pe,K))}if(K!==O.current)return;if(H.current=!0,D.current.length===0){r==null||r("TTS stream produced no audio."),oe();return}!E.current&&!$.current&&Me(pe,K)}catch(Ee){if(K!==O.current)return;r==null||r(String((Ee==null?void 0:Ee.message)||Ee||"TTS stream failed")),oe()}},ye=f.useCallback(async(pe,Ie)=>{const ke=String(pe||"").trim(),Z=String(Ie||"").trim();if(!ke||!Z)return;const K=s.current.tts,xe=s.current.tts_stream;if(typeof K!="function"&&typeof xe!="function"){r==null||r("TTS is not available.");return}const Ee=ae();if(!Ee){r==null||r("TTS playback is not supported in this browser.");return}const De=p.current,te=De.key===ke;if(te&&De.status==="playing"){if(E.current){const ve=Math.max(0,Ee.ctx.currentTime-Number(M.current||0));C.current=ve}else C.current=0;$.current=!0,fe(),_({key:ke,status:"paused"});return}if(te&&De.status==="paused"){if(D.current.length>0){r==null||r(""),$.current=!1,_({key:ke,status:"playing"}),Me(ke,O.current);return}const ve=I.current;if(ve){r==null||r(""),$.current=!1;try{await Ne(ke,ve,C.current)}catch(G){r==null||r(String((G==null?void 0:G.message)||G||"TTS play failed")),_({key:"",status:"idle"})}return}}if(te&&De.status==="loading")return;if(typeof xe=="function"){await be(ke,Z,xe);return}fe(),O.current+=1;const J=O.current;D.current=[],F.current=0,H.current=!0,$.current=!1,I.current=null,C.current=0,M.current=0,y.current=ke,b.current=ke,_({key:ke,status:"loading"}),r==null||r("");try{const ve=await K(Z);if(b.current!==ke||O.current!==J)return;const G=await Cu(Ee.ctx,ve);if(b.current!==ke||O.current!==J)return;I.current=G,C.current=0,await Ne(ke,G,0)}catch(ve){if(O.current!==J)return;b.current===ke&&(b.current="",y.current="",_({key:"",status:"idle"})),r==null||r(String((ve==null?void 0:ve.message)||ve||"TTS failed"))}},[]),[ue,q]=f.useState(!1),[R,V]=f.useState(!1),ne=f.useRef(!1),Y=f.useRef(c);Y.current=c;const me=f.useCallback(pe=>{ne.current=pe,q(Ie=>Ie===pe?Ie:pe)},[]),A=f.useRef(!1),w=f.useRef(null),L=f.useRef(null),X=f.useRef([]),ge=f.useRef(""),de=f.useRef(0),P=f.useRef(!1);function je(){var pe,Ie;try{(Ie=(pe=w.current)==null?void 0:pe.getTracks)==null||Ie.call(pe).forEach(ke=>{try{ke.stop()}catch{}})}catch{}w.current=null}const Ae=f.useCallback(()=>{de.current+=1,P.current=!1;const pe=L.current;if(pe){pe.onstop=null,pe.ondataavailable=null,pe.onerror=null;try{pe.stop()}catch{}}L.current=null,je(),me(!1),A.current=!1,V(!1),X.current=[]},[me]);f.useEffect(()=>()=>Ae(),[Ae]);async function Fe(pe,Ie){var K,xe;if(r==null||r(""),!pe||!pe.size||A.current)return;const ke=s.current.transcribe;if(typeof ke!="function"){r==null||r("Transcription is not available.");return}A.current=!0;const Z=de.current;V(!0);try{const Ee=String(await ke(pe,Ie)||"").trim();Z===de.current&&Ee&&((xe=(K=s.current).on_transcript)==null||xe.call(K,Ee))}catch(Ee){Z===de.current&&(r==null||r(String((Ee==null?void 0:Ee.message)||Ee||"Transcription failed")))}finally{Z===de.current&&(A.current=!1,V(!1))}}const Ve=f.useCallback(async()=>{if(r==null||r(""),!Y.current){r==null||r("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(A.current||P.current||ne.current||L.current)return;X.current=[];const pe=de.current;P.current=!0;try{const Ie=await navigator.mediaDevices.getUserMedia({audio:!0});if(pe!==de.current){Ie.getTracks().forEach(K=>K.stop());return}w.current=Ie;const ke=G_();ge.current=ke;const Z=ke?new MediaRecorder(Ie,{mimeType:ke}):new MediaRecorder(Ie);L.current=Z,Z.ondataavailable=K=>{if(pe===de.current)try{K!=null&&K.data&&X.current.push(K.data)}catch{}},Z.onerror=()=>{pe===de.current&&(r==null||r("Recording failed."))},Z.onstop=()=>{if(pe===de.current){me(!1),je(),L.current=null;try{const K=new Blob(X.current,{type:ge.current||""});Fe(K,ge.current)}catch(K){r==null||r(String((K==null?void 0:K.message)||K||"Failed to build recording"))}}},Z.start(),me(!0)}catch(Ie){if(pe!==de.current)return;je(),L.current=null,me(!1);const ke=String((Ie==null?void 0:Ie.message)||Ie||"Failed to access microphone");r==null||r(ke.toLowerCase().includes("permission")?`Microphone permission denied: ${ke}`:ke)}finally{pe===de.current&&(P.current=!1)}},[]),lt=f.useCallback(()=>{const pe=L.current;if(!(!ne.current||!pe)){me(!1);try{pe.stop()}catch(Ie){r==null||r(String((Ie==null?void 0:Ie.message)||Ie||"Failed to stop recording"))}}},[]);return f.useEffect(()=>{if(!ue)return;const pe=()=>lt();return window.addEventListener("pointerup",pe),window.addEventListener("pointercancel",pe),()=>{window.removeEventListener("pointerup",pe),window.removeEventListener("pointercancel",pe)}},[ue]),{tts_supported:l,tts_playback:d,toggle_tts:ye,stop_tts:oe,voice_ptt_supported:c,voice_ptt_recording:ue,voice_ptt_busy:R,start_voice_ptt_recording:Ve,stop_voice_ptt_recording:lt,cancel_voice_ptt_recording:Ae}}function J_(a){const s=String(a??"").trim();if(!s||!(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]")))return null;try{return JSON.parse(s)}catch{return null}}async function fn(a){const s=String(a||"");if(!s)return!1;try{return await navigator.clipboard.writeText(s),!0}catch{try{const r=document.createElement("textarea");return r.value=s,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),!0}catch{return!1}}}const Y_=3,X_=Number.MAX_SAFE_INTEGER;function ih(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function lh(a){return Array.isArray(a)}function Z_(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function ji({kind:a,children:s}){return e.jsx("span",{className:`pc-json-token ${a}`,children:s})}function eg(a){const s=JSON.stringify(a.value),r=s.length>96||s.includes("\\n")||s.includes("\\r")||s.includes("\\t"),[l,c]=f.useState(!r||a.expansionMode==="unfolded");return f.useEffect(()=>{r&&c(a.expansionMode==="unfolded")},[r,a.expansionMode,a.expansionVersion]),r?e.jsxs("span",{className:`pc-json-string ${l?"open":"collapsed"}`,children:[e.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>c(d=>!d),"aria-label":l?"Collapse string value":"Expand string value","aria-expanded":l,children:l?"▾":"▸"}),l?e.jsx("span",{className:"pc-json-token string pc-json-string__value",children:s}):e.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>c(!0),"aria-label":"Expand string value",children:[e.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:s}),e.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):e.jsx(ji,{kind:"string",children:s})}function tg(a,s,r){return a===null?e.jsx(ji,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(eg,{value:a,expansionMode:s,expansionVersion:r}):typeof a=="number"?e.jsx(ji,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx(ji,{kind:"boolean",children:a?"true":"false"}):e.jsx(ji,{kind:"string",children:JSON.stringify(String(a))})}function ng(a){return lh(a)?a.length===1?"1 item":`${a.length} items`:ih(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function oh(a){const{label:s,value:r,depth:l,collapseAfterDepth:c,expansionMode:d,expansionVersion:h,trailingComma:p}=a,_=l*14,y=ih(r),b=lh(r),x=y||b,N=l<c,[E,I]=f.useState(N);f.useEffect(()=>{I(N)},[N,h]);const C=s?e.jsxs(e.Fragment,{children:[e.jsx(ji,{kind:"key",children:JSON.stringify(s)}),": "]}):null;if(!x)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[C,tg(r,d,h),p?",":""]});const M=b?"[":"{",O=b?"]":"}",D=ng(r),F=E?`${M}`:`${M}…${O}${D?` (${D})`:""}`,H=b?r.map(($,ae)=>({key:String(ae),label:void 0,value:$})):Object.entries(r).map(([$,ae])=>({key:$,label:$,value:ae}));return e.jsxs("details",{className:"pc-json-viewer__details",open:E,onToggle:$=>I($.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:_},children:[C,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:E?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:F}),!E&&p?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),E?e.jsx("div",{className:"pc-json-viewer__children",children:H.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:O}),p?",":""]}):e.jsxs(e.Fragment,{children:[H.map(($,ae)=>{const fe=ae===H.length-1;return e.jsx(oh,{label:$.label,value:$.value,depth:l+1,collapseAfterDepth:c,expansionMode:d,expansionVersion:h,trailingComma:!fe},`${l}:${s||"root"}:${$.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:O}),p?",":""]})]})}):null]})}function sg(a){const s=a.trim();if(!s)return a;if(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]"))try{return JSON.parse(s)}catch{return a}return a}function nc(a){const{value:s,className:r,showCopy:l=!0}=a,[c,d]=f.useState({mode:"folded",version:0}),h=typeof a.collapseAfterDepth=="number"&&(Number.isFinite(a.collapseAfterDepth)||a.collapseAfterDepth===1/0)&&a.collapseAfterDepth>=0?a.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(a.collapseAfterDepth):Y_,p=c.mode==="unfolded"?X_:h,_=f.useMemo(()=>typeof s=="string"?sg(s):s,[s]),y=f.useMemo(()=>Z_(s),[s]),b=["pc-json-viewer",r].filter(Boolean).join(" ");f.useEffect(()=>{d(N=>({mode:"folded",version:N.version+1}))},[_]);const x=()=>{d(N=>({mode:N.mode==="unfolded"?"folded":"unfolded",version:N.version+1}))};return e.jsxs("div",{className:b,children:[e.jsxs("div",{className:"pc-json-viewer__toolbar",children:[e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:x,"aria-expanded":c.mode==="unfolded",children:c.mode==="unfolded"?"Fold all":"Unfold all"}),l?e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void fn(y),children:"Copy JSON"}):null]}),e.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:e.jsx(oh,{value:_,depth:0,collapseAfterDepth:p,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function Nl(a,s){const r=String(a??"");if(!s||!s.needles.length)return[r];const l=[],c=r.toLowerCase();let d=0;for(;d<r.length;){let h=-1,p="";for(let b=0;b<s.needlesLower.length;b++){const x=s.needlesLower[b];if(!x)continue;const N=c.indexOf(x,d);if(N===-1)continue;const E=s.needles[b]||"";E&&(h===-1||N<h||N===h&&E.length>p.length)&&(h=N,p=E)}if(h===-1||!p){l.push(r.slice(d));break}h>d&&l.push(r.slice(d,h));const _=s.hits===0&&s.id?s.id:void 0,y=r.slice(h,h+p.length);l.push(e.jsx("span",{id:_,className:s.className,children:y},`hl:${s.hits}`)),s.hits+=1,d=h+p.length}return l}function ch(a){const s=String(a||"").trim();if(s&&/^(https?:|mailto:|tel:|#|\/)/i.test(s))return s}const Gu="http://same-origin.invalid/";function ag(a){try{const s=new URL(a,Gu);return s.protocol==="http:"&&s.origin===new URL(Gu).origin}catch{return!1}}function uh(a){const s=String(a||"").trim();return ch(s)??(s&&ag(s)?s:void 0)}let zr=null;function rg(a){const s=String(a||"").trim();if(!s)return!1;const r=typeof document<"u"&&document.baseURI?document.baseURI:null;if(r===null&&/^[a-z][a-z0-9+.-]*:/i.test(s))return!1;const l=r??Gu;let c,d;try{c=new URL(l).origin,d=new URL(s,l)}catch{return!1}return d.protocol!=="http:"&&d.protocol!=="https:"?!1:d.origin===c}function dh(a,s,r){return e.jsx("a",{className:"pc-md_link pc-md_image_link",href:s,target:"_blank",rel:"noopener noreferrer",children:`image: ${r||s}`},a)}function Qa(a,s){const r=[],l=String(a??"");let c=0,d="";const h=()=>{if(d){for(const p of Nl(d,s))r.push(p);d=""}};for(;c<l.length;){const p=l[c];if(p==="!"&&l[c+1]==="["){const _=l.indexOf("]",c+2);if(_!==-1&&l[_+1]==="("){const y=l.indexOf(")",_+2);if(y!==-1){const b=l.slice(c+2,_),x=uh(l.slice(_+2,y));if(x&&zr&&!zr(x)){h(),r.push(dh(`img:${c}`,x,b)),c=y+1;continue}if(x){h(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:x,alt:b,loading:"lazy"}),b?e.jsx("span",{className:"pc-md_img_caption",children:s?Nl(b,s):b}):null]},`img:${c}`)),c=y+1;continue}}}}if(p==="["){const _=l.indexOf("]",c+1);if(_!==-1&&l[_+1]==="("){const y=l.indexOf(")",_+2);if(y!==-1){const b=l.slice(c+1,_),x=ch(l.slice(_+2,y));if(x){h(),r.push(e.jsx("a",{className:"pc-md_link",href:x,target:x.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Qa(b,s)},`link:${c}`)),c=y+1;continue}}}}if(p==="`"){const _=l.indexOf("`",c+1);if(_!==-1){h();const y=l.slice(c+1,_);r.push(e.jsx("code",{children:s?Nl(y,s):y},`code:${c}`)),c=_+1;continue}}if(p==="*"&&l[c+1]==="*"){const _=l.indexOf("**",c+2);if(_!==-1){h();const y=l.slice(c+2,_);r.push(e.jsx("strong",{children:s?Nl(y,s):y},`bold:${c}`)),c=_+2;continue}}if(p==="*"&&l[c+1]!=="*"){const _=l.indexOf("*",c+1);if(_!==-1){h();const y=l.slice(c+1,_);r.push(e.jsx("em",{children:s?Nl(y,s):y},`em:${c}`)),c=_+1;continue}}d+=p,c+=1}return h(),r}function ig(a){return String(a??"").replace(/\r\n/g,`
42
- `).replace(/\r/g,`
43
- `).split(`
44
- `)}function sc(a){const r=String(a??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return r?{indent:r[1].replace(/\t/g," ").length,ordered:!!r[3],start:r[3]?Math.max(1,parseInt(r[3],10)||1):1,content:r[4]??""}:null}function lg(a){const s=[];for(const c of a){const d=sc(c);d?s.push(d):s.length>0&&c.trim()&&(s[s.length-1].content+=` ${c.trim()}`)}const r=[],l=[];for(const c of s){for(;l.length>0&&c.indent<l[l.length-1].indent;)l.pop();let d=l.length>0?l[l.length-1]:null;if(d&&c.indent>d.indent){const h=d.node.items,p=h[h.length-1];if(p){const _={ordered:c.ordered,start:c.start,items:[]};p.children.push(_),l.push({indent:c.indent,node:_}),d=l[l.length-1]}}else if(d&&d.node.ordered!==c.ordered){l.pop();const h=l.length>0?l[l.length-1]:null,p={ordered:c.ordered,start:c.start,items:[]};if(h){const _=h.node.items,y=_[_.length-1];y?y.children.push(p):h.node.items.push({content:"",children:[p]})}else r.push(p);l.push({indent:c.indent,node:p}),d=l[l.length-1]}if(!d){const h={ordered:c.ordered,start:c.start,items:[]};r.push(h),l.push({indent:c.indent,node:h}),d=l[l.length-1]}d.node.items.push({content:c.content,children:[]})}return r}function mh(a,s,r){const l=a.items.map((c,d)=>e.jsxs("li",{children:[Qa(c.content,s),c.children.map((h,p)=>mh(h,s,`${r}:${d}:${p}`))]},`${r}:li:${d}`));return a.ordered?e.jsx("ol",{className:"pc-md_ol",start:a.start!==1?a.start:void 0,children:l},r):e.jsx("ul",{className:"pc-md_ul",children:l},r)}function og(a,s,r){return lg(a).map((l,c)=>mh(l,s,`${r}:${c}`))}function cf(a){let s=String(a??"").trim();return s?(s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1)),s.split("|").map(r=>String(r??"").trim())):[]}function uf(a){let s=String(a??"").trim();if(!s)return!1;s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1));const r=s.split("|").map(l=>String(l??"").trim());return r.length<2?!1:r.every(l=>/^:?-{3,}:?$/.test(l))}const df=/^(#{1,5})\s+(.*)$/;function mf(a){return a.trim().startsWith("```")}function ff(a){return a.trimStart().startsWith(">")}function ls(a){const s=zr;zr=a.images==="link"?a.inlineImage||rg:null;try{return cg(a)}finally{zr=s}}function cg({text:a,className:s,highlight:r,highlights:l,highlightClassName:c,highlightId:d}){const h=ig(a),p=[],_=[];Array.isArray(l)&&_.push(...l),typeof r=="string"&&r.trim()&&_.push(r);const y=Array.from(new Set(_.map(E=>String(E??"").trim()).filter(Boolean))).filter(E=>E.length>=4),b=y.length?{needles:y,needlesLower:y.map(E=>E.toLowerCase()),className:c||"pc-md_hl",id:d,hits:0}:null;let x=0;for(;x<h.length;){const E=String(h[x]??"");if(!E.trim()){x+=1;continue}const I=E.trim();if(/^([-_*])(\s*\1){2,}$/.test(I)){p.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}const C=E.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(C){const D=uh(C[2]||"");if(D&&zr&&!zr(D)){p.push(e.jsx("p",{className:"pc-md_p",children:dh(`img:${x}`,D,C[1]||"")},`p:${x}`)),x+=1;continue}if(D){const F=C[1]||"";p.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:D,alt:F,loading:"lazy"}),F?e.jsx("figcaption",{children:Qa(F,b)}):null]},`figure:${x}`)),x+=1;continue}}if(mf(E)){const F=E.trim().replace(/```/g,"").trim(),H=[];for(x+=1;x<h.length&&!String(h[x]??"").trim().startsWith("```");)H.push(String(h[x]??"")),x+=1;x<h.length&&(x+=1);const $=H.join(`
45
- `);p.push(e.jsx("pre",{className:"pc-md_pre",children:e.jsx("code",{className:F?`language-${F}`:void 0,children:$})},`pre:${x}`));continue}const M=E.match(df);if(M){const D=M[1].length,F=M[2]||"",H=Qa(F,b);D===1?p.push(e.jsx("h1",{children:H},`h1:${x}`)):D===2?p.push(e.jsx("h2",{children:H},`h2:${x}`)):D===3?p.push(e.jsx("h3",{children:H},`h3:${x}`)):D===4?p.push(e.jsx("h4",{children:H},`h4:${x}`)):p.push(e.jsx("h5",{children:H},`h5:${x}`)),x+=1;continue}if(ff(E)){const D=[];for(;x<h.length&&String(h[x]??"").trimStart().startsWith(">");){const H=String(h[x]??"").trimStart();D.push(H.replace(/^>\s?/,"")),x+=1}p.push(e.jsx("blockquote",{className:"pc-md_quote",children:D.map((F,H)=>e.jsxs(Wt.Fragment,{children:[Qa(F,b),H<D.length-1?e.jsx("br",{}):null]},`q:${x}:${H}`))},`quote:${x}`));continue}if(E.includes("|")&&x+1<h.length&&uf(String(h[x+1]??""))){const D=cf(E),F=Math.max(1,D.length),H=[];for(x+=2;x<h.length;){const $=String(h[x]??"");if(!$.trim()||!$.includes("|"))break;const ae=cf($),fe=[];for(let oe=0;oe<F;oe++)fe.push(ae[oe]??"");H.push(fe),x+=1}p.push(e.jsx("div",{className:"pc-md_table_wrap",children:e.jsxs("table",{className:"pc-md_table",children:[e.jsx("thead",{children:e.jsx("tr",{children:D.slice(0,F).map(($,ae)=>e.jsx("th",{children:Qa($,b)},`th:${x}:${ae}`))})}),e.jsx("tbody",{children:H.map(($,ae)=>e.jsx("tr",{children:$.map((fe,oe)=>e.jsx("td",{children:Qa(fe,b)},`td:${x}:${ae}:${oe}`))},`tr:${x}:${ae}`))})]})},`table:${x}`));continue}if(sc(E)){const D=[];for(;x<h.length;){const F=String(h[x]??"");if(!F.trim()||F.trimStart().startsWith("```"))break;if(sc(F)||/^\s{2,}\S/.test(F)){D.push(F),x+=1;continue}break}p.push(e.jsx(Wt.Fragment,{children:og(D,b,`list:${x}`)},`list:${x}`));continue}const O=[];for(;x<h.length&&String(h[x]??"").trim()&&!(O.length>0&&sc(String(h[x]??"")));){const D=String(h[x]??"");if(O.length>0&&(df.test(D)||mf(D)||ff(D))||O.length>0&&D.includes("|")&&x+1<h.length&&uf(String(h[x+1]??"")))break;O.push(D),x+=1}p.push(e.jsx("p",{className:"pc-md_p",children:O.map((D,F)=>e.jsxs(Wt.Fragment,{children:[Qa(D,b),F<O.length-1?e.jsx("br",{}):null]},`pl:${x}:${F}`))},`p:${x}`))}const N=["pc-md",s].filter(Boolean).join(" ");return e.jsx("div",{className:N,children:p})}function ug(a){const s=String(a.text??""),r=f.useMemo(()=>J_(s),[s]),l=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:l,children:e.jsx(nc,{value:r,collapseAfterDepth:a.jsonCollapseAfterDepth})}):a.renderMarkdown?e.jsx("div",{className:l,children:a.renderMarkdown(s)}):e.jsx("div",{className:l,children:e.jsx(ls,{text:s,images:a.images,inlineImage:a.inlineImage})})}function fh(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function dg(a){const s=fh(a);if(!s||typeof s!="object"||Array.isArray(s))return{label:"input",value:s==null?"":String(s)};const r=Object.entries(s),c=["command","query","url","file_path","path","pattern","name"].map(d=>r.find(([h])=>h===d)).find(Boolean)||r[0];return c?{label:c[0].replace(/_/g," "),value:typeof c[1]=="string"?c[1]:JSON.stringify(c[1])??""}:{label:"",value:""}}function hh({tool:a,showCopy:s=!0}){const[r,l]=f.useState(!1),c=fh(a.arguments),d=dg(a.arguments),h=["file path","path"].includes(d.label)&&d.value.length>60?`${d.value.split(/[\\/]/).pop()} · ${d.value.slice(0,24)}…`:d.value,p=a.error&&/^File ['"].+['"] does not exist\.?$/.test(a.error)?"File not found. Expand for the exact path.":a.error&&a.error.length>180?`${a.error.slice(0,100)}…${a.error.slice(-70)}`:a.error,_={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},y=a.startedAt&&a.endedAt?Date.parse(a.endedAt)-Date.parse(a.startedAt):NaN,b=c&&typeof c=="object"&&!Array.isArray(c)?Object.entries(c):null;return e.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${a.status}`,children:[e.jsxs("summary",{className:"pc-tool-activity__summary",children:[e.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:e.jsx(et,{name:a.status==="completed"?"check":a.status==="failed"?"x":a.status==="waiting"?"warning":"loader",size:15})}),e.jsx("strong",{children:a.name}),e.jsx("span",{className:"pc-tool-activity__preview",title:d.value,children:d.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:d.label}),h]}):"No parameters"}),e.jsx("span",{className:"pc-tool-activity__status",children:_[a.status]}),Number.isFinite(y)&&y>=0?e.jsxs("span",{className:"pc-tool-activity__duration",children:[(y/1e3).toFixed(1),"s"]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(et,{name:"chevronRight",size:13})}),a.error?e.jsx("span",{className:"pc-tool-activity__error",title:a.error,children:p}):null]}),e.jsxs("div",{className:"pc-tool-activity__detail",children:[a.error?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Error"}),e.jsx("pre",{className:"pc-tool-activity__output",children:a.error})]}):null,e.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[e.jsx("h4",{children:"Parameters"}),s?e.jsxs("button",{type:"button",onClick:async()=>l(await fn(JSON.stringify(a,null,2))),children:[e.jsx(et,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),b?e.jsx("dl",{className:"pc-tool-activity__parameters",children:b.map(([x,N])=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:x}),e.jsx("dd",{children:N&&typeof N=="object"?e.jsx(nc,{value:N}):e.jsx("code",{children:typeof N=="string"?N:JSON.stringify(N)})})]},x))}):a.arguments===void 0?e.jsx("p",{children:"Arguments are unavailable in this ledger."}):e.jsx(nc,{value:c}),a.output!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Result"}),typeof a.output=="string"?e.jsx("pre",{className:"pc-tool-activity__output",children:a.output}):e.jsx("div",{className:"pc-tool-activity__output",children:e.jsx(nc,{value:a.output})})]}):null]})]})}function mg({tools:a,showCopy:s}){const r=l=>a.filter(c=>c.status===l).length;return e.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[e.jsxs("div",{className:"pc-tool-group__heading",children:[e.jsx(et,{name:"terminal",size:14}),e.jsx("strong",{children:"Tools"}),e.jsxs("span",{children:[a.length," ",a.length===1?"call":"calls"]}),e.jsx("div",{}),r("running")?e.jsxs("span",{className:"pc-tool-group__running",children:[r("running")," running"]}):null,r("waiting")?e.jsxs("span",{className:"pc-tool-group__waiting",children:[r("waiting")," need approval"]}):null,r("failed")?e.jsxs("span",{className:"pc-tool-group__failed",children:[r("failed")," failed"]}):null,r("completed")?e.jsxs("span",{className:"pc-tool-group__completed",children:[r("completed")," done"]}):null]}),a.map(l=>e.jsx(hh,{tool:l,showCopy:s},l.id))]})}const xn="not reported",Mn=a=>a===void 0?xn:Math.round(a).toLocaleString(),Gn=a=>{if(a===void 0)return xn;if(a<6e4)return`${(a/1e3).toFixed(1)}s`;const s=Math.round(a/1e3);return`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`},ph=a=>a===void 0?xn:`${Math.round(a).toLocaleString()} tok/s`,fg=(a,s)=>s>0?`${Math.round(a/s*100)}%`:"",Pr=(a,s,r=`${s}s`)=>`${a.toLocaleString()} ${a===1?s:r}`,hg=a=>{const s=a.split("#")[0].replace(/\/+$/,"");return s.slice(s.lastIndexOf("/")+1)||a};function pg(a){const s=new Map;for(const r of a)r&&s.set(r,(s.get(r)||0)+1);return[...s].map(([r,l])=>l>1?`${r} ×${l}`:r).join(" · ")}function rc(a){const s=[],r=(a.models||[]).map(hg),l=a.providers||[];return(r.length||l.length)&&s.push([r.join(", ")||"model not reported",l.join(", ")].filter(Boolean).join(" · ")),s.push("From the run ledger; summed across this turn and its child runs."),s}function _g(a){const s=a.modelCalls||[],r=[],l=[{label:"Input",value:Mn(a.inputTokens)},{label:"Output",value:Mn(a.outputTokens)}];if(a.reasoningTokens!==void 0&&l.push({label:"Reasoning",value:Mn(a.reasoningTokens),hint:"part of output"}),l.push({label:"Total",value:Mn(a.totalTokens)}),r.push({heading:`Usage · ${Pr(a.llmCalls,"model call")}`,rows:l}),a.measuredCacheCalls){const d=a.cachedTokens||0,h=a.fedTokens||0,p=[{label:"Reused from cache",value:`${Mn(d)}${d+h?` (${fg(d,d+h)})`:""}`},{label:"Newly processed",value:Mn(a.fedTokens)},{label:"Outcome",value:pg(s.map(_=>_.cacheOutcome))||(a.cacheOutcomes||[]).join(" · ")||xn},{label:"Backend",value:(a.cacheBackends||[]).join(", ")||xn}];a.measuredCacheCalls!==a.llmCalls&&p.push({label:"Measured on",value:`${a.measuredCacheCalls} of ${a.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:p})}else a.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:xn}]});const c=s.filter(d=>d.inputTokens!==void 0);return c.length===1&&s.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${Mn(c[0].inputTokens)} tokens`}]}):c.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${Mn(c[0].inputTokens)} → ${Mn(c[c.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),s.length>1&&r.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:s.map((d,h)=>[String(h+1),Mn(d.inputTokens),d.cachedTokens===void 0?"—":Mn(d.cachedTokens),d.fedTokens===void 0?"—":Mn(d.fedTokens),Mn(d.outputTokens),d.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?xn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:rc(a)}}function Ko(a,s,r,l){if(a===void 0)return xn;const c=[Gn(a)];return s!==void 0&&c.push(`${s.toLocaleString()} ${l}${r!==void 0?` at ${ph(r)}`:""}`),c.join(" · ")}function gg(a){var y,b,x;const s=a.modelCalls||[],r=[],l=a.durationMs,c=[{label:"Wall clock",value:Gn(l)}];if(c.push({label:"Model",value:a.genTimeMs===void 0?xn:`${Gn(a.genTimeMs)} · ${Pr(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),c.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`:a.toolCalls?xn:"none",hint:a.toolTimeIncludesApproval?"includes approval wait":void 0}),l!==void 0&&a.genTimeMs!==void 0){const N=l-a.genTimeMs-(a.toolTimeMs||0);c.push({label:"Orchestration",value:N>=0?Gn(N):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:c});const d=[],h=a.ttftCalls||0,p=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?d.push({label:h&&h===p?"Prefill (TTFT)":"Prefill",value:Ko(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:h===p?"measured time to first token":h?`TTFT measured on ${h} of ${p}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?d.push({label:"Prefill",value:Ko(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?d.push({label:"Prefill",value:`${Gn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${ph(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):d.push({label:"Prefill",value:xn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&d.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),d.push({label:"Generation",value:a.generationPhaseMs!==void 0?Ko(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):Ko(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&d.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:d});const _=a.speculation;if(_){const N=(_.draftKinds||[]).map(I=>I.toUpperCase()).join(", "),E=[{label:"Mode",value:`${_.used?"on":"off"}${N?` · ${N}`:""}${(y=_.modes)!=null&&y.length?` (${_.modes.join(", ")})`:""}`,hint:_.calls!==a.llmCalls||_.used!==_.calls?`used on ${_.used} of ${a.llmCalls} calls`:void 0},{label:"Acceptance",value:_.acceptanceRate===void 0?xn:`${Math.round(_.acceptanceRate*100)}% · ${Mn(_.acceptedTokens)} of ${Mn(_.draftedTokens)} drafted`}];((b=_.draftLengths)!=null&&b.length||_.rounds!==void 0)&&E.push({label:"Draft length",value:`${(x=_.draftLengths)!=null&&x.length?`${_.draftLengths.join("/")} tok/round`:xn}${_.rounds!==void 0?` · ${_.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:E})}return a.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Gn(a.slowestToolBatch.ms)} · ${_h(a.slowestToolBatch)}`}],note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),s.length>1&&r.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:s.map((N,E)=>[String(E+1),N.promptMs===void 0?"—":`${Gn(N.promptMs)}${N.promptSource==="rate"?"*":""}`,N.promptNewTokensPerSecond===void 0?"—":Math.round(N.promptNewTokensPerSecond).toLocaleString(),N.generationMs===void 0?"—":Gn(N.generationMs),N.generationTokensPerSecond===void 0?"—":Math.round(N.generationTokensPerSecond).toLocaleString(),N.cacheOutcome||"—"])},note:s.some(N=>N.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:l===void 0?xn:`${Gn(l)} wall clock`,sections:r,footer:rc(a)}}function _h(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${Pr(a.calls,"call")} (${a.tools.join(", ")})`}function vg(a){const s=[],r=(a.toolsWaiting||0)+(a.toolsRunning||0);if(!a.toolCalls&&!r)return s.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:s,footer:rc(a)};const l=[{label:"Succeeded",value:(a.toolCalls-(a.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(a.toolsFailed||0).toLocaleString()}];a.toolsRunning&&l.push({label:"Running",value:a.toolsRunning.toLocaleString()}),a.toolsWaiting&&l.push({label:"Awaiting approval",value:a.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),s.push({heading:"Outcome",rows:l});const c=Object.entries(a.toolBreakdown||{}).sort((p,_)=>_[1].calls-p[1].calls||p[0].localeCompare(_[0]));c.length&&s.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:c.map(([p,_])=>[p,_.calls.toLocaleString(),_.failed.toLocaleString(),_.ms!==void 0?`${Gn(_.ms)}${_.sharedBatches?" +shared":""}`:_.sharedBatches?"shared":xn])},note:c.some(([,p])=>p.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const d=c.filter(([,p])=>p.errors&&Object.keys(p.errors).length);d.length&&s.push({heading:"Failures",rows:d.map(([p,_])=>({label:p,value:Object.entries(_.errors).sort((y,b)=>b[1]-y[1]).map(([y,b])=>b>1?`${y} ×${b}`:y).join(" · ")}))});const h=[{label:"Tool time",value:a.toolTimeMs===void 0?xn:`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&h.push({label:"Slowest batch",value:`${Gn(a.slowestToolBatch.ms)} · ${_h(a.slowestToolBatch)}`}),s.push({heading:"Timing",rows:h,note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Pr(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:s,footer:rc(a)}}function $u(a,s){return a==="tokens"?_g(s):a==="time"?gg(s):vg(s)}function yg(a){const s=a.detail;return e.jsxs("div",{ref:a.panelRef,id:a.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${s.kind}`,style:a.style,onMouseEnter:a.onMouseEnter,onMouseLeave:a.onMouseLeave,children:[e.jsxs("div",{className:"pc-stat-detail-head",children:[e.jsx("span",{className:"pc-stat-detail-title",children:s.title}),e.jsx("span",{className:"pc-stat-detail-headline",children:s.headline})]}),s.sections.map(r=>{var l;return e.jsxs("div",{className:"pc-stat-detail-section",children:[e.jsx("div",{className:"pc-stat-detail-heading",children:r.heading}),(l=r.rows)!=null&&l.length?e.jsx("dl",{className:"pc-stat-detail-rows",children:r.rows.map(c=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:c.label}),e.jsxs("dd",{children:[e.jsx("span",{className:c.value===xn?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:c.value}),c.hint?e.jsx("span",{className:"pc-stat-detail-hint",children:c.hint}):null]})]},c.label))}):null,r.table?e.jsxs("table",{className:"pc-stat-detail-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:r.table.columns.map(c=>e.jsx("th",{scope:"col",children:c},c))})}),e.jsx("tbody",{children:r.table.rows.map((c,d)=>e.jsx("tr",{children:c.map((h,p)=>e.jsx("td",{children:h},p))},d))})]}):null,r.note?e.jsx("p",{className:"pc-stat-detail-note",children:r.note}):null]},r.heading)}),e.jsx("div",{className:"pc-stat-detail-foot",children:s.footer.map(r=>e.jsx("div",{children:r},r))})]})}const ma=8;function xg(a){const[s,r]=f.useState(!!a.defaultOpen),[l,c]=f.useState(null),d=f.useRef(null),h=f.useRef(null),p=f.useRef(null),_=`pc-stat-${f.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=f.useCallback(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=null},[]),b=f.useCallback(()=>{y(),r(!0)},[y]),x=f.useCallback(()=>{y(),p.current=window.setTimeout(()=>r(!1),120)},[y]);f.useEffect(()=>y,[y]),f.useLayoutEffect(()=>{if(!s){c(null);return}const C=()=>{const M=d.current,O=h.current;if(!M||!O)return;const D=M.getBoundingClientRect(),F=O.offsetWidth,H=O.offsetHeight,$=window.innerWidth,ae=window.innerHeight,fe=D.top-ma-H,oe=D.bottom+ma,Ne=fe>=ma?fe:oe+H<=ae-ma?oe:Math.max(ma,ae-ma-H),Me=Math.min(Math.max(ma,D.left),Math.max(ma,$-ma-F));c({top:Ne,left:Me})};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[s]),f.useEffect(()=>{if(!s)return;const C=M=>{M.key==="Escape"&&r(!1)};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[s]);const N=typeof a.onClick=="function",E=N?"button":"span",I=s?e.jsx(yg,{detail:a.detail,id:_,panelRef:h,onMouseEnter:y,onMouseLeave:x,style:{position:"fixed",top:(l==null?void 0:l.top)??0,left:(l==null?void 0:l.left)??0,visibility:l?"visible":"hidden"}}):null;return e.jsxs(e.Fragment,{children:[e.jsxs(E,{ref:d,...N?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",N?"pc-chat-stat--clickable":"",a.className].filter(Boolean).join(" "),"aria-label":`${a.label} — ${a.detail.title.toLowerCase()} details`,"aria-describedby":s?_:void 0,"data-stat-kind":a.detail.kind,onMouseEnter:b,onMouseLeave:x,onFocus:b,onBlur:()=>r(!1),onKeyDown:C=>{C.key==="Escape"&&r(!1)},onClick:N?()=>{var C;return(C=a.onClick)==null?void 0:C.call(a)}:void 0,children:[a.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:a.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:a.label})]}),I&&typeof document<"u"?nh.createPortal(I,document.body):I]})}function bg(a){const s=a.totalTokens!==void 0?$u("tokens",a):null,r=$u("tools",a),l=a.durationMs!==void 0?$u("time",a):null;return[...s?[{label:`${a.totalTokens.toLocaleString()} tokens`,detail:s}]:[],{label:`${a.toolCalls} ${a.toolCalls===1?"tool":"tools"}`,detail:r},...a.changedFiles.length?[{label:`${a.changedFiles.length} ${a.changedFiles.length===1?"file":"files"} changed`,title:a.changedFiles.join(`
46
- `)}]:[],...l?[{label:`${(a.durationMs/1e3).toFixed(a.durationMs<1e4?1:0)}s`,detail:l}]:[]]}function wg(a){const s=String(a.role||"").trim().toLowerCase()||"system",r=String(a.kind||"").trim().toLowerCase(),l=String(a.level||"").trim().toLowerCase();return s==="system"&&r==="report_bug"?{label:String(a.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:s==="system"&&r==="report_feature"?{label:String(a.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:s==="user"?{label:String(a.title||"").trim()||"You",icon:"user",variant:"user"}:s==="assistant"?{label:String(a.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(a.title||"").trim()||(l==="error"?"Error":l==="warn"?"Warning":"System"),icon:l==="error"?"error":l==="warn"?"warning":"info",variant:l==="error"?"error":l==="warn"?"warn":"status"}}function jg(a){var O;const s=a.message,r=f.useMemo(()=>wg(s),[s.kind,s.level,s.role,s.title]),l=String(s.ts||"").trim(),c=f.useMemo(()=>{if(!l)return"";const D=new Date(l);return Number.isFinite(D.getTime())?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[l]),[d,h]=f.useState("idle"),p=f.useRef(null);f.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);const _=s.live,y=!_&&typeof a.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(s.content||"").trim(),b=y&&((O=a.getSpeakState)==null?void 0:O.call(a,s))||"idle",x=b==="loading"?"loader":b==="playing"?"pause":"speaker",N=b==="loading"?"Generating audio…":b==="playing"?"Pause":b==="paused"?"Resume":"Speak (TTS)",E=a.showCopy!==!1,I=Array.isArray(a.attachments)?a.attachments:[],C=s.statistics,M=f.useMemo(()=>Array.isArray(a.stats)?a.stats:C?bg(C):[],[a.stats,C]);return s.toolActivity?e.jsx(hh,{tool:s.toolActivity,showCopy:a.showCopy}):e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,_?"pc-chat-item--live":"",a.className].filter(Boolean).join(" "),..._?{"aria-busy":!0}:{},children:[e.jsxs("div",{className:"pc-chat-header",children:[e.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:e.jsx(et,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),_?e.jsxs("span",{className:"pc-chat-live-indicator",title:"The reply is still being written",children:[e.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),"streaming"]}):null,_!=null&&_.caption?e.jsx("span",{className:"pc-chat-live-caption",children:_.caption}):null,e.jsx("span",{className:"pc-chat-header-spacer"}),c?e.jsx("span",{className:"pc-chat-time",children:c}):null,e.jsxs("div",{className:"pc-chat-header-actions",children:[y?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":N,title:N,onClick:()=>{var D;return(D=a.onSpeakToggle)==null?void 0:D.call(a,s)},children:e.jsx(et,{name:x,size:22})}):null,E?e.jsx("button",{className:`pc-chat-icon-btn ${d!=="idle"?`pc-chat-icon-btn--${d}`:""}`.trim(),type:"button","aria-label":"Copy message",title:d==="idle"?"Copy":d==="copied"?"Copied":"Copy failed",onClick:async()=>{const D=await fn(String(s.content||""));h(D?"copied":"failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>h("idle"),900)},children:e.jsx(et,{name:"copy",size:22})}):null]})]}),_!=null&&_.reasoning?e.jsxs("details",{className:"pc-chat-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("div",{className:"pc-chat-thinking-body",children:_.reasoning})]}):null,!_||String(s.content||"").trim()?e.jsx("div",{className:"pc-chat-body",children:e.jsx(ug,{text:String(s.content||""),renderMarkdown:a.renderMarkdown,jsonCollapseAfterDepth:a.jsonCollapseAfterDepth,images:a.images||(r.variant==="user"?"inline":"link"),inlineImage:a.inlineImage})}):null,I.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:I.slice(0,24).map((D,F)=>{const H=String(D.label||"").trim()||"attachment",$=String(D.target||"").trim(),ae=String(D.title||"").trim(),fe=!!D.disabled||typeof D.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:ae||H,onClick:fe?void 0:D.onClick,disabled:fe,children:[e.jsx(et,{name:"paperclip",size:14}),$?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${$}`,children:$}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:H})]},D.id||`${H}:${F}`)})}):null,M.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:M.slice(0,12).map((D,F)=>{const H=String(D.label||"").trim();if(!H)return null;if(D.detail)return e.jsx(xg,{label:H,detail:D.detail,icon:D.icon,onClick:D.onClick},D.id||`${H}:${F}`);const $=String(D.title||"").trim(),ae=typeof D.onClick=="function",fe=ae?"button":"span";return e.jsxs(fe,{...ae?{type:"button"}:{},className:["pc-chat-stat",ae?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:$||void 0,onClick:ae?()=>{var oe;return(oe=D.onClick)==null?void 0:oe.call(D)}:void 0,children:[D.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:D.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:H})]},D.id||`${H}:${F}`)})}):null]})}function kg(a,s){const r=Math.max(0,Math.trunc(s));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function cd(a){const s=typeof a.autoScrollThresholdPx=="number"&&Number.isFinite(a.autoScrollThresholdPx)?a.autoScrollThresholdPx:120,r=a.autoScroll!==!1,l=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(!0),p=f.useMemo(()=>Array.isArray(a.messages)?a.messages:[],[a.messages]),_=f.useMemo(()=>{var x;const b=[];for(const N of p){const E=b[b.length-1];N.toolActivity&&((x=E==null?void 0:E[0])!=null&&x.toolActivity)&&E[0].runId===N.runId?E.push(N):b.push([N])}return b},[p]);f.useEffect(()=>{if(!r)return;const b=l.current;if(!b)return;const x=()=>{h(kg(b,s))};return b.addEventListener("scroll",x,{passive:!0}),x(),()=>b.removeEventListener("scroll",x)},[r,s]);const y=f.useMemo(()=>{let b=0;for(const x of p)b+=String(x.content??"").length;return`${p.length}:${b}:${String(a.afterKey??"")}`},[p,a.afterKey]);return f.useEffect(()=>{if(!r||!d)return;const b=l.current;b&&(b.scrollTop=b.scrollHeight)},[r,d,y]),e.jsxs("div",{ref:l,className:["pc-chat-thread",a.className].filter(Boolean).join(" "),children:[p.length?null:a.empty||null,_.map((b,x)=>{var I;const N=b[0],E=String(N.id||"")||String(N.ts||"")+":"+String(N.role||"")+":"+x;return N.toolActivity?e.jsx(mg,{tools:b.map(C=>C.toolActivity),showCopy:(I=a.messageProps)==null?void 0:I.showCopy},E):e.jsx(jg,{message:N,...a.messageProps||{}},E)}),a.after,e.jsx("div",{ref:c})]})}const ic=Wt.forwardRef(function(s,r){const l=typeof s.rows=="number"&&Number.isFinite(s.rows)?Math.max(1,Math.trunc(s.rows)):3,c=!!s.disabled,d=!!s.busy,h=!c&&!d&&!!String(s.value||"").trim();return e.jsxs("div",{className:["pc-composer",s.className].filter(Boolean).join(" "),children:[s.leading,e.jsx("textarea",{ref:r,className:["pc-composer__textarea",s.textareaClassName].filter(Boolean).join(" "),value:s.value,onChange:p=>s.onChange(p.target.value),rows:l,style:{"--pc-composer-rows":String(l)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:s.placeholder||"","aria-label":s.ariaLabel||s.placeholder||"Message",disabled:c,autoFocus:!!s.autoFocus,onPaste:s.onPaste,onKeyDown:p=>{p.key!=="Enter"||p.shiftKey||p.nativeEvent.isComposing||p.keyCode===229||(p.preventDefault(),h&&s.onSubmit())}}),e.jsxs("div",{className:"pc-composer__row",children:[e.jsx("div",{className:"pc-composer__actions",children:s.actions}),e.jsx("button",{type:"button",className:s.sendButtonClassName||"pc-btn",disabled:!h,onClick:()=>s.onSubmit(),children:d?s.busyLabel||"Thinking…":s.sendLabel||"Send"})]}),s.overlay]})});function Sg(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function Ng(a){const[s,r]=f.useState([]),l=a.messages??s,c=C=>{a.onMessagesChange&&a.onMessagesChange(C),a.messages===void 0&&r(C)},d=f.useRef(l);d.current=l;const[h,p]=f.useState(""),[_,y]=f.useState(!1),b=f.useRef(null),x=a.assistantName||"Assistant",N=!!a.blockedNotice,E=async C=>{const M=String(C||"").trim();if(!M||_||N)return;p("");const O=d.current,D=[...O,{role:"user",content:M,ts:new Date().toISOString()}];c(D),y(!0);const F=new AbortController;b.current=F;try{const H=a.ask(M,{signal:F.signal,history:O});if(Sg(H)){let $="";const ae=[...D,{role:"assistant",title:x,content:"",ts:new Date().toISOString()}];c(ae);for await(const fe of H){if(F.signal.aborted)break;$+=String(fe??""),c([...D,{role:"assistant",title:x,content:$,ts:new Date().toISOString()}])}!$.trim()&&!F.signal.aborted&&c([...D,{role:"assistant",title:x,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const $=String(await H??"").trim();c([...D,$?{role:"assistant",title:x,content:$,ts:new Date().toISOString()}:{role:"assistant",title:x,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(H){F.signal.aborted||c([...d.current,{role:"assistant",title:x,content:`#FALLBACK assistant request failed: ${String((H==null?void 0:H.message)||H||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{b.current===F&&(b.current=null),y(!1)}},I=f.useMemo(()=>l.length>0?null:e.jsxs("div",{className:"pc-assistant__empty",children:[e.jsx("div",{className:"pc-assistant__empty-text",children:a.emptyState||"Ask about this app — answers are grounded in its documentation."}),a.suggestions&&a.suggestions.length>0?e.jsx("div",{className:"pc-assistant__suggestions",children:a.suggestions.map(C=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void E(C),disabled:_||N,children:C},C))}):null]}),[l.length,a.emptyState,a.suggestions,_,N]);return e.jsxs("div",{className:`pc-assistant${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[I,e.jsx(cd,{messages:l,autoScroll:!0}),N?e.jsx("div",{className:"pc-assistant__blocked",children:a.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(ic,{value:h,onChange:p,onSubmit:()=>void E(h),placeholder:a.placeholder||"Ask about this app…",disabled:N,busy:_,rows:2,actions:_?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var C;(C=b.current)==null||C.abort()},children:"Stop"}):null})})]})}function Cg(a){const s=a.trim();if(!s)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return s}const $g=Cg("0.5.0");function bi(a){return a?a.value!==void 0&&a.value!==null?!!a.value:a.enabled!==void 0?!!a.enabled:a.configured!==void 0?!!a.configured:a.path!==void 0?!!a.path:null:null}function Cl(a){if(!a)return"";const s=a.value!==void 0&&a.value!==null?a.value:a.id??a.path??"";return typeof s=="string"?s.trim():""}const hf="abstractcontinuum_gateway_csrf",Eg="x-abstractcontinuum-csrf",Tg="x-abstract-csrf";function pf(a){var l;const s=(a||"").trim(),r={};s&&(r.Authorization=`Bearer ${s}`);try{const c=(l=document.cookie.split(";").map(d=>d.trim()).find(d=>d.startsWith(`${hf}=`)))==null?void 0:l.slice(`${hf}=`.length);if(c){const d=decodeURIComponent(c);r[Eg]=d,r[Tg]=d}}catch{}return r}function _f(a){const s={},r=(l,c)=>{const d=String(c||"").trim();d&&(s[l]=d)};return r("provider",a==null?void 0:a.provider),r("model",a==null?void 0:a.model),r("profile",a==null?void 0:a.profile),r("voice",a==null?void 0:a.voice),r("quality_preset",a==null?void 0:a.quality_preset),s}async function Ag(a){try{const s=await a.text();return s!=null&&s.trim()?s.trim():`${a.status}`}catch{return`${a.status}`}}class gh extends Error{constructor(r,l,c){super(r);Rr(this,"status");Rr(this,"body");this.name="GatewayRequestError",this.status=l,this.body=c}}const Eu=[15,30,60,120];class Rg{constructor(s){Rr(this,"_cfg");Rr(this,"_backoff_until",0);Rr(this,"_backoff_step",0);this._cfg={...s,base_url:(s.base_url||"").trim()}}is_backing_off(){return Date.now()<this._backoff_until}backoff_until(){return this.is_backing_off()?this._backoff_until:0}async _fetch(s,r,l){const c=await fetch(rf(this._cfg.base_url,r),{...l,headers:{...l==null?void 0:l.headers,...pf(this._cfg.auth_token)}});if(c.ok)return this._backoff_step=0,this._backoff_until=0,c;const d=await Ag(c);let h=null;try{h=JSON.parse(d)}catch{}let p=d;if(h&&typeof h=="object"&&h.detail!==void 0&&(p=typeof h.detail=="string"?h.detail:JSON.stringify(h.detail)),c.status===429||/too many requests|auth lockout|locked/i.test(p)){const y=Eu[Math.min(this._backoff_step,Eu.length-1)];this._backoff_until=Date.now()+y*1e3,this._backoff_step<Eu.length-1&&(this._backoff_step+=1)}throw new gh(`${s} failed: ${p}`,c.status,h)}async _get_json(s,r){return await(await this._fetch(s,r)).json()}async _post_json(s,r,l){return await(await this._fetch(s,r,{method:"POST",headers:l===void 0?void 0:{"Content-Type":"application/json"},body:l===void 0?void 0:JSON.stringify(l)})).json()}async _post_form(s,r,l){return await(await this._fetch(s,r,{method:"POST",body:l})).json()}async list_runs(s){const r=new URLSearchParams;r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"?s.limit:50));const l=String((s==null?void 0:s.status)||"").trim();l&&r.set("status",l);const c=String((s==null?void 0:s.session_id)||"").trim();return c&&r.set("session_id",c),(s==null?void 0:s.root_only)===!0&&r.set("root_only","true"),await this._get_json("list_runs",`api/gateway/runs?${r.toString()}`)}async download_run_artifact_content(s,r,l){const c=String(s||"").trim(),d=String(r||"").trim();if(!c)throw new Error("download_run_artifact_content: run_id is required");if(!d)throw new Error("download_run_artifact_content: artifact_id is required");const h=String((l==null?void 0:l.access)||"").trim(),p=h?`?access=${encodeURIComponent(h)}`:"";return await(await this._fetch("download_run_artifact_content",`api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(d)}/content${p}`)).blob()}async attachments_upload(s,r,l){const c=String(s||"").trim();if(!c)throw new Error("attachments_upload: session_id is required");if(!r)throw new Error("attachments_upload: file is required");const d=String((l==null?void 0:l.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",h=String((l==null?void 0:l.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),p=new FormData;p.append("session_id",c),p.append("file",r,d),p.append("filename",d),h&&p.append("content_type",h);const _=await this._post_form("attachments_upload","api/gateway/attachments/upload",p),y=_==null?void 0:_.attachment;if(!y||typeof y!="object")throw new Error("attachments_upload: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return y}async audio_transcribe(s,r){const l=String(s||"").trim();if(!l)throw new Error("audio_transcribe: run_id is required");const c=r==null?void 0:r.audio_artifact;if(!c||typeof c!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(c.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const h={audio_artifact:c},p=String((r==null?void 0:r.language)||"").trim();p&&(h.language=p);const _=String((r==null?void 0:r.request_id)||"").trim();_&&(h.request_id=_);const y=await this._post_json("audio_transcribe",`api/gateway/runs/${encodeURIComponent(l)}/audio/transcribe`,h);return{ok:!!(y!=null&&y.ok),run_id:String((y==null?void 0:y.run_id)||""),request_id:String((y==null?void 0:y.request_id)||""),text:String((y==null?void 0:y.text)||""),transcript_artifact:y==null?void 0:y.transcript_artifact}}async voice_tts(s,r){const l=String(s||"").trim();if(!l)throw new Error("voice_tts: run_id is required");const c=String((r==null?void 0:r.text)||"").trim();if(!c)throw new Error("voice_tts: text is required");const d={text:c,..._f(r)},h=String((r==null?void 0:r.format)||"").trim();h&&(d.format=h),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(d.timeout_s=r.timeout_s);const p=String((r==null?void 0:r.request_id)||"").trim();p&&(d.request_id=p);const _=await this._post_json("voice_tts",`api/gateway/runs/${encodeURIComponent(l)}/voice/tts`,d);return{ok:!!(_!=null&&_.ok),run_id:String((_==null?void 0:_.run_id)||""),request_id:String((_==null?void 0:_.request_id)||""),audio_artifact:_==null?void 0:_.audio_artifact}}async capability_defaults(){return await this._get_json("capability_defaults","api/gateway/config/capability-defaults")}async voice_voices(s){const r=new URLSearchParams({compact:"true"}),l=String((s==null?void 0:s.provider)||"").trim(),c=String((s==null?void 0:s.model)||"").trim();return l&&r.set("provider",l),c&&r.set("model",c),s!=null&&s.providers_only&&r.set("providers_only","true"),await this._get_json("voice_voices",`api/gateway/voice/voices?${r.toString()}`)}voice_stream_transport(s,r){const l=String(s||"").trim();if(!l)throw new Error("voice_stream_transport: run_id is required");return{path:rf(this._cfg.base_url,`api/gateway/runs/${encodeURIComponent(l)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",..._f(r)},headers:pf(this._cfg.auth_token)}}async list_bug_reports(){return await this._get_json("list_bug_reports","api/gateway/reports/bugs")}async list_feature_requests(){return await this._get_json("list_feature_requests","api/gateway/reports/features")}async get_bug_report_content(s){const r=String(s||"").trim();if(!r)throw new Error("get_bug_report_content: filename is required");return await this._get_json("get_bug_report_content",`api/gateway/reports/bugs/${encodeURIComponent(r)}/content`)}async get_feature_request_content(s){const r=String(s||"").trim();if(!r)throw new Error("get_feature_request_content: filename is required");return await this._get_json("get_feature_request_content",`api/gateway/reports/features/${encodeURIComponent(r)}/content`)}async bug_report_create(s){return await this._post_json("bug_report_create","api/gateway/bugs/report",gf(s,"bug_report_create"))}async feature_report_create(s){return await this._post_json("feature_report_create","api/gateway/features/report",gf(s,"feature_report_create"))}async email_list_accounts(){return await this._get_json("email_list_accounts","api/gateway/email/accounts")}async email_list_messages(s){const r=new URLSearchParams,l=String((s==null?void 0:s.account)||"").trim();l&&r.set("account",l);const c=String((s==null?void 0:s.mailbox)||"").trim();c&&r.set("mailbox",c);const d=String((s==null?void 0:s.since)||"").trim();d&&r.set("since",d);const h=String((s==null?void 0:s.status)||"").trim();return h&&r.set("status",h),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):20)),await this._get_json("email_list_messages",`api/gateway/email/messages?${r.toString()}`)}async email_read_message(s,r){const l=String(s||"").trim();if(!l)throw new Error("email_read_message: uid is required");const c=new URLSearchParams,d=String((r==null?void 0:r.account)||"").trim();d&&c.set("account",d);const h=String((r==null?void 0:r.mailbox)||"").trim();h&&c.set("mailbox",h);const p=typeof(r==null?void 0:r.max_body_chars)=="number"&&Number.isFinite(r.max_body_chars)?Number(r.max_body_chars):2e4;return c.set("max_body_chars",String(p)),await this._get_json("email_read_message",`api/gateway/email/messages/${encodeURIComponent(l)}?${c.toString()}`)}async email_send(s){if(!String((s==null?void 0:s.subject)||"").trim())throw new Error("email_send: subject is required");return await this._post_json("email_send","api/gateway/email/send",s||{})}async triage_run(s){const r={};return typeof(s==null?void 0:s.write_drafts)=="boolean"&&(r.write_drafts=!!s.write_drafts),typeof(s==null?void 0:s.enable_llm)=="boolean"&&(r.enable_llm=!!s.enable_llm),await this._post_json("triage_run","api/gateway/triage/run",r)}async list_triage_decisions(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):200)),await this._get_json("list_triage_decisions",`api/gateway/triage/decisions?${r.toString()}`)}async apply_triage_decision(s,r){const l=String(s||"").trim();if(!l)throw new Error("apply_triage_decision: decision_id is required");const c=String((r==null?void 0:r.action)||"").trim();if(!c)throw new Error("apply_triage_decision: action is required");const d={action:c};if(c==="defer"){const h=r==null?void 0:r.defer_days;typeof h=="number"&&Number.isFinite(h)&&h>0&&(d.defer_days=Number(h))}return await this._post_json("apply_triage_decision",`api/gateway/triage/decisions/${encodeURIComponent(l)}/apply`,d)}async backlog_list(s){const r=String(s||"").trim();if(!r)throw new Error("backlog_list: kind is required");return await this._get_json("backlog_list",`api/gateway/backlog/${encodeURIComponent(r)}`)}async backlog_content(s,r){const l=String(s||"").trim(),c=String(r||"").trim();if(!l)throw new Error("backlog_content: kind is required");if(!c)throw new Error("backlog_content: filename is required");return await this._get_json("backlog_content",`api/gateway/backlog/${encodeURIComponent(l)}/${encodeURIComponent(c)}/content`)}async backlog_template(){return await this._get_json("backlog_template","api/gateway/backlog/template")}async backlog_status(){return await this._get_json("backlog_status","api/gateway/backlog/status")}async backlog_move(s){const r=String((s==null?void 0:s.from_kind)||"").trim(),l=String((s==null?void 0:s.to_kind)||"").trim(),c=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_move: from_kind is required");if(!l)throw new Error("backlog_move: to_kind is required");if(!c)throw new Error("backlog_move: filename is required");return await this._post_json("backlog_move","api/gateway/backlog/move",{from_kind:r,to_kind:l,filename:c})}async backlog_update(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_update: kind is required");if(!l)throw new Error("backlog_update: filename is required");const c={content:String((s==null?void 0:s.content)??"")},d=String((s==null?void 0:s.expected_sha256)||"").trim();return d&&(c.expected_sha256=d),await this._post_json("backlog_update",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/update`,c)}async backlog_create(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_create: kind is required");if(!l)throw new Error("backlog_create: package is required");if(!c)throw new Error("backlog_create: title is required");const d={kind:r,package:l,title:c},h=String((s==null?void 0:s.task_type)||"").trim();h&&(d.task_type=h);const p=String((s==null?void 0:s.summary)||"").trim();p&&(d.summary=p);const _=(s==null?void 0:s.content)==null?"":String((s==null?void 0:s.content)??"");return _.trim()&&(d.content=_),await this._post_json("backlog_create","api/gateway/backlog/create",d)}async backlog_merge(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim(),d=Array.isArray(s==null?void 0:s.items)?s.items:[];if(!r)throw new Error("backlog_merge: kind is required");if(!l)throw new Error("backlog_merge: package is required");if(!c)throw new Error("backlog_merge: title is required");if(d.length<2)throw new Error("backlog_merge: at least 2 items are required");const h={kind:r,package:l,title:c,items:d.map(y=>({kind:String((y==null?void 0:y.kind)||"").trim(),filename:String((y==null?void 0:y.filename)||"").trim()}))},p=String((s==null?void 0:s.task_type)||"").trim();p&&(h.task_type=p);const _=String((s==null?void 0:s.summary)||"").trim();return _&&(h.summary=_),await this._post_json("backlog_merge","api/gateway/backlog/merge",h)}async backlog_upload_attachment(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim(),c=s==null?void 0:s.file;if(!r)throw new Error("backlog_upload_attachment: kind is required");if(!l)throw new Error("backlog_upload_attachment: filename is required");if(!c)throw new Error("backlog_upload_attachment: file is required");const d=new FormData;return d.set("overwrite",(s==null?void 0:s.overwrite)===!0?"true":"false"),d.set("file",c,c.name||"attachment"),await this._post_form("backlog_upload_attachment",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/attachments/upload`,d)}async backlog_assist(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_assist: kind is required");if(!l)throw new Error("backlog_assist: package is required");if(!c)throw new Error("backlog_assist: title is required");const d={kind:r,package:l,title:c,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},h=String((s==null?void 0:s.summary)||"").trim();h&&(d.summary=h);const p=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");p.trim()&&(d.draft_markdown=p);const _=String((s==null?void 0:s.provider)||"").trim();_&&(d.provider=_);const y=String((s==null?void 0:s.model)||"").trim();y&&(d.model=y);const b=String((s==null?void 0:s.thinking)||"").trim();return b&&(d.thinking=b),await this._post_json("backlog_assist","api/gateway/backlog/assist",d)}async backlog_maintain(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim(),c=String((s==null?void 0:s.package)||"").trim(),d=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_maintain: kind is required");if(!l)throw new Error("backlog_maintain: filename is required");if(!c)throw new Error("backlog_maintain: package is required");if(!d)throw new Error("backlog_maintain: title is required");const h={kind:r,filename:l,package:c,title:d,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},p=String((s==null?void 0:s.summary)||"").trim();p&&(h.summary=p);const _=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");_.trim()&&(h.draft_markdown=_);const y=String((s==null?void 0:s.provider)||"").trim();y&&(h.provider=y);const b=String((s==null?void 0:s.model)||"").trim();return b&&(h.model=b),await this._post_json("backlog_maintain","api/gateway/backlog/maintain",h)}async backlog_advisor(s){const r={messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},l=String((s==null?void 0:s.provider)||"").trim();l&&(r.provider=l);const c=String((s==null?void 0:s.model)||"").trim();c&&(r.model=c);const d=String((s==null?void 0:s.thinking)||"").trim();d&&(r.thinking=d);const h=String((s==null?void 0:s.agent)||"").trim();h&&(r.agent=h),(s==null?void 0:s.include_trace)===!0&&(r.include_trace=!0);const p=String((s==null?void 0:s.focus_kind)||"").trim();p&&(r.focus_kind=p);const _=String((s==null?void 0:s.focus_type)||"").trim();return _&&(r.focus_type=_),await this._post_json("backlog_advisor","api/gateway/backlog/advisor",r)}async backlog_execute(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_execute: kind is required");if(!l)throw new Error("backlog_execute: filename is required");const c=new URLSearchParams,d=String((s==null?void 0:s.execution_mode)||"").trim();d&&c.set("execution_mode",d);const h=String((s==null?void 0:s.executor)||"").trim();h&&c.set("executor",h);const p=String((s==null?void 0:s.target_model)||"").trim();p&&c.set("target_model",p);const _=String((s==null?void 0:s.target_reasoning_effort)||"").trim();return _&&c.set("target_reasoning_effort",_),(s==null?void 0:s.dor)==="check"&&c.set("dor","check"),(s==null?void 0:s.override)===!0&&c.set("override","true"),await(await this._fetch("backlog_execute",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/execute${c.toString()?`?${c.toString()}`:""}`,{method:"POST"})).json()}async backlog_execute_batch(s){const r=Array.isArray(s==null?void 0:s.items)?s.items:[];if(!r.length)throw new Error("backlog_execute_batch: items are required");const l={items:r.map(_=>({kind:String((_==null?void 0:_.kind)||"").trim(),filename:String((_==null?void 0:_.filename)||"").trim()}))},c=String((s==null?void 0:s.execution_mode)||"").trim();c&&(l.execution_mode=c);const d=String((s==null?void 0:s.executor)||"").trim();d&&(l.executor=d);const h=String((s==null?void 0:s.target_model)||"").trim();h&&(l.target_model=h);const p=String((s==null?void 0:s.target_reasoning_effort)||"").trim();return p&&(l.target_reasoning_effort=p),(s==null?void 0:s.dor)==="check"&&(l.dor="check"),(s==null?void 0:s.override)===!0&&(l.override=!0),await this._post_json("backlog_execute_batch","api/gateway/backlog/execute_batch",l)}async backlog_exec_config(){return await this._get_json("backlog_exec_config","api/gateway/backlog/exec/config")}async backlog_exec_requests(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):200)),await this._get_json("backlog_exec_requests",`api/gateway/backlog/exec/requests?${r.toString()}`)}async backlog_exec_request(s,r){const l=String(s||"").trim();if(!l)throw new Error("backlog_exec_request: request_id is required");const c=new URLSearchParams;return(r==null?void 0:r.include_prompt)===!0&&c.set("include_prompt","true"),await this._get_json("backlog_exec_request",`api/gateway/backlog/exec/requests/${encodeURIComponent(l)}?${c.toString()}`)}async backlog_exec_feedback(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_feedback: request_id is required");const l=String((s==null?void 0:s.feedback)??"");if(!l.trim())throw new Error("backlog_exec_feedback: feedback is required");return await this._post_json("backlog_exec_feedback",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/feedback`,{feedback:l})}async backlog_exec_promote(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_promote: request_id is required");const l={};return(s==null?void 0:s.redeploy)===!0&&(l.redeploy=!0),await this._post_json("backlog_exec_promote",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/promote`,l)}async backlog_exec_deploy_uat(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_deploy_uat: request_id is required");return await this._post_json("backlog_exec_deploy_uat",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/uat/deploy`,{})}async backlog_exec_log_tail(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_log_tail: request_id is required");const l=new URLSearchParams,c=String((s==null?void 0:s.name)||"").trim();c&&l.set("name",c);const d=typeof(s==null?void 0:s.max_bytes)=="number"&&Number.isFinite(s.max_bytes)?Number(s.max_bytes):0;d>0&&l.set("max_bytes",String(Math.floor(d)));const h=typeof(s==null?void 0:s.after_bytes)=="number"&&Number.isFinite(s.after_bytes)?Math.max(0,Math.floor(s.after_bytes)):null;return h!==null&&l.set("after_bytes",String(h)),await this._get_json("backlog_exec_log_tail",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/logs/tail?${l.toString()}`)}async backlog_exec_active_items(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):600)),await this._get_json("backlog_exec_active_items",`api/gateway/backlog/exec/active_items?${r.toString()}`)}async discovery_providers(){return await(await this._fetch("discovery_providers","api/gateway/discovery/providers")).json()}async discovery_model_capabilities(s){const r=String(s||"").trim();if(!r)throw new Error("discovery_model_capabilities: model_name is required");return await(await this._fetch("discovery_model_capabilities",`api/gateway/discovery/models/capabilities?model_name=${encodeURIComponent(r)}`)).json()}async discovery_provider_models(s){const r=String(s||"").trim();if(!r)throw new Error("discovery_provider_models: provider is required");return await(await this._fetch("discovery_provider_models",`api/gateway/discovery/providers/${encodeURIComponent(r)}/models`)).json()}async list_entities(){return await(await this._fetch("list_entities","api/gateway/entities")).json()}async admin_runtime_config(){return await(await this._fetch("admin_runtime_config","api/gateway/admin/runtime-config")).json()}async admin_executors(){return await(await this._fetch("admin_executors","api/gateway/admin/executors")).json()}async admin_runtime_config_update(s){return await(await this._fetch("admin_runtime_config_update","api/gateway/admin/runtime-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s||{})})).json()}async entity_state(s,r){return await(await this._fetch("entity_state",`api/gateway/entities/${encodeURIComponent(s)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()}async entity_skills(s){return await(await this._fetch("entity_skills",`api/gateway/entities/${encodeURIComponent(s)}/skills`)).json()}async put_entity_skills(s,r){return await(await this._fetch("put_entity_skills",`api/gateway/entities/${encodeURIComponent(s)}/skills`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({skills:r})})).json()}async list_bundles(){return await(await this._fetch("list_bundles","api/gateway/bundles")).json()}async admin_data_homes(){return await(await this._fetch("admin_data_homes","api/gateway/admin/data-homes")).json()}async gateway_about(){return await this._get_json("gateway_about","api/gateway/about")}async list_processes(){return await this._get_json("list_processes","api/gateway/processes")}async list_process_env_vars(){return await this._get_json("list_process_env_vars","api/gateway/processes/env")}async update_process_env_vars(s){const r={},l=s!=null&&s.set&&typeof s.set=="object"?s.set:{},c=Array.isArray(s==null?void 0:s.unset)?s==null?void 0:s.unset:[];return l&&Object.keys(l).length&&(r.set=l),c&&c.length&&(r.unset=c),await this._post_json("update_process_env_vars","api/gateway/processes/env",r)}async start_process(s){const r=String(s||"").trim();return await this._post_json("start_process",`api/gateway/processes/${encodeURIComponent(r)}/start`)}async stop_process(s){const r=String(s||"").trim();return await this._post_json("stop_process",`api/gateway/processes/${encodeURIComponent(r)}/stop`)}async restart_process(s){const r=String(s||"").trim();return await this._post_json("restart_process",`api/gateway/processes/${encodeURIComponent(r)}/restart`)}async redeploy_process(s){const r=String(s||"").trim();return await this._post_json("redeploy_process",`api/gateway/processes/${encodeURIComponent(r)}/redeploy`)}async process_log_tail(s,r){const l=String(s||"").trim(),c=typeof(r==null?void 0:r.max_bytes)=="number"?Math.max(1024,Math.min(4e5,Math.floor(r.max_bytes))):8e4;return await this._get_json("process_log_tail",`api/gateway/processes/${encodeURIComponent(l)}/logs/tail?max_bytes=${encodeURIComponent(String(c))}`)}}function gf(a,s){const r=String((a==null?void 0:a.session_id)||"").trim();if(!r)throw new Error(`${s}: session_id is required`);const l=String((a==null?void 0:a.description)||"").trim();if(!l)throw new Error(`${s}: description is required`);const c={session_id:r,description:l};for(const h of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const p=String((a==null?void 0:a[h])||"").trim();p&&(c[h]=p)}const d=a==null?void 0:a.context;return d&&typeof d=="object"&&(c.context=d),c}const vf=[["Gateway","checking…"]];function Lg(a){if(a instanceof gh){const r=a.message.replace(/^gateway_about failed:\s*/,"").trim();return`HTTP ${a.status}${r&&r!==String(a.status)?`: ${r}`:""}`}return(a instanceof Error?a.message:String(a))||"request failed"}async function Mg(a){let s;try{s=await a.gateway_about()}catch(r){return of(null,Lg(r))}return of(s)}const zg=/^[a-zA-Z0-9_-]+$/;function yf(a){return zg.test(String(a||"").trim())}async function Pg(a){const s=String(a||""),r=new TextEncoder().encode(s),l=globalThis.crypto;if(!l||!l.subtle||typeof l.subtle.digest!="function")return"";const c=await l.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(c)).map(d=>d.toString(16).padStart(2,"0")).join("")}async function ud(a){const s=String(a||"").trim();if(!s)throw new Error("session_id is required");if(yf(s)){const l=`session_memory_${s}`;if(yf(l))return l}return`session_memory_sha_${(await Pg(s)).slice(0,32)}`}const Ja=["bug","feature","improvement","task"];function Dl(a){return String(a||"").trim().toLowerCase()}function vh(a){return Ja.includes(Dl(a))}function yh(a){const s=Dl(a);return vh(s)?s:"task"}function xh(a){return a.toUpperCase()}function bh(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function wh(a){return vh(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Ja.join(" / ")})`}function jh(a){const s=String(a||"").trim();return s.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||s}function ha(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Ku(a=new Date){const s=p=>String(p).padStart(2,"0"),r=-a.getTimezoneOffset(),l=r>=0?"+":"-",c=Math.abs(r),d=s(Math.floor(c/60)),h=s(c%60);return`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())} ${l}${d}${h}`}function Ig(a){try{return JSON.parse(a)}catch{return null}}function xf(a,s){return a.scrollHeight-a.scrollTop-a.clientHeight<=s}function Tu(a){const s=typeof a=="string"?a.trim():"";if(!s)return null;const r=s.replace(/(\.\d{3})\d+/,"$1"),l=Date.parse(r);return Number.isFinite(l)?l:null}function Ws(a){if(!Number.isFinite(a))return"";const s=Math.max(0,Math.floor(a/1e3)),r=s%60,l=Math.floor(s/60),c=l%60,d=Math.floor(l/60),h=d%24,p=Math.floor(d/24);return p>0?`${p}d ${h}h`:d>0?`${d}h ${c}m`:l>0?`${l}m ${r}s`:`${s}s`}async function Qu(a){const s=String(a||""),r=new TextEncoder().encode(s),l=globalThis.crypto;if(!l||!l.subtle||typeof l.subtle.digest!="function")return"";const c=await l.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(c)).map(d=>d.toString(16).padStart(2,"0")).join("")}function Il(a){const s=String(a||"").trim().toLowerCase();return s==="completed"||s==="promoted"?"ok":s==="failed"?"danger":s==="running"?"info":s==="queued"||s==="awaiting_qa"?"warn":"muted"}function Og(a,s){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&s==="runs"?"completed,promoted":""}function $l(a,s){const r=a&&typeof a=="object"?a:{},l=r.backlog&&typeof r.backlog=="object"?r.backlog:{},c=r.result&&typeof r.result=="object"?r.result:{},d=r.executor&&typeof r.executor=="object"?r.executor:{},h=String(c.last_message||"").trim(),p=String(r.target_model||d.model||"").trim(),_=String(r.target_reasoning_effort||d.reasoning_effort||"").trim();return{request_id:s,status:String(r.status||"unknown"),created_at:r.created_at??null,started_at:r.started_at??null,finished_at:r.finished_at??null,backlog_relpath:l.relpath??null,backlog_kind:l.kind??null,backlog_filename:l.filename??null,target_agent:r.target_agent??null,target_model:p||null,target_reasoning_effort:_||null,executor_type:d.type??null,ok:typeof c.ok=="boolean"?c.ok:null,exit_code:typeof c.exit_code=="number"?c.exit_code:c.exit_code??null,error:typeof c.error=="string"?c.error:c.error??null,run_dir_relpath:r.run_dir_relpath??null,last_message:Dg(h)}}const Au=1200;function Dg(a){const s=String(a||"");return s?s.length<=Au?s:`${s.slice(0,Au)}
47
- … [#TRUNCATION: ${Au} of ${s.length} chars; the full last_message is in the run directory]`:null}function Fg(a){const s=String(a||""),r=s.split(/\r?\n/).filter(d=>String(d||"").trim().length>0),l=[];let c=0;for(let d=0;d<r.length;d+=1){const h=String(r[d]||"").trim(),p=Ig(h);if(!p||typeof p!="object"){c+=1,l.push({idx:d,type:"raw",payload:null,raw:h});continue}const _=String(p.type||p.event||"event");l.push({idx:d,type:_,payload:p,raw:h})}return{total:r.length,bad:c,events:l,raw:s}}function qg(a){if(!a)return null;let s=0,r=0,l=0,c=0,d=0;for(const p of a.events){const _=p.payload,y=_&&typeof _.usage=="object"?_.usage:null;y&&(Number.isFinite(Number(y.input_tokens))&&(s+=Number(y.input_tokens)),Number.isFinite(Number(y.cached_input_tokens))&&(r+=Number(y.cached_input_tokens)),Number.isFinite(Number(y.output_tokens))&&(l+=Number(y.output_tokens)));const b=_&&typeof _.item=="object"?_.item:null;b&&String(b.type||"").trim()==="command_execution"&&(c+=1,String(b.status||"").trim().toLowerCase()==="failed"&&(d+=1))}return{has_tokens:s>0||l>0||r>0,input_tokens:s,cached_input_tokens:r,output_tokens:l,total_tokens:s+l,command_count:c,command_fail_count:d}}function Fl(a,s=Date.now()){const r=Tu(a==null?void 0:a.created_at),l=Tu(a==null?void 0:a.started_at),c=Tu(a==null?void 0:a.finished_at),d=String((a==null?void 0:a.status)||"").trim().toLowerCase(),h=c??(d==="running"?s:null),p=c!=null,_=r!=null&&l!=null?Math.max(0,l-r):null,y=l!=null&&h!=null?Math.max(0,h-l):null,b=r!=null&&h!=null?Math.max(0,h-r):null,x=!p&&r!=null?Math.max(0,s-r):null;return{is_done:p,queue_delay_ms:_,run_ms:y,total_ms:b,age_ms:x}}function Bg(a,s){const r=String(s.package_name).trim()||"{Package}",l=jh(String(s.title||"").trim()||"{Title}"),c=String(s.summary||"").trim(),d=yh(s.task_type),h=`# {ID}-${r}: [${xh(d)}] ${l}`.trim();let p=String(a||"");p=p.split("{Package}").join(r).split("{Title}").join(l);const _=p.split(/\r?\n/);let y=!1;for(let I=0;I<_.length;I+=1){const C=String(_[I]||"");if(C.trim().startsWith("# ")){_[I]=h,y=!0;break}if(C.trim())break}y||(_.unshift("",h),_.shift());const b=`> Created: ${String(s.created_at||"").trim()}`.trim();let x=!1;for(let I=0;I<Math.min(_.length,40);I+=1)if(String(_[I]||"").trim().toLowerCase().startsWith("> created:")){_[I]=b,x=!0;break}if(!x){const I=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(I,0,b,"")}const N=`> Type: ${d}`.trim();let E=!1;for(let I=0;I<Math.min(_.length,60);I+=1)if(String(_[I]||"").trim().toLowerCase().startsWith("> type:")){_[I]=N,E=!0;break}if(!E){let I=-1;for(let C=0;C<Math.min(_.length,60);C+=1)if(String(_[C]||"").trim().toLowerCase().startsWith("> created:")){I=C;break}if(I>=0){const C=I+1;C<_.length&&!String(_[C]||"").trim()?_.splice(C,0,N):_.splice(C,0,N,"")}else{const C=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(C,0,N,"")}}if(c){for(let I=0;I<_.length;I+=1)if(String(_[I]||"").trim().toLowerCase()==="## summary"){let C=I+1;for(;C<_.length&&!String(_[C]||"").trim();)C+=1;(C<_.length?String(_[C]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?_[C]=c:_.splice(I+1,0,c,"");break}}return p=_.join(`
48
- `),p.endsWith(`
49
- `)||(p+=`
50
- `),p}function Va(a){return String(a||"").split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function Ug(a){const s=String(a.package_name||"").trim()||"{Package}",r=jh(String(a.title||"").trim()||"{Title}"),l=yh(a.task_type),c=String(a.created_at||"").trim()||Ku(),d=String(a.diagram||"").trim(),h=String(a.context||"").trim(),p=[];return p.push(`# {ID}-${s}: [${xh(l)}] ${r}`),p.push(""),p.push(`> Created: ${c}`),p.push(`> Type: ${l}`),p.push(""),p.push("## Summary"),p.push(a.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),p.push(""),p.push("## Diagram"),p.push("```"),p.push(d||`ASCII diagram of the system change.
51
- Show inputs/outputs and where code lives.`),p.push("```"),p.push(""),p.push("## Context"),p.push(h||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),p.push(""),p.push("## Scope"),p.push("### Included"),a.included.length?p.push(...a.included.map(_=>`- ${_}`)):p.push("- "),p.push(""),p.push("### Excluded"),a.excluded.length?p.push(...a.excluded.map(_=>`- ${_}`)):p.push("- "),p.push(""),p.push("## Implementation Plan"),a.plan.length?p.push(...a.plan.map((_,y)=>`${y+1}. ${_}`)):p.push("1. "),p.push(""),p.push("## Dependencies"),a.dependencies.length?p.push(...a.dependencies.map(_=>`- ${_}`)):p.push("- Related backlog items / ADRs"),p.push(""),p.push("## Acceptance Criteria"),a.acceptance.length?p.push(...a.acceptance.map(_=>`- [ ] ${_}`)):p.push("- [ ] Criterion 1 (clear, testable)"),p.push(""),p.push("## Testing (ADR-0019)"),p.push("- Level A:"),a.tests_a.length?p.push(...a.tests_a.map(_=>` - \`${_}\``)):p.push(" - `...`"),p.push("- Level B:"),a.tests_b.length?p.push(...a.tests_b.map(_=>` - \`${_}\``)):p.push(" - `...`"),p.push("- Level C (optional / opt-in):"),a.tests_c.length?p.push(...a.tests_c.map(_=>` - \`${_}\``)):p.push(" - n/a"),p.push(""),p.push("## Related"),p.push("- ADRs:"),p.push("- Code:"),p.push("- Reports:"),a.attachments.length&&(p.push("- Attachments:"),p.push(...a.attachments.map(_=>` - ${_}`))),p.push(""),p.push("---"),p.push("## Report (added when completed)"),p.push(""),p.push("> Completed: YYYY-MM-DD"),p.push(""),p.push("### What changed"),p.push("- "),p.push(""),p.push("### Security / hardening"),p.push("- "),p.push(""),p.push("### Testing (ADR-0019)"),p.push("Levels executed:"),p.push("- A:"),p.push("- B:"),p.push("- C (if any):"),p.push(""),p.push("Commands run:"),p.push("- `...`"),p.push(""),p.push("### Follow-ups"),p.push("- "),p.push(""),p.join(`
52
- `)}function Wg(a,s){const r=s.map(_=>String(_||"").trim()).filter(Boolean);if(!r.length)return a;const l=String(a||"").split(/\r?\n/),c=l.map(_=>_.toLowerCase()),d=c.findIndex(_=>_.trim()==="## related");if(d<0)return`${String(a||"").trimEnd()}
53
-
54
- ## Related
55
- - Attachments:
56
- ${r.map(y=>` - ${y}`).join(`
57
- `)}
58
- `;let h=-1;for(let _=d+1;_<l.length;_+=1){const y=c[_].trim();if(y.startsWith("## ")||y.startsWith("---"))break;if(y.startsWith("- attachments:")){h=_;break}}const p=["- Attachments:",...r.map(_=>` - ${_}`)];if(h>=0){let _=h+1;for(;_<l.length&&/^\s+-\s/.test(l[_]);)_+=1;l.splice(_,0,...r.map(y=>` - ${y}`))}else{let _=d+1;for(let y=d+1;y<l.length;y+=1){const b=c[y].trim();if(b.startsWith("## ")||b.startsWith("---")){_=y;break}_=y+1}l.splice(_,0,...p,"")}return l.join(`
59
- `)}function Hg(a,s){const r=sh(a);if(!r.ok)return null;const l=r.payload.phases.map(h=>h.id),c=new Map;for(const h of s)c.set(`${h.section}\0${h.item}\0${h.phase}`,h.op);const d=[];for(const h of r.payload.sections)for(const p of h.items){const _=[];for(const y of l){const b=p.cells[y];if(!b)continue;const x=c.get(`${h.id}\0${p.id}\0${y}`);(x?x==="grant":!!b.assigned)&&_.push(y)}_.length&&(_.length===l.length?d.push({name:p.id}):d.push({name:p.id,phases:_}))}return d}function Vg(a){var $,ae;const{gateway:s,entity_name:r}=a,[l,c]=f.useState(null),[d,h]=f.useState(""),[p,_]=f.useState(!1),[y,b]=f.useState([]),[x,N]=f.useState(!1),[E,I]=f.useState(""),[C,M]=f.useState(""),O=f.useCallback(async()=>{_(!0),h("");try{c(await s.entity_skills(r))}catch(fe){c(null),h(String((fe==null?void 0:fe.message)||fe))}finally{_(!1)}},[s,r]);f.useEffect(()=>{b([]),M(""),I(""),O()},[O]);async function D(){if(!(l!=null&&l.matrix))return;const fe=Hg(l.matrix,y);if(fe===null){I("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}N(!0),I("");try{const oe=await s.put_entity_skills(r,fe);c(oe),b([]),M("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>M(""),5e3)}catch(oe){I(String((oe==null?void 0:oe.message)||oe))}finally{N(!1)}}const F=Array.isArray(($=l==null?void 0:l.selection)==null?void 0:$.warnings)?l.selection.warnings.map(String):[],H=Array.isArray((ae=l==null?void 0:l.resolved)==null?void 0:ae.skills)?l.resolved.skills:[];return e.jsxs("div",{className:"entity_skills_panel",children:[e.jsxs("div",{className:"entity_skills_head",children:[e.jsxs("span",{className:"pane_title",children:["Skills — ",r]}),e.jsx("span",{className:"muted",style:{fontSize:"var(--font-size-xs)"},children:"what this mind is taught, per phase; the trust gate resolves server-side"}),e.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",gap:6},children:[e.jsx("button",{className:"btn",onClick:()=>void O(),disabled:p||x,title:"Reload the resolved view (discards pending edits)",children:p?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]})]}),d?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",d]}):null,F.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:F.join(" · ")}):null,H.length?e.jsx("div",{className:"entity_skills_resolved",children:H.map(fe=>{const oe=String((fe==null?void 0:fe.name)||""),Ne=!!(fe!=null&&fe.active),Me=!!(fe!=null&&fe.blocked),be=!!(fe!=null&&fe.requires_review),ye=fe==null?void 0:fe.requires_unmet,ue=Array.isArray(ye)?ye.map(String):ye&&typeof ye=="object"?Object.entries(ye).map(([ne,Y])=>`${ne}: ${String(Y)}`):[],q=Ne?"ok":Me?"danger":ue.length||be?"warn":"muted",R=Ne?"active":Me?"blocked":ue.length?"requires unmet":be?"requires review":"inactive",V=[...Array.isArray(fe==null?void 0:fe.reasons)?fe.reasons.map(String):[],...ue].join("; ");return e.jsxs("span",{className:`chip mono ${q}`,title:V||void 0,children:[oe," · ",R]},oe)})}):null,e.jsx(g_,{payload:l==null?void 0:l.matrix,patches:y,onPatchesChange:b,disabled:x||p,title:"Phase capabilities",subtitle:"Grant/Deny per phase; Default clears the operator word (unselected). Save replaces the whole selection."}),e.jsxs("div",{className:"entity_skills_actions",children:[e.jsx("button",{className:"btn primary",onClick:()=>void D(),disabled:x||!y.length,title:y.length?`Save ${y.length} pending change(s)`:"No pending changes",children:x?"Saving…":y.length?`Save ${y.length} change${y.length>1?"s":""}`:"Save"}),y.length?e.jsx("button",{className:"btn",onClick:()=>b([]),disabled:x,children:"Discard edits"}):null,E?e.jsx("span",{className:"page_error",style:{margin:0},children:E}):null,C?e.jsx("span",{className:"chip mono ok",children:C}):null]})]})}function Gg(a){const s=new Map;for(const r of a){const l=String(r.target_agent||(r.target_model?`${String(r.executor_type||"agent").trim()||"agent"}:${r.target_model}`:"")||"(unattributed)").trim();let c=s.get(l);c||(c={agent:l,model:String(r.target_model||"").trim(),runs:0,active:0,promoted:0,completed:0,failed:0,awaiting_qa:0,total_run_ms:0,timed_runs:0,last_active:""},s.set(l,c)),c.runs+=1;const d=String(r.status||"").toLowerCase();d==="queued"||d==="running"?c.active+=1:d==="promoted"?c.promoted+=1:d==="completed"?c.completed+=1:d==="failed"?c.failed+=1:d==="awaiting_qa"&&(c.awaiting_qa+=1);const h=Fl(r);h.run_ms!=null&&(c.total_run_ms+=h.run_ms,c.timed_runs+=1);const p=String(r.finished_at||r.started_at||r.created_at||"");p>c.last_active&&(c.last_active=p)}return[...s.values()].sort((r,l)=>l.runs-r.runs)}function Kg(a){const{gateway:s,gateway_connected:r}=a,l=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[c,d]=f.useState(null),[h,p]=f.useState([]),[_,y]=f.useState([]),[b,x]=f.useState(""),[N,E]=f.useState(null),[I,C]=f.useState(!1),[M,O]=f.useState(""),[D,F]=f.useState(!1),[H,$]=f.useState(""),[ae,fe]=f.useState(null),oe=f.useRef(0);async function Ne(){if(!r||I)return;const w=++oe.current;C(!0),O("");try{const[L,X,ge]=await Promise.all([s.backlog_exec_config(),s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]);if(w!==oe.current)return;d(L),p([...Array.isArray(X==null?void 0:X.requests)?X.requests:[],...Array.isArray(ge==null?void 0:ge.requests)?ge.requests:[]])}catch(L){w===oe.current&&O(String((L==null?void 0:L.message)||L||"Failed to load agents"))}finally{oe.current,C(!1)}try{const L=await s.list_entities();if(w!==oe.current)return;y(Array.isArray(L==null?void 0:L.entities)?L.entities:[]),x("")}catch(L){if(w!==oe.current)return;y([]),x(`#FALLBACK entity registry unavailable: ${String((L==null?void 0:L.message)||L)}`)}try{const L=await s.admin_executors();if(w!==oe.current)return;const X=Array.isArray(L)?L:Array.isArray(L==null?void 0:L.executors)?L.executors:[];E(X)}catch{w===oe.current&&E(L=>L===null?null:L)}try{const L=await s.admin_runtime_config();w===oe.current&&F((L==null?void 0:L.writable)===!0)}catch{w===oe.current&&F(!1)}}async function Me(){oe.current+=1;try{const w=await s.list_entities();y(Array.isArray(w==null?void 0:w.entities)?w.entities:[]),x("")}catch(w){x(`#FALLBACK entity registry unavailable: ${String((w==null?void 0:w.message)||w)}`)}}async function be(){oe.current+=1;try{const w=await s.admin_executors(),L=Array.isArray(w)?w:Array.isArray(w==null?void 0:w.executors)?w.executors:[];E(L)}catch{}try{d(await s.backlog_exec_config())}catch{}}async function ye(w){if(H)return;const L=`executor:${w}`;$(L),fe(null);try{await s.admin_runtime_config_update({executor:w}),await be()}catch(X){fe({key:L,text:String((X==null?void 0:X.message)||X||"Executor change refused")})}finally{$("")}}const[ue,q]=f.useState(null);async function R(w,L){if(H)return;const X=String(w.slug||w.name||"").trim();if(!X)return;const ge=`entity:${X}`;$(ge),fe(null);try{await s.entity_state(X,{state:L,reason:"by the operator via Continuum (Agents & Entities)"}),await Me()}catch(de){fe({key:ge,text:String((de==null?void 0:de.message)||de||"State change refused")})}finally{$("")}}f.useEffect(()=>{Ne()},[r]);const V=f.useMemo(()=>Gg(h),[h]),ne=!!(c!=null&&c.runner_alive),Y=String((c==null?void 0:c.executor)||"").trim(),me=!Y||Y==="none",A=me?"No execution agent":Y;return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("span",{className:"page_hint",children:"The workforce behind the pipeline — the executor is a pluggable seam; this console renders whatever the gateway reports."}),M?e.jsx("span",{className:"page_error mono",children:M}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${I?"is_loading":""}`,onClick:()=>void Ne(),disabled:!r||I,title:"Refresh","aria-label":"Refresh",children:e.jsx(et,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[N!==null&&N.length?N.map(w=>e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(et,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.display||w.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",w.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${w.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:w.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(w.models)&&w.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",w.models.slice(0,4).join(", "),w.models.length>4?` +${w.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:w.default?e.jsx("span",{className:"chip mono ok",title:"New executions run under this agent unless the request overrides it.",children:"gateway default"}):D?e.jsx("button",{className:"btn",disabled:!!H||w.available===!1,title:w.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":H&&H!==`executor:${w.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void ye(w.id),children:H===`executor:${w.id}`?"Setting…":"Set as default"}):e.jsx("span",{className:"chip mono muted",title:"Changing the default executor is admin-only — the gateway authorizes it (Settings → Gateway administration).",children:"admin only"})}),(ae==null?void 0:ae.key)===`executor:${w.id}`?e.jsx("div",{className:"detail_warn",children:ae.text}):null]},w.id)):c?e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(et,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:A}),e.jsx("div",{className:"entity_card_sub",children:me?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${ne?"ok":me?"warn":"danger"}`,style:{marginLeft:"auto"},children:ne?"available":me?"not configured":"offline"})]}),e.jsxs("div",{className:"agent_facts",children:[c.codex_model?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model:"})," ",c.codex_model]}):null,c.codex_reasoning_effort?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"reasoning:"})," ",c.codex_reasoning_effort]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"can execute:"})," ",c.can_execute?"yes":"no"]}),c.runner_error?e.jsx("div",{className:"page_error",children:c.runner_error}):null]})]}):null,e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(et,{name:"edit",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:l}),e.jsx("div",{className:"entity_card_sub",children:"backlog advisor (read-only chat agent)"})]}),e.jsx("span",{className:"chip mono muted",style:{marginLeft:"auto"},children:"advisory"})]}),e.jsxs("div",{className:"agent_facts",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"surface:"})," assistant drawer + Backlog advisor"]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"writes:"})," none (advice only)"]})]}),e.jsx("div",{className:"entity_card_actions",children:e.jsx("button",{className:"btn",onClick:()=>{var w;return(w=a.on_open_assistant)==null?void 0:w.call(a)},disabled:!a.on_open_assistant,title:"Open the assistant drawer and ask this advisor a question",children:"Ask the advisor"})})]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Summoned entities"}),e.jsxs("span",{className:"pane_count",children:[_.length," on this gateway"]}),e.jsx("span",{className:"pane_header_actions muted",style:{fontSize:"var(--font-size-xs)"},children:"persistent minds with full package history — recruitable for development alongside agents"})]}),e.jsxs("div",{className:"pane_body",children:[b?e.jsx("div",{className:"page_error",style:{fontSize:"var(--font-size-sm)"},children:b}):null,!b&&!_.length?e.jsx("div",{className:"empty_note",children:"No summoned entities on this gateway yet. Entities are created and summoned through the gateway (its CLI/console); once they exist they appear here as recruitable developers."}):null,_.length?e.jsx("div",{className:"agents_grid",style:{marginTop:0},children:_.map(w=>{var P,je,Ae,Fe,Ve,lt;if(w.error)return e.jsxs("div",{className:"entity_card",style:{borderColor:"var(--danger, rgb(248,113,113))"},children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(et,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.name||w.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:w.entity_id||w.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:w.error})]},w.entity_id||w.slug||w.name);const L=String(((P=w.state)==null?void 0:P.state)||"unknown").toLowerCase(),X=L==="awake"?"ok":L==="asleep"?"info":L==="paused"?"warn":"muted",de=String(w.liveness||((je=w.state)==null?void 0:je.liveness)||"").toLowerCase()==="stopped";return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(et,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.name||w.slug}),e.jsx("div",{className:"entity_card_sub mono",children:w.entity_id})]}),de?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${L}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${X}`,style:{marginLeft:"auto"},children:L})]}),e.jsxs("div",{className:"agent_facts",children:[w.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(w.created_at).toLocaleDateString()]}):null,(Ae=w.state)!=null&&Ae.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",w.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(Fe=w.files)!=null&&Fe.spark?"✓":"—"," · memory ",(Ve=w.files)!=null&&Ve.memory?"✓":"—"," · book ",(lt=w.files)!=null&&lt.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!de&&(L==="asleep"||L==="paused")?e.jsx("button",{className:"btn",disabled:!!H,title:H&&H!==`entity:${w.slug||w.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void R(w,"awake"),children:H===`entity:${w.slug||w.name}`?"Waking…":"Wake"}):null,!de&&L==="awake"?e.jsx("button",{className:"btn",disabled:!!H,title:H&&H!==`entity:${w.slug||w.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void R(w,"asleep"),children:H===`entity:${w.slug||w.name}`?"Sending…":"Sleep"}):null,de?e.jsx("span",{className:"chip mono warn",title:"Restore lives on the gateway console — the kill switch keeps one management surface.",children:"restore via gateway console"}):null,e.jsx("button",{className:"btn",onClick:()=>q(pe=>pe===(w.name||w.slug)?null:w.name||w.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:ue===(w.name||w.slug)?"Hide skills":"Skills"})]}),(ae==null?void 0:ae.key)===`entity:${w.slug||w.name}`?e.jsx("div",{className:"detail_warn",children:ae.text}):null]},w.entity_id||w.slug)})}):null,ue?e.jsx(Vg,{gateway:s,entity_name:ue,on_close:()=>q(null)}):null]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Capabilities"}),e.jsx("span",{className:"pane_subtitle",children:"live features link to their surface; pending ones name their owner"})]}),e.jsx("div",{className:"pane_body",children:e.jsxs("div",{className:"cap_rows",children:[e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Executor choice per task"}),e.jsx("span",{className:"chip mono ok",children:"live"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Watch runs execute under their chosen agent",children:"Open Executions"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Every Execute dialog (Board and Backlog) carries an Execution agent dropdown — codex, claude, cursor-agent, abstractcode, probed live by the gateway. The default is set on the executor cards above; runs attribute canonically in the track record."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Skills per run and per member"}),e.jsx("span",{className:"chip mono warn",children:"partial"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Run detail → Skills section shows which teachings rode each run",children:"View on a run"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Which skills rode each run renders in the run detail today (requested vs active, held verdicts verbatim). Per-MEMBER skill grants (trust levels, review badges) land when the gateway serves the abstractskill union contract over HTTP (c1778) — the cards above grow a Skills action that day."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"MCP access grants"}),e.jsx("span",{className:"chip mono muted",children:"pending contract"})]}),e.jsx("div",{className:"cap_row_detail",children:"Per-member MCP grants — the ruled home is the gateway's phases config family, endpoint mirroring tool-policy (c1554). No continuum surface until the gateway serves it; this row turns live then."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Agora charters and recruitment"}),e.jsx("span",{className:"chip mono info",children:"read live"}),a.on_open_team?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_team,title:"Team page → ⓘ About shows each channel's charter, purpose, SLA, and members",children:"Open Team"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Per-channel charters, purpose, SLA, and members render on the Team page (ⓘ About on any channel). Charter WRITES and recruitment criteria are the next hub-proxy slice — writes are governance acts and get their own confirmation surface."})]})]})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Track record"}),e.jsxs("span",{className:"pane_count",children:[V.length," agent",V.length===1?"":"s"]}),e.jsx("span",{className:"pane_header_actions muted",style:{fontSize:"var(--font-size-xs)"},children:"all live + last 200 finished — counts, not quality"})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:V.length?e.jsx("div",{className:"table_scroll",children:e.jsxs("table",{className:"data_table track_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"agent"}),e.jsx("th",{children:"runs"}),e.jsx("th",{className:"col_aux",children:"active"}),e.jsx("th",{className:"col_aux",children:"promoted"}),e.jsx("th",{className:"col_aux",children:"completed"}),e.jsx("th",{className:"col_aux",children:"in review"}),e.jsx("th",{children:"failed"}),e.jsx("th",{className:"col_aux2",children:"avg run"}),e.jsx("th",{className:"col_aux2",children:"last active"})]})}),e.jsx("tbody",{children:V.map(w=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:w.agent}),e.jsx("td",{children:w.runs}),e.jsx("td",{className:"col_aux",children:w.active||""}),e.jsx("td",{className:"col_aux",children:w.promoted||""}),e.jsx("td",{className:"col_aux",children:w.completed||""}),e.jsx("td",{className:"col_aux",children:w.awaiting_qa||""}),e.jsx("td",{className:w.failed?"page_error":"",children:w.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:w.timed_runs?Ws(w.total_run_ms/w.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:w.last_active?new Date(w.last_active).toLocaleString():""})]},w.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Hs(a){const s=String(a||"").trim(),r=s.lastIndexOf("-");if(r<=0||r===s.length-1)return null;const l=s.slice(0,r),c=s.slice(r+1);return!/^[0-9]+$/.test(c)||!/^[a-z0-9][a-z0-9_.-]*$/.test(l)?null:{package:l,num:c}}function bf(a,s){const r=String(s||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function Qg(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function Jg(a){const r=String(a||"").replace(/\\/g,"/").match(/(?:^|\/)(proposed|planned|completed|deprecated|recurrent)\/([^/]+\.md)$/i);return r?{kind:r[1].toLowerCase(),filename:r[2]}:null}const Yg=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,Xg=6;function Zg(a){const s=[];for(const r of String(a||"").matchAll(Yg)){const l=r[1];if(Hs(l)&&(s.includes(l)||s.push(l),s.length>=Xg))break}return s}function kh(a,s,r=24){const l=a.started_at;if(l==null||l==="")return null;let c;if(typeof l=="number")c=l>1e12?l:l*1e3;else{const p=Date.parse(String(l));if(Number.isNaN(p))return null;c=p}const d=Math.max(0,(s-c)/36e5);return{label:d<1?`claimed ${Math.max(1,Math.round(d*60))}m`:d<48?`claimed ${Math.round(d)}h`:`claimed ${Math.round(d/24)}d`,stale:d>=r}}const ql=["P0","P1","P2","P3"],Sh={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},Nh=/^>\s*priority:\s*(p[0-3])\b/i,Ch=/^>\s*labels:\s*(.+)$/i;function dd(a){return String(a||"").split(",").map(s=>s.trim().toLowerCase().replace(/\s+/g,"-")).filter(s=>!!s&&s.length<=40).slice(0,12)}function Ru(a,s){const r=[];let l=!1;for(const c of a){const d=c.trim();if(/^#{1,6}\s/.test(d)){l=s.test(d);continue}l&&r.push(c)}return r}const ev=["one paragraph describing","criterion 1 (clear, testable)"];function wf(a){const s=a.trim().toLowerCase();return s?ev.some(r=>s.startsWith(r)):!0}function Ni(a){const s=String(a||"").split(/\r?\n/);let r=null,l=[];for(const _ of s.slice(0,60)){const y=_.trim();if(/^##+\s/.test(y))break;const b=Nh.exec(y);b&&!r&&(r=b[1].toUpperCase());const x=Ch.exec(y);x&&!l.length&&(l=dd(x[1]))}const c=[];for(const _ of Ru(s,/acceptance criteria/i)){const y=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(_);if(!y)continue;const b=y[2].trim();wf(b)||c.push({text:b,checked:y[1].toLowerCase()==="x"})}const d=[];for(const _ of Ru(s,/testing/i))for(const y of _.matchAll(/`([^`]+)`/g)){const b=y[1].trim();!b||b==="..."||b.toLowerCase()==="n/a"||d.push(b)}const h=Ru(s,/^#{1,6}\s*summary\b/i).map(_=>_.trim()).filter(Boolean),p=h.length>0&&!h.every(wf);return{priority:r,labels:l,acceptance:c,test_commands:d,has_summary:p}}function md(a,s){const r=String(a.task_type||"").trim().toLowerCase(),l=[{id:"type",label:`Work type is set (${Ja.join(" / ")})`,ok:Ja.includes(r),evidence:r?`type: ${r}`:"no type"},{id:"summary",label:"Summary describes the outcome (not the template placeholder)",ok:s.has_summary,evidence:s.has_summary?"summary present":"empty or template placeholder"},{id:"acceptance",label:"At least one acceptance criterion",ok:s.acceptance.length>0,evidence:s.acceptance.length?`found ${s.acceptance.length}: "${jf(s.acceptance[0].text,60)}"${s.acceptance.length>1?", …":""}`:"none found under ## Acceptance Criteria"},{id:"tests",label:"At least one concrete test command (Testing A/B)",ok:s.test_commands.length>0,evidence:s.test_commands.length?`found ${s.test_commands.length}: \`${jf(s.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:l.every(c=>c.ok),checks:l}}function jf(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Ju(a){const s=a;if(!s||s.status!==409)return null;const r=s.body,l=r&&typeof r=="object"&&r.detail&&typeof r.detail=="object"?r.detail:r;if(!l||l.error!=="definition_of_ready_failed")return null;const d=(Array.isArray(l.checks)?l.checks:Array.isArray(l.members)?l.members.flatMap(h=>(Array.isArray(h==null?void 0:h.checks)?h.checks:[]).map(p=>({...p,label:h!=null&&h.relpath?`${h.relpath}: ${String((p==null?void 0:p.label)||"")}`:p==null?void 0:p.label}))):[]).map(h=>({id:String((h==null?void 0:h.id)||""),label:String((h==null?void 0:h.label)||""),ok:(h==null?void 0:h.ok)===!0,evidence:h!=null&&h.evidence?String(h.evidence):void 0}));return d.length?{ok:d.every(h=>h.ok),checks:d}:null}function Yu(a,s){const l=[...String(a||"").split(/\r?\n/)];function c(d,h){const p=[];for(let y=0;y<Math.min(l.length,60);y+=1){const b=l[y].trim();if(/^##+\s/.test(b))break;d.test(b)&&p.push(y)}if(p.length){for(let y=p.length-1;y>=1;y-=1)l.splice(p[y],1);h?l[p[0]]=h:l.splice(p[0],1);return}if(!h)return;let _=-1;for(let y=0;y<Math.min(l.length,60);y+=1){const b=l[y].trim();if(b.startsWith("> ")&&(_=y),/^##\s/.test(b))break}if(_<0){const y=l.findIndex(b=>b.trim().startsWith("# "));if(y>=0)_=y;else{l.unshift(h);return}}l.splice(_+1,0,h)}return c(Nh,s.priority?`> Priority: ${s.priority}`:null),c(Ch,s.labels.length?`> Labels: ${s.labels.join(", ")}`:null),l.join(`
60
- `)}const kf=[{id:"triage",label:"Triage",hint:"Proposed — needs a decision (merge/advisor tooling lives on the Backlog page)"},{id:"ready",label:"Ready",hint:"Planned — executable. A ⚠ badge counts recent failed attempts."},{id:"in_progress",label:"In Progress",hint:"Queued/running executions + seat-claimed items (live hub pointer claims — the ⛏ chip names the owner)"},{id:"in_review",label:"In Review",hint:"Awaiting QA decision (receipts-posted seat work joins when the /work index is live)"},{id:"done",label:"Done",hint:"Recent promotions/completions (attempts). The full archive lives in Backlog → Completed."},{id:"failed",label:"Failed",hint:"Recent failed attempts (history) — the item itself stays executable in Ready"}];function Xu(a){const s=String(a||"").trim().toUpperCase();return ql.includes(s)?s:null}function Zu(a){return a.priority!==void 0||a.labels!==void 0}const tv="decision-gate";function nv(a){return Array.isArray(a)&&a.some(s=>String(s||"").trim().toLowerCase()===tv)}function $h(a,s){return nv(a.labels!==void 0?a.labels:s==null?void 0:s.labels)}function Eh(a){return a.priority!==void 0||a.labels!==void 0}function ed(a,s){return a.priority!==void 0?a.priority:(s==null?void 0:s.priority)??null}function td(a,s){return a.labels!==void 0?a.labels:(s==null?void 0:s.labels)??[]}const sv=new Set(["queued","running"]);function av(a){const s=String(a||"").split("/").filter(Boolean);return s.length?s[s.length-1]:""}const rv=/^batch\((\d+)\)$/i;function Sf(a){const s=rv.exec(String(a||"").trim());return s?Number(s[1]):null}function iv(a){const s=a.recent_limit??12,r=[],l=new Set;for(const b of a.active_items){const x=String(b.filename||"").trim();x&&l.add(x)}const c=(b,x,N)=>{const E=String(b.backlog_filename||"").trim()||av(String(b.backlog_relpath||"")),I=Sf(E),C=I!==null?"":E;return C&&N&&l.add(C),{key:C&&N?`file:${C}`:`req:${b.request_id}`,column:x,title:I!==null?`Batch execution (${I} items)`:C||`Execution ${b.request_id.slice(0,8)}…`,filename:C||void 0,request_id:b.request_id,exec_status:String(b.status||"").trim().toLowerCase(),created_at:b.created_at??null,started_at:b.started_at??null,finished_at:b.finished_at??null,target_agent:b.target_agent??(b.target_model?`${String(b.executor_type||"agent").trim()||"agent"}:${b.target_model}`:null),batch_size:I!==null?I:void 0}};for(const b of a.active_requests){const x=String(b.status||"").trim().toLowerCase();sv.has(x)?r.push(c(b,"in_progress",!0)):x==="awaiting_qa"&&r.push(c(b,"in_review",!0))}const d=[...a.terminal_requests].sort((b,x)=>{const N=String(b.finished_at||b.started_at||b.created_at||"");return String(x.finished_at||x.started_at||x.created_at||"").localeCompare(N)}),h=new Map;let p=0,_=0;for(const b of d){const x=String(b.status||"").trim().toLowerCase();if(x==="failed"){const N=String(b.backlog_filename||"").trim();N&&Sf(N)===null&&h.set(N,(h.get(N)||0)+1),_<s&&(r.push(c(b,"failed",!1)),_+=1)}else(x==="promoted"||x==="completed")&&p<s&&(r.push(c(b,"done",!1)),p+=1)}for(const b of a.planned){const x=String(b.filename||"").trim();!x||l.has(x)||r.push({key:`file:${x}`,column:"ready",title:b.title||x,kind:"planned",filename:x,item_id:b.item_id,package:b.package,task_type:b.task_type,summary:b.summary,recent_failures:h.get(x)||void 0,priority:Zu(b)?Xu(b.priority):void 0,labels:Array.isArray(b.labels)?b.labels:void 0})}for(const b of a.proposed){const x=String(b.filename||"").trim();!x||l.has(x)||r.push({key:`file:${x}`,column:"triage",title:b.title||x,kind:"proposed",filename:x,item_id:b.item_id,package:b.package,task_type:b.task_type,summary:b.summary,priority:Zu(b)?Xu(b.priority):void 0,labels:Array.isArray(b.labels)?b.labels:void 0})}const y=new Map;for(const b of[...a.planned,...a.proposed])y.set(String(b.filename||"").trim(),b);for(const b of r){if(!b.filename||b.kind)continue;const x=y.get(b.filename);x&&(b.title=x.title||b.title,b.item_id=x.item_id,b.package=x.package,b.task_type=x.task_type,b.summary=x.summary)}return r}const lv=200;function ov(a,s){var b;const{live:r,done:l}=s,c=s.work||new Map;if(!r.size&&!l.length&&!c.size)return a;const d=new Set,h=new Set;for(const x of a){if(!x.filename||!x.package)continue;const N=bf(x.package,x.filename);N&&h.add(N)}const p=a.map(x=>{if(x.column!=="ready"||x.kind!=="planned"||!x.filename||!x.package)return x;const N=bf(x.package,x.filename);if(!N)return x;const E=r.get(N);return!E||!E.owner?x:(d.add(N),{...x,column:"in_progress",work_id:N,claim_owner:E.owner,claim_started_at:E.started_at})}),_=new Map;p.forEach((x,N)=>{x.filename&&_.set(x.filename,N)});for(const[x,N]of c){const E=N.card?_.get(Qg(N.card)):void 0;if(h.has(x)||E!==void 0){if(E!==void 0){const M=p[E],O={...M,work_id:M.work_id||x,card_path:M.card_path||N.card},D=r.get(x);D!=null&&D.owner&&(d.add(x),O.claim_owner||(O.claim_owner=D.owner,O.claim_started_at=D.started_at)),p[E]=O}continue}if(N.status==="deprecated")continue;const I=r.get(x),C=N.status==="completed"?"done":N.status==="planned"?I!=null&&I.owner?"in_progress":"ready":"triage";I!=null&&I.owner&&d.add(x),p.push({key:`work:${x}`,column:C,title:N.title||x,work_id:x,package:(b=Hs(x))==null?void 0:b.package,summary:N.receipt,card_path:N.card,claim_owner:(I==null?void 0:I.owner)||(N.status==="completed"?N.owner:void 0),claim_started_at:I==null?void 0:I.started_at})}for(const[x,N]of r){if(d.has(x)||!N.owner)continue;const E=Hs(x);p.push({key:`claim:${x}`,column:"in_progress",title:typeof N.task=="string"&&N.task?N.task:x,work_id:E?x:void 0,package:E==null?void 0:E.package,claim_owner:N.owner,claim_started_at:N.started_at})}const y=new Set(p.filter(x=>x.column==="done").map(x=>x.work_id).filter(Boolean));for(const x of l.slice(0,lv)){if(y.has(x.item))continue;const N=Hs(x.item);p.push({key:`claim-done:${x.item}`,column:"done",title:x.item,work_id:N?x.item:void 0,package:N==null?void 0:N.package,claim_owner:x.owner,summary:x.receipt})}return p}function Si(a){const s=String((a==null?void 0:a.message)??a??"");return/backlog folder not available|backlog browsing not configured/i.test(s)}function Nf(a){return String((a==null?void 0:a.message)??a??"").trim().replace(/^[a-z_]+ failed: /,"")}function fd(a,s,r){const[l,c]=f.useState({status:null,legacy:!1});return f.useEffect(()=>{if(!s)return;let d=!1;return(async()=>{try{const h=await a.backlog_status();d||c({status:h,legacy:!1})}catch(h){d||c({status:null,legacy:Number(h==null?void 0:h.status)===404})}})(),()=>{d=!0}},[a,s,r]),l}function cv(){return e.jsxs(e.Fragment,{children:["Ask the gateway admin to set the backlog folder (gateway console → Apps → Backlog settings, or"," ",e.jsx("code",{className:"mono",children:"abstractgateway config set triage_repo_root PATH"})," on the gateway's computer)."]})}function hd(a){const{gateway:s,surface:r,status:l,legacy:c,on_changed:d}=a,[h,p]=f.useState(!1),[_,y]=f.useState(""),[b,x]=f.useState(!1),[N,E]=f.useState(""),[I,C]=f.useState((l==null?void 0:l.writable)??null);f.useEffect(()=>{if((l==null?void 0:l.writable)!==void 0){C(!!l.writable);return}if(!c)return;let F=!1;return s.admin_runtime_config().then(H=>{F||C((H==null?void 0:H.writable)===!0)}).catch(()=>{F||C(!1)}),()=>{F=!0}},[s,l==null?void 0:l.writable,c]);async function M(F){if(!b){x(!0),E("");try{await s.admin_runtime_config_update({triage_repo_root:F}),p(!1),d==null||d()}catch(H){E(Nf(H))}finally{x(!1)}}}const O=String((l==null?void 0:l.reason)||"").trim()||(a.error?Nf(a.error):""),D=String((l==null?void 0:l.default_path)||"").trim();return e.jsxs("div",{className:"pane setup_callout","data-testid":"backlog_unavailable",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"This gateway's backlog folder is not available"}),e.jsxs("span",{className:"chip mono warn",children:[r," has no data"]})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{style:{fontSize:"var(--font-size-md)"},children:[l!=null&&l.path?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"mono",children:l.path})," —"," "]}):null,O||"the gateway did not say why."]}),I===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[D?e.jsx("button",{className:"btn primary",disabled:b,onClick:()=>void M(D),title:D,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:b,onClick:()=>p(F=>!F),children:"Choose a folder…"})]}),D?e.jsxs("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["The gateway's own folder is ",e.jsx("code",{className:"mono",children:D}),"; it is created with a starter overview and item template."]}):null,h?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:F=>{F.preventDefault(),_.trim()&&M(_.trim())},children:[e.jsx("label",{htmlFor:"backlog_folder_path",children:"Folder on the gateway's computer that contains docs/backlog"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{id:"backlog_folder_path",className:"mono",value:_,onChange:F=>y(String(F.target.value||"")),placeholder:"/path/to/your/project",autoFocus:!0}),e.jsx("button",{className:"btn primary",type:"submit",disabled:b||!_.trim(),children:b?"Saving…":"Use this folder"})]})]}):null,N?e.jsx("div",{className:"page_error mono",role:"alert",style:{marginTop:"8px"},children:N}):null]}):I===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(cv,{})}):null]})]})}function uv(a){const{status:s,on_create:r}=a,[l,c]=f.useState(!1),d=String((s==null?void 0:s.path)||"").trim(),h=d?`${d.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",p=d?`${d.replace(/\/+$/,"")}/${(s==null?void 0:s.template_relpath)||"docs/backlog/template.md"}`:(s==null?void 0:s.template_relpath)||"docs/backlog/template.md";return e.jsxs("div",{className:"pane setup_callout","data-testid":"backlog_empty",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Your backlog is empty"}),s!=null&&s.is_default?e.jsx("span",{className:"chip mono muted",children:"the gateway's own folder"}):null]}),e.jsxs("div",{className:"pane_body",children:[d?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Backlog folder"}),e.jsx("code",{className:"mono",children:d}),e.jsx("button",{className:"btn",onClick:()=>{fn(d),c(!0)},children:l?"Copied":"Copy"})]}):null,e.jsxs("div",{className:"callout_text",style:{marginTop:"8px"},children:["Each item is a Markdown file: new ones land in ",e.jsx("code",{className:"mono",children:h})," (Triage), accepted ones move to"," ",e.jsx("code",{className:"mono",children:"planned/"})," (Ready). Start from the template ",e.jsx("code",{className:"mono",children:p}),", or let Continuum write it for you."]}),r?e.jsx("div",{className:"callout_actions",style:{marginTop:"10px"},children:e.jsx("button",{className:"btn primary",onClick:r,children:"Create your first item"})}):null]})]})}function dv(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function Th(a){const{gateway:s,can_use_gateway:r,target:l,on_close:c,on_mutated:d,on_open_executions:h}=a,p=!!l,[_,y]=f.useState("spec"),[b,x]=f.useState(""),[N,E]=f.useState(""),[I,C]=f.useState(null),[M,O]=f.useState(!1),[D,F]=f.useState(""),[H,$]=f.useState(!1),[ae,fe]=f.useState(""),[oe,Ne]=f.useState(!1),[Me,be]=f.useState(""),[ye,ue]=f.useState(""),[q,R]=f.useState(!1),[V,ne]=f.useState([]),[Y,me]=f.useState(!1),[A,w]=f.useState(null),[L,X]=f.useState(null),[ge,de]=f.useState(""),[P,je]=f.useState(!1),[Ae,Fe]=f.useState(""),[Ve,lt]=f.useState({}),pe=f.useMemo(()=>Ni(b),[b]);f.useEffect(()=>{if(!p||!l)return;const J=ve=>{ve.key!=="Escape"||ve.defaultPrevented||mv(ve.target)||H||document.querySelector(".modal_backdrop")||(ve.preventDefault(),c())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[p,l,c,H]),f.useEffect(()=>{!p||!l||(y(l.initial_tab||"spec"),$(!1),F(""),Fe(""),de(""),lt({}),Ee(!1),w(null),X(null),C(null),Ie(l),ke(l))},[p,l==null?void 0:l.filename,l==null?void 0:l.kind,l==null?void 0:l.request_id]);async function Ie(J){if(!J.filename){x(""),E("");return}O(!0);try{let ve=null,G=null;for(const Ge of dv(J))try{const ze=await s.backlog_content(Ge,J.filename);ve={kind:Ge,text:String((ze==null?void 0:ze.content)||"")};break}catch(ze){G=ze}if(!ve)throw G||new Error("Spec not found in any backlog kind");C(ve.kind),x(ve.text),E(await Qu(ve.text));const Se=Ni(ve.text);be(Se.priority||""),ue(Se.labels.join(", "))}catch(ve){F(String((ve==null?void 0:ve.message)||ve||"Failed to load the spec"))}finally{O(!1)}}async function ke(J){me(!0);try{const[ve,G]=await Promise.all([s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),Ge=[...Array.isArray(ve==null?void 0:ve.requests)?ve.requests:[],...Array.isArray(G==null?void 0:G.requests)?G.requests:[]].filter(Qe=>J.filename&&String(Qe.backlog_filename||"").trim()===J.filename||Qe.request_id===J.request_id);Ge.sort((Qe,ee)=>String(ee.created_at||"").localeCompare(String(Qe.created_at||""))),ne(Ge);const ze=Ge.find(Qe=>String(Qe.status||"").toLowerCase()==="awaiting_qa")||null;if(w(ze),ze)try{const Qe=await s.backlog_exec_request(ze.request_id);X((Qe==null?void 0:Qe.payload)??null)}catch{X(null)}}catch{ne([])}finally{me(!1)}}async function Z(){if(!l||oe)return;const J=I||l.kind;if(J){Ne(!0),F("");try{const ve=await s.backlog_update({kind:J,filename:l.filename,content:ae,expected_sha256:N||null}),G=ae.endsWith(`
61
- `)?ae:`${ae}
62
- `;x(G),E(String((ve==null?void 0:ve.sha256)||"")),$(!1),await d()}catch(ve){F(String((ve==null?void 0:ve.message)||ve||"Save failed"))}finally{Ne(!1)}}}async function K(){if(!l||q)return;const J=I||l.kind;if(J){R(!0),F("");try{const ve=Yu(b,{priority:Me||null,labels:dd(ye)}),G=await s.backlog_update({kind:J,filename:l.filename,content:ve,expected_sha256:N||null});x(ve.endsWith(`
63
- `)?ve:`${ve}
64
- `),E(String((G==null?void 0:G.sha256)||"")),await d()}catch(ve){F(String((ve==null?void 0:ve.message)||ve||"Metadata save failed"))}finally{R(!1)}}}const[xe,Ee]=f.useState(!1);async function De(J){if(!(!A||P)){if(J==="feedback"&&!ge.trim()){Fe("Feedback is required.");return}je(!0),Fe("");try{J==="feedback"?await s.backlog_exec_feedback({request_id:A.request_id,feedback:ge}):J==="promote"?await s.backlog_exec_promote({request_id:A.request_id,redeploy:!0}):await s.backlog_exec_deploy_uat({request_id:A.request_id}),de(""),Ee(!1),l&&await ke(l),await d()}catch(ve){Fe(String((ve==null?void 0:ve.message)||ve||"QA action failed"));try{const G=await s.backlog_exec_request(A.request_id);X((G==null?void 0:G.payload)??null)}catch{}}finally{je(!1)}}}if(!p||!l)return null;const te=pe.acceptance.filter((J,ve)=>!Ve[`${ve}:${J.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:J=>{J.target===J.currentTarget&&c()},children:e.jsxs("div",{className:"drawer_panel work_drawer",role:"dialog","aria-modal":"true","aria-label":l.title||"Work item",children:[e.jsxs("div",{className:"drawer_header",children:[e.jsxs("div",{className:"col",style:{gap:2,minWidth:0},children:[e.jsx("div",{className:"drawer_title",title:l.filename,children:l.title}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:[I||l.kind||"locating…",l.filename?` • ${l.filename}`:""]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[l.filename?e.jsx("button",{className:"btn",onClick:()=>fn(`docs/backlog/${I||l.kind||"planned"}/${l.filename}`),title:"Copy repo path",children:"Copy path"}):null,e.jsx("button",{className:"btn",onClick:c,children:"Close"})]})]}),e.jsxs("div",{className:"tab_bar work_drawer_tabs",children:[e.jsx("button",{className:`tab ${_==="spec"?"active":""}`,onClick:()=>y("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${_==="runs"?"active":""}`,onClick:()=>y("runs"),children:["Runs ",V.length?`(${V.length})`:""]}),e.jsxs("button",{className:`tab ${_==="review"?"active":""}`,onClick:()=>y("review"),children:["Review",A?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[D?e.jsx("div",{className:"mono board_error",children:D}):null,_==="spec"?e.jsxs(e.Fragment,{children:[l.has_live_request?e.jsx("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"An execution holds a queue-time snapshot of this spec — edits here will NOT reach the running agent; they apply to the next run (and QA iterations re-run from the snapshot plus your feedback)."}):null,l.filename?e.jsxs("div",{className:"work_meta_editor",children:[e.jsxs("select",{value:Me,onChange:J=>be(J.target.value),disabled:q,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),ql.map(J=>e.jsx("option",{value:J,children:Sh[J]},J))]}),e.jsx("input",{value:ye,onChange:J=>ue(J.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:q}),e.jsx("button",{className:"btn",onClick:()=>void K(),disabled:q||!r||M,children:q?"Saving…":"Save metadata"}),H?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>$(!1),disabled:oe,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Z(),disabled:oe,children:oe?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{fe(b),$(!0)},disabled:M,children:"Edit spec"})]}):null,M?e.jsx("div",{className:"mono muted",children:"Loading…"}):H?e.jsx("textarea",{className:"mono work_spec_editor",value:ae,onChange:J=>fe(J.target.value),rows:24}):b?e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"md_doc",text:b}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)",marginTop:"10px"},children:"Deep tooling (maintenance AI chat, attachments, advisor) lives on the Backlog page."})]}):e.jsx("div",{className:"mono muted",children:"No spec file for this card (batch execution). See Runs."})]}):null,_==="runs"?e.jsxs(e.Fragment,{children:[Y?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!Y&&!V.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,V.map(J=>{const ve=String(J.status||"").toLowerCase(),G=Fl(J);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Il(ve)}`,children:ve}),e.jsx("span",{className:"mono muted",children:ha(J.request_id,18)}),e.jsx("span",{className:"mono muted",children:J.created_at?new Date(J.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:G.run_ms!=null?`ran ${Ws(G.run_ms)}`:""}),J.target_agent?e.jsx("span",{className:"chip mono muted",children:J.target_agent}):null,ve==="running"||ve==="queued"||ve==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>h(J.request_id),children:ve==="awaiting_qa"?"View logs":"Follow live"}):null]},J.request_id)})]}):null,_==="review"?A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",style:{marginTop:0},children:"Definition of Done — acceptance criteria"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)",marginBottom:"6px"},children:"Criteria come from the current spec file; if the agent refined them inside the candidate, review against the candidate patch too. Ticks live in this drawer session only."}),pe.acceptance.length?e.jsx("div",{className:"work_dod_list",children:pe.acceptance.map((J,ve)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Ve[`${ve}:${J.text}`],onChange:G=>lt(Se=>({...Se,[`${ve}:${J.text}`]:G.target.checked}))}),e.jsx("span",{children:J.text})]},`dod:${ve}:${J.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const J=String((L==null?void 0:L.execution_mode)||"uat").toLowerCase(),ve=String((L==null?void 0:L.candidate_relpath)||"").trim(),G=L==null?void 0:L.promotion_report,Se=!!(G!=null&&G.blocked);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",gap:"10px",flexWrap:"wrap",marginTop:"8px"},children:[e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:["mode: ",J,ve?` • candidate: ${ve}`:""]}),e.jsx("button",{className:"btn",onClick:()=>h(A.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),Se?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((G==null?void 0:G.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),pe.acceptance.length&&te>0?e.jsxs("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[te," acceptance criteri",te===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:ge,onChange:J=>de(J.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:P}),Ae?e.jsx("div",{className:"mono board_error",children:Ae}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void De("deploy_uat"),disabled:P,children:"Restart UAT"}),xe?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void De("promote"),disabled:P,children:["Confirm: promote to prod",te>0?` (${te} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>Ee(!1),disabled:P,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>Ee(!0),disabled:P,children:pe.acceptance.length&&te>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void De("feedback"),disabled:P,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function mv(a){const s=a;return!s||typeof s.closest!="function"?!1:!!s.closest("input, textarea, select, [contenteditable=''], [contenteditable='true']")}function Mr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}async function fv(a){const s=[],r=[];for(const l of a){const c=String((l==null?void 0:l.name)||"").trim()||"attachment";r.push(c);try{const d=await l.text();s.push(`[attached file: ${c}]
65
-
66
- \`\`\`
67
- ${d}
68
- \`\`\``)}catch{s.push(`[attached file: ${c}] (unreadable in browser)`)}}return{picked:r,text:s.join(`
69
-
70
- `)}}function hv(a){const{gateway:s,can_use_gateway:r,is_compact_layout:l,maint_provider:c,maint_model:d,maint_reasoning:h,advisor_agent:p,focus_kind:_,focus_type:y}=a,[b,x]=f.useState(!1),[N,E]=f.useState([]),[I,C]=f.useState(""),[M,O]=f.useState(!1),[D,F]=f.useState(""),[H,$]=f.useState(!1),[ae,fe]=f.useState([]),oe=f.useRef(null),Ne=f.useRef(null),Me=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[be,ye]=f.useState(""),[ue,q]=f.useState("");f.useEffect(()=>{(async()=>{try{const L=await ud(Me);ye(L)}catch{ye("")}})()},[Me]);const R=f.useMemo(()=>{if(!r)return{};const L=String(be||"").trim(),X=Me;return{tts:async ge=>{if(!L)throw new Error("Voice store not available (missing run_id).");const de=await s.voice_tts(L,{text:ge,request_id:Mr()}),P=de==null?void 0:de.audio_artifact,je=P&&typeof P=="object"&&!Array.isArray(P)?String(P.$artifact||"").trim():"";if(!je)throw new Error("TTS failed: missing audio artifact");return await(await s.download_run_artifact_content(L,je)).arrayBuffer()},transcribe:async(ge,de)=>{if(!L)throw new Error("Voice input unavailable (missing run_id).");const P=String(de||ge.type||"").toLowerCase(),je=P.includes("mp4")?"m4a":P.includes("ogg")?"ogg":P.includes("wav")?"wav":"webm",Ae=new File([ge],`recording.${je}`,{type:P||"audio/webm"}),Fe=await s.attachments_upload(X,Ae,{filename:Ae.name,content_type:Ae.type}),Ve=await s.audio_transcribe(L,{audio_artifact:Fe,request_id:Mr()});return String((Ve==null?void 0:Ve.text)||"").trim()}}},[r,s,be,Me]),V=rh({...R,on_error:q,on_transcript:L=>{const X=String(L||"").trim();X&&(C(ge=>{const de=String(ge||"");return de.trim()?`${de.trimEnd()}
71
- ${X}`:X}),window.setTimeout(()=>{var ge;return(ge=oe.current)==null?void 0:ge.focus()},0))}});f.useEffect(()=>{if(!b)return;const L=X=>{X.key==="Escape"&&(w(),x(!1))};return window.addEventListener("keydown",L),setTimeout(()=>{var X;return(X=oe.current)==null?void 0:X.focus()},0),()=>window.removeEventListener("keydown",L)},[b]);async function ne(){if(M||!r)return;if(V.voice_ptt_busy){q("Wait for transcription to finish.");return}F(""),q("");const L=I.trim();if(!L)return;const X={id:Mr(),role:"user",content:L,ts:new Date().toISOString()},ge=[...N,X];E(ge),C(""),O(!0);try{const de=await s.backlog_advisor({messages:ge.map(Fe=>({role:Fe.role,content:Fe.content})),provider:c||null,model:d||null,thinking:h||null,agent:p||null,include_trace:H,focus_kind:_,focus_type:y}),P=H&&Array.isArray(de==null?void 0:de.tool_trace)?de.tool_trace:[],je=String((de==null?void 0:de.run_id)||"").trim(),Ae=String((de==null?void 0:de.reply)||"").trim();if(H&&P.length){const Fe={id:Mr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:je||null,tool_trace:P},null,2)};E(Ve=>[...Ve,Fe])}Ae&&E(Fe=>[...Fe,{id:Mr(),role:"assistant",content:Ae,ts:new Date().toISOString()}])}catch(de){F(String((de==null?void 0:de.message)||de||"Backlog advisor failed"))}finally{O(!1)}}async function Y(L){var P;const X=Array.from(L||[]);if(!X.length)return;const{picked:ge,text:de}=await fv(X);fe(je=>[...ge,...je].slice(0,12)),C(je=>{const Ae=String(je||"").trim();return Ae?`${Ae}
72
-
73
- ${de}`:de});try{(P=oe.current)==null||P.focus()}catch{}}function me(L){const X=String(L.id||L.ts||"").trim(),ge=String(L.content||"").trim();!X||!ge||(q(""),V.toggle_tts(X,ge))}function A(L){const X=String(L.id||L.ts||"").trim(),ge=V.tts_playback;return!X||!ge.key||ge.key!==X?"idle":ge.status}function w(){V.stop_voice_ptt_recording(),V.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${b?"open":""}`,onClick:()=>{x(L=>{const X=!L;return X||w(),X})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:e.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),b?e.jsx("div",{className:"drawer_backdrop",onMouseDown:L=>{L.target===L.currentTarget&&(w(),x(!1))},children:e.jsxs("div",{className:"drawer_panel",children:[e.jsxs("div",{className:"drawer_header",children:[e.jsxs("div",{className:"col",style:{gap:2},children:[e.jsx("div",{className:"drawer_title",children:"Backlog advisor"}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["Read-only. Agent: ",p||"basic-agent"," • Using: ",c||"(gateway default)"," / ",d||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${H?"primary":""}`,onClick:()=>$(L=>!L),disabled:M,title:H?"Hide tool execution":"Show tool execution","aria-label":H?"Hide tool execution":"Show tool execution",children:[e.jsx(et,{name:"terminal",size:16}),l?null:H?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>E([]),disabled:M||!N.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{w(),x(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(cd,{messages:N,className:"drawer_chat_thread",messageProps:V.tts_supported&&r&&be.trim()?{onSpeakToggle:me,getSpeakState:A,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Ask about the backlog, e.g. “What are the top 5 planned items to focus on next and why?”"})}),e.jsxs("div",{className:"drawer_footer",children:[e.jsx("input",{ref:Ne,type:"file",multiple:!0,style:{display:"none"},onChange:L=>{const X=Array.from(L.currentTarget.files||[]);L.currentTarget.value="",X.length&&Y(X)}}),e.jsx(ic,{ref:oe,value:I,onChange:C,onSubmit:()=>void ne(),placeholder:"Message to backlog advisor…",disabled:!r,busy:M||V.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:V.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${V.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!be.trim()||M||V.voice_ptt_busy||!V.voice_ptt_supported,title:V.voice_ptt_supported?V.voice_ptt_busy?"Transcribing…":V.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":"Voice recording is not supported in this browser","aria-label":"Voice input",onPointerDown:L=>{var X,ge;if(!(!r||!be.trim()||M||V.voice_ptt_busy||!V.voice_ptt_supported)){L.preventDefault();try{(ge=(X=L.currentTarget)==null?void 0:X.setPointerCapture)==null||ge.call(X,L.pointerId)}catch{}V.start_voice_ptt_recording()}},onPointerUp:L=>{L.preventDefault(),V.stop_voice_ptt_recording()},onPointerCancel:L=>{L.preventDefault(),V.stop_voice_ptt_recording()},children:[e.jsx(et,{name:V.voice_ptt_recording?"x":"mic",size:16}),l?null:V.voice_ptt_busy?"Transcribing…":V.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var L;return(L=Ne.current)==null?void 0:L.click()},disabled:M,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(et,{name:"paperclip",size:16}),l?null:"Attach"]})]})}),ae.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",ae[0]]}):null,D?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:D}):null,ue?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ue}):null,r?null:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Connect the gateway in Settings to use the advisor."})]})]})]})}):null]})}function Ya({open:a,title:s,children:r,actions:l,variant:c="default",onClose:d}){if(f.useEffect(()=>{if(!a)return;const p=_=>{_.key!=="Escape"||_.defaultPrevented||(_.preventDefault(),d())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a,d]),!a)return null;const h=c==="fullscreen";return e.jsx("div",{className:`modal_backdrop${h?" fullscreen":""}`,onMouseDown:p=>{p.target===p.currentTarget&&d()},children:e.jsxs("div",{className:`modal_panel${h?" fullscreen":""}`,role:"dialog","aria-modal":"true","aria-label":s,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:s}),e.jsx("button",{className:"btn",onClick:d,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),l?e.jsx("div",{className:"modal_footer",children:l}):null]})})}function pv(a){const{readiness:s,server_refused:r,on_open_spec:l}=a;return s?e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:["Definition of Ready"," ",e.jsx("span",{style:{opacity:.7},children:r?"(the gateway refused this execute — server-evaluated checks below)":"(advisory — parsed from the spec)"})]}),s.checks.map(c=>e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",color:c.ok?"rgb(74, 222, 128)":"rgb(250, 204, 21)"},children:[c.ok?"✓":"○"," ",c.label,c.evidence?e.jsxs("span",{style:{opacity:.75},children:[" — ",c.evidence]}):null]},c.id)),s.ok?null:e.jsxs("div",{className:"row",style:{alignItems:"center",gap:"10px",marginTop:"6px",flexWrap:"wrap"},children:[e.jsx("span",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)"},children:"This spec is not ready — executing anyway is an override."}),l?e.jsx("button",{className:"btn",type:"button",onClick:l,children:"Open spec to fix"}):null]})]}):e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)"},children:"Definition of Ready: NOT EVALUATED — the spec could not be scanned. The server gate still checks on execute."})})}function Ah(a){const{exec_cfg:s,with_setup:r}=a,l=["abstractgateway config set backlog_exec_runner on # or: Settings → Gateway administration → Enable","abstractgateway config set executor codex # canonical: codex | claude | cursor-agent | abstractcode"];return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:(s==null?void 0:s.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway — admins can enable it live from Settings → Gateway administration.":(s==null?void 0:s.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(s==null?void 0:s.codex_available)===!1?`The configured executor is not available on the gateway host (${String((s==null?void 0:s.codex_bin)||(s==null?void 0:s.executor)||"binary")} not found).`:"Backlog exec is not available on this gateway."}),s!=null&&s.runner_error?e.jsx("div",{className:"detail_hint",children:s.runner_error}):null,r?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsx("summary",{className:"muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:"Setup from the gateway's computer (terminal)"}),e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[e.jsx("pre",{className:"mono setup_callout_pre",style:{marginTop:0},children:l.join(`
74
- `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>fn(l.join(`
75
- `)),children:"Copy setup"})]})]}):null]})}function Rh(a){const{value:s,onChange:r,disabled:l,inplace_warning:c,uat_note:d}=a;return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution mode"}),e.jsxs("select",{className:"input",value:s,onChange:h=>r(h.target.value),disabled:l,style:{width:"100%"},children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),s==="inplace"?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:c}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:d})]})}const _v=["minimal","low","medium","high"];function Lh(a){const{executors:s,value:r,onChange:l,disabled:c}=a;if(!s||!s.length)return null;const d=s.find(h=>h.default);return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution agent"}),e.jsxs("select",{className:"input",value:r,onChange:h=>l(h.target.value),disabled:c,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",d?` (${d.display||d.id})`:""]}),s.map(h=>e.jsxs("option",{value:h.id,disabled:h.available===!1,children:[h.display||h.id,h.available===!1?" (unavailable on the gateway host)":""]},h.id))]})]})}function gv(a){const{exec_cfg:s,model:r,set_model:l,effort:c,set_effort:d,disabled:h}=a;return e.jsxs("details",{style:{marginTop:"8px"},open:!!(r||c),children:[e.jsx("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:"Assign a different agent (operator override)"}),e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap",marginTop:"8px"},children:[e.jsx("div",{className:"col",style:{minWidth:200},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Model"}),e.jsx("input",{value:r,onChange:p=>l(p.target.value),placeholder:String((s==null?void 0:s.codex_model)||"gateway default"),disabled:h})]})}),e.jsx("div",{className:"col",style:{minWidth:160},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Reasoning effort"}),e.jsxs("select",{value:c,onChange:p=>d(p.target.value),disabled:h,children:[e.jsx("option",{value:"",children:"gateway default"}),_v.map(p=>e.jsx("option",{value:p,children:p},p))]})]})})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"4px"},children:"Overrides validate against the gateway's model allowlist; a refusal is shown verbatim below."})]})}function Mh(a){const{open:s,target:r,execute_mode:l,set_execute_mode:c,action_loading:d,action_error:h,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:b,on_close:x}=a,N=a.readiness??null,E=a.show_readiness===!0,[I,C]=Wt.useState(""),[M,O]=Wt.useState(""),[D,F]=Wt.useState(""),H=(r==null?void 0:r.filename)||"";Wt.useEffect(()=>{C(""),O(""),F("")},[H]);const $=I.trim()||M||D?{executor:D||void 0,target_model:I.trim()||void 0,target_reasoning_effort:M||void 0}:void 0;return e.jsxs(Ya,{open:s,title:"Execute backlog item?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:d,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b($),disabled:d||_||!r||(p==null?void 0:p.can_execute)!==!0,children:d?"Executing…":E&&!N?"Execute (readiness unknown)":N&&!N.ok?"Execute anyway (override)":"Execute"})]}),children:[e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Target:"," ",e.jsx("span",{className:"mono",style:{fontWeight:700},children:r?r.title:"(unknown)"})]}),p?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Agent: ",String(p.executor||"executor"),p.codex_model?` · ${p.codex_model}`:"",p.codex_reasoning_effort?` (reasoning ${p.codex_reasoning_effort})`:""]}):null,e.jsx(Lh,{executors:a.executors??null,value:D,onChange:F,disabled:d}),e.jsx(gv,{exec_cfg:p,model:I,set_model:C,effort:M,set_effort:O,disabled:d}),E?e.jsx(pv,{readiness:N,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(Rh,{value:l,onChange:c,disabled:d,inplace_warning:"Warning: inplace runs directly in the prod workspace. Use only when you understand the risk.",uat_note:"The run will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."}),_?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!_&&(p==null?void 0:p.can_execute)!==!0?e.jsx(Ah,{exec_cfg:p,with_setup:!0}):null,y?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:y}):null,h?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:h}):null]})}function vv(a){const{open:s,batch_selected_items:r,batch_execute_mode:l,set_batch_execute_mode:c,batch_execute_loading:d,batch_execute_error:h,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:b,on_close:x}=a,[N,E]=Wt.useState("");return Wt.useEffect(()=>{s||E("")},[s]),e.jsxs(Ya,{open:s,title:"Execute batch (single context)?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:d,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b(N||void 0),disabled:d||_||r.length<2||(p==null?void 0:p.can_execute)!==!0,children:d?"Executing…":"Execute batch"})]}),children:[e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Items:"," ",e.jsx("span",{className:"mono",style:{fontWeight:700},children:r.length})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"This queues a single exec request whose prompt includes all selected backlog items (in order), so the agent keeps a shared growing context."}),e.jsx(Lh,{executors:a.executors??null,value:N,onChange:E,disabled:d}),e.jsx(Rh,{value:l,onChange:c,disabled:d,inplace_warning:"Warning: inplace runs directly in the prod workspace (for the entire batch). Use only when you understand the risk.",uat_note:"The batch will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."}),r.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:r.map(I=>e.jsxs("div",{children:["- docs/backlog/planned/",I.filename]},`batchitem:${I.filename}`))}):null,_?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!_&&(p==null?void 0:p.can_execute)!==!0?e.jsx(Ah,{exec_cfg:p}):null,y?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:y}):null,h?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:h}):null]})}function yv(a){const{open:s,batch_selected_items:r,merge_package:l,set_merge_package:c,merge_task_type:d,set_merge_task_type:h,merge_title:p,set_merge_title:_,merge_summary:y,set_merge_summary:b,merge_loading:x,merge_error:N,on_confirm:E,on_close:I}=a;return e.jsxs(Ya,{open:s,title:"Merge planned items into master backlog?",onClose:I,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:I,disabled:x,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:E,disabled:x||r.length<2||!p.trim()||!l.trim(),children:x?"Merging…":"Create master"})]}),children:[e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:l,onChange:C=>c(C.target.value),placeholder:"framework"})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:d,onChange:C=>h(C.target.value),children:Ja.map(C=>e.jsx("option",{value:C,children:C},C))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:p,onChange:C=>_(C.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:y,onChange:C=>b(C.target.value),rows:3})]}),r.length?e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Referenced backlog items:"}),e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:r.map(C=>e.jsxs("div",{children:["- docs/backlog/planned/",C.filename]},`mergeitem:${C.filename}`))})]}):null,N?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:N}):null]})}function pd(a){const s=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,l]=f.useState(s);return f.useEffect(()=>{var h;if(typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia(a),d=()=>l(c.matches);return d(),typeof c.addEventListener=="function"?c.addEventListener("change",d):(h=c.addListener)==null||h.call(c,d),()=>{var p;typeof c.removeEventListener=="function"?c.removeEventListener("change",d):(p=c.removeListener)==null||p.call(c,d)}},[a]),r}function zh(a,s){const[r,l]=f.useState(null);return f.useEffect(()=>{if(!s){l(null);return}let c=!1;return(async()=>{try{const d=await a.admin_executors(),h=Array.isArray(d)?d:Array.isArray(d==null?void 0:d.executors)?d.executors:[];c||l(h)}catch{c||l(null)}})(),()=>{c=!0}},[s]),r}function _d(a){const{gateway:s,can_use_gateway:r,kind:l,completed_view:c,is_exec_view:d,is_compact_layout:h,set_compact_pane:p,on_status_transfer:_}=a,[y,b]=f.useState(null),[x,N]=f.useState(!1),[E,I]=f.useState(""),[C,M]=f.useState([]),[O,D]=f.useState(!1),[F,H]=f.useState(""),[$,ae]=f.useState(null),[fe,oe]=f.useState(null),[Ne,Me]=f.useState(!1),[be,ye]=f.useState(""),[ue,q]=f.useState(""),[R,V]=f.useState(!1),[ne,Y]=f.useState(""),[me,A]=f.useState("events"),[w,L]=f.useState(""),[X,ge]=f.useState(!1),[de,P]=f.useState(""),[je,Ae]=f.useState(!1),[Fe,Ve]=f.useState(!0),lt=f.useRef(null),pe=f.useRef(!0),Ie=f.useRef(null),ke=f.useRef(!1),Z=f.useRef(!1),K=1e6,xe=f.useMemo(()=>me!=="events"?null:Fg(w),[w,me]),Ee=f.useMemo(()=>qg(xe),[xe]),De=Fl($);function te(){ae(null),oe(null),ye(""),L(""),P(""),Ae(!1),Ie.current=null}async function J(){if(!r)return null;if(x)return y;I(""),N(!0);try{const ee=await s.backlog_exec_config();return b(ee),ee}catch(ee){const U=String((ee==null?void 0:ee.message)||ee||"Failed to load backlog exec config");return I(U),b(null),null}finally{N(!1)}}async function ve(ee,U,se){if(Z.current)return C;Z.current=!0,se!=null&&se.background||D(!0);const le=ee||l;try{const Ue=Og(le,U||c),ut=await s.backlog_exec_requests({status:Ue,limit:200}),mt=Array.isArray(ut==null?void 0:ut.requests)?ut.requests:[];H(""),M(mt);const ot=String(($==null?void 0:$.status)||"").trim().toLowerCase(),dt=ot==="failed"||ot==="completed"||ot==="promoted";if(le==="processing"&&($!=null&&$.request_id)&&!dt&&!mt.some(bt=>bt.request_id===$.request_id))try{const bt=await s.backlog_exec_request($.request_id),Re=bt==null?void 0:bt.payload,rt=String((Re==null?void 0:Re.status)||"").trim().toLowerCase();(rt==="failed"||rt==="completed"||rt==="promoted")&&(_(rt),oe(Re),ae($l(Re,$.request_id)))}catch{}if($!=null&&$.request_id){const bt=mt.find(Re=>Re.request_id===$.request_id)||null;bt&&ae(bt)}return mt}catch(Ue){return H(String((Ue==null?void 0:Ue.message)||Ue||"Failed to load backlog exec requests")),[]}finally{Z.current=!1,se!=null&&se.background||D(!1)}}async function G(ee){if(r){ae(ee),h&&p("detail"),oe(null),ye(""),Me(!0),Y(""),q(""),L(""),P(""),Ae(!1),Ie.current=null;try{const U=await s.backlog_exec_request(ee.request_id);oe((U==null?void 0:U.payload)??null)}catch(U){ye(String((U==null?void 0:U.message)||U||"Failed to load request"))}finally{Me(!1)}}}async function Se(ee){if(!r)return;const U=String(($==null?void 0:$.request_id)||"").trim();if(!U||R)return;const se=String(ue||"");if(!se.trim()){Y("Feedback is required.");return}Y(""),V(!0);try{const le=await s.backlog_exec_feedback({request_id:U,feedback:se}),Ue=(le==null?void 0:le.payload)??null;oe(Ue),Ue&&ae($l(Ue,U)),q(""),await ee()}catch(le){Y(String((le==null?void 0:le.message)||le||"Failed to send feedback"))}finally{V(!1)}}async function Ge(ee){if(!r)return;const U=String(($==null?void 0:$.request_id)||"").trim();if(U&&!R){Y(""),V(!0);try{const se=await s.backlog_exec_promote({request_id:U,redeploy:!0}),le=(se==null?void 0:se.payload)??null;oe(le),le&&ae($l(le,U)),q(""),await ee()}catch(se){Y(String((se==null?void 0:se.message)||se||"Failed to promote to prod"));try{const le=await s.backlog_exec_request(U),Ue=(le==null?void 0:le.payload)??null;oe(Ue),Ue&&ae($l(Ue,U))}catch{}}finally{V(!1)}}}async function ze(ee){if(!r)return;const U=String(($==null?void 0:$.request_id)||"").trim();if(U&&!R){Y(""),V(!0);try{const se=await s.backlog_exec_deploy_uat({request_id:U}),le=(se==null?void 0:se.payload)??null;oe(le),le&&ae($l(le,U)),await ee()}catch(se){Y(String((se==null?void 0:se.message)||se||"Failed to deploy to UAT"))}finally{V(!1)}}}async function Qe(ee){if(!r)return;const U=String((ee==null?void 0:ee.request_id)||($==null?void 0:$.request_id)||"").trim();if(!U)return;const se=(ee==null?void 0:ee.name)||me,le=typeof(ee==null?void 0:ee.max_bytes)=="number"&&Number.isFinite(ee.max_bytes)?Number(ee.max_bytes):16e4;if(!ke.current){ke.current=!0,P(""),ge(!0);try{const Ue=`${U}::${String(se)}`,ut=Ie.current,mt=ut!==null&&ut.key===Ue,ot=await s.backlog_exec_log_tail({request_id:U,name:String(se),max_bytes:le,...mt?{after_bytes:ut.offset}:{}}),dt=typeof(ot==null?void 0:ot.next_offset)=="number"&&Number.isFinite(ot.next_offset),bt=String((ot==null?void 0:ot.content)||"");mt&&dt&&(ot==null?void 0:ot.reset)!==!0?(bt&&L(Re=>{let rt=Re+bt;if(rt.length>K){const vt=rt.length-K,zt=rt.indexOf(`
76
- `,vt);rt=zt>=0?rt.slice(zt+1):rt.slice(vt),Ae(!0)}return rt}),Ie.current={key:Ue,offset:Number(ot.next_offset)}):(L(bt),Ae(!!(ot!=null&&ot.truncated)),Ie.current=dt?{key:Ue,offset:Number(ot.next_offset)}:null)}catch(Ue){P(String((Ue==null?void 0:Ue.message)||Ue||"Failed to load logs"))}finally{ke.current=!1,ge(!1)}}}return f.useEffect(()=>{r&&d&&J()},[d,r]),f.useEffect(()=>{if(!r||!d)return;const U=setInterval(()=>{s.is_backing_off()||ve(l,void 0,{background:!0})},l==="processing"?2e3:5e3);return()=>clearInterval(U)},[l,c,r,d,$==null?void 0:$.request_id]),f.useEffect(()=>{r&&d&&$!=null&&$.request_id&&Qe({request_id:$.request_id,name:me})},[$==null?void 0:$.request_id,me,d,r]),f.useEffect(()=>{pe.current=!0},[$==null?void 0:$.request_id,me]),f.useEffect(()=>{if(!lt.current||!pe.current)return;const U=window.requestAnimationFrame(()=>{const se=lt.current;se&&(se.scrollTop=se.scrollHeight)});return()=>window.cancelAnimationFrame(U)},[w,me,$==null?void 0:$.request_id]),f.useEffect(()=>{if(!r||!d||!($!=null&&$.request_id))return;const ee=String($.status||"").trim().toLowerCase();if(ee==="completed"||ee==="promoted"||ee==="failed"||ee!=="running"&&Fe!==!0)return;const se=setInterval(()=>{s.is_backing_off()||Qe({request_id:$.request_id,name:me})},ee==="running"?1500:2500);return()=>clearInterval(se)},[$==null?void 0:$.request_id,$==null?void 0:$.status,me,d,r,Fe]),{exec_cfg:y,exec_cfg_loading:x,exec_cfg_error:E,exec_requests:C,exec_loading:O,exec_error:F,exec_selected:$,set_exec_selected:ae,exec_detail:fe,set_exec_detail:oe,exec_detail_loading:Ne,exec_detail_error:be,set_exec_detail_error:ye,exec_qa_feedback:ue,set_exec_qa_feedback:q,exec_qa_loading:R,exec_qa_error:ne,exec_log_name:me,set_exec_log_name:A,exec_log_text:w,exec_log_loading:X,exec_log_error:de,exec_log_truncated:je,exec_log_auto:Fe,set_exec_log_auto:Ve,exec_log_scroll_el_ref:lt,exec_log_follow_ref:pe,parsed_exec_events:xe,event_stats:Ee,time_stats:De,clear_exec_selection:te,load_exec_config:J,refresh_exec_list:ve,load_exec_request:G,exec_send_feedback:Se,exec_promote_to_prod:Ge,exec_deploy_uat_now:ze,load_exec_log_tail:Qe}}const Cf=[{id:"planned",label:"Planned"},{id:"proposed",label:"Proposed"},{id:"recurrent",label:"Recurrent"},{id:"completed",label:"Completed"},{id:"deprecated",label:"Deprecated"},{id:"trash",label:"Trash"}];function xv(a){var tn;const s=a.gateway,r=a.gateway_connected,l=String(a.maintenance_ai_provider||"").trim(),c=String(a.maintenance_ai_model||"").trim(),d=String(a.maintenance_ai_reasoning||"").trim(),h=String(a.backlog_advisor_agent||"").trim()||"basic-agent",p=a.default_execution_mode==="inplace"?"inplace":"uat",_=pd("(max-width: 767.98px)"),[y,b]=f.useState("planned"),[x,N]=f.useState([]),[E,I]=f.useState(!1),[C,M]=f.useState(""),[O,D]=f.useState(""),[F,H]=f.useState("all"),[$,ae]=f.useState(""),[fe,oe]=f.useState(new Set),Ne=f.useRef(0),[Me,be]=f.useState(null),[ye,ue]=f.useState([]),[q,R]=f.useState(null),[V,ne]=f.useState(p),[Y,me]=f.useState(!1),A=zh(s,r),[w,L]=f.useState(""),[X,ge]=f.useState(!1),[de,P]=f.useState(p),[je,Ae]=f.useState(!1),[Fe,Ve]=f.useState(""),[lt,pe]=f.useState(!1),[Ie,ke]=f.useState(!1),[Z,K]=f.useState("framework"),[xe,Ee]=f.useState("task"),[De,te]=f.useState(""),[J,ve]=f.useState(""),[G,Se]=f.useState(!1),[Ge,ze]=f.useState(""),Qe=_d({gateway:s,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:_,set_compact_pane:()=>{},on_status_transfer:()=>{}});async function ee(){if(!r)return;const _e=++Ne.current;I(!0),M("");try{const Ce=await s.backlog_list(y);if(_e!==Ne.current)return;N(Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[])}catch(Ce){if(_e!==Ne.current)return;N([]),M(String((Ce==null?void 0:Ce.message)||Ce||"Failed to load backlog"))}finally{_e===Ne.current&&I(!1)}if(y==="planned")try{const Ce=await s.backlog_exec_active_items();if(_e!==Ne.current)return;const Ye=new Set;for(const _t of Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[]){const ht=String((_t==null?void 0:_t.filename)||"").trim();ht&&Ye.add(ht)}oe(Ye)}catch{_e===Ne.current&&oe(new Set)}else oe(new Set)}f.useEffect(()=>{ue([]),ae(""),ee()},[y,r]),f.useEffect(()=>{ue(_e=>{const Ce=new Set(x.map(_t=>String(_t.filename||"").trim())),Ye=_e.filter(_t=>Ce.has(_t));return Ye.length===_e.length?_e:Ye})},[x]);const U=f.useMemo(()=>{const _e=O.trim().toLowerCase(),Ce=F.trim().toLowerCase();return x.filter(Ye=>{if(Ce&&Ce!=="all"&&Dl(Ye.task_type)!==Ce)return!1;if(!_e)return!0;const _t=Array.isArray(Ye.labels)?Ye.labels.join(" "):"";return`${Ye.item_id||""} ${Ye.package||""} ${Ye.title||""} ${Ye.task_type||""} ${Ye.summary||""} ${Ye.filename||""} ${_t} ${Ye.priority||""}`.toLowerCase().includes(_e)})},[x,O,F]),se=f.useMemo(()=>x.filter(_e=>ye.includes(String(_e.filename||"").trim())),[x,ye]),le=Si(C),[Ue,ut]=f.useState(0),mt=fd(s,r&&le,Ue);function ot(_e){be({filename:String(_e.filename||""),kind:y,title:_e.title||_e.filename,initial_tab:"spec"})}async function dt(_e,Ce){ae("");try{await s.backlog_move({from_kind:y,to_kind:Ce,filename:String(_e.filename||"")}),await ee()}catch(Ye){ae(String((Ye==null?void 0:Ye.message)||Ye||"Move failed"))}}async function bt(_e){const Ce=String(_e.filename||"").trim();if(!Ce)return;let Ye=null;try{const _t=await s.backlog_content("planned",Ce);Ye=md({task_type:_e.task_type},Ni(String((_t==null?void 0:_t.content)||"")))}catch{Ye=null}L(""),ne(p),R({filename:Ce,title:_e.title||Ce,readiness:Ye}),Qe.load_exec_config()}async function Re(_e){if(!(!q||Y)){me(!0),L("");try{const Ce=Qe.exec_cfg||await Qe.load_exec_config();if(!Ce||Ce.can_execute!==!0){L((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}const Ye=!!(q.readiness&&!q.readiness.ok);await s.backlog_execute({kind:"planned",filename:q.filename,execution_mode:V,executor:_e==null?void 0:_e.executor,target_model:_e==null?void 0:_e.target_model,target_reasoning_effort:_e==null?void 0:_e.target_reasoning_effort,dor:"check",override:Ye}),R(null),await ee()}catch(Ce){const Ye=Ju(Ce);Ye?(R(_t=>_t&&{..._t,readiness:Ye,server_refused:!0}),L("")):L(String((Ce==null?void 0:Ce.message)||Ce||"Execute failed"))}finally{me(!1)}}}async function rt(_e){if(!(je||se.length<2)){Ve(""),Ae(!0);try{const Ce=Qe.exec_cfg||await Qe.load_exec_config();if(!Ce||Ce.can_execute!==!0){Ve((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}await s.backlog_execute_batch({items:se.map(Ye=>({kind:"planned",filename:String(Ye.filename||"")})),execution_mode:de,executor:_e,dor:"check",override:lt}),ge(!1),ue([]),pe(!1),await ee()}catch(Ce){const Ye=Ju(Ce);if(Ye){const _t=Ye.checks.filter(ht=>!ht.ok);pe(!0),Ve(`Definition of Ready refused by the gateway:
77
- ${_t.map(ht=>`○ ${ht.label}${ht.evidence?` — ${ht.evidence}`:""}`).join(`
78
- `)}
79
- Execute batch again to override (recorded as dor_overridden).`)}else Ve(String((Ce==null?void 0:Ce.message)||Ce||"Execute batch failed"))}finally{Ae(!1)}}}async function vt(){if(G||se.length<2)return;const _e=De.trim();if(!_e){ze("Title is required.");return}ze(""),Se(!0);try{await s.backlog_merge({kind:"planned",items:se.map(Ce=>({kind:"planned",filename:String(Ce.filename||"")})),package:Z.trim()||"framework",task_type:xe,title:_e,summary:J.trim()||void 0}),ke(!1),ue([]),await ee()}catch(Ce){ze(String((Ce==null?void 0:Ce.message)||Ce||"Merge failed"))}finally{Se(!1)}}function zt(_e){const Ce=String(_e||"").trim();ue(Ye=>Ye.includes(Ce)?Ye.filter(_t=>_t!==Ce):[...Ye,Ce])}function wt(_e){if(y==="planned"){const Ce=fe.has(String(_e.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void bt(_e),disabled:!r||Ce,title:Ce?"A live execution request already exists for this item":void 0,children:Ce?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void dt(_e,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(_e,"trash"),disabled:!r,children:"Trash"})]})}return y==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void dt(_e,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void dt(_e,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(_e,"trash"),disabled:!r,children:"Trash"})]}):y==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void dt(_e,"trash"),disabled:!r,children:"Trash"}):y==="deprecated"||y==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void dt(_e,"proposed"),disabled:!r,children:"Restore"}):null}return e.jsxs("div",{className:"page page_pad backlog_page",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Backlog kinds",children:Cf.map(_e=>e.jsx("button",{"aria-pressed":y===_e.id,className:`seg_btn ${y===_e.id?"active":""}`,onClick:()=>b(_e.id),children:_e.label},_e.id))}),r?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection control (top right)."}),e.jsx("div",{className:"page_toolbar_spacer"}),e.jsxs("button",{className:`btn btn_icon ${E?"is_loading":""}`,onClick:()=>void ee(),disabled:!r||E,title:"Refresh","aria-label":"Refresh",children:[e.jsx(et,{name:"refresh",size:16}),E?"Refreshing":"Refresh"]})]}),le?e.jsx(hd,{gateway:s,surface:"the backlog archive",status:mt.status,legacy:mt.legacy,error:C,on_changed:()=>{ut(_e=>_e+1),ee()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:O,onChange:_e=>D(_e.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:F,onChange:_e=>H(_e.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Ja.map(_e=>e.jsx("option",{value:_e,children:_e},_e))]}),e.jsx("div",{className:"page_toolbar_spacer"}),y==="planned"&&ye.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[ye.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:ye.length<2,onClick:()=>{Ve(""),P(p),pe(!1),ge(!0),Qe.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:ye.length<2,onClick:()=>{const _e=se.map(Ce=>String(Ce.package||"").trim()).filter(Boolean);K(_e.length&&_e.every(Ce=>Ce===_e[0])?_e[0]:"framework"),Ee("task"),te(`Master backlog (${se.length} items)`),ve(""),ze(""),ke(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[U.length,"/",x.length]})]}),C&&!le?e.jsx("div",{className:"page_error mono",children:C}):null,$?e.jsx("div",{className:"page_error mono",children:$}):null,e.jsxs("div",{className:"pane backlog_table_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:(tn=Cf.find(_e=>_e.id===y))==null?void 0:tn.label}),e.jsxs("span",{className:"pane_count",children:[U.length," item",U.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:U.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[y==="planned"?e.jsx("th",{className:"backlog_table_sel col_sel"}):null,e.jsx("th",{className:"col_id",children:"#"}),e.jsx("th",{className:"col_type",children:"type"}),e.jsx("th",{className:"col_package",children:"package"}),e.jsx("th",{children:"title"}),e.jsx("th",{className:"col_priority",children:"priority"}),e.jsx("th",{className:"col_labels",children:"labels"}),y!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:U.map(_e=>{const Ce=String(_e.filename||"").trim(),Ye=Dl(_e.task_type),_t=Zu(_e)?Xu(_e.priority):null,ht=Array.isArray(_e.labels)?_e.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>ot(_e),children:[y==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:jt=>jt.stopPropagation(),children:e.jsx("label",{className:"backlog_sel_hit",children:e.jsx("input",{type:"checkbox",checked:ye.includes(Ce),onChange:()=>zt(Ce),"aria-label":`Select ${Ce}`})})}):null,e.jsx("td",{className:"mono muted col_id",children:_e.item_id||""}),e.jsx("td",{className:"col_type",children:Ye?e.jsx("span",{className:`chip mono ${bh(Ye)}`,title:wh(Ye),children:Ye}):null}),e.jsx("td",{className:"mono muted col_package",title:_e.package||"",children:_e.package||""}),e.jsx("td",{className:"backlog_table_title",title:Ce,children:_e.title||Ce}),e.jsx("td",{className:"col_priority",children:_t?e.jsx("span",{className:`chip mono board_prio_${_t.toLowerCase()}`,children:_t}):null}),e.jsxs("td",{className:"col_labels",title:ht.join(", "),children:[ht.slice(0,2).map(jt=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:jt},jt)),ht.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",ht.length-2]}):null]}),y!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:jt=>jt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:wt(_e)})}):null]},`${y}:${Ce}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:E?"Loading…":"No items."})})]})]}),e.jsx(Mh,{open:!!q,target:q?{kind:"planned",filename:q.filename,title:q.title}:null,execute_mode:V,set_execute_mode:ne,action_loading:Y,action_error:w,exec_cfg:Qe.exec_cfg,exec_cfg_loading:Qe.exec_cfg_loading,exec_cfg_error:Qe.exec_cfg_error,executors:A,readiness:(q==null?void 0:q.readiness)??null,server_refused:(q==null?void 0:q.server_refused)===!0,show_readiness:!0,on_open_spec:q?()=>{const _e=q;R(null),be({filename:_e.filename,kind:"planned",title:_e.title,initial_tab:"spec"})}:void 0,on_confirm:_e=>void Re(_e),on_close:()=>R(null)}),e.jsx(vv,{open:X,batch_selected_items:se,batch_execute_mode:de,set_batch_execute_mode:P,batch_execute_loading:je,batch_execute_error:Fe,executors:A,exec_cfg:Qe.exec_cfg,exec_cfg_loading:Qe.exec_cfg_loading,exec_cfg_error:Qe.exec_cfg_error,on_confirm:_e=>void rt(_e),on_close:()=>{ge(!1),Ve(""),pe(!1)}}),e.jsx(yv,{open:Ie,batch_selected_items:se,merge_package:Z,set_merge_package:K,merge_task_type:xe,set_merge_task_type:Ee,merge_title:De,set_merge_title:te,merge_summary:J,set_merge_summary:ve,merge_loading:G,merge_error:Ge,on_confirm:()=>void vt(),on_close:()=>{ke(!1),ze("")}}),e.jsx(Th,{gateway:s,can_use_gateway:r,target:Me,on_close:()=>be(null),on_mutated:async()=>{await ee()},on_open_executions:_e=>{var Ce;return(Ce=a.on_open_executions)==null?void 0:Ce.call(a,_e)}}),e.jsx(hv,{gateway:s,can_use_gateway:r,is_compact_layout:_,maint_provider:l,maint_model:c,maint_reasoning:d,advisor_agent:h,focus_kind:y,focus_type:F,voice_session_id:a.voice_session_id})]})}function bv(a){const{open:s,gateway:r,can_use_gateway:l,maint_provider:c,maint_model:d,maint_reasoning:h,on_close:p,on_created:_}=a,[y,b]=f.useState(""),[x,N]=f.useState(!1),[E,I]=f.useState(""),[C,M]=f.useState("proposed"),[O,D]=f.useState("feature"),[F,H]=f.useState("framework"),[$,ae]=f.useState(""),[fe,oe]=f.useState(""),[Ne,Me]=f.useState(""),[be,ye]=f.useState(""),[ue,q]=f.useState(""),[R,V]=f.useState(""),[ne,Y]=f.useState(!1),[me,A]=f.useState(""),[w,L]=f.useState(""),[X,ge]=f.useState(""),[de,P]=f.useState(""),[je,Ae]=f.useState(""),[Fe,Ve]=f.useState(""),[lt,pe]=f.useState(""),[Ie,ke]=f.useState(""),[Z,K]=f.useState(""),[xe,Ee]=f.useState(""),[De,te]=f.useState([]),[J,ve]=f.useState(!1),[G,Se]=f.useState(""),[Ge,ze]=f.useState([]),[Qe,ee]=f.useState(""),[U,se]=f.useState(!1);function le(){M("proposed"),D("feature"),H("framework"),ae(""),oe(""),Me(""),ye(""),q(""),V(""),Y(!1),A(""),L(""),ge(""),P(""),Ae(""),Ve(""),pe(""),ke(""),K(""),Ee(""),te([]),ve(!1),Se(""),ze([]),ee(""),se(!1)}function Ue(){p(),le()}async function ut(){const Re=String(y||"").trim();if(Re)return Re;if(x)return"";I(""),N(!0);try{const rt=await r.backlog_template(),vt=String((rt==null?void 0:rt.content)||"");return b(vt),vt}catch(rt){return I(String((rt==null?void 0:rt.message)||rt||"Failed to load backlog template")),""}finally{N(!1)}}async function mt(Re){if(!l)return;const rt=(Re==null?void 0:Re.force)===!0;if(!rt&&ue.trim())return;const vt=await ut();if(!vt.trim())return;const zt=String(F||"").trim().toLowerCase()||"{Package}",wt=Ku(),tn=Bg(vt,{package_name:zt,title:$,task_type:O,summary:fe,created_at:wt});q(_e=>rt||!String(_e||"").trim()?tn:_e)}f.useEffect(()=>{s&&l&&mt()},[s,l]);function ot(Re){if(ue.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const rt=String(F||"").trim().toLowerCase()||"{Package}",vt=Ku(),zt=Ug({package_name:rt,title:$,task_type:O,summary:fe,diagram:me,context:w,included:Va(X),excluded:Va(de),plan:Va(je),dependencies:Va(Fe),acceptance:Va(lt),tests_a:Va(Ie),tests_b:Va(Z),tests_c:Va(xe),created_at:vt,attachments:[]});q(zt)}async function dt(){var rt;if(ne)return;V(""),Y(!0),Se("");let Re="";try{const vt=String(F||"").trim().toLowerCase(),zt=dd(be),wt=!!(Ne||zt.length);let tn=ue||"";wt&&tn.trim()&&(tn=Yu(tn,{priority:Ne||null,labels:zt}));const _e=await r.backlog_create({kind:C,package:vt,title:$,task_type:O,summary:fe||null,content:tn||null}),Ce=String((_e==null?void 0:_e.kind)||"").trim(),Ye=String((_e==null?void 0:_e.filename)||"").trim();if(wt&&!tn.trim()&&Ce&&Ye)try{const ht=await r.backlog_content(Ce,Ye),jt=String((ht==null?void 0:ht.content)||""),st=await Qu(jt),Cn=Yu(jt,{priority:Ne||null,labels:zt});await r.backlog_update({kind:Ce,filename:Ye,content:Cn,expected_sha256:st||null})}catch(ht){Re=[Re,`metadata lines not written: ${String((ht==null?void 0:ht.message)||ht)}`].filter(Boolean).join("; ")}const _t=[...De||[]];if(Ce&&Ye&&_t.length){ve(!0);const ht=[];try{for(const jt of _t){const st=await r.backlog_upload_attachment({kind:Ce,filename:Ye,file:jt,overwrite:!1}),Cn=String(((rt=st==null?void 0:st.stored)==null?void 0:rt.relpath)||"").trim();Cn&&ht.push(Cn)}}catch(jt){Re=[Re,String((jt==null?void 0:jt.message)||jt||"Attachment upload failed")].filter(Boolean).join("; "),Se(Re)}finally{if(ht.length)try{const jt=await r.backlog_content(Ce,Ye),st=String((jt==null?void 0:jt.content)||""),Cn=await Qu(st),Cs=Wg(st,ht);await r.backlog_update({kind:Ce,filename:Ye,content:Cs,expected_sha256:Cn||null})}catch(jt){Re=[Re,`uploaded files not linked: ${String((jt==null?void 0:jt.message)||jt)}`].filter(Boolean).join("; ")}ve(!1)}}p(),le();try{await _(Ce,Ye,Re)}catch{}}catch(vt){V(String((vt==null?void 0:vt.message)||vt||"Create failed"))}finally{Y(!1)}}async function bt(){if(U)return;V("");const Re=Qe.trim();if(!Re)return;if(!$.trim()){V("Title is required before using AI assist.");return}const rt=String(F||"").trim().toLowerCase();if(!rt){V("Package is required before using AI assist.");return}const vt={id:Mr(),role:"user",content:Re,ts:new Date().toISOString()},zt=[...Ge,vt];ze(zt),ee(""),se(!0);try{const wt=await r.backlog_assist({kind:C,package:rt,title:$,summary:fe||null,draft_markdown:ue||null,messages:zt.map(Ce=>({role:Ce.role,content:Ce.content})),provider:c||null,model:d||null,thinking:h||null}),tn=String((wt==null?void 0:wt.reply)||"").trim(),_e=String((wt==null?void 0:wt.draft_markdown)||"").trim();tn&&ze(Ce=>[...Ce,{id:Mr(),role:"assistant",content:tn,ts:new Date().toISOString()}]),_e&&q(_e)}catch(wt){V(String((wt==null?void 0:wt.message)||wt||"AI assist failed"))}finally{se(!1)}}return e.jsxs(Ya,{open:s,title:"New backlog task",onClose:Ue,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:Ue,disabled:ne||U,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void dt(),disabled:ne||!$.trim()||!F.trim(),children:ne?"Creating…":"Create"})]}),children:[e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Kind (proposed → board Triage · planned → board Ready · recurrent → Backlog page)"}),e.jsxs("select",{value:C,onChange:Re=>M(Re.target.value),children:[e.jsx("option",{value:"proposed",children:"proposed"}),e.jsx("option",{value:"planned",children:"planned"}),e.jsx("option",{value:"recurrent",children:"recurrent"})]})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:O,onChange:Re=>D(Re.target.value),children:Ja.map(Re=>e.jsx("option",{value:Re,children:Re},Re))})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:F,onChange:Re=>H(Re.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:$,onChange:Re=>ae(Re.target.value),placeholder:"Short descriptive title"})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Priority"}),e.jsxs("select",{value:Ne,onChange:Re=>Me(Re.target.value),children:[e.jsx("option",{value:"",children:"unset"}),ql.map(Re=>e.jsx("option",{value:Re,children:Sh[Re]},Re))]})]})}),e.jsx("div",{className:"col",style:{minWidth:320},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Labels (comma-separated; sprints: sprint-29)"}),e.jsx("input",{value:be,onChange:Re=>ye(Re.target.value),placeholder:"ui, security, sprint-29",className:"mono"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:fe,onChange:Re=>oe(Re.target.value),rows:3,placeholder:"One paragraph summary"})]}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Guided fields (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to generate a structured draft without editing markdown directly. One item per line for list fields."}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs("details",{children:[e.jsx("summary",{className:"mono",style:{cursor:"pointer"},children:"Show guided fields"}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Diagram (ASCII)"}),e.jsx("textarea",{value:me,onChange:Re=>A(Re.target.value),rows:4,className:"mono",placeholder:"(optional) ascii diagram"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Context"}),e.jsx("textarea",{value:w,onChange:Re=>L(Re.target.value),rows:4,placeholder:"Why is this needed? Link to evidence (reports, discussions, etc.)."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Included (1 per line)"}),e.jsx("textarea",{value:X,onChange:Re=>ge(Re.target.value),rows:4,className:"mono",placeholder:"..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Excluded (1 per line)"}),e.jsx("textarea",{value:de,onChange:Re=>P(Re.target.value),rows:4,className:"mono",placeholder:"..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Implementation Plan (1 per line)"}),e.jsx("textarea",{value:je,onChange:Re=>Ae(Re.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Dependencies (1 per line)"}),e.jsx("textarea",{value:Fe,onChange:Re=>Ve(Re.target.value),rows:3,className:"mono",placeholder:"Related backlog items / ADRs / external libs…"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Acceptance Criteria (1 per line)"}),e.jsx("textarea",{value:lt,onChange:Re=>pe(Re.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level A (1 per line)"}),e.jsx("textarea",{value:Ie,onChange:Re=>ke(Re.target.value),rows:3,className:"mono",placeholder:"cd pkg && pytest -q ..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level B (1 per line)"}),e.jsx("textarea",{value:Z,onChange:Re=>K(Re.target.value),rows:3,className:"mono",placeholder:"run local gateway + manual verification..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level C (1 per line)"}),e.jsx("textarea",{value:xe,onChange:Re=>Ee(Re.target.value),rows:2,className:"mono",placeholder:"(optional / opt-in)"})]}),e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end"},children:e.jsx("button",{className:"btn",onClick:()=>ot(),disabled:ne||U,children:"Generate draft from guided fields"})})]})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Attachments (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Upload screenshots/diagrams to `docs/backlog/assets/<id>/` and link them under `## Related` after the task is created."}),e.jsx("div",{className:"field",style:{marginTop:"8px"},children:e.jsx("input",{type:"file",multiple:!0,onChange:Re=>{const rt=Array.from(Re.target.files||[]);rt.length&&(te(vt=>[...vt,...rt]),Re.currentTarget.value="")}})}),De.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:De.map((Re,rt)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Re.name," (",Math.round(Re.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>te(vt=>vt.filter((zt,wt)=>wt!==rt)),disabled:ne||J,children:"Remove"})]},`${Re.name}_${Re.size}_${rt}`))}):null,J?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,G?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:G}):null,e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Draft (Markdown)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Prefilled from `docs/backlog/template.md` (editable). AI assist can also refine the draft."}),x?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Loading template…"}):null,E?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:E}):null,e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{ue.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||mt({force:!0})},disabled:ne||U||x||!l,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:ue,onChange:Re=>q(Re.target.value),rows:10,className:"mono",placeholder:"(optional) full markdown draft"})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"AI Assist (chat)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to iteratively refine a backlog draft; assistant replies can also update the draft markdown."}),e.jsx(cd,{messages:Ge,className:"backlog_chat_thread_small",empty:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages yet."})}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx(ic,{value:Qe,onChange:ee,onSubmit:()=>void bt(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!l||!$.trim(),busy:U,rows:3,sendButtonClassName:"btn primary"})}),R?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:R}):null]})}class Ph extends Wt.Component{constructor(){super(...arguments);Rr(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,l){return l.error&&l.for_key!==void 0&&r.resetKey!==l.for_key?{error:null,for_key:r.resetKey}:l.for_key!==r.resetKey&&!l.error?{for_key:r.resetKey}:null}componentDidCatch(r,l){var c,d;try{(d=(c=this.props).onError)==null||d.call(c,r,l)}catch{}}render(){const{error:r}=this.state;if(r){const{fallback:l}=this.props;return typeof l=="function"?l(r):l}return this.props.children}}class gd{async _fetch(s,r,l){const c=await fetch(`api/hub${r}`,{...l,signal:(l==null?void 0:l.signal)??AbortSignal.timeout(2e4),headers:{...l!=null&&l.body?{"Content-Type":"application/json"}:{}}}),d=await c.text();let h=null;try{h=JSON.parse(d)}catch{}if(!c.ok){const p=h&&typeof h=="object"&&(h.detail||h.error)||d,_=new Error(`${s} failed: ${p}`);throw _.status=c.status,_}return h}async meta(){return await this._fetch("hub_meta","/meta")}async healthz(){return await this._fetch("hub_healthz","/healthz")}async ledger(s){return await this._fetch("hub_ledger",`/channels/${encodeURIComponent(s)}/ledger`)}async channel_info(s){return await this._fetch("hub_channel_info",`/channels/${encodeURIComponent(s)}/info`)}async digest(s){return await this._fetch("hub_digest",`/channels/${encodeURIComponent(s)}/digest`)}async fs_list(s,r=""){const l=r?`?prefix=${encodeURIComponent(r)}`:"",c=await this._fetch("hub_fs_list",`/channels/${encodeURIComponent(s)}/fs${l}`);return Array.isArray(c)?c:[]}async fs_read(s,r){const l=r.split("/").map(encodeURIComponent).join("/");return await this._fetch("hub_fs_read",`/channels/${encodeURIComponent(s)}/fs/${l}`)}async inbox(){const s=await this._fetch("hub_inbox","/inbox");return Array.isArray(s)?s:[]}async channels(){const s=await this._fetch("hub_channels","/channels");return Array.isArray(s)?s:[]}async messages(s,r){const l=new URLSearchParams;(r==null?void 0:r.since)!==void 0&&l.set("since",String(r.since)),r!=null&&r.limit&&l.set("limit",String(r.limit)),r!=null&&r.sort&&l.set("sort",r.sort);const c=await this._fetch("hub_messages",`/channels/${encodeURIComponent(s)}/messages?${l.toString()}`);return Array.isArray(c)?c:[]}async search(s){const r=new URLSearchParams;r.set("q",s.q);for(const l of s.channel??[])r.append("channel",l);return s.sender&&r.set("sender",s.sender),s.kind&&r.set("kind",s.kind),s.since!==void 0&&r.set("since",String(s.since)),s.until!==void 0&&r.set("until",String(s.until)),s.ref&&r.set("ref",s.ref),s.rated&&r.set("rated",s.rated),s.min_votes&&r.set("min_votes",String(s.min_votes)),s.sort&&r.set("sort",s.sort),s.limit&&r.set("limit",String(s.limit)),s.cursor&&r.set("cursor",s.cursor),await this._fetch("hub_search",`/search?${r.toString()}`)}async read_message(s,r){const l=await this._fetch("hub_read_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}`);return(Array.isArray(l)?l[0]:l)??null}async post_message(s,r){return await this._fetch("hub_post",`/channels/${encodeURIComponent(s)}/messages`,{method:"POST",body:JSON.stringify(r)})}async upload_attachment(s,r){const l=`api/hub/channels/${encodeURIComponent(s)}/attachments?filename=${encodeURIComponent(r.name)}`,c=await fetch(l,{method:"POST",headers:{"Content-Type":r.type||"application/octet-stream"},body:r,signal:AbortSignal.timeout(6e4)}),d=await c.text();let h=null;try{h=JSON.parse(d)}catch{}if(!c.ok){const p=h&&typeof h=="object"&&(h.detail||h.error)||d,_=new Error(`upload failed: ${p}`);throw _.status=c.status,_}if(!h||typeof h!="object"||!h.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return h}attachment_url(s,r){return`api/hub/channels/${encodeURIComponent(s)}/attachments/${encodeURIComponent(r)}`}async ack(s,r){return await this._fetch("hub_ack","/inbox/ack",{method:"POST",body:JSON.stringify({cursors:{[s]:r}})})}async members(s){const r=await this._fetch("hub_members",`/channels/${encodeURIComponent(s)}/members`);return Array.isArray(r)?r:[]}async create_channel(s,r){return await this._fetch("hub_create_channel","/channels",{method:"POST",body:JSON.stringify({name:s,private:r})})}async put_channel_meta(s,r,l){const c={value:r};return typeof l=="number"&&(c.expect_version=l),await this._fetch("hub_channel_meta_put",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent("channel:meta")}`,{method:"PUT",body:JSON.stringify(c)})}async channel_meta(s){return await this._fetch("hub_channel_meta",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent("channel:meta")}`)}async block(s,r,l){return await this._fetch("hub_block",`/channels/${encodeURIComponent(s)}/blocks`,{method:"POST",body:JSON.stringify({agent:r,seconds:l==null?void 0:l.seconds,reason:l==null?void 0:l.reason})})}async unblock(s,r){return await this._fetch("hub_unblock",`/channels/${encodeURIComponent(s)}/blocks/${encodeURIComponent(r)}`,{method:"DELETE"})}async hub_block(s,r){return await this._fetch("hub_hub_block","/hub/blocks",{method:"POST",body:JSON.stringify({agent:s,seconds:r==null?void 0:r.seconds,reason:r==null?void 0:r.reason})})}async hub_unblock(s){return await this._fetch("hub_hub_unblock",`/hub/blocks/${encodeURIComponent(s)}`,{method:"DELETE"})}async leave(s){return await this._fetch("hub_leave",`/channels/${encodeURIComponent(s)}/leave`,{method:"POST"})}async archive(s){return await this._fetch("hub_archive",`/channels/${encodeURIComponent(s)}/archive`,{method:"POST"})}async unarchive(s){return await this._fetch("hub_unarchive",`/channels/${encodeURIComponent(s)}/archive`,{method:"DELETE"})}async retire_agent(s,r){return await this._fetch("hub_retire",`/agents/${encodeURIComponent(s)}/retire`,{method:"POST",body:JSON.stringify(r?{reason:r}:{})})}async unretire_agent(s){return await this._fetch("hub_unretire",`/agents/${encodeURIComponent(s)}/retire`,{method:"DELETE"})}async retired_agents(){const s=await this._fetch("hub_retired","/agents/retired");return Array.isArray(s)?s:[]}async delete_agent(s){return await this._fetch("hub_delete_agent",`/agents/${encodeURIComponent(s)}`,{method:"DELETE"})}async list_blocks(s){const r=s?`?scope=${encodeURIComponent(s)}`:"",l=await this._fetch("hub_blocks",`/blocks${r}`);return Array.isArray(l)?l:[]}async send_dm(s,r){return await this._fetch("hub_send_dm",`/dms/${encodeURIComponent(s)}/messages`,{method:"POST",body:JSON.stringify({body:r.body,title:r.title||void 0,status:r.status||"open"})})}async store_keys(s){const r=await this._fetch("hub_store_keys",`/channels/${encodeURIComponent(s)}/store`);return Array.isArray(r)?r:[]}async store_get(s,r){return await this._fetch("hub_store_get",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent(r)}`)}async delegations(){const s=await this._fetch("hub_delegations","/delegations");return Array.isArray(s)?s:[]}async set_delegation(s,r,l){return await this._fetch("hub_set_delegation","/admin/delegation",{method:"PUT",body:JSON.stringify({agent_id:s,powers:r,ttl_seconds:(l==null?void 0:l.ttl_seconds)??null,note:(l==null?void 0:l.note)??""})})}async revoke_delegation(s){return await this._fetch("hub_revoke_delegation",`/admin/delegation/${encodeURIComponent(s)}`,{method:"DELETE"})}async retract_message(s,r){return await this._fetch("hub_retract",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/retract`,{method:"POST",body:JSON.stringify({})})}async desk(){const s=await this._fetch("hub_desk","/desk");return Array.isArray(s)?{rows:s,satisfied:[]}:{...s,rows:Array.isArray(s==null?void 0:s.rows)?s.rows:[],satisfied:Array.isArray(s==null?void 0:s.satisfied)?s.satisfied:[]}}async owed(){const s=await this._fetch("hub_owed","/owed"),r=s&&typeof s=="object"?s:{};return{...r,to_answer:Array.isArray(r.to_answer)?r.to_answer:[],to_consume:Array.isArray(r.to_consume)?r.to_consume:[],waiting_on:Array.isArray(r.waiting_on)?r.waiting_on:[]}}async create_group(s){return await this._fetch("hub_create_group","/groups",{method:"POST",body:JSON.stringify({name:s.name,members:s.members,purpose:s.purpose,opening_post:s.opening_post||s.purpose,private:s.private!==!1})})}async work_rows(s){const r=await this._fetch("hub_work_rows",`/channels/${encodeURIComponent(s)}/work`);return Array.isArray(r)?r:[]}async work(s){return await this._fetch("hub_work",`/work/${encodeURIComponent(s)}`)}async create_invite(s,r){const l=await this._fetch("hub_create_invite",`/channels/${encodeURIComponent(s)}/invites`,{method:"POST",body:JSON.stringify({agent_id:r})}),c=l&&typeof l=="object"?String(l.invite_token||""):"";if(!c)throw new Error("invite mint returned no token (unexpected hub response shape)");return c}async presence(){const s=await this._fetch("hub_presence","/presence");return Array.isArray(s)?s:[]}async reputation(s){return await this._fetch("hub_reputation",`/channels/${encodeURIComponent(s)}/reputation`)}async reputation_hub(){return await this._fetch("hub_reputation_hub","/reputation")}async reputation_votes(s,r){const l=await this._fetch("hub_reputation_votes",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}/votes`);return Array.isArray(l)?l:[]}async rate_message(s,r,l,c=""){const d={value:l,note:c};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(d)})}async unrate_message(s,r){return await this._fetch("hub_unrate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"DELETE"})}async rate(s,r,l,c,d=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:l,value:c,note:d})})}async _delete_reputation(s,r,l){return await this._fetch("hub_unrate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}?axis=${encodeURIComponent(l)}`,{method:"DELETE"})}ws_url(){const s=new URL("api/hub/ws",document.baseURI);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.href}}const wv=["commons"],jv=3e4,kv=5*6e4,$f={live:new Map,done:[],work:new Map},Ef=new Set(["proposed","planned","completed","deprecated"]);function Sv(a,s){const r=s&&typeof s=="object"?String(s.item||""):"";if(r&&Hs(r))return r;const l=a.startsWith("claim:")?a.slice(6):"";return l&&Hs(l)?l:null}function Nv(a){const[s,r]=f.useState($f),l=f.useRef(new gd),c=f.useRef(new Map),d=f.useRef(0),h=f.useRef(!1);return f.useEffect(()=>{let p=!0;const _=async()=>{if(!(h.current||Date.now()<d.current)){h.current=!0;try{const b=new Map,x=[],N=new Map;for(const E of wv){let I=!1;try{const M=await l.current.work_rows(E);for(const O of M){const D=String(O.id||O.item||""),F=String(O.status||"").toLowerCase();!Hs(D)||!Ef.has(F)||N.set(D,{item:D,title:typeof O.title=="string"?O.title:void 0,status:F,owner:typeof O.owner=="string"?O.owner:void 0,receipt:typeof O.receipt=="string"?O.receipt:void 0,card:typeof O.card=="string"?O.card:void 0,updated_at:O.updated_at})}I=!0}catch{}const C=await l.current.store_keys(E);for(const M of C){const O=String(M.key||"");if(O.startsWith("work:")){if(I)continue;const oe=O.slice(5);if(!Hs(oe))continue;const Ne=Number(M.version||0),Me=`${E}\0${O}`,be=c.current.get(Me);let ye;if(be&&be.version===Ne)ye=be.value;else{const q=await l.current.store_get(E,O);ye=q==null?void 0:q.value,c.current.set(Me,{version:Ne,value:ye})}const ue=ye&&typeof ye=="object"?String(ye.status||"").toLowerCase():"";if(!Ef.has(ue))continue;N.set(oe,{item:oe,title:typeof ye.title=="string"?ye.title:void 0,status:ue,owner:typeof ye.owner=="string"?ye.owner:void 0,receipt:typeof ye.receipt=="string"?ye.receipt:void 0,card:typeof ye.card=="string"?ye.card:void 0,updated_at:M.updated_at});continue}if(!O.startsWith("claim:"))continue;const D=Number(M.version||0),F=`${E}\0${O}`,H=c.current.get(F);let $;if(H&&H.version===D)$=H.value;else{const oe=await l.current.store_get(E,O);$=oe==null?void 0:oe.value,c.current.set(F,{version:D,value:$})}if(!$||typeof $!="object"||typeof $.owner!="string"||!$.owner)continue;const ae=Sv(O,$)||O.slice(6);if(!ae)continue;!!$.done||String($.status||"").toLowerCase()==="done"?x.push({item:ae,owner:$.owner,receipt:typeof $.receipt=="string"?$.receipt:void 0,updated_at:M.updated_at}):b.has(ae)||b.set(ae,$)}}x.sort((E,I)=>(I.updated_at||0)-(E.updated_at||0)),p&&r(E=>E.live.size===b.size&&[...b.keys()].every(C=>JSON.stringify(E.live.get(C))===JSON.stringify(b.get(C)))&&JSON.stringify(E.done)===JSON.stringify(x)&&E.work.size===N.size&&[...N.keys()].every(C=>JSON.stringify(E.work.get(C))===JSON.stringify(N.get(C)))?E:{live:b,done:x,work:N})}catch{d.current=Date.now()+kv,p&&r(b=>b.live.size||b.done.length||b.work.size?$f:b)}finally{h.current=!1}}};_();const y=setInterval(()=>void _(),jv);return()=>{p=!1,clearInterval(y)}},[a]),s}const Cv=40,$v=4;function Ev(a){const{gateway:s,can_use_gateway:r,data_nonce:l}=a,[c,d]=f.useState([]),[h,p]=f.useState(!1),[_,y]=f.useState(""),[b,x]=f.useState(""),[N,E]=f.useState(null),[I,C]=f.useState(null),[M,O]=f.useState({}),D=f.useRef({}),F=f.useRef(!1),H=f.useCallback(async oe=>{if(r&&!F.current){F.current=!0,oe!=null&&oe.background||p(!0);try{const[Ne,Me,be,ye,ue]=await Promise.allSettled([s.backlog_list("proposed"),s.backlog_list("planned"),s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:60}),s.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200})]),q=[],R=[],V=(je,Ae)=>je.status==="fulfilled"?je.value:(q.push(Ae),R.push(je.reason),null),ne=V(Ne,"proposed list"),Y=V(Me,"planned list"),me=V(be,"live requests"),A=V(ye,"recent history"),w=V(ue,"busy set");if(E(R.find(je=>Si(je))??null),!ne&&!Y&&!me&&!A){y("Failed to load the board (all sources failed)");return}y("");const L=Array.isArray(me==null?void 0:me.requests)?me.requests:[];let X=Array.isArray(w==null?void 0:w.items)?w.items:[];w||(X=L.map(je=>({request_id:String(je.request_id||""),status:String(je.status||""),kind:"planned",filename:String(je.backlog_filename||"").trim(),relpath:String(je.backlog_relpath||"").trim()})).filter(je=>je.filename&&!/^batch\(\d+\)$/i.test(je.filename)));const ge=Array.isArray(ne==null?void 0:ne.items)?ne.items:[],de=Array.isArray(Y==null?void 0:Y.items)?Y.items:[];C(ne&&Y?ge.length+de.length:null);const P=iv({proposed:ge,planned:de,active_requests:L,terminal_requests:Array.isArray(A==null?void 0:A.requests)?A.requests:[],active_items:X});d(P),x(q.length?`#FALLBACK partial board — failed: ${q.join(", ")}`:""),$(P,ge,de)}finally{F.current=!1,oe!=null&&oe.background||p(!1)}}},[s,r]);async function $(oe,Ne,Me){const be=new Map;for(const R of Ne)be.set(String(R.filename||"").trim(),"proposed");for(const R of Me)be.set(String(R.filename||"").trim(),"planned");const ye=oe.filter(R=>R.filename&&!D.current[R.filename]&&be.has(R.filename)).filter(R=>!Eh(R)||R.column==="ready").slice(0,Cv).map(R=>({filename:R.filename,kind:be.get(R.filename)}));if(!ye.length)return;const ue=[...ye],q=Array.from({length:Math.min($v,ue.length)},async()=>{for(;;){const R=ue.shift();if(!R)return;try{const V=await s.backlog_content(R.kind,R.filename),ne=Ni(String((V==null?void 0:V.content)||""));D.current={...D.current,[R.filename]:ne}}catch{}}});await Promise.all(q),O(D.current)}const ae=f.useCallback(async(oe,Ne)=>{try{const Me=await s.backlog_content(oe,Ne),be=Ni(String((Me==null?void 0:Me.content)||""));D.current={...D.current,[Ne]:be},O(D.current)}catch{}},[s]);return f.useEffect(()=>{H()},[H,l]),f.useEffect(()=>{if(!r)return;const oe=setInterval(()=>{s.is_backing_off()||H({background:!0})},1e4);return()=>clearInterval(oe)},[r,H,s]),{cards:c,loading:h,error:_,degraded:b,unconfigured:N!==null,unavailable:N,item_count:I,metadata:M,refresh:H,refresh_item_metadata:ae}}function Tf(a,s){return a.length<=s?a:`${a.slice(0,s-1).trimEnd()}…`}const Tv=new gd;function Av(a){if(!a)return"";const s=Math.max(0,Date.now()/1e3-a);return s<3600?`${Math.max(1,Math.round(s/60))}m`:s<172800?`${Math.round(s/3600)}h`:`${Math.round(s/86400)}d`}function Rv(a){const{card:s}=a,r=s.work_id||"",l=!!(r&&Hs(r)),[c,d]=f.useState({loading:l,error:"",claims:[],decisions:[],messages:[]});f.useEffect(()=>{let _=!0;if(l)return d(y=>({...y,loading:!0,error:""})),Tv.work(r).then(y=>{_&&d({loading:!1,error:"",claims:Array.isArray(y==null?void 0:y.claims)?y.claims:[],decisions:Array.isArray(y==null?void 0:y.decisions)?y.decisions:[],messages:(Array.isArray(y==null?void 0:y.messages)?y.messages:[]).slice().sort((b,x)=>(x.created_at||0)-(b.created_at||0))})}).catch(y=>{_&&d({loading:!1,error:String((y==null?void 0:y.message)||y||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{_=!1}},[r,l]);const h=c.messages[0],p=s.claim_started_at!==void 0&&s.claim_owner?kh({owner:s.claim_owner,started_at:s.claim_started_at},Date.now()):null;return e.jsx("div",{className:"modal_backdrop",onClick:a.on_close,children:e.jsxs("div",{className:"modal_panel board_claim_panel board_activity_panel",onClick:_=>_.stopPropagation(),children:[e.jsxs("div",{className:"modal_head",children:[e.jsx("span",{className:"modal_title",children:s.title}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]}),e.jsxs("div",{className:"board_claim_facts",children:[r?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"work id:"})," ",e.jsx("span",{className:"mono",children:r})]}):null,s.claim_owner?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:s.column==="done"?"completed by:":"held by:"})," ",s.claim_owner,p?e.jsxs("span",{className:"muted",children:[" · ",p.label]}):null]}):null,s.summary?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"receipt:"})," ",s.summary]}):null,s.card_path?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"item file:"})," ",e.jsx("span",{className:"mono",children:s.card_path}),e.jsxs("span",{className:"muted",children:[" (in ",s.package||"its own","'s repository)"]})]}):null]}),e.jsxs("div",{className:"board_activity_section",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Discussion & receipts ",c.loading?"· loading…":c.messages.length?`· ${c.messages.length} citing message(s)`:""]}),c.error?e.jsxs("div",{className:"muted team_note",children:["#FALLBACK hub activity unavailable (",c.error.slice(0,80),") — the Team thread button below still works."]}):null,!c.loading&&!c.error&&l&&!c.messages.length?e.jsx("div",{className:"muted team_note",children:"No citing messages on the hub yet."}):null,l?null:e.jsx("div",{className:"muted team_note",children:"This claim has no ruled work id — discussion lives in the coordination channel."}),c.messages.slice(0,8).map(_=>e.jsxs("div",{className:"board_activity_msg",children:[e.jsxs("div",{className:"board_activity_msg_head mono",children:[e.jsx("span",{children:_.sender}),e.jsxs("span",{className:"muted",children:[_.channel," #",_.seq," · ",Av(_.created_at)]}),a.on_open_team?e.jsx("button",{className:"team_row_expand",onClick:()=>a.on_open_team({channel:String(_.channel||""),message_id:String(_.id||""),seq:Number(_.seq)}),title:"Open this message in its Team channel",children:"open ↗"}):null]}),_.title?e.jsx("div",{className:"board_activity_msg_title",children:Tf(String(_.title),140)}):null,_.body?e.jsx("div",{className:"board_activity_msg_body muted",children:Tf(String(_.body),220)}):null]},_.id||_.seq))]}),e.jsx("div",{className:"entity_skills_actions",children:a.on_open_team?e.jsx("button",{className:"btn primary",onClick:()=>a.on_open_team(h?{channel:String(h.channel||"commons"),message_id:String(h.id||""),seq:Number(h.seq)}:{channel:"commons"}),title:h?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function Lv(a){var ve;const{gateway:s,gateway_connected:r,data_nonce:l,on_mutated:c,on_open_executions:d}=a,h=a.default_execution_mode==="inplace"?"inplace":"uat",p=pd("(max-width: 767.98px)"),_=zh(s,r),y=Ev({gateway:s,can_use_gateway:r,data_nonce:l}),[b,x]=f.useState(0),N=fd(s,r,l+b),E=y.unconfigured||((ve=N.status)==null?void 0:ve.available)===!1,I=!E&&y.item_count===0&&!y.error,C=Nv(!0),M=f.useMemo(()=>ov(y.cards,C),[y.cards,C]),O=_d({gateway:s,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:p,set_compact_pane:()=>{},on_status_transfer:()=>{}}),[D,F]=f.useState("");f.useEffect(()=>{var Se;if(!a.query_preset)return;const G=Hs(a.query_preset);F(G?G.num.padStart(4,"0"):a.query_preset),(Se=a.on_query_preset_consumed)==null||Se.call(a)},[a.query_preset]);const[H,$]=f.useState("all"),[ae,fe]=f.useState("all"),[oe,Ne]=f.useState(""),[Me,be]=f.useState(!1),[ye,ue]=f.useState(null),[q,R]=f.useState(null),[V,ne]=f.useState(null),[Y,me]=f.useState("uat"),[A,w]=f.useState(!1),[L,X]=f.useState(""),[ge,de]=f.useState(""),[P,je]=f.useState(null),Ae=f.useRef(null),Fe=M.some(G=>G.column==="in_progress"),[,Ve]=f.useState(0);f.useEffect(()=>{if(!Fe)return;const G=setInterval(()=>Ve(Se=>(Se+1)%3600),1e3);return()=>clearInterval(G)},[Fe]);const lt=f.useMemo(()=>{const G=new Set;for(const Se of M)Se.package&&G.add(Se.package);return[...G].sort()},[M]),pe=f.useMemo(()=>M.filter(G=>G.filename&&G.kind).length,[M]),Ie=f.useMemo(()=>M.filter(G=>G.filename&&G.kind&&(Eh(G)||y.metadata[G.filename])).length,[M,y.metadata]),ke=f.useMemo(()=>{const G=new Map;for(const Se of M)if(Se.filename)for(const Ge of td(Se,y.metadata[Se.filename]))G.set(Ge,(G.get(Ge)||0)+1);return[...G.entries()].sort((Se,Ge)=>Ge[1]-Se[1]).slice(0,12)},[M,y.metadata]),Z=f.useMemo(()=>{const G=D.trim().toLowerCase();return M.filter(Se=>{if(H!=="all"&&(Se.package||"")!==H||ae!=="all"&&String(Se.task_type||"").toLowerCase()!==ae)return!1;const Ge=Se.filename?y.metadata[Se.filename]:void 0,ze=td(Se,Ge);return oe&&!ze.includes(oe)||Me&&!ze.some(ee=>{const U=ee.toLowerCase();return U==="decision-gate"||U.startsWith("wave-")||U.startsWith("seat-")})?!1:G?`${Se.item_id||""} ${Se.title} ${Se.filename||""} ${Se.package||""} ${Se.summary||""} ${Se.exec_status||""} ${ze.join(" ")} ${ed(Se,Ge)||""}`.toLowerCase().includes(G):!0})},[M,y.metadata,D,H,ae,oe,Me]),K=f.useMemo(()=>{var Ge;const G=new Map;for(const ze of kf)G.set(ze.id,[]);for(const ze of Z)(Ge=G.get(ze.column))==null||Ge.push(ze);const Se=ze=>{const Qe=ze.filename?ed(ze,y.metadata[ze.filename]):null;return Qe?ql.indexOf(Qe):ql.length};for(const[ze,Qe]of G)(ze==="triage"||ze==="ready")&&Qe.sort((ee,U)=>Se(ee)-Se(U)||(U.item_id||0)-(ee.item_id||0));return G},[Z,y.metadata]);async function xe(G,Se){if(!(!G.filename||!G.kind||G.kind==="completed")&&G.kind!==Se){de("");try{await s.backlog_move({from_kind:G.kind,to_kind:Se,filename:G.filename}),await y.refresh(),c()}catch(Ge){de(String((Ge==null?void 0:Ge.message)||Ge||"Move failed"))}}}async function Ee(G){if(!G.filename)return;let Se=y.metadata[G.filename];if(!Se)try{const ze=await s.backlog_content("planned",G.filename);Se=Ni(String((ze==null?void 0:ze.content)||""))}catch{Se=void 0}const Ge=Se?md({task_type:G.task_type},Se):null;X(""),me(h),ne({filename:G.filename,title:G.title,readiness:Ge}),O.load_exec_config()}async function De(G){if(!(!V||A)){w(!0),X("");try{const Se=O.exec_cfg||await O.load_exec_config();if(!Se||Se.can_execute!==!0){X((Se==null?void 0:Se.runner_error)||"Backlog exec is not available on this gateway.");return}const Ge=!!(V.readiness&&!V.readiness.ok);await s.backlog_execute({kind:"planned",filename:V.filename,execution_mode:Y,executor:G==null?void 0:G.executor,target_model:G==null?void 0:G.target_model,target_reasoning_effort:G==null?void 0:G.target_reasoning_effort,dor:"check",override:Ge}),ne(null),await y.refresh(),c()}catch(Se){const Ge=Ju(Se);Ge?(ne(ze=>ze&&{...ze,readiness:Ge,server_refused:!0}),X("")):X(String((Se==null?void 0:Se.message)||Se||"Execute failed"))}finally{w(!1)}}}function te(G){if(!G.filename&&!G.request_id){const Se=Jg(G.card_path);if(Se&&r){s.backlog_content(Se.kind,Se.filename).then(()=>{ue({filename:Se.filename,kind:Se.kind,title:G.title,work_id:G.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>R(G));return}R(G);return}ue({filename:G.filename||"",kind:G.kind||null,request_id:G.request_id,title:G.title,work_id:G.work_id,has_live_request:G.column==="in_progress"||G.column==="in_review",initial_tab:G.column==="in_review"?"review":G.column==="in_progress"?"runs":"spec"})}const J={ready:"planned",triage:"proposed"};return e.jsxs("div",{className:"page board_page_root",children:[e.jsxs("div",{className:"board_toolbar",children:[e.jsx("input",{className:"board_search",value:D,onChange:G=>F(G.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:H,onChange:G=>$(G.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),lt.map(G=>e.jsx("option",{value:G,children:G},G))]}),e.jsxs("select",{value:ae,onChange:G=>fe(G.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Ja.map(G=>e.jsx("option",{value:G,children:G},G))]}),e.jsx("button",{className:`chip mono board_facet ${Me?"active":"muted"}`,onClick:()=>be(G=>!G),"aria-pressed":Me,title:"Room supervision: only operator decision gates + wave items (labels decision-gate / wave-* / seat-*)",children:"Supervision"}),e.jsx("div",{className:"board_toolbar_spacer"}),y.degraded&&!E?e.jsx("span",{className:"mono board_warn",title:y.degraded,children:"partial board"}):null,y.error&&!E?e.jsx("span",{className:"mono board_error",children:y.error}):null,ge?e.jsx("span",{className:"mono board_error",children:ge}):null,e.jsx("button",{className:`btn btn_icon ${y.loading?"is_loading":""}`,onClick:()=>void y.refresh(),disabled:!r||y.loading,children:y.loading?"Refreshing…":"Refresh"})]}),E?e.jsx(hd,{gateway:s,surface:"the board",status:N.status,legacy:N.legacy,error:y.unavailable,on_changed:()=>{x(G=>G+1),y.refresh()}}):null,I?e.jsx(uv,{status:N.status,on_create:a.on_new_task}):null,!E&&(ke.length||pe)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),ke.map(([G,Se])=>e.jsxs("button",{className:`chip mono board_facet ${oe===G?"active":"info"}`,onClick:()=>Ne(Ge=>Ge===G?"":G),title:`${Se} scanned card(s) carry ${G} — click to filter (sprints are labels: sprint-N)`,children:[G," ",e.jsx("span",{className:"muted",children:Se})]},G)),oe?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>Ne(""),children:"clear ✕"}):null,Ie<pe?e.jsxs("span",{className:"chip mono warn",title:"Label chips/filters cover only scanned cards — this gateway does not serve list-level metadata yet (#FALLBACK content scan; exact on gateways ≥ c1090)",children:["scanned ",Ie,"/",pe]}):null]}):null,e.jsx("div",{className:"board_columns",style:E?{display:"none"}:void 0,children:kf.map(G=>{const Se=K.get(G.id)||[],Ge=J[G.id];return e.jsxs("div",{className:`board_column board_column_${G.id} ${P===G.id?"drag_over":""}`,onDragOver:ze=>{!Ge||!Ae.current||(ze.preventDefault(),je(G.id))},onDragLeave:()=>je(ze=>ze===G.id?null:ze),onDrop:ze=>{ze.preventDefault(),je(null);const Qe=Ae.current;Ae.current=null,Qe&&Ge&&xe(Qe,Ge)},children:[e.jsxs("div",{className:"board_column_header",title:G.hint,children:[e.jsx("span",{className:"board_column_title",children:G.label}),e.jsx("span",{className:"board_column_count mono",children:Se.length})]}),e.jsxs("div",{className:"board_column_body",children:[Se.map(ze=>{const Qe=$h(ze,ze.filename?y.metadata[ze.filename]:void 0);return e.jsx(Mv,{card:ze,metadata:ze.filename?y.metadata[ze.filename]:void 0,draggable:!Qe&&!!(ze.kind&&ze.filename&&(ze.column==="triage"||ze.column==="ready")),on_drag_start:()=>{Ae.current=ze},on_drag_end:()=>{Ae.current=null,je(null)},on_open:()=>te(ze),on_promote:!Qe&&G.id==="triage"?()=>void xe(ze,"planned"):void 0,on_demote:!Qe&&G.id==="ready"?()=>void xe(ze,"proposed"):void 0,on_execute:!Qe&&G.id==="ready"?()=>void Ee(ze):void 0,on_follow:ze.exec_status==="running"||ze.exec_status==="queued"?()=>d(ze.request_id):void 0},ze.key)}),Se.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},G.id)})}),e.jsx(Mh,{open:!!V,target:V?{kind:"planned",filename:V.filename,title:V.title}:null,execute_mode:Y,set_execute_mode:me,action_loading:A,action_error:L,exec_cfg:O.exec_cfg,exec_cfg_loading:O.exec_cfg_loading,exec_cfg_error:O.exec_cfg_error,executors:_,readiness:(V==null?void 0:V.readiness)??null,server_refused:(V==null?void 0:V.server_refused)===!0,show_readiness:!0,on_open_spec:V?()=>{const G=V;ne(null),ue({filename:G.filename,kind:"planned",title:G.title,initial_tab:"spec"})}:void 0,on_confirm:G=>void De(G),on_close:()=>ne(null)}),e.jsx(Th,{gateway:s,can_use_gateway:r,target:ye,on_close:()=>ue(null),on_mutated:async()=>{ye!=null&&ye.filename&&(ye.kind==="proposed"||ye.kind==="planned")&&await y.refresh_item_metadata(ye.kind,ye.filename),await y.refresh(),c()},on_open_executions:d}),q?e.jsx(Rv,{card:q,on_close:()=>R(null),on_open_team:a.on_open_team}):null]})}function Mv(a){const{card:s,metadata:r,draggable:l,on_drag_start:c,on_drag_end:d,on_open:h,on_promote:p,on_demote:_,on_execute:y,on_follow:b}=a,x=ed(s,r),N=$h(s,r),E=!N&&r?md({task_type:s.task_type},r):null,I=Dl(s.task_type),C=s.exec_status==="running"&&s.started_at?Math.max(0,Date.now()-Date.parse(s.started_at)):null;return e.jsxs("div",{className:`board_card ${l?"draggable":""} ${N?"gate":""}`,onClick:h,role:"button",tabIndex:0,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),h())},draggable:l,onDragStart:l?c:void 0,onDragEnd:l?d:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[E?e.jsx("span",{className:`board_ready_dot ${E.ok?"ok":"warn"}`,title:E.ok?"Definition of Ready: satisfied":`Not ready: ${E.checks.filter(M=>!M.ok).map(M=>M.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:s.title})]}),e.jsxs("div",{className:"board_card_chips",children:[N?e.jsx("span",{className:"chip mono warn",title:"Operator decision gate — resolved by the operator's ruling, never assignable or executable (c1631)",children:"⛬ operator gate"}):null,s.item_id?e.jsxs("span",{className:"chip mono muted",children:["#",s.item_id]}):null,I&&!N?e.jsx("span",{className:`chip mono ${bh(I)}`,title:wh(I),children:I}):null,x?e.jsx("span",{className:`chip mono board_prio_${x.toLowerCase()}`,children:x}):null,s.package?e.jsx("span",{className:"chip mono muted",children:s.package}):null,s.batch_size?e.jsxs("span",{className:"chip mono info",children:[s.batch_size," items"]}):null,td(s,r).filter(M=>!N||M.toLowerCase()!=="decision-gate").slice(0,3).map(M=>e.jsx("span",{className:"chip mono info",children:M},M)),s.exec_status?e.jsx("span",{className:`chip mono ${s.exec_status==="failed"?"danger":s.exec_status==="awaiting_qa"?"warn":"info"}`,children:s.exec_status}):null,C!==null?e.jsx("span",{className:"chip mono info",children:Ws(C)}):null,s.recent_failures?e.jsxs("span",{className:"chip mono danger",title:`${s.recent_failures} recent failed attempt(s) — see the Failed lane`,children:["⚠ ",s.recent_failures]}):null,s.target_agent?e.jsx("span",{className:"chip mono muted",children:s.target_agent}):null,s.claim_owner?(()=>{const M=kh({owner:s.claim_owner,started_at:s.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${M!=null&&M.stale?"warn":"info"}`,title:`Live hub claim${s.work_id?` (claim:${s.work_id})`:""}${M!=null&&M.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",s.claim_owner,M?` · ${M.label.replace("claimed ","")}`:""]})})():null]}),p||_||y||b?e.jsxs("div",{className:"board_card_actions",onClick:M=>M.stopPropagation(),children:[p?e.jsx("button",{className:"btn",onClick:p,title:"Move to Ready (planned)",children:"→ Ready"}):null,y?e.jsx("button",{className:"btn primary",onClick:y,children:"Execute"}):null,_?e.jsx("button",{className:"btn",onClick:_,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,b?e.jsx("button",{className:"btn",onClick:b,children:"Follow live"}):null]}):null]})}function Lu(a,s){const r=String(a||"").replace(/\r/g,"").trim();if(!r)return"";const c=(r.split(`
80
- `,1)[0]||"").trim();return c.length<=s?c:`${c.slice(0,Math.max(0,s-1))}…`}function zv(a){const s=String(a||"").trim();if(s.length<2)return s;const r=s[0],l=s[s.length-1];return r==="'"&&l==="'"||r==='"'&&l==='"'?s.slice(1,-1):s}function Ih(a){const s=String(a||"").trim();if(!s)return"";const r=s.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?zv(String(r[1]||"").trim()):s}function Pv(a,s){const r=String(a||"").trim().toLowerCase();if(r==="error"||r==="turn.failed")return"error";if(r==="turn.completed"||r==="turn.succeeded"||r==="turn.success")return"ok";const l=s&&typeof s=="object"?s:null,c=l&&typeof l.item=="object"?l.item:null;if(c&&String(c.type||"").trim()==="command_execution"){const d=String(c.status||"").trim().toLowerCase();if(d==="failed")return"error";const h=c.exit_code,p=typeof h=="number"?h:Number.isFinite(Number(h))?Number(h):null;if(p!=null)return p===0?"ok":"error";if(d==="completed")return"ok"}return"info"}function Iv(a,s){var y;const r=s&&typeof s=="object"?s:{},l=r.item&&typeof r.item=="object"?r.item:null,c=l?String(l.type||"").trim():"",d=l?String(l.text||"").trim():"",h=l?String(l.command||"").trim():"",p=l&&Array.isArray(l.items)?l.items:[],_=String((r==null?void 0:r.message)||((y=r==null?void 0:r.error)==null?void 0:y.message)||"").trim();if(c==="command_execution"&&h)return Ih(h)||h;if(c==="todo_list"&&p.length>0){const b=p.length,x=p.filter(O=>(O&&O.completed)===!0).length,N=p.find(O=>(O&&O.completed)!==!0),E=String((N==null?void 0:N.text)||"").trim(),I=b>1?` (+${b-1})`:"",C=b>0?` (${x}/${b})`:"",M=E?`todo: ${E}${I}`:`todo list (${b})`;return Lu(`${M}${C}`,96)}return d?Lu(d,96)||d:_?Lu(_,96)||_:c||String(a||"").trim()||"event"}function Af(a){const s=new Date(a),r=l=>String(l).padStart(2,"0");return`${r(s.getHours())}:${r(s.getMinutes())}`}function Ov(a){var l,c,d;const s=a&&typeof a=="object"?a:{},r=[s.at,s.created_at,s.timestamp,s.time,s.ts,s.datetime,(l=s.item)==null?void 0:l.at,(c=s.item)==null?void 0:c.created_at,(d=s.item)==null?void 0:d.timestamp];for(const h of r)if(h!=null){if(typeof h=="number"&&Number.isFinite(h)){const p=h>1e11?h:h*1e3;return Af(p)}if(typeof h=="string"){const p=h.trim();if(!p)continue;const _=Date.parse(p.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(_))return Af(_)}}return null}function Dv(a){var M;const{exec_selected:s,exec_detail:r,is_compact_layout:l,exec_log_name:c,set_exec_log_name:d,exec_log_text:h,exec_log_loading:p,exec_log_error:_,exec_log_truncated:y,exec_log_auto:b,set_exec_log_auto:x,exec_log_scroll_el_ref:N,exec_log_follow_ref:E,parsed_exec_events:I,load_exec_log_tail:C}=a;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",marginTop:"8px"},children:[e.jsx("div",{className:"section_title",style:{marginTop:0},children:"Live logs"}),e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center",justifyContent:"flex-end",flexWrap:"wrap"},children:[e.jsxs("select",{value:c,onChange:O=>d(O.target.value),children:[e.jsx("option",{value:"events",children:"events"}),e.jsx("option",{value:"stderr",children:"stderr"}),e.jsx("option",{value:"last_message",children:"last message"})]}),e.jsx("button",{className:`btn ${b?"primary":""}`,onClick:()=>x(O=>!O),disabled:!(s!=null&&s.request_id),children:b?"Auto on":"Auto off"}),e.jsxs("button",{className:`btn btn_icon ${p?"is_loading":""}`,onClick:()=>C(),disabled:p||!(s!=null&&s.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(et,{name:"refresh",size:16}),l?null:p?"Loading…":"Refresh"]})]})]}),_?e.jsx("div",{className:"detail_warn",children:_}):null,!_&&y?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,c==="events"&&I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:O=>{E.current=xf(O.currentTarget,12)},children:I.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):I.events.map(O=>{var me;const D=O.payload,F=D&&typeof D.item=="object"?D.item:null,H=F?String(F.type||"").trim():"",$=F?String(F.id||"").trim():"",ae=D?String(D.thread_id||"").trim():"",fe=Pv(O.type,D),oe=fe==="error"?"danger":fe==="ok"?"ok":"info",Ne=Ov(D),Me=Iv(O.type,D),be=String((D==null?void 0:D.message)||((me=D==null?void 0:D.error)==null?void 0:me.message)||"").trim(),ye=F?String(F.text||"").trim():"",ue=F?String(F.command||"").trim():"",q=F?String(F.status||"").trim():"",R=F&&F.exit_code!=null?String(F.exit_code):"",V=F?String(F.aggregated_output||"").trim():"",ne=F&&Array.isArray(F.items)?F.items:[],Y=ue?Ih(ue)||ue:"";return e.jsxs("details",{className:`exec_event ${fe}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[Ne?e.jsx("span",{className:"exec_event_when mono muted",children:Ne}):null,Ne?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:Me,children:Me}),e.jsx("span",{className:`chip mono ${oe}`,children:H||O.type}),R?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",R]}):null]}),e.jsxs("div",{className:"exec_event_body",children:[e.jsxs("div",{className:"row exec_event_meta",children:[e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:O.type}),$?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:$}):null,ae?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",ha(ae,18)]}):null]}),be?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:be}):null,ne&&ne.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ne.map((A,w)=>e.jsxs("div",{children:[(A&&A.completed)===!0?"✓":"○"," ",String((A==null?void 0:A.text)||"").trim()]},`${O.idx}-todo-${w}`))}):null,ue?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",q?`(${q})`:""," ",R?`exit=${R}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Y})]}):null,V?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",V.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:V})]}):null,ye?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(ls,{className:"md_doc",text:ye})}):null]})]},`${O.idx}-${$}-${O.type}`)})}),e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["Raw JSONL",I.bad?` (${I.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px",maxHeight:"240px",overflow:"auto"},children:I.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:O=>{E.current=xf(O.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var D;if(String(h||"").trim())return h;if(c==="last_message"){const F=String(((D=r==null?void 0:r.result)==null?void 0:D.last_message)||s.last_message||"").trim();if(F)return F;const H=String(s.status||"").trim().toLowerCase();return H==="queued"||H==="running"?"(last message is written when the run finishes — use events for live output)":"(no last message yet)"}return c==="stderr"?"(no stderr yet)":"(no logs yet)"})()})}),(M=r==null?void 0:r.result)!=null&&M.logs?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Logs"}),e.jsxs("div",{className:"fact_grid",children:[r.result.logs.events_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"events"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.events_relpath})]}):null,r.result.logs.stderr_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"stderr"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.stderr_relpath})]}):null,r.result.logs.last_message_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"last message"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.last_message_relpath})]}):null]})]}):null]})}function Fv(a){const{pipeline:s,is_compact_layout:r,on_back_to_list:l,on_send_feedback:c,on_promote:d,on_deploy_uat:h}=a,p=s.exec_selected;if(!p)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:_,exec_detail_loading:y,exec_detail_error:b,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:E,exec_qa_error:I,event_stats:C,time_stats:M,exec_log_name:O}=s;return e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{style:{fontWeight:650,fontSize:"var(--font-size-md)"},children:p.backlog_filename||p.backlog_relpath||p.request_id}),(()=>{const D=String(p.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${Il(D)}`,children:D||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:ha(p.request_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[r?e.jsx("button",{className:"btn",onClick:l,disabled:y,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(p.request_id),disabled:y,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(et,{name:"copy",size:16}),r?null:"Copy request id"]}),p.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(p.backlog_relpath||""),disabled:y,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(et,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var H;const F=(Array.isArray((H=_==null?void 0:_.backlog_queue)==null?void 0:H.items)?_.backlog_queue.items:[]).map($=>String(($==null?void 0:$.relpath)||"").trim()).filter(Boolean);return F.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(F.join(`
81
- `)),disabled:y,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(et,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),p.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(p.run_dir_relpath||""),disabled:y,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(et,{name:"copy",size:16}),r?null:"Copy run dir"]}):null]})]}),e.jsxs("div",{className:"detail_hint",style:{marginTop:0},children:[p.created_at?`created ${new Date(p.created_at).toLocaleString()}`:"",p.started_at?` • started ${new Date(p.started_at).toLocaleString()}`:"",p.finished_at?` • finished ${new Date(p.finished_at).toLocaleString()}`:""]}),p.error?e.jsx("div",{className:"detail_warn",children:p.error}):null,b?e.jsx("div",{className:"detail_warn",children:b}):null,e.jsx("div",{style:{marginTop:"12px"},children:y?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(qv,{exec_selected:p,exec_detail:_,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:E,exec_qa_error:I,on_send_feedback:c,on_promote:d,on_deploy_uat:h}),e.jsx(Bv,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_title",children:"Execution"}),e.jsxs("div",{className:"fact_grid",children:[e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"status"}),e.jsx("span",{className:"fact_value",children:p.status||"unknown"})]}),p.executor_type?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"executor"}),e.jsx("span",{className:"fact_value",children:p.executor_type})]}):null,p.target_agent?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"target agent"}),e.jsx("span",{className:"fact_value",children:p.target_agent})]}):null,p.target_model?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"model"}),e.jsxs("span",{className:"fact_value",children:[p.target_model,p.target_reasoning_effort?` (reasoning ${p.target_reasoning_effort})`:""]})]}):null,p.exit_code!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"exit code"}),e.jsx("span",{className:"fact_value",children:String(p.exit_code)})]}):null,M.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Ws(M.age_ms)})]}):null,M.queue_delay_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"queue delay"}),e.jsx("span",{className:"fact_value",children:Ws(M.queue_delay_ms)})]}):null,M.run_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"run time"}),e.jsx("span",{className:"fact_value",children:Ws(M.run_ms)})]}):null,M.total_ms!=null&&M.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Ws(M.total_ms)})]}):null,C?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"commands"}),e.jsxs("span",{className:"fact_value",children:[C.command_count.toLocaleString(),C.command_fail_count?` (${C.command_fail_count.toLocaleString()} failed)`:""]})]}):null,e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"tokens"}),e.jsx("span",{className:"fact_value",children:C!=null&&C.has_tokens?e.jsxs(e.Fragment,{children:["in ",C.input_tokens.toLocaleString(),C.cached_input_tokens?` (cached ${C.cached_input_tokens.toLocaleString()})`:"",", out ",C.output_tokens.toLocaleString(),", total ",C.total_tokens.toLocaleString()]}):e.jsx("span",{className:"muted",children:O==="events"?"n/a":'select "events"'})})]}),p.run_dir_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"run dir"}),e.jsx("span",{className:"fact_value mono",children:p.run_dir_relpath})]}):null]}),e.jsx(Hv,{exec_detail:_}),e.jsx(Uv,{exec_detail:_,exec_qa_loading:E,status:String(p.status||"")}),e.jsx(Wv,{exec_detail:_}),e.jsx(Vv,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_divider"}),e.jsx(Dv,{exec_selected:p,exec_detail:_,is_compact_layout:r,exec_log_name:s.exec_log_name,set_exec_log_name:s.set_exec_log_name,exec_log_text:s.exec_log_text,exec_log_loading:s.exec_log_loading,exec_log_error:s.exec_log_error,exec_log_truncated:s.exec_log_truncated,exec_log_auto:s.exec_log_auto,set_exec_log_auto:D=>s.set_exec_log_auto(D),exec_log_scroll_el_ref:s.exec_log_scroll_el_ref,exec_log_follow_ref:s.exec_log_follow_ref,parsed_exec_events:s.parsed_exec_events,load_exec_log_tail:()=>void s.load_exec_log_tail()})]})})]})}function qv(a){const{exec_selected:s,exec_detail:r,exec_qa_feedback:l,set_exec_qa_feedback:c,exec_qa_loading:d,exec_qa_error:h,on_send_feedback:p,on_promote:_,on_deploy_uat:y}=a;if(String(s.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const x=String((r==null?void 0:r.execution_mode)||"").trim().toLowerCase()||"uat",N=String((r==null?void 0:r.candidate_relpath)||"").trim(),E=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),I=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),C=String((r==null?void 0:r.uat_current_relpath)||"").trim(),M=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),O=!!(r!=null&&r.uat_lock_acquired),D=!!(r!=null&&r.uat_pending),F=(r==null?void 0:r.uat_deploy)??null,H=String((r==null?void 0:r.uat_deploy_error)||"").trim(),$=r==null?void 0:r.attempt,ae=(r==null?void 0:r.promotion_report)??null,fe=!!(ae!=null&&ae.blocked),oe=String((ae==null?void 0:ae.reason)||"").trim(),Ne=Array.isArray(ae==null?void 0:ae.conflicts)?(ae==null?void 0:ae.conflicts).slice(0,8):[],Me=typeof(ae==null?void 0:ae.conflicts_total)=="number"?Number(ae.conflicts_total):Ne.length;let be="",ye="";const ue=[];try{const q=F==null?void 0:F.processes;if(q&&typeof q=="object"&&!Array.isArray(q)){typeof q.status=="string"&&(be=String(q.status||"").trim()),typeof q.reason=="string"&&(ye=String(q.reason||"").trim());for(const[R,V]of Object.entries(q)){if(!V||typeof V!="object"||Array.isArray(V))continue;const ne=V.probe;!ne||typeof ne!="object"||ne.ok===!1&&ue.push(String(R))}}}catch{}return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"QA decision"}),e.jsxs("div",{className:"fact_grid",children:[e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:x})]}),typeof $=="number"?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"attempt"}),e.jsx("span",{className:"fact_value",children:$})]}):null,x==="uat"&&M?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[ha(M,18),O?" (owned)":D?" (pending)":""]})]}):null,N?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"candidate"}),e.jsx("span",{className:"fact_value mono",children:N})]}):null,I?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:I})]}):null,E?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:E})]}):null,C?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"uat current"}),e.jsx("span",{className:"fact_value mono",children:C})]}):null]}),x==="inplace"?e.jsx("div",{className:"detail_warn",children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):x==="uat"&&D&&M&&!O?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",ha(M,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):x==="uat"&&O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"detail_hint",children:["UAT URLs: gateway ",e.jsx("code",{children:"http://localhost:6081"}),", observer ",e.jsx("code",{children:"http://localhost:6082"}),", code ",e.jsx("code",{children:"http://localhost:6083"}),", flow"," ",e.jsx("code",{children:"http://localhost:6084"})]}),e.jsx("div",{className:"detail_hint",children:"UAT is intentionally short-lived: promoting or iterating will stop the shared UAT services."}),ue.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",ue.slice(0,4).join(", "),ue.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,x==="uat"&&be==="skipped"&&ye==="process_manager_disabled"?e.jsxs("div",{className:"detail_warn",children:["UAT services were not started: the process manager is off. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("code",{children:"abstractgateway config set process_manager on"}),")."]}):null,H?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",H]}):null,fe&&oe==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",Me," conflict",Me===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",Ne.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:Ne.map((q,R)=>e.jsxs("li",{children:[String((q==null?void 0:q.repo)||""),"/",String((q==null?void 0:q.path)||"")," (",String((q==null?void 0:q.reason)||"conflict"),")"]},`c:${R}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[E?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(E),disabled:d,children:[e.jsx(et,{name:"copy",size:16}),"Copy patch path"]}):null,I?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(I),disabled:d,children:[e.jsx(et,{name:"copy",size:16}),"Copy manifest path"]}):null,N?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(N),disabled:d,children:[e.jsx(et,{name:"copy",size:16}),"Copy candidate path"]}):null]}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("textarea",{value:l,onChange:q=>c(q.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:d})}),h?e.jsx("div",{className:"detail_warn",children:h}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[x==="uat"?e.jsx("button",{className:"btn",onClick:y,disabled:d,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:_,disabled:d,children:x==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:p,disabled:d,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function Bv(a){const{exec_selected:s,exec_detail:r}=a;if(String(s.status||"").trim().toLowerCase()!=="promoted")return null;const c=String((r==null?void 0:r.promoted_at)||"").trim(),d=(r==null?void 0:r.promotion)??null,h=(r==null?void 0:r.promotion_report)??null,p=typeof(d==null?void 0:d.copied)=="number"?Number(d==null?void 0:d.copied):null,_=typeof(d==null?void 0:d.deleted)=="number"?Number(d==null?void 0:d.deleted):null,y=String((d==null?void 0:d.manifest_sha256)||"").trim(),b=String((d==null?void 0:d.mode)||"").trim(),x=(h==null?void 0:h.redeploy)??null,N=String((x==null?void 0:x.status)||"").trim(),E=String((x==null?void 0:x.reason)||"").trim(),I=String((h==null?void 0:h.redeploy_error)||"").trim();return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[c?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"promoted at"}),e.jsx("span",{className:"fact_value",children:new Date(c).toLocaleString()})]}):null,b?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:b})]}):null,y?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[y.slice(0,16),"…"]})]}):null,p!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[p," files"]})]}):null,_!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[_," files"]})]}):null,N?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsxs("span",{className:"fact_value",children:[N,E?` (${E})`:""]})]}):null,I?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"redeploy error"}),e.jsx("span",{className:"fact_value",style:{color:"var(--danger, rgb(248, 113, 113))"},children:I})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function Uv(a){const{exec_detail:s,exec_qa_loading:r}=a;if(String(a.status||"").trim().toLowerCase()==="promoted")return null;const l=s&&typeof s.promotion=="object"?s.promotion:null;if(!l)return null;const c=s&&typeof s.promotion_report=="object"?s.promotion_report:null,d=String((l==null?void 0:l.mode)||"").trim(),h=(l==null?void 0:l.copied)!=null?String(l.copied):"",p=(l==null?void 0:l.deleted)!=null?String(l.deleted):"",_=String((l==null?void 0:l.manifest_sha256)||"").trim(),y=c&&typeof c.redeploy=="object"?c.redeploy:null,b=y?String(y.status||"").trim():"";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[d?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:d})]}):null,h?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[h," files"]})]}):null,p?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[p," files"]})]}):null,_?e.jsxs("div",{className:"fact fact_wide",children:[e.jsxs("span",{className:"fact_label",children:["manifest sha256"," ",e.jsx("button",{className:"chip_icon_btn",onClick:()=>fn(_),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(et,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[_.slice(0,16),"…"]})]}):null,b?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsx("span",{className:"fact_value",children:b})]}):null]})]})}function Wv(a){var l,c;const r=(Array.isArray((c=(l=a.exec_detail)==null?void 0:l.backlog_queue)==null?void 0:c.items)?a.exec_detail.backlog_queue.items:[]).map(d=>String((d==null?void 0:d.relpath)||"").trim()).filter(Boolean);return r.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Backlog queue"}),e.jsx("div",{className:"path_list mono",children:r.map(d=>e.jsx("div",{children:d},`bq:${d}`))})]}):null}function Hv(a){var _,y,b;const s=((_=a.exec_detail)==null?void 0:_.skills)||((b=(y=a.exec_detail)==null?void 0:y.payload)==null?void 0:b.skills);if(!s||typeof s!="object")return null;const r=Array.isArray(s.requested)?s.requested:[],l=Array.isArray(s.active)?s.active:[],c=s.resolved_tree_hashes&&typeof s.resolved_tree_hashes=="object"?s.resolved_tree_hashes:{},d=Array.isArray(s.verdicts)?s.verdicts:[];if(!r.length&&!l.length&&!d.length)return null;const h=new Set(l.map(x=>String(x))),p=d.filter(x=>{const N=String((x==null?void 0:x.status)||(x==null?void 0:x.state)||"").toLowerCase();return N&&N!=="active"});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Skills"}),s.source?e.jsx("div",{className:"fact_grid",children:e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"source"}),e.jsx("span",{className:"fact_value",children:String(s.source)})]})}):null,e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:r.map(x=>{const N=h.has(String(x)),E=c[String(x)];return e.jsxs("span",{className:`chip mono ${N?"ok":"warn"}`,title:N?E?`active · ${String(E).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[x,N?"":" (held)"]},`skill:${x}`)})}),p.map((x,N)=>{const E=String((x==null?void 0:x.name)||(x==null?void 0:x.skill)||"skill"),I=String((x==null?void 0:x.reason)||(x==null?void 0:x.detail)||(x==null?void 0:x.status)||"held");return e.jsxs("div",{className:"detail_warn",children:[E,": ",I]},`verdict:${N}:${E}`)})]})}function Vv(a){var r,l;const s=String(((l=(r=a.exec_detail)==null?void 0:r.result)==null?void 0:l.last_message)||a.exec_selected.last_message||"").trim();return s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Last message"}),e.jsx("div",{className:"detail_prose",children:e.jsx(ls,{className:"md_doc",text:s})})]}):null}const Gv=10;function Kv(a){const{gateway:s,gateway_connected:r}=a,l=pd("(max-width: 767.98px)"),[c,d]=f.useState("list"),[h,p]=f.useState(null);async function _(){try{const R=await s.admin_executors(),V=Array.isArray(R)?R:Array.isArray(R==null?void 0:R.executors)?R.executors:[];p(V)}catch{p(null)}}f.useEffect(()=>{if(!r){p(null);return}_()},[s,r]);const y=_d({gateway:s,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:l,set_compact_pane:d,on_status_transfer:()=>{I()}}),[b,x]=f.useState([]),[N,E]=f.useState("");async function I(){if(r)try{const R=await s.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),V=Array.isArray(R==null?void 0:R.requests)?R.requests:[];V.sort((ne,Y)=>{const me=String(ne.finished_at||ne.started_at||ne.created_at||"");return String(Y.finished_at||Y.started_at||Y.created_at||"").localeCompare(me)}),x(V.slice(0,Gv)),E("")}catch(R){E(String((R==null?void 0:R.message)||R||"Failed to load recent executions"))}}f.useEffect(()=>{if(!r)return;(async()=>{var Y;const V=await y.refresh_exec_list("processing");await I();const ne=String(a.focus_request_id||"").trim();if(ne){const me=V.find(A=>A.request_id===ne);if(me)await y.load_exec_request(me);else try{const A=await s.backlog_exec_request(ne);A!=null&&A.payload&&await y.load_exec_request({request_id:ne,status:String(A.payload.status||"unknown")})}catch{}(Y=a.on_focus_consumed)==null||Y.call(a)}})();const R=setInterval(()=>{s.is_backing_off()||I()},15e3);return()=>clearInterval(R)},[r,a.focus_request_id]);const C=y.exec_requests.some(R=>String(R.status||"").toLowerCase()==="running"),[,M]=f.useState(0);f.useEffect(()=>{if(!C)return;const R=setInterval(()=>M(V=>(V+1)%3600),1e3);return()=>clearInterval(R)},[C]);const O=y.exec_requests,D=f.useMemo(()=>{let R=0,V=0,ne=0;for(const Y of O){const me=String(Y.status||"").trim().toLowerCase();me==="queued"?R+=1:me==="running"?V+=1:me==="awaiting_qa"&&(ne+=1)}return{queued:R,running:V,awaiting:ne}},[O]),F=y.exec_cfg,H=!!(F!=null&&F.runner_alive),$=String((F==null?void 0:F.executor)||"").trim(),ae=!$||$==="none",fe=ae?"execution agent":$,oe=!!(F!=null&&F.can_execute),Ne=Si(y.exec_error)||Si(N),[Me,be]=f.useState(0),ye=fd(s,r&&Ne,Me),ue=!l||c==="list",q=!l||c==="detail";return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&F?e.jsxs("span",{className:`chip mono ${oe?"ok":"warn"}`,title:F.codex_model?`${fe}: ${F.codex_model}${F.codex_reasoning_effort?` (reasoning ${F.codex_reasoning_effort})`:""}`:void 0,children:[ae?"no execution agent":`${fe} worker ${H?"on":"off"}`,!l&&F.codex_model?` · ${F.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!Ne&&y.exec_error?e.jsx("span",{className:"page_error mono",children:y.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${y.exec_loading?"is_loading":""}`,onClick:()=>{y.refresh_exec_list("processing"),I(),y.load_exec_config(),_()},disabled:!r||y.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(et,{name:"refresh",size:16})})]}),r&&F&&!oe&&!Ne?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(et,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[ae?h!=null&&h.length?"No default executor selected":"No execution agent on this gateway":H?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:ae?"setup required":H?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!ae)return F.runner_error?`The worker reports: ${F.runner_error} — new executions queue until it comes back.`:H?"The worker is alive but the gateway reports it cannot execute — check the executor configuration below.":"New executions will queue until the worker comes back.";if(!(h!=null&&h.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const R=h.map(Y=>Y.display||Y.id),V=R.slice(0,4).join(", ")+(R.length>4?` +${R.length-4} more`:"");return h.some(Y=>Y.available!==!1)?`The gateway's registry serves ${h.length} executor${h.length===1?"":"s"} (${V}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${h.length} executor${h.length===1?"":"s"} (${V}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(h!=null&&h.length)||!h.some(R=>R.available!==!1))&&(ae||!H)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
82
- abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
83
- # the agent program must be installed on the gateway's computer (on its PATH)`}):null,e.jsx("div",{className:"callout_actions",children:a.on_open_settings?e.jsx("button",{className:"btn primary",onClick:a.on_open_settings,title:"Settings → Gateway administration (admin-gated; the gateway authorizes every change)",children:"Open Settings"}):null}),e.jsxs("p",{className:"callout_text muted",children:["The gateway is the gatekeeper: admins enable the worker and pick the executor from Settings → Gateway administration — changes apply live, no gateway restart (the worker reconciles in-process). On the gateway's computer the same settings are"," ",e.jsx("code",{children:"abstractgateway config set …"}),"."]})]})]}):null,Ne?e.jsx(hd,{gateway:s,surface:"the execution pipeline",status:ye.status,legacy:ye.legacy,error:Si(y.exec_error)?y.exec_error:N,on_changed:()=>{be(R=>R+1),y.refresh_exec_list("processing")}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${D.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:D.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${D.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:D.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:D.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${oe?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:oe?"on":ae?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[fe,ae?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[ue?e.jsxs("div",{className:"exec_side",children:[e.jsxs("div",{className:"pane exec_pane_active",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Active"}),e.jsx("span",{className:"pane_count",children:O.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:O.length?O.map(R=>{var L;const V=String(R.status||"").trim().toLowerCase(),ne=Fl(R),Y=((L=y.exec_selected)==null?void 0:L.request_id)===R.request_id,me=V==="running"&&R.started_at?Math.max(0,Date.now()-Date.parse(R.started_at)):null,A=String(R.backlog_filename||R.backlog_relpath||"").trim(),w=R.target_agent||(R.target_model?`${String(R.executor_type||"agent").trim()||"agent"}:${R.target_model}`:"");return e.jsxs("button",{className:`run_card ${Y?"selected":""} ${V==="running"?"is_running":""}`,onClick:()=>void y.load_exec_request(R),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:A,children:A||`request ${ha(R.request_id,12)}`}),e.jsx("span",{className:`chip mono ${Il(V)}`,children:V||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:me!==null?`running ${Ws(me)}`:ne.queue_delay_ms!=null?`queued ${Ws(ne.queue_delay_ms)}`:" "}),w?e.jsx("span",{className:"chip mono muted",children:w}):null,e.jsx("span",{className:"run_card_id mono",children:ha(R.request_id,14)})]})]},R.request_id)}):e.jsx("div",{className:"empty_note",children:"Nothing is executing right now. Execute a Ready item from the Board (or Backlog)."})})]}),e.jsxs("div",{className:"pane exec_pane_recent",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Recently finished"}),e.jsx("span",{className:"pane_count",children:b.length})]}),e.jsxs("div",{className:"pane_body",style:{padding:0},children:[N&&!Ne?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:N}):null,!N&&!b.length?e.jsx("div",{className:"empty_note",style:{padding:"10px 12px"},children:"No finished executions yet."}):null,b.length?e.jsx("div",{className:"recent_list",children:b.map(R=>{var A;const V=String(R.status||"").trim().toLowerCase(),ne=Fl(R),Y=((A=y.exec_selected)==null?void 0:A.request_id)===R.request_id,me=ha(R.backlog_filename||R.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${Y?"selected":""}`,onClick:()=>void y.load_exec_request(R),title:String(R.backlog_filename||R.backlog_relpath||R.request_id),children:[e.jsx("span",{className:`chip mono ${Il(V)}`,children:V||"?"}),e.jsx("span",{className:"recent_row_name",children:me}),e.jsx("span",{className:"recent_row_time mono",children:ne.run_ms!=null?Ws(ne.run_ms):""})]},`recent:${R.request_id}`)})}):null]})]})]}):null,q?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Run detail"}),y.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${Il(String(y.exec_selected.status||"").toLowerCase())}`,children:String(y.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:ha(y.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(Fv,{pipeline:y,is_compact_layout:l,on_back_to_list:()=>d("list"),on_send_feedback:()=>void y.exec_send_feedback(async()=>{await y.refresh_exec_list("processing")}),on_promote:()=>void y.exec_promote_to_prod(async()=>{await y.refresh_exec_list("processing"),await I()}),on_deploy_uat:()=>void y.exec_deploy_uat_now(async()=>{await y.refresh_exec_list("processing")})})})]}):null]})]})]})}function Mu(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Qv(a){const s=String(a||"").trim().toLowerCase();return s==="running"?{cls:"ok",label:"running"}:s==="stopped"?{cls:"muted",label:"stopped"}:s.includes("restart")?{cls:"warn",label:s}:s.includes("error")||s.includes("failed")?{cls:"danger",label:s||"error"}:{cls:"warn",label:s||"unknown"}}function Rf(a){const s=r=>{const l=String((r==null?void 0:r.id)||"").trim(),c=l.endsWith("_uat")?l.slice(0,-4):l;return c==="gateway"?0:c==="build"?1:c==="abstractobserver"?2:c==="abstractcode_web"?3:c==="abstractflow_backend"?4:c==="abstractflow_frontend"?5:10};return[...a||[]].sort((r,l)=>{const c=s(r),d=s(l);if(c!==d)return c-d;const h=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),p=String((l==null?void 0:l.label)||(l==null?void 0:l.id)||"").toLowerCase();return h<p?-1:h>p?1:0})}function Jv(a){const s=String(a||"").trim().toLowerCase();return s==="override"?{cls:"ok",label:"override"}:s.startsWith("inherited")?{cls:"info",label:s}:s==="unset"?{cls:"warn",label:"unset"}:!s||s==="missing"?{cls:"muted",label:"missing"}:{cls:"muted",label:s}}function Yv({gateway:a,gateway_connected:s}){const[r,l]=f.useState("prod"),[c,d]=f.useState(null),[h,p]=f.useState([]),[_,y]=f.useState(!1),[b,x]=f.useState(""),[N,E]=f.useState(!1),[I,C]=f.useState(null),[M,O]=f.useState([]),[D,F]=f.useState(!1),[H,$]=f.useState(""),[ae,fe]=f.useState({}),[oe,Ne]=f.useState(!1),[Me,be]=f.useState(null),[ye,ue]=f.useState(""),[q,R]=f.useState(""),[V,ne]=f.useState(!1),Y=f.useRef(null),me=f.useMemo(()=>Rf(h.filter(Z=>!String((Z==null?void 0:Z.id)||"").trim().endsWith("_uat"))),[h]),A=f.useMemo(()=>Rf(h.filter(Z=>String((Z==null?void 0:Z.id)||"").trim().endsWith("_uat"))),[h]),w=r==="uat"?A:me,L=f.useCallback(async()=>{if(s){y(!0),x("");try{const Z=await a.list_processes();d(!!(Z!=null&&Z.enabled));const K=Array.isArray(Z==null?void 0:Z.processes)?Z.processes:[];p(K)}catch(Z){x(String((Z==null?void 0:Z.message)||Z||"Failed to list processes"))}finally{y(!1)}}},[a,s]),X=f.useCallback(async()=>{if(s){F(!0),$("");try{const Z=await a.list_process_env_vars();C(!!(Z!=null&&Z.enabled));const K=Array.isArray(Z==null?void 0:Z.vars)?Z.vars:[];O(K);const xe=String((Z==null?void 0:Z.error)||"").trim();xe&&$(xe)}catch(Z){$(String((Z==null?void 0:Z.message)||Z||"Failed to list env vars"))}finally{F(!1)}}},[a,s]),ge=f.useCallback(async()=>{if(!s)return;const Z=Me;if(Z){ne(!0);try{const K=await a.process_log_tail(String(Z.id||""),{max_bytes:16e4}),xe=String((K==null?void 0:K.content)||""),Ee=typeof(K==null?void 0:K.bytes)=="number"?Number(K.bytes):0,De=!!(K!=null&&K.truncated),te=String((K==null?void 0:K.log_relpath)||"");ue(xe),R(`${Ee.toLocaleString()} bytes${De?" (tail)":""}${te?` • ${te}`:""}`)}catch(K){ue(""),R(String((K==null?void 0:K.message)||K||"Failed to read logs"))}finally{ne(!1)}}},[a,s,Me]),de=f.useCallback(async Z=>{be(Z),Ne(!0)},[]),P=f.useCallback(()=>{Ne(!1),be(null),ue(""),R("")},[]);f.useEffect(()=>{s&&L()},[s,L]),f.useEffect(()=>{if(!s||r==="env"||!N)return;const Z=window.setInterval(()=>{a.is_backing_off()||L()},2e3);return()=>window.clearInterval(Z)},[s,r,N,L,a]),f.useEffect(()=>{s&&r==="env"&&X()},[s,r,X]),f.useEffect(()=>{if(s&&oe)return ge(),Y.current&&window.clearInterval(Y.current),Y.current=window.setInterval(()=>{a.is_backing_off()||ge()},1500),()=>{Y.current&&window.clearInterval(Y.current),Y.current=null}},[s,oe,ge]);const je=f.useRef(!1),[Ae,Fe]=f.useState(!1);async function Ve(Z,K){if(!je.current){je.current=!0,Fe(!0),x("");try{K==="start"?await a.start_process(Z.id):K==="stop"?await a.stop_process(Z.id):K==="restart"?await a.restart_process(Z.id):K==="redeploy"&&await a.redeploy_process(Z.id),await L()}catch(xe){x(String((xe==null?void 0:xe.message)||xe||`Failed to ${K}`))}finally{je.current=!1,Fe(!1)}}}async function lt(Z){const K=String(Z||"").trim();if(K){$("");try{const xe=String((ae==null?void 0:ae[K])??""),Ee=await a.update_process_env_vars({set:{[K]:xe}});C(!!(Ee!=null&&Ee.enabled)),O(Array.isArray(Ee==null?void 0:Ee.vars)?Ee.vars:[]),fe(te=>({...te||{},[K]:""}));const De=String((Ee==null?void 0:Ee.error)||"").trim();De&&$(De)}catch(xe){$(String((xe==null?void 0:xe.message)||xe||"Failed to set env var"))}}}async function pe(Z){const K=String(Z||"").trim();if(K){$("");try{const xe=await a.update_process_env_vars({unset:[K]});C(!!(xe!=null&&xe.enabled)),O(Array.isArray(xe==null?void 0:xe.vars)?xe.vars:[]),fe(De=>({...De||{},[K]:""}));const Ee=String((xe==null?void 0:xe.error)||"").trim();Ee&&$(Ee)}catch(xe){$(String((xe==null?void 0:xe.message)||xe||"Failed to unset env var"))}}}const Ie=c===null?"…":c?"enabled":"disabled",ke=I===null?"…":I?"enabled":"disabled";return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsxs("div",{className:"seg",role:"group","aria-label":"Service views",children:[e.jsx("button",{"aria-pressed":r==="prod",className:`seg_btn ${r==="prod"?"active":""}`,onClick:()=>l("prod"),children:"Production"}),e.jsx("button",{"aria-pressed":r==="uat",className:`seg_btn ${r==="uat"?"active":""}`,onClick:()=>l("uat"),children:"UAT"}),e.jsx("button",{"aria-pressed":r==="env",className:`seg_btn ${r==="env"?"active":""}`,onClick:()=>l("env"),children:"ENV"})]}),s?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection badge in the sidebar."}),s&&r!=="env"?e.jsxs("span",{className:`chip mono ${c===!1?"warn":"muted"}`,children:["manager ",Ie]}):null,s&&r==="env"?e.jsxs("span",{className:`chip mono ${I===!1?"warn":"muted"}`,children:["env ",ke]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"btn btn_icon",style:{display:"inline-flex",alignItems:"center",gap:"8px"},children:[e.jsx("input",{type:"checkbox",checked:N,onChange:Z=>E(!!Z.target.checked)}),"auto"]}),e.jsxs("button",{className:`btn btn_icon ${_?"is_loading":""}`,onClick:()=>void L(),disabled:!s||_,children:[e.jsx(et,{name:"refresh",size:16}),_?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${D?"is_loading":""}`,onClick:()=>void X(),disabled:!s||D,children:[e.jsx(et,{name:"refresh",size:16}),D?"Refreshing…":"Refresh"]})]}),s&&r!=="env"&&c===!1?e.jsxs("div",{className:"page_hint mono",children:["The process manager is off on this gateway. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("span",{className:"mono",children:"abstractgateway config set process_manager on"}),"). Process control also needs the framework checkout it manages: set the backlog folder to it (Settings → Backlog folder)."]}):null,s&&r==="env"&&I===!1?e.jsxs("div",{className:"page_hint mono",children:["The process manager is off on this gateway. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("span",{className:"mono",children:"abstractgateway config set process_manager on"}),")."]}):null,r!=="env"&&b?e.jsx("div",{className:"page_error mono",children:b}):null,r==="env"&&H?e.jsx("div",{className:"page_error mono",children:H}):null,s&&r!=="env"?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:r==="uat"?"UAT services":"Production services"}),e.jsx("span",{className:"pane_count",children:w.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[w.length?null:e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"6px 4px"},children:["No ",r==="uat"?"UAT":"production"," processes reported."]}),w.map(Z=>{const K=String(Z.id||"").trim(),xe=String(Z.label||K).trim()||K,Ee=Qv(String(Z.status||"")),te=String(Z.status||"").trim().toLowerCase()==="running",J=Array.isArray(Z==null?void 0:Z.actions)?Z.actions.map(mt=>String(mt||"").trim()):[],ve=J.includes("start"),G=J.includes("stop"),Se=J.includes("restart"),Ge=J.includes("redeploy"),ze=J.includes("logs"),Qe=typeof(Z==null?void 0:Z.pid)=="number"?Number(Z.pid):null,ee=String((Z==null?void 0:Z.url)||"").trim(),U=String((Z==null?void 0:Z.description)||"").trim(),se=String((Z==null?void 0:Z.last_error)||"").trim(),le=typeof(Z==null?void 0:Z.exit_code)=="number"?Number(Z.exit_code):null,Ue=[];Qe&&Ue.push(`pid ${Qe}`),le!==null&&Ue.push(`exit ${le}`);const ut=Ue.join(" • ");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:xe}),e.jsx("span",{className:`chip mono ${Ee.cls}`,children:Ee.label}),e.jsx("span",{className:"chip mono muted",children:K}),ut?e.jsx("span",{className:"entity_card_sub mono",children:ut}):null]}),U?e.jsx("div",{className:"entity_card_sub mono",children:Mu(U,220)}):null,ee?e.jsx("div",{className:"entity_card_sub mono",children:te?e.jsx("a",{href:ee,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:ee}):e.jsx("span",{className:"mono",children:ee})}):null,se?e.jsx("div",{className:"page_error mono",children:Mu(se,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[ve?e.jsx("button",{className:"btn primary",onClick:()=>void Ve(Z,"start"),disabled:_||Ae,children:"Start"}):null,G?e.jsx("button",{className:"btn danger",onClick:()=>void Ve(Z,"stop"),disabled:_||Ae,children:"Stop"}):null,Se?e.jsx("button",{className:"btn",onClick:()=>void Ve(Z,"restart"),disabled:_||Ae,children:"Restart"}):null,Ge?e.jsx("button",{className:"btn",onClick:()=>void Ve(Z,"redeploy"),disabled:_||Ae,children:"Redeploy"}):null,ze?e.jsx("button",{className:"btn",onClick:()=>void de(Z),disabled:_,children:"Logs"}):null]})]},K)})]})]}):null,s&&r==="env"?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Environment variables"}),e.jsx("span",{className:"pane_count",children:M.length}),e.jsx("span",{className:"pane_header_actions mono muted",style:{fontSize:"var(--font-size-xs)"},children:"write-only: the gateway will never return env var values to the browser"})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[M.map(Z=>{const K=String((Z==null?void 0:Z.key)||"").trim();if(!K)return null;const xe=String((Z==null?void 0:Z.label)||K).trim()||K,Ee=String((Z==null?void 0:Z.description)||"").trim(),De=String((Z==null?void 0:Z.source)||"").trim(),te=!!(Z!=null&&Z.secret),J=String((Z==null?void 0:Z.updated_at)||"").trim(),ve=Jv(De),G=String((ae==null?void 0:ae[K])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:xe}),e.jsx("span",{className:`chip mono ${ve.cls}`,children:ve.label}),e.jsx("span",{className:"chip mono muted",children:K})]}),Ee?e.jsx("div",{className:"entity_card_sub mono",children:Mu(Ee,280)}):null,J?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",J]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:G,onChange:Se=>fe(Ge=>({...Ge||{},[K]:String(Se.target.value||"")})),placeholder:te?"••••••••":"value",type:te?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void lt(K),disabled:D,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void pe(K),disabled:D,children:"Unset"})]})]},`env:${K}`)}),M.length?null:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"6px 4px"},children:"No env vars available (process manager must be enabled)."})]})]}):null,oe&&Me?e.jsxs(Ya,{open:oe,title:`${String(Me.label||Me.id||"logs").trim()||"Logs"}`,onClose:P,children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:q}),e.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[e.jsxs("button",{className:`btn btn_icon ${V?"is_loading":""}`,onClick:()=>void ge(),disabled:V,children:[e.jsx(et,{name:"refresh",size:16}),V?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{try{navigator.clipboard.writeText(ye||"")}catch{}},disabled:!ye,children:[e.jsx(et,{name:"copy",size:16}),"Copy"]})]}),e.jsx("pre",{className:"mono",style:{marginTop:"10px",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.12)",background:"rgba(0,0,0,0.22)",overflowX:"auto",maxHeight:"55vh",whiteSpace:"pre-wrap"},children:ye||"(no logs yet)"})]}):null]})})}function Lf(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function El(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function zu(a){const s=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return s.length<=1?s[0]||"":s}function Xv(a){const s=a.gateway,[r,l]=f.useState(!1),[c,d]=f.useState([]),[h,p]=f.useState(""),[_,y]=f.useState(""),[b,x]=f.useState(""),[N,E]=f.useState("7d"),[I,C]=f.useState("unread"),[M,O]=f.useState(25),[D,F]=f.useState(!1),[H,$]=f.useState(!1),[ae,fe]=f.useState(!1),[oe,Ne]=f.useState(!1),[Me,be]=f.useState(""),[ye,ue]=f.useState(""),[q,R]=f.useState(""),[V,ne]=f.useState([]),[Y,me]=f.useState(""),[A,w]=f.useState(null),[L,X]=f.useState(!1),[ge,de]=f.useState(""),[P,je]=f.useState(""),[Ae,Fe]=f.useState(""),[Ve,lt]=f.useState(""),[pe,Ie]=f.useState(""),ke=a.enabled,Z=f.useMemo(()=>(Array.isArray(c)?c:[]).map(se=>({account:String((se==null?void 0:se.account)||"").trim(),can_read:(se==null?void 0:se.can_read)!==!1,can_send:(se==null?void 0:se.can_send)!==!1,label:""})).filter(se=>!!se.account),[c]),K=f.useMemo(()=>{const U=String(_||"").trim();return U&&Z.find(se=>se.account===U)||null},[Z,_]),xe=!!(K!=null&&K.can_read),Ee=!!(K!=null&&K.can_send),De=f.useMemo(()=>Z.map(U=>{const se=U.can_read?U.can_send?"":" (read-only)":" (send-only)";return{...U,label:`${U.account}${se}`}}),[Z]);async function te(){if(ke){be(""),F(!0);try{const U=await s.email_list_accounts();d(Array.isArray(U==null?void 0:U.accounts)?U.accounts:[]),p(String((U==null?void 0:U.default_account)||"").trim())}catch(U){be(String((U==null?void 0:U.message)||U||"Failed to list email accounts")),d([]),p("")}finally{F(!1)}}}f.useEffect(()=>{te()},[ke]),f.useEffect(()=>{if(!ke)return;const U=String(_||"").trim();if(U&&Z.some(le=>le.account===U))return;const se=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(se&&Z.some(le=>le.account===se)){y(se);return}if(h&&Z.some(le=>le.account===h)){y(h);return}Z.length&&y(Z[0].account)},[ke,_,h,Z]),f.useEffect(()=>{const U=String(_||"").trim();U&&localStorage.setItem("abstractcontinuum_email_account",U)},[_]);async function J(){if(!ke)return;const U=String(_||"").trim();if(U){if(!xe){be("Selected account is not allowed to read email."),ne([]),me(""),w(null);return}be(""),$(!0);try{const se=await s.email_list_messages({account:U,mailbox:String(b||"").trim()||void 0,since:String(N||"").trim()||void 0,status:I,limit:M}),le=Array.isArray(se==null?void 0:se.messages)?se.messages:[];ne(le);const Ue=String(Y||"").trim();Ue&&!le.some(ut=>String((ut==null?void 0:ut.uid)||"").trim()===Ue)&&(me(""),w(null))}catch(se){be(String((se==null?void 0:se.message)||se||"Failed to list emails")),ne([]),me(""),w(null)}finally{$(!1)}}}f.useEffect(()=>{ke&&String(_||"").trim()&&J()},[ke,_]);async function ve(U){if(!ke)return;const se=String(_||"").trim(),le=String(U||"").trim();if(!(!se||!le)&&xe){me(le),w(null),ue(""),fe(!0);try{const Ue=await s.email_read_message(le,{account:se,mailbox:String(b||"").trim()||void 0,max_body_chars:2e4});w(Ue)}catch(Ue){ue(String((Ue==null?void 0:Ue.message)||Ue||"Failed to read email"))}finally{fe(!1)}}}function G(U){R(""),de(String((U==null?void 0:U.to)||"").trim()),je(""),Fe(""),lt(String((U==null?void 0:U.subject)||"").trim()),Ie(String((U==null?void 0:U.body)||"")),X(!0)}function Se(){if(!A)return;const U=String((A==null?void 0:A.from)||"").trim(),se=String((A==null?void 0:A.subject)||"").trim(),le=se.toLowerCase().startsWith("re:")?se:`Re: ${se||"(no subject)"}`,Ue=String((A==null?void 0:A.body_text)||"").trim(),ut=`
84
-
85
- ---
86
- On ${Lf((A==null?void 0:A.date)||"")}, ${U} wrote:
87
-
88
- ${Ue}`;G({to:U,subject:le,body:ut})}async function Ge(){if(!ke||oe)return;const U=String(_||"").trim();if(U){if(!Ee){R("Selected account is not allowed to send email.");return}R(""),Ne(!0);try{const se=zu(ge);if(!se)throw new Error("to is required");const le=String(Ve||"").trim();if(!le)throw new Error("subject is required");const Ue=String(pe||"").trim();if(!Ue)throw new Error("body is required");await s.email_send({account:U,to:se,subject:le,body_text:Ue,cc:zu(P),bcc:zu(Ae)}),X(!1),de(""),je(""),Fe(""),lt(""),Ie(""),await J()}catch(se){R(String((se==null?void 0:se.message)||se||"Failed to send email"))}finally{Ne(!1)}}}const ze=f.useMemo(()=>{const U=String(Y||"").trim();return U&&V.find(se=>String((se==null?void 0:se.uid)||"").trim()===U)||null},[V,Y]),Qe=String((A==null?void 0:A.body_text)||"").trim()||String((A==null?void 0:A.body_html)||"").trim(),ee=String((A==null?void 0:A.body_text)||"").trim()?"Body (text)":String((A==null?void 0:A.body_html)||"").trim()?"Body (html, raw)":"Body";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`inbox_layout exec_layout ${r?"phone_detail":"phone_list"}`,children:[e.jsxs("div",{className:"pane",onClickCapture:U=>{var se,le;(le=(se=U.target)==null?void 0:se.closest)!=null&&le.call(se,".inbox_item")&&l(!0)},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Email"}),e.jsx("span",{className:"pane_count",children:V.length})]}),e.jsxs("div",{className:"pane_body",style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center"},children:[e.jsx("select",{value:_,onChange:U=>y(String(U.target.value||"")),disabled:!ke||D,children:De.length?De.map(U=>e.jsx("option",{value:U.account,children:U.label},U.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void te(),disabled:!ke||D,children:D?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void J(),disabled:!ke||H||!String(_||"").trim()||!xe,children:H?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>G(),disabled:!ke||!String(_||"").trim()||!Ee,children:"Compose"})]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"1 1 120px"},children:[e.jsx("label",{children:"Since"}),e.jsx("input",{value:N,onChange:U=>E(String(U.target.value||"")),placeholder:"7d"})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[e.jsx("label",{children:"Status"}),e.jsxs("select",{value:I,onChange:U=>C(String(U.target.value||"all")),children:[e.jsx("option",{value:"all",children:"all"}),e.jsx("option",{value:"unread",children:"unread"}),e.jsx("option",{value:"read",children:"read"})]})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[e.jsx("label",{children:"Limit"}),e.jsx("input",{value:String(M),onChange:U=>O(Number(U.target.value||"0")||25),inputMode:"numeric",placeholder:"25"})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:160,flex:"1 1 160px"},children:[e.jsx("label",{children:"Mailbox"}),e.jsx("input",{value:b,onChange:U=>x(String(U.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void J(),disabled:!ke||H||!String(_||"").trim()||!xe,children:"Apply"})})]}),Me?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Me}):null,e.jsx("div",{className:"inbox_list",children:V.length?V.map((U,se)=>{const le=String((U==null?void 0:U.uid)||"").trim(),Ue=!!le&&le===String(Y||"").trim(),ut=String((U==null?void 0:U.subject)||"").trim()||"(no subject)",mt=String((U==null?void 0:U.from)||"").trim(),ot=String((U==null?void 0:U.date)||"").trim(),dt=!!(U!=null&&U.seen);return e.jsxs("button",{className:`inbox_item ${Ue?"active":""}`,onClick:()=>void ve(le),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${dt?"approved":"pending"}`,children:dt?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:El(ut,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:El(mt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[El(ot,36)||"(date?)"," • uid ",El(le,10)]})]},le||`idx:${se}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane",children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>l(!1),children:"← Back to the list"})}),Y?ae?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):ye?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ye}):A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",flexWrap:"wrap"},children:[e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("div",{className:"mono",style:{fontWeight:700},children:String((A==null?void 0:A.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((A==null?void 0:A.account)||"").trim()||_}),e.jsx("span",{className:"pill muted",children:String((A==null?void 0:A.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",El(String((A==null?void 0:A.uid)||Y),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>fn(String((A==null?void 0:A.message_id)||"")),disabled:!String((A==null?void 0:A.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>fn(String(Y||"")),disabled:!String(Y||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>Se(),disabled:!Ee||!String((A==null?void 0:A.from)||"").trim(),children:"Reply"})]})]}),e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"From"}),e.jsx("div",{className:"mono",children:String((A==null?void 0:A.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((A==null?void 0:A.to)||"").trim()||"(to?)"})]}),String((A==null?void 0:A.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((A==null?void 0:A.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:Lf(String((A==null?void 0:A.date)||(ze==null?void 0:ze.date)||"").trim())||String((A==null?void 0:A.date)||(ze==null?void 0:ze.date)||"").trim()||"(date?)"})]}),Array.isArray(A==null?void 0:A.attachments)&&A.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:A.attachments.map((U,se)=>e.jsxs("div",{children:[String((U==null?void 0:U.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((U==null?void 0:U.content_type)||"").trim()?`(${String((U==null?void 0:U.content_type)||"").trim()})`:""})]},`${(U==null?void 0:U.filename)||""}:${se}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:ee}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255, 255, 255, 0.10)",background:"rgba(0, 0, 0, 0.12)",maxHeight:"60vh",overflow:"auto"},children:Qe||"(empty)"})]})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."})]})})]}),e.jsxs(Ya,{open:L,title:`Compose (${String(_||"").trim()||"account"})`,onClose:()=>{oe||X(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[q?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:q}):null,e.jsx("button",{className:"btn",onClick:()=>X(!1),disabled:oe,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Ge(),disabled:oe,children:oe?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:ge,onChange:U=>de(String(U.target.value||"")),placeholder:"you@example.com"})]}),e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Cc"}),e.jsx("input",{value:P,onChange:U=>je(String(U.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:Ae,onChange:U=>Fe(String(U.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:Ve,onChange:U=>lt(String(U.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:pe,onChange:U=>Ie(String(U.target.value||"")),placeholder:"Write your message…"})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:"Tip: separate multiple recipients with commas or newlines."})]})]})}function Mf(a){const s=String(a||"").trim();if(!s)return"";const r=s.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Qo(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function wi(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Zv(a){const s=a.gateway,r=!!a.enable_triage,[l,c]=f.useState(!1),[d,h]=f.useState(r?"messages":"email"),[p,_]=f.useState([]),[y,b]=f.useState([]),[x,N]=f.useState([]),[E,I]=f.useState(!1),[C,M]=f.useState(""),[O,D]=f.useState(null),[F,H]=f.useState(""),[$,ae]=f.useState(!1),[fe,oe]=f.useState(""),[Ne,Me]=f.useState("pending"),[be,ye]=f.useState(null),[ue,q]=f.useState(""),[R,V]=f.useState(null),[ne,Y]=f.useState(""),[me,A]=f.useState(!1),[w,L]=f.useState(!1),[X,ge]=f.useState(""),[de,P]=f.useState(""),je=!!de,[Ae,Fe]=f.useState(""),[Ve,lt]=f.useState(""),[pe,Ie]=f.useState(""),[ke,Z]=f.useState(!1),K=a.gateway_connected;f.useEffect(()=>{!r&&d!=="email"&&h("email")},[r,d]);const xe=f.useMemo(()=>d==="bugs"?p:d==="features"?y:[],[d,p,y]);f.useEffect(()=>{d==="email"&&(M(""),I(!1))},[d]);async function Ee(){const ee=await s.list_bug_reports();_(Array.isArray(ee==null?void 0:ee.items)?ee.items:[])}async function De(){const ee=await s.list_feature_requests();b(Array.isArray(ee==null?void 0:ee.items)?ee.items:[])}async function te(){const ee=await s.list_triage_decisions({status:Ne||void 0,limit:500}),U=Array.isArray(ee==null?void 0:ee.decisions)?ee.decisions:[];N(U),be&&!U.some(se=>se.decision_id===be.decision_id)&&(ye(null),q(""),V(null),Y(""))}async function J(){if(K&&r&&d!=="email"){M(""),I(!0);try{d==="bugs"?await Ee():d==="features"?await De():await te()}catch(ee){M(String((ee==null?void 0:ee.message)||ee||"Refresh failed"))}finally{I(!1)}}}f.useEffect(()=>{J()},[d,K,Ne,r]);async function ve(ee){D(ee),H(""),oe(""),ae(!0);try{if(ee.report_type==="bug"){const U=await s.get_bug_report_content(ee.filename);H(String((U==null?void 0:U.content)||""))}else{const U=await s.get_feature_request_content(ee.filename);H(String((U==null?void 0:U.content)||""))}}catch(U){oe(String((U==null?void 0:U.message)||U||"Failed to load report"))}finally{ae(!1)}}async function G(ee){ye(ee),q(""),V(null),Y("");const U=Mf(ee.report_relpath);if(U)try{if(ee.report_type==="bug"){const se=await s.get_bug_report_content(U);q(String((se==null?void 0:se.content)||""))}else if(ee.report_type==="feature"){const se=await s.get_feature_request_content(U);q(String((se==null?void 0:se.content)||""))}}catch(se){Y(String((se==null?void 0:se.message)||se||"Failed to load report"))}}async function Se(ee){Y(""),V(null);const U=String(ee.draft_relpath||"").trim();if(!U)return;const se=Mf(U);if(se)try{const le=await s.backlog_content("proposed",se);V(le)}catch(le){Y(String((le==null?void 0:le.message)||le||"Failed to load draft (is repo root configured on gateway?)"))}}async function Ge(ee,U){if(be&&!me){Y(""),A(!0);try{const se=await s.apply_triage_decision(be.decision_id,{action:ee,defer_days:U??null});await te();const le=String(Ne||"").trim().toLowerCase(),Ue=String((se==null?void 0:se.status)||"").trim().toLowerCase();if(!(!le||le===Ue))ye(null),q(""),V(null);else if(ye(se),String(se.draft_relpath||"").trim())try{await Se(se)}catch{}}catch(se){Y(String((se==null?void 0:se.message)||se||"Decision action failed"))}finally{A(!1)}}}async function ze(){if(!w){M(""),L(!0);try{const ee=await s.triage_run({write_drafts:!1,enable_llm:!1});ge(`Scanned ${(ee==null?void 0:ee.reports)??0} report(s); updated ${(ee==null?void 0:ee.updated_decisions)??0} decision(s).`),await te()}catch(ee){M(String((ee==null?void 0:ee.message)||ee||"Triage failed"))}finally{L(!1)}}}f.useEffect(()=>{je&&(Ie(""),lt(""),Z(!1),Fe(String(a.default_session_id||"").trim()))},[je,a.default_session_id]);async function Qe(){var ee,U;if(de&&!ke){Ie(""),Z(!0);try{const se=String(Ae||"").trim();if(!se)throw new Error("session_id is required");const le=String(Ve||"").trim();if(!le)throw new Error("description is required");const Ue={session_id:se,description:le,active_run_id:String(a.default_active_run_id||"").trim()||void 0,workflow_id:String(a.default_workflow_id||"").trim()||void 0,client:"abstractcontinuum/web",client_version:"",user_agent:String(((ee=globalThis==null?void 0:globalThis.navigator)==null?void 0:ee.userAgent)||""),url:String(((U=globalThis==null?void 0:globalThis.location)==null?void 0:U.href)||"")};if(de==="bug"){const ut=await s.bug_report_create(Ue),mt=String((ut==null?void 0:ut.filename)||"").trim();P(""),h("bugs");const ot=await s.list_bug_reports(),dt=Array.isArray(ot==null?void 0:ot.items)?ot.items:[];_(dt);const bt=dt.find(Re=>Re.filename===mt)||null;bt&&await ve(bt)}else{const ut=await s.feature_report_create(Ue),mt=String((ut==null?void 0:ut.filename)||"").trim();P(""),h("features");const ot=await s.list_feature_requests(),dt=Array.isArray(ot==null?void 0:ot.items)?ot.items:[];b(dt);const bt=dt.find(Re=>Re.filename===mt)||null;bt&&await ve(bt)}}catch(se){Ie(String((se==null?void 0:se.message)||se||"Failed to create report"))}finally{Z(!1)}}}return f.useEffect(()=>{c(!1)},[d]),e.jsxs("div",{className:"page page_pad",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Inbox views",children:r?e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-pressed":d==="messages",className:`seg_btn ${d==="messages"?"active":""}`,onClick:()=>h("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"}),e.jsx("button",{"aria-pressed":d==="bugs",className:`seg_btn ${d==="bugs"?"active":""}`,onClick:()=>h("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":d==="features",className:`seg_btn ${d==="features"?"active":""}`,onClick:()=>h("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"})}),r&&d!=="email"&&X?e.jsx("span",{className:"page_hint mono",children:X}):null,r&&d!=="email"&&C?e.jsx("span",{className:"page_error mono",children:C}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r?e.jsxs(e.Fragment,{children:[d==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:Ne,onChange:ee=>Me(String(ee.target.value)),title:"Filter triage decisions by status",children:[e.jsx("option",{value:"pending",children:"pending"}),e.jsx("option",{value:"approved",children:"approved"}),e.jsx("option",{value:"deferred",children:"deferred"}),e.jsx("option",{value:"rejected",children:"rejected"}),e.jsx("option",{value:"",children:"all"})]}),e.jsx("button",{className:"btn",onClick:()=>void J(),disabled:!K||E,children:E?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void ze(),disabled:!K||w,children:w?"Running…":"Run triage"})]}):d==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void J(),disabled:!K||E,children:E?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>P("bug"),disabled:!K,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>P("feature"),disabled:!K,children:"File feature"})]}):null]}),d==="email"?e.jsx(Xv,{gateway:s,enabled:K}):e.jsxs("div",{className:`inbox_layout exec_layout ${l?"phone_detail":"phone_list"}`,children:[e.jsxs("div",{className:"pane",onClickCapture:ee=>{var U,se;(se=(U=ee.target)==null?void 0:U.closest)!=null&&se.call(U,".inbox_item")&&c(!0)},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:d==="messages"?"Triage decisions":d==="bugs"?"Bug reports":"Feature requests"}),e.jsx("span",{className:"pane_count",children:d==="messages"?x.length:xe.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:d==="messages"?e.jsx(e.Fragment,{children:x.length?x.map(ee=>{const U=(be==null?void 0:be.decision_id)===ee.decision_id,se=Array.isArray(ee.missing_fields)?ee.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${U?"active":""}`,onClick:()=>void G(ee),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(ee.status||"").toLowerCase()}`,children:String(ee.status||"pending")}),e.jsx("span",{className:"mono",children:ee.report_type}),e.jsx("span",{className:"mono muted",children:wi(ee.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[se?`${se} missing`:"complete"," • ",Qo(ee.updated_at||ee.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:wi(ee.report_relpath||"",46)})]},ee.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:xe.length?xe.map(ee=>{const U=(O==null?void 0:O.filename)===ee.filename&&(O==null?void 0:O.report_type)===ee.report_type,se=String(ee.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${U?"active":""}`,onClick:()=>void ve(ee),children:[e.jsxs("div",{className:"inbox_item_title",children:[se?e.jsx("span",{className:`pill ${se}`,children:se}):null,e.jsx("span",{className:"mono",children:wi(ee.title||ee.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Qo(ee.created_at)||"(time?)"," • ",ee.session_id?wi(ee.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:ee.filename})]},ee.relpath)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})})]}),e.jsx("div",{className:"pane",children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>c(!1),children:"← Back to the list"})}),d==="messages"?be?e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{className:"mono",style:{fontWeight:700},children:"Triage decision"}),e.jsx("span",{className:"chip mono muted",children:be.report_type}),e.jsx("span",{className:"chip mono muted",children:be.status}),e.jsx("span",{className:"chip mono muted",children:wi(be.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{fn(be.report_relpath||"")},children:"Copy report path"}),be.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void Se(be),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void Ge("approve"),disabled:me,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void Ge("defer",1),disabled:me,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void Ge("defer",7),disabled:me,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void Ge("reject"),disabled:me,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[be.updated_at?`updated ${Qo(be.updated_at)}`:null,be.created_at?`${be.updated_at?" • ":""}created ${Qo(be.created_at)}`:null,be.defer_until?` • defer until ${be.defer_until}`:null]}),ne?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ne}):null,e.jsxs("div",{className:"row",style:{gap:"12px"},children:[e.jsxs("div",{className:"col",style:{minWidth:240},children:[e.jsx("div",{className:"section_title",children:"Missing fields"}),be.missing_fields&&be.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:be.missing_fields.map(ee=>e.jsx("li",{children:ee},ee))}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."}),e.jsx("div",{className:"section_title",style:{marginTop:"10px"},children:"Possible duplicates"}),be.duplicates&&be.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:be.duplicates.slice(0,20).map((ee,U)=>{const se=String((ee==null?void 0:ee.title)||(ee==null?void 0:ee.ref)||(ee==null?void 0:ee.kind)||"duplicate").trim(),le=typeof(ee==null?void 0:ee.score)=="number"&&Number.isFinite(ee.score)?` (score ${ee.score.toFixed(2)})`:"";return e.jsxs("li",{children:[se,le]},`${se}_${U}`)})}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."})]}),e.jsxs("div",{className:"col",style:{minWidth:240},children:[e.jsx("div",{className:"section_title",children:"Draft"}),be.draft_relpath?e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[e.jsx("div",{className:"mono muted",children:"path"}),e.jsx("div",{className:"mono",children:be.draft_relpath})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No draft yet. Approve to generate one (requires repo mounted on gateway host)."})]})]}),R?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(ls,{className:"md_doc",text:String(R.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),ue?e.jsx(ls,{className:"md_doc",text:ue}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No report preview loaded."})]})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a decision."}):O?e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{className:"mono",style:{fontWeight:700},children:O.report_type==="bug"?"Bug report":"Feature request"}),O.triage_status?e.jsx("span",{className:`pill ${O.triage_status}`,children:O.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:O.filename}),O.session_id?e.jsx("span",{className:"chip mono muted",children:wi(O.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{fn(O.relpath||"")},children:"Copy path"})})]}),fe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:fe}):null,$?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):F?e.jsx(ls,{className:"md_doc",text:F}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No content loaded."})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a report."})]})})]}),e.jsxs(Ya,{open:je,title:de==="bug"?"File bug report":"File feature request",onClose:()=>P(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>P(""),disabled:ke,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Qe(),disabled:ke,children:ke?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:Ae,onChange:ee=>Fe(ee.target.value),placeholder:"session id (required)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"This correlates runs + attachments (via the session memory run)."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:de==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:Ve,onChange:ee=>lt(ee.target.value),placeholder:de==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),pe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:pe}):null]})]})}const ey="api/continuum/settings";async function Oh(a){const s=await fetch(ey,{...a,signal:AbortSignal.timeout(1e4),headers:a!=null&&a.body?{"Content-Type":"application/json"}:void 0}),r=await s.text();let l=null;try{l=JSON.parse(r)}catch{}if(!s.ok||!l||typeof l!="object"||!l.settings){const c=l&&typeof l=="object"?l.detail||l.error:"",d=new Error(c||`settings unavailable (HTTP ${s.status})`);throw d.status=s.status,d}return l}function ty(){return Oh()}function ny(a,s){return Oh({method:"PUT",body:JSON.stringify({[a]:s})})}const Dh="abstractcontinuum_voice_override_v1",Pu={enabled:!1};function nd(){try{const a=localStorage.getItem(Dh);if(!a)return{...Pu};const s=JSON.parse(a);return!s||typeof s!="object"?{...Pu}:{enabled:!!s.enabled,provider:Us(s.provider),model:Us(s.model),profile:Us(s.profile),voice:Us(s.voice),quality_preset:Us(s.quality_preset)}}catch{return{...Pu}}}const sd="abstractcontinuum:voice_override_changed";function sy(a){try{localStorage.setItem(Dh,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(sd))}catch{}}function Fh(a){if(!a)return{};const s={},r=Us(a.quality_preset);if(r&&(s.quality_preset=r),!a.enabled)return s;for(const l of["provider","model","profile","voice"]){const c=Us(a[l]);c&&(s[l]=c)}return s}function Us(a){return String(a??"").trim()||void 0}function qh(a){const s=a&&typeof a=="object"?a.routes:null;if(!Array.isArray(s))return{};const r=y=>s.find(b=>b&&typeof b=="object"&&String(b.key||"").trim()===y&&!!b.configured),l=r("output.voice.tts")||r("output.voice");if(!l)return{};const c={},d=Us(l.provider),h=Us(l.model),p=l.options,_=p&&typeof p=="object"?Us(p.voice):void 0;return d&&(c.provider=d),h&&(c.model=h),_&&(c.voice=_),c}function ay(a){let s=String(a||"");return s=s.replace(/```[\s\S]*?```/g," "),s=s.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),s=s.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1"),s=s.replace(/`([^`]+)`/g,"$1"),s=s.replace(/^[ \t]*#{1,6}[ \t]+/gm,""),s=s.replace(/^[ \t]*>[ \t]?/gm,""),s=s.replace(/^[ \t]*[-*+][ \t]+/gm,""),s=s.replace(/^[ \t]*\d+[.)][ \t]+/gm,""),s=s.replace(/^[ \t]*\|/gm,"").replace(/\|[ \t]*$/gm,"").replace(/\|/g,", "),s=s.replace(/(\*\*|__|~~)(.*?)\1/g,"$2"),s=s.replace(/\*([^*\n]+)\*/g,"$1"),s=s.replace(/(^|[^\w])_([^_\n]+)_(?=[^\w]|$)/g,"$1$2"),s=s.replace(/^[ \t]*([-*_])(?:[ \t]*\1){2,}[ \t]*$/gm," "),s=s.replace(/\s+/g," ").trim(),s}const Tl={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function ry(a){const s={};if(!Array.isArray(a))return s;for(const r of a){if(!r||typeof r!="object")continue;const l=r.voice_kinds;if(!(Array.isArray(l)&&l.some(_=>String(_).toLowerCase().includes("clone"))))continue;const d=String(r.provider||"").trim(),h=String(r.id||r.voice||r.name||"").trim();if(!h)continue;const p=d||"*";(s[p]||(s[p]=[])).push(h)}for(const r of Object.keys(s))s[r]=[...new Set(s[r])];return s}function ad(a){if(!Array.isArray(a))return[];const s=[];for(const r of a)if(typeof r=="string"){const l=r.trim();l&&s.push(l)}else if(r&&typeof r=="object"){const l=String(r.id||r.name||r.voice||r.value||"").trim();l&&s.push(l)}return[...new Set(s)]}function Iu(a){const s={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,l]of Object.entries(a)){const c=ad(l);c.length&&(s[String(r)]=c)}return s}function iy(a){const{gateway:s,gateway_connected:r}=a,[l,c]=f.useState(()=>nd()),[d,h]=f.useState(Tl),[p,_]=f.useState(!1),[y,b]=f.useState(""),x=f.useRef(null),N=f.useCallback(F=>{c(H=>{const $={...H,...F};return sy($),$})},[]);f.useEffect(()=>{if(!r){h(Tl);return}if(typeof(s==null?void 0:s.voice_voices)!="function"){h(Tl);return}let F=!0;h($=>({...$,loading:!0,error:""}));let H;try{H=s.voice_voices()}catch($){h({...Tl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")});return}return H.then($=>{if(!F)return;const ae=[...new Set([...ad($==null?void 0:$.providers),...ad($==null?void 0:$.tts_providers)])];h({loading:!1,error:"",providers:ae,models_by_provider:Iu($==null?void 0:$.tts_models_by_provider),profiles_by_provider:Iu($==null?void 0:$.tts_profiles_by_provider),voices_by_provider:Iu($==null?void 0:$.tts_voices_by_provider),cloned_by_provider:ry($==null?void 0:$.items)})}).catch($=>{F&&h({...Tl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")})}),()=>{F=!1}},[s,r]);const E=l.provider||"",I=E&&d.models_by_provider[E]?d.models_by_provider[E]:[],C=E&&d.voices_by_provider[E]?d.voices_by_provider[E]:[],M=E&&d.profiles_by_provider[E]?d.profiles_by_provider[E]:[],O=[...E&&d.cloned_by_provider[E]?d.cloned_by_provider[E]:[],...d.cloned_by_provider["*"]||[]];async function D(){if(!(p||!r)){_(!0),b("");try{const F=await ud("abstractcontinuum_team_voice");let H={};if(typeof s.capability_defaults=="function")try{H=qh(await s.capability_defaults())}catch{H={}}const $=await s.voice_tts(F,{text:"This is the voice AbstractContinuum will use to read your messages.",...H,...Fh(l),timeout_s:30}),ae=$==null?void 0:$.audio_artifact,fe=ae&&typeof ae=="object"?String(ae.$artifact||"").trim():"";if(!fe)throw new Error("no audio returned");const oe=await s.download_run_artifact_content(F,fe),Ne=URL.createObjectURL(oe);if(x.current)try{x.current.pause()}catch{}const Me=x.current;if(Me){try{Me.pause()}catch{}const ye=Me.src;ye.startsWith("blob:")&&URL.revokeObjectURL(ye)}const be=new Audio(Ne);x.current=be,be.onended=()=>{URL.revokeObjectURL(Ne),b("")};try{await be.play(),b("Playing…")}catch(ye){b(String((ye==null?void 0:ye.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((ye==null?void 0:ye.message)||ye).slice(0,80)}`),URL.revokeObjectURL(Ne)}}catch(F){b(`Test failed: ${String((F==null?void 0:F.message)||F||"synthesis error").slice(0,120)}`)}finally{_(!1)}}}return e.jsxs("div",{className:"pane",style:{marginTop:12},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Voice"}),e.jsx("span",{className:"pane_subtitle",children:"message read-aloud — this browser"})]}),e.jsx("div",{className:"pane_body",children:r?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted team_note",style:{marginTop:0},children:"Each message can be read aloud (the speaker button on a message). By default the gateway's configured voice is used, streamed so playback starts immediately. Override it here for this browser."}),e.jsxs("label",{className:"settings_row",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:F=>N({enabled:F.target.checked})}),"Override the gateway default voice"]}),d.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",d.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,d.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,l.enabled&&!E&&(l.voice||l.profile)?e.jsx("div",{className:"muted team_note",style:{color:"var(--warning, #facc15)"},children:"A voice id is provider-specific — pick the provider it belongs to, or the gateway's default provider may reject it."}):null,l.enabled?e.jsxs("div",{style:{display:"grid",gap:8,marginTop:8},children:[e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Provider"}),e.jsx(Jo,{value:E,options:d.providers,placeholder:"gateway default",onChange:F=>N({provider:F,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(Jo,{value:l.model||"",options:I,placeholder:"default",onChange:F=>N({model:F})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(Jo,{value:l.profile||"",options:M,placeholder:"default",onChange:F=>N({profile:F})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(Jo,{value:l.voice||"",options:[...O,...C],placeholder:"none",onChange:F=>N({voice:F})})]})]}):null,e.jsxs("label",{className:"settings_field",style:{marginTop:8},children:[e.jsx("span",{className:"muted",children:"Quality"}),e.jsxs("select",{className:"team_compose_control",value:l.quality_preset||"",onChange:F=>N({quality_preset:F.target.value}),children:[e.jsx("option",{value:"",children:"gateway default"}),e.jsx("option",{value:"low",children:"low (fastest)"}),e.jsx("option",{value:"standard",children:"standard"}),e.jsx("option",{value:"high",children:"high (best)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[e.jsx("button",{className:"btn primary",disabled:p,onClick:()=>void D(),children:p?"Synthesizing…":"Test voice"}),y?e.jsx("span",{className:"muted team_note",children:y}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function Jo(a){const s=Wt.useId();return e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"team_compose_control mono",list:s,value:a.value,placeholder:a.placeholder||"",onChange:r=>a.onChange(r.target.value.trim())}),a.options.length?e.jsx("datalist",{id:s,children:a.options.map(r=>e.jsx("option",{value:r},r))}):null]})}const ly=["minimal","low","medium","high","xhigh"];function oy(a){const{gateway:s,connected:r,model:l,value:c,onChange:d}=a,[h,p]=f.useState({state:"unknown",levels:[]}),[_,y]=f.useState(!1);if(f.useEffect(()=>{y(!1);const N=String(l||"").trim();if(!N||!r){p({state:"unknown",levels:[]});return}let E=!1;return p({state:"loading",levels:[]}),s.discovery_model_capabilities(N).then(I=>{if(E)return;const C=I!=null&&I.capabilities&&typeof I.capabilities=="object"?I.capabilities:{},M=C.thinking_support,O=Array.isArray(C.reasoning_levels)?C.reasoning_levels.map(D=>String(D)):[];p(M===!0?{state:"supported",levels:O}:M===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{E||p({state:"unknown",levels:[]})}),()=>{E=!0}},[l,r]),!String(l||"").trim())return null;const b=h.state==="unsupported"||h.state==="unknown"&&!_||h.state==="loading",x=h.state==="supported"&&h.levels.length?h.levels:h.state==="unknown"&&_?[...ly]:[];return e.jsxs("div",{className:"field","data-testid":"reasoning_select",children:[e.jsxs("label",{children:["Reasoning (effort for ",l,")"]}),e.jsxs("select",{value:b?"":c,onChange:N=>d(String(N.target.value||"")),disabled:b,title:h.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":h.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":h.state==="loading"?"Checking the model's served capabilities…":"The gateway serves no reasoning facts for this model (unknown ≠ unsupported). Locked fail-safe; tick “set anyway” if you know the model reasons.",children:[e.jsx("option",{value:"",children:h.state==="unsupported"?"none — this model doesn't reason":h.state==="loading"?"checking…":h.state==="unknown"&&!_?"unknown — no served facts":"gateway default"}),x.map(N=>e.jsx("option",{value:N,children:N},N))]}),h.state==="unknown"&&!b?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Override active: efforts unverified for this model — the provider may reject or ignore them."}):null,h.state==="unknown"?e.jsxs("label",{className:"muted",style:{fontSize:"var(--font-size-sm)",display:"inline-flex",gap:"6px",alignItems:"center"},children:[e.jsx("input",{type:"checkbox",checked:_,onChange:N=>{y(N.target.checked),N.target.checked||d("")}}),"set anyway (I know this model reasons)"]}):null]})}function cy(a){const[s,r]=f.useState(!1),[l,c]=f.useState("");return s?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono",style:{minWidth:260},value:l,onChange:d=>c(d.target.value),placeholder:"/path/to/a/folder/with/docs/backlog",disabled:a.busy}),e.jsx("button",{className:"btn primary",disabled:a.busy||!l.trim(),onClick:()=>{a.on_apply(l.trim()),r(!1)},children:"Apply"}),e.jsx("button",{className:"btn",disabled:a.busy,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx("button",{className:"btn",disabled:a.busy,onClick:()=>{c(a.current),r(!0)},children:a.current?"Change…":"Set…"})}function uy(a){const s=String(a||"").trim();if(!s)return null;const r={flag:["launch flag","info","Set by a launch flag of the running Continuum; a saved value applies once it restarts without the flag."],setting:["setting","info","Saved setting (here, or `abstractcontinuum config set`)."],env:["environment (legacy)","warn","Set by the environment Continuum was started with. Save a value here to replace it."],default:["default","muted","Nothing saved: Continuum's default."]},[l,c,d]=r[s]||[s,"muted",""];return e.jsx("span",{className:`chip mono ${c}`,title:d,"data-testid":"hub_seat_source",children:l})}function dy(){var I;const[a,s]=f.useState(null),[r,l]=f.useState(""),[c,d]=f.useState(""),[h,p]=f.useState(!1),[_,y]=f.useState("");f.useEffect(()=>{let C=!1;return ty().then(M=>{var O;C||(s(M),d(String(((O=M.settings.hub_seat)==null?void 0:O.value)??"")))}).catch(M=>{C||l(String((M==null?void 0:M.message)||M))}),()=>{C=!0}},[]);async function b(C){var M;p(!0),y("");try{const O=await ny("hub_seat",C);s(O),d(String(((M=O.settings.hub_seat)==null?void 0:M.value)??""))}catch(O){y(String((O==null?void 0:O.message)||O||"Save refused"))}finally{p(!1)}}const x=a==null?void 0:a.settings.hub_seat,N=String((x==null?void 0:x.value)??""),E=!!((I=a==null?void 0:a.writable)!=null&&I.includes("hub_seat"));return e.jsxs("div",{className:"pane","data-testid":"hub_seat_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Team (agora hub)"}),e.jsx("span",{className:"pane_subtitle",children:"server-side — this Continuum"})]}),e.jsx("div",{className:"pane_body",children:a?e.jsxs("div",{className:"admin_row","data-testid":"admin_row_hub_seat",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Hub seat"}),e.jsx("span",{className:"chip mono ok","data-testid":"hub_seat_value",children:N}),uy(x==null?void 0:x.source),e.jsx("div",{className:"admin_row_action",children:E?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono","aria-label":"Hub seat",value:c,onChange:C=>d(C.target.value),placeholder:"your seat",disabled:h}),e.jsx("button",{className:"btn primary",disabled:h||!c.trim()||c.trim()===N&&(x==null?void 0:x.source)==="setting",onClick:()=>void b(c.trim()),children:"Save"}),(x==null?void 0:x.source)==="setting"?e.jsx("button",{className:"btn",disabled:h,onClick:()=>void b(null),children:"Use default"}):null]}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["The seat the Team page reads and posts as — set it to your own seat. Saved in ",e.jsx("code",{children:a.settings_file}),"; the same setting: ",e.jsx("code",{children:"abstractcontinuum config set hub_seat <seat>"}),", or ",e.jsx("code",{children:"--hub-seat <seat>"})," for one run.",(x==null?void 0:x.source)==="flag"?" A launch flag sets the seat for this run; a saved value applies once Continuum restarts without it.":null]}),_?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:_}):null]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:r?`Continuum's server settings are not available here (${r}). Set the seat with \`abstractcontinuum config set hub_seat <seat>\` or start Continuum with --hub-seat <seat>.`:"Loading…"})})]})}function my(a){var ye,ue;const{gateway:s,gateway_connected:r,settings:l,set_settings:c}=a,d=(ue=(ye=a.connection)==null?void 0:ye.gateway)==null?void 0:ue.principal,[h,p]=f.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[_,y]=f.useState(null),[b,x]=f.useState(null),[N,E]=f.useState(!1),[I,C]=f.useState(null),[M,O]=f.useState([]),[D,F]=f.useState(""),[H,$]=f.useState(!1),[ae,fe]=f.useState(0);async function oe(q){if(!H){$(!0),F("");try{const R=await s.admin_runtime_config_update(q);y(R),fe(V=>V+1)}catch(R){F(String((R==null?void 0:R.message)||R||"Config update refused"))}finally{$(!1)}}}f.useEffect(()=>{if(!r)return;let q=!1;return(async()=>{var V;const R={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const ne=await s.backlog_exec_config(),Y=!!(ne!=null&&ne.runner_enabled),me=!!(ne!=null&&ne.runner_alive),A=(ne==null?void 0:ne.can_execute)===!0;R.exec_pipeline=A?"on":Y||me?"degraded":"off",R.exec_detail=A?"":Y?me?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",R.executor=String((ne==null?void 0:ne.executor)||"").trim()}catch{R.exec_pipeline=null}try{const ne=await s.admin_runtime_config();if(ne&&typeof ne=="object"){q||(y(ne),R.process_manager=bi(ne.process_manager),R.backlog_root=((V=ne.triage_repo_root)==null?void 0:V.available)!==void 0?!!ne.triage_repo_root.available:bi(ne.triage_repo_root),p(R));return}}catch{}try{const ne=await s.list_processes();R.process_manager=!!(ne!=null&&ne.enabled)}catch{R.process_manager=null}try{await s.backlog_template(),R.backlog_root=!0}catch(ne){R.backlog_root=Si(ne)?!1:null}q||p(R)})(),(async()=>{try{const R=await s.admin_data_homes();q||(C(Array.isArray(R==null?void 0:R.homes)?R.homes:[]),O(Array.isArray(R==null?void 0:R.warnings)?R.warnings:[]))}catch{q||C(null)}})(),(async()=>{try{const R=await s.list_bundles(),V=Array.isArray(R==null?void 0:R.items)?R.items:Array.isArray(R==null?void 0:R.bundles)?R.bundles:Array.isArray(R)?R:[],ne=[];for(const A of V){const w=String((A==null?void 0:A.bundle_id)||(A==null?void 0:A.id)||"").trim();if(!w)continue;const L=Array.isArray(A==null?void 0:A.entrypoints)?A.entrypoints:[];for(const X of L){if((X==null?void 0:X.deprecated)===!0||!(Array.isArray(X==null?void 0:X.interfaces)?X.interfaces:[]).some(P=>String(P||"").trim().length>0))continue;const de=String((X==null?void 0:X.name)||"").trim();ne.push({id:w,name:de?`${w} · ${de}`:w,description:String((X==null?void 0:X.description)||"").trim()||void 0})}}const Y=new Set,me=ne.filter(A=>Y.has(A.id)?!1:(Y.add(A.id),!0));me.sort((A,w)=>A.name.localeCompare(w.name)),q||x(me)}catch{q||x(null)}})(),()=>{q=!0}},[s,r,ae]);function Ne(q){return typeof q!="number"||!Number.isFinite(q)||q<0?"":q>=1e12?`${(q/1e12).toFixed(1)} TB`:q>=1e9?`${(q/1e9).toFixed(1)} GB`:q>=1e6?`${(q/1e6).toFixed(1)} MB`:q>=1e3?`${(q/1e3).toFixed(1)} KB`:`${q} B`}function Me(q,R="on",V="off"){return q===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${q?"ok":"warn"}`,children:q?R:V})}function be(q){const R=String(q||"").trim();if(!R)return null;const V={flag:["launch flag","info","Set by a launch flag of the running gateway; a saved value applies once it restarts without the flag."],stored:["setting","info","Saved setting (Settings here, the gateway console, or `abstractgateway config set`)."],env:["environment (legacy)","warn","Set by the environment the gateway was started with. Save a value here to replace it."],default:["default","muted","Nothing saved: the gateway's default."]},[ne,Y,me]=V[R]||[R,"muted",""];return e.jsx("span",{className:`chip mono ${Y}`,title:me,"data-testid":"source_chip",children:ne})}return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Execution defaults"}),e.jsx("span",{className:"pane_subtitle",children:"preference — this browser"})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Default execution mode (preselected in execute dialogs)"}),e.jsxs("select",{value:l.default_execution_mode,onChange:q=>c(R=>({...R,default_execution_mode:q.target.value==="inplace"?"inplace":"uat"})),children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe) — recommended"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]})]}),e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Every execute dialog still shows the mode selector — this only sets what it starts on."})]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"AI assistance"}),e.jsx("span",{className:"pane_subtitle",children:"preference — this browser"})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Maintenance AI (backlog assist — refine/dod/labels)"}),e.jsx(Xp,{disabled:!r,value:{provider:l.maintenance_ai_provider,model:l.maintenance_ai_model},onChange:q=>c(R=>({...R,maintenance_ai_provider:q.provider,maintenance_ai_model:q.model,maintenance_ai_reasoning:q.model===R.maintenance_ai_model?R.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const q=await s.discovery_providers();return(Array.isArray(q==null?void 0:q.items)?q.items:[]).map(R=>({name:R.name,display_name:R.display_name}))},fetchModels:async q=>{const R=await s.discovery_provider_models(q);return Array.isArray(R==null?void 0:R.models)?R.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(oy,{gateway:s,connected:r,model:l.maintenance_ai_model,value:l.maintenance_ai_reasoning,onChange:q=>c(R=>({...R,maintenance_ai_reasoning:q}))}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Advisor workflow (executable workflows served by this gateway)"}),b===null?e.jsx("input",{className:"mono",value:l.backlog_advisor_agent,onChange:q=>c(R=>({...R,backlog_advisor_agent:String(q.target.value||"")})),placeholder:"basic-agent",title:"This gateway does not serve the workflow catalog — enter a bundle id."}):(()=>{const q=String(l.backlog_advisor_agent||"").trim(),R=q===""||b.some(V=>V.id===q);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:R&&!N?q:"__custom__",onChange:V=>{const ne=V.target.value;ne==="__custom__"?E(!0):(E(!1),c(Y=>({...Y,backlog_advisor_agent:ne})))},title:"Workflows the gateway can run for advice; blank = the shipped basic-agent",children:[e.jsx("option",{value:"",children:"gateway default (basic-agent)"}),b.map(V=>e.jsx("option",{value:V.id,title:V.description||void 0,children:V.name||V.id},V.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!R||N?e.jsx("input",{className:"mono",style:{marginTop:6},value:l.backlog_advisor_agent,onChange:V=>c(ne=>({...ne,backlog_advisor_agent:String(V.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(iy,{gateway:s,gateway_connected:r}),e.jsx(dy,{}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Gateway administration"}),e.jsx("span",{className:"pane_subtitle",children:"server-side — the gateway is the gatekeeper"})]}),e.jsx("div",{className:"pane_body",children:r?e.jsxs(e.Fragment,{children:[d!=null&&d.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:d.user_id}),d.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):d.admin===!1?e.jsx("span",{className:"chip mono muted",style:{marginLeft:6},title:"This pane stays read-only for non-admin principals.",children:"not admin"}):null]}):null,(()=>{var V,ne,Y,me,A,w,L,X,ge;const q=(_==null?void 0:_.writable)===!0,R=Array.isArray(_==null?void 0:_.executors)?_.executors:[];return e.jsxs("div",{children:[e.jsxs("div",{className:"admin_row","data-testid":"admin_row_backlog_folder",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Backlog folder"}),Me(h.backlog_root,"available","not available"),be((V=_==null?void 0:_.triage_repo_root)==null?void 0:V.source),e.jsxs("div",{className:"admin_row_action",children:[q&&((ne=_==null?void 0:_.triage_repo_root)!=null&&ne.default_path)&&Cl(_==null?void 0:_.triage_repo_root)!==_.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:H,onClick:()=>{var de;return void oe({triage_repo_root:((de=_==null?void 0:_.triage_repo_root)==null?void 0:de.default_path)||null})},title:_.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,q?e.jsx(cy,{current:Cl(_==null?void 0:_.triage_repo_root),busy:H,on_apply:de=>void oe({triage_repo_root:de})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((Y=_==null?void 0:_.triage_repo_root)==null?void 0:Y.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",Cl(_==null?void 0:_.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:Cl(_==null?void 0:_.triage_repo_root)})]}):null,((me=_==null?void 0:_.triage_repo_root)==null?void 0:me.available)===!1&&_.triage_repo_root.reason?e.jsxs(e.Fragment,{children:[" — not available: ",_.triage_repo_root.reason]}):null]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Exec runner"}),h.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${h.exec_pipeline==="on"?"ok":"warn"}`,children:h.exec_pipeline}),be((A=_==null?void 0:_.backlog_exec_runner)==null?void 0:A.source),e.jsx("div",{className:"admin_row_action",children:q?e.jsx("button",{className:"btn",disabled:H,onClick:()=>void oe({backlog_exec_runner:bi(_==null?void 0:_.backlog_exec_runner)!==!0}),children:bi(_==null?void 0:_.backlog_exec_runner)===!0?"Disable":"Enable"}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:[((w=_==null?void 0:_.backlog_exec_runner)==null?void 0:w.help)||"Runs the backlog items queued for execution on the gateway's computer.",h.exec_detail?e.jsxs(e.Fragment,{children:[" — ",h.exec_detail]}):null]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Executor"}),h.executor&&h.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:h.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),be((L=_==null?void 0:_.executor)==null?void 0:L.source),e.jsx("div",{className:"admin_row_action",children:q&&R.length?e.jsx("select",{value:Cl(_==null?void 0:_.executor),disabled:H,onChange:de=>void oe({executor:String(de.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:R.map(de=>e.jsxs("option",{value:de.id,disabled:de.available===!1,children:[de.display||de.id,de.available===!1?" (unavailable)":""]},de.id))}):null})]}),e.jsx("div",{className:"admin_row_detail",children:"The agent that runs queued items (the gateway lists what is installed on its computer)."})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Process manager"}),Me(h.process_manager,"enabled","disabled"),be((X=_==null?void 0:_.process_manager)==null?void 0:X.source),e.jsx("div",{className:"admin_row_action",children:q?e.jsx("button",{className:"btn",disabled:H,onClick:()=>void oe({process_manager:bi(_==null?void 0:_.process_manager)!==!0}),children:bi(_==null?void 0:_.process_manager)===!0?"Disable":"Enable"}):null})]}),e.jsx("div",{className:"admin_row_detail",children:((ge=_==null?void 0:_.process_manager)==null?void 0:ge.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),D?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:D}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:_?_.writable===!0?"Changes are saved on the gateway and apply at once; a launch flag of the running gateway wins until it restarts without it. The same settings: gateway console (Apps → Backlog settings) or `abstractgateway config set <key> <value>` on the gateway's computer.":_.writable===!1?"This gateway serves the admin config surface, but your principal is not authorized to change it (admin only).":"This gateway serves the admin config surface (write authority unknown — it predates the writable flag).":"This gateway does not serve its settings to Continuum (older build): update the gateway to change these from here."})]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Connect to a gateway to see its posture (top-right control)."})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Data and caches"}),e.jsx("span",{className:"pane_subtitle",children:I?`server-side — ${I.length} registered home${I.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?I===null?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"This gateway does not serve the data-homes registry yet (older build) — the table lights up on its next restart. Purge actions live on the gateway console either way; this card is read-only by design."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"table_scroll",children:e.jsxs("table",{className:"data_table mono",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"name"}),e.jsx("th",{children:"kind"}),e.jsx("th",{children:"owner"}),e.jsx("th",{children:"size"}),e.jsx("th",{children:"purge"})]})}),e.jsx("tbody",{children:[...I].sort((q,R)=>(R.size_bytes||0)-(q.size_bytes||0)).map(q=>e.jsxs("tr",{title:q.description||q.path,children:[e.jsx("td",{children:q.name}),e.jsx("td",{children:e.jsx("span",{className:"chip mono muted",children:q.kind})}),e.jsx("td",{className:"muted",children:q.owner}),e.jsx("td",{children:q.exists===!1?e.jsx("span",{className:"chip mono warn",children:"missing"}):Ne(q.size_bytes)}),e.jsx("td",{children:q.safe_to_purge?e.jsx("span",{className:"chip mono ok",children:"purgeable"}):e.jsx("span",{className:"chip mono warn",title:q.description||"Protected — the owner's rule refuses purge",children:"protected"})})]},q.name))})]})}),M.map((q,R)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:q},`dhw:${R}`)),e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Read-only view over the framework data registry (hover a row for its path and purge rule). Purge verbs live on the gateway console — one management surface, per the cache-management split ruling."})]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Connect to a gateway to see its data footprint."})})]})]})})}const fy=/^(```+|~~~+)\s*mermaid\s*$/i;function hy(a){const s=String(a||"").split(`
89
- `),r=[];let l=[],c=0;for(;c<s.length;){const d=s[c].match(fy);if(!d){l.push(s[c]),c+=1;continue}const h=d[1];let p=-1;for(let _=c+1;_<s.length;_++){const y=s[_].trimEnd();if(y.startsWith(h[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(y)&&y[0]===h[0]){p=_;break}}if(p===-1){l.push(s[c]),c+=1;continue}l.length&&(r.push({kind:"md",text:l.join(`
90
- `)}),l=[]),r.push({kind:"mermaid",text:s.slice(c+1,p).join(`
91
- `)}),c=p+1}return l.length&&r.push({kind:"md",text:l.join(`
92
- `)}),r}const py="modulepreload",_y=function(a,s){return new URL(a,s).href},zf={},gy=function(s,r,l){let c=Promise.resolve();if(r&&r.length>0){let h=function(b){return Promise.all(b.map(x=>Promise.resolve(x).then(N=>({status:"fulfilled",value:N}),N=>({status:"rejected",reason:N}))))};const p=document.getElementsByTagName("link"),_=document.querySelector("meta[property=csp-nonce]"),y=(_==null?void 0:_.nonce)||(_==null?void 0:_.getAttribute("nonce"));c=h(r.map(b=>{if(b=_y(b,l),b in zf)return;zf[b]=!0;const x=b.endsWith(".css"),N=x?'[rel="stylesheet"]':"";if(!!l)for(let C=p.length-1;C>=0;C--){const M=p[C];if(M.href===b&&(!x||M.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${b}"]${N}`))return;const I=document.createElement("link");if(I.rel=x?"stylesheet":py,x||(I.as="script"),I.crossOrigin="",I.href=b,y&&I.setAttribute("nonce",y),document.head.appendChild(I),x)return new Promise((C,M)=>{I.addEventListener("load",C),I.addEventListener("error",()=>M(new Error(`Unable to preload CSS for ${b}`)))})}))}function d(h){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=h,window.dispatchEvent(p),!p.defaultPrevented)throw h}return c.then(h=>{for(const p of h||[])p.status==="rejected"&&d(p.reason);return s().catch(d)})};let Ou=null;function vy(){return Ou||(Ou=gy(()=>import("./mermaid.core-zt0bcQ8D.js").then(a=>a.bp),[],import.meta.url).then(a=>{const s=a.default||a;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),s})),Ou}let yy=0;function xy(a){const s=f.useRef(null),[r,l]=f.useState("");return f.useEffect(()=>{let c=!0;return l(""),vy().then(async d=>{const h=`af_mermaid_${yy+=1}`,{svg:p}=await d.render(h,a.text);c&&s.current&&(s.current.innerHTML=p)}).catch(d=>{c&&l(String((d==null?void 0:d.message)||d||"mermaid render failed"))}),()=>{c=!1}},[a.text]),r?e.jsxs("div",{className:"team_mermaid_error",children:[e.jsxs("div",{className:"muted team_note",children:["#FALLBACK diagram did not render (",r.slice(0,120),") — source below:"]}),e.jsx("pre",{className:"team_mermaid_src",children:a.text})]}):e.jsx("div",{className:"team_mermaid",ref:s})}const Bh=5e4,by="abstractcontinuum history_window.estimate_tokens (~4 chars per token)";function wy(a){const s=String(a??"");return s?Math.max(1,Math.floor(s.length/4)):0}function jy(a,s,r=Bh){if(!Number.isInteger(r)||r<=0)throw new Error(`history window max_tokens must be a positive integer, got ${r}`);const l=a.map(_=>({item:_,tokens:s(_)}));let c=0,d=l.length,h=!1;for(let _=l.length-1;_>=0;_--){const y=l[_].tokens;if(c+y>r){d===l.length&&(h=!0,c+=y,d=_);break}c+=y,d=_}const p=l.slice(0,d);return{kept:l.slice(d).map(_=>_.item),report:{policy:"newest_whole_messages",max_tokens:r,token_estimator:by,total_messages:l.length,replayed_messages:l.length-d,replayed_tokens:c,dropped_messages:p.length,dropped_tokens:p.reduce((_,y)=>_+y.tokens,0),oversize_message_kept:h}}}const ky=400;function Sy(a){const s=new Map;for(const c of a)s.set(c.id,c);const r=c=>{let d=c,h=!1;const p=new Set([d.id]);for(let _=0;_<ky;_++){const y=String(d.reply_to||"");if(!y)break;const b=s.get(y);if(!b){h=d.id===c.id||h;break}if(p.has(b.id))break;p.add(b.id),d=b}return{root:d,orphan:h&&d.id===c.id}},l=new Map;for(const c of[...a].sort((d,h)=>(d.seq||0)-(h.seq||0))){const{root:d,orphan:h}=r(c);let p=l.get(d.id);p||(p={root:d,replies:[],orphan:d.id===c.id?h:!1,last_seq:d.seq||0},l.set(d.id,p)),c.id!==d.id&&(p.replies.push(c),p.last_seq=Math.max(p.last_seq,c.seq||0))}return[...l.values()].sort((c,d)=>c.last_seq-d.last_seq||(c.root.seq||0)-(d.root.seq||0))}const Pf=[{id:"all",label:"All",title:"Every message in the window"},{id:"unread",label:"Unread",title:"Unread MESSAGES (same number as the blue channel badge); the list shows the threads containing them"},{id:"asks",label:"Asks",title:"Threads with open/blocked messages — something expects an answer"},{id:"vigilance",label:"Needs vigilance",title:"Threads with unanswered asks, critical messages, or messages addressed to your seat"},{id:"fyi",label:"FYI",title:"Threads of fyi/system traffic"},{id:"resolved",label:"Resolved",title:"Threads closed by a resolved reply (the ✓ Resolve act) or a resolved root"},{id:"to_me",label:"@me",title:"Threads with messages addressed to your seat"}];function Uh(a,s,r){var c,d,h,p,_;if(a.retracted===!0)return s==="all"?!0:s==="unread"?!!((c=r.unread_seqs)!=null&&c.has(a.seq)||(d=r.unread_snapshot_seqs)!=null&&d.has(a.seq)):!1;const l=String(a.status||"").toLowerCase();switch(s){case"all":return!0;case"unread":return!!((h=r.unread_seqs)!=null&&h.has(a.seq)||(p=r.unread_snapshot_seqs)!=null&&p.has(a.seq));case"asks":return l==="open"||l==="blocked";case"fyi":return l==="fyi";case"resolved":return l==="resolved";case"to_me":return Array.isArray(a.to)&&a.to.includes(r.seat);case"vigilance":{const y=(l==="open"||l==="blocked")&&a.has_resolved_reply!==!0,b=a.critical===!0,x=Array.isArray(a.to)&&a.to.includes(r.seat),N=!!((_=r.escalated_seqs)!=null&&_.has(a.seq));return y||b||x||N}}}function If(a,s,r){return s==="all"?a:a.filter(l=>[l.root,...l.replies].some(c=>Uh(c,s,r)))}function Ny(a,s,r){return Uh(a,s,r)}function Cy(a){const s={},r={};for(const l of a){const c=String(l.channel||"");if(!c)continue;const d=Number(l.seq);if(Number.isFinite(d)){const h=s[c]||(s[c]=new Set);if(h.has(d))continue;h.add(d)}r[c]=(r[c]||0)+1}return r}function $y(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);!l||!Number.isFinite(c)||(s[l]||(s[l]=new Set)).add(c)}return s}function Ey(a,s){const r={};for(const l of a){const c=String(l.channel||""),d=Number(l.seq);if(!c||!Number.isFinite(d))continue;const h=String(l.status||"").toLowerCase(),p=Array.isArray(l.to)&&s?l.to.includes(s):!1;(h==="open"||h==="blocked"||(h==="reply"||h==="fyi")&&p)&&(r[c]||(r[c]=new Set)).add(d)}return r}function Ty(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);if(!l||!Number.isFinite(c))continue;const d=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||d==="interrupt")&&(s[l]||(s[l]=new Set)).add(c)}return s}function Ay(a,s){const r=s?s.replace(/\/+$/,"")+"/":"",l=new Map,c=[];for(const d of a){const h=String(d.path||"");if(!h.startsWith(r))continue;const p=h.slice(r.length);if(!p)continue;const _=p.indexOf("/");if(_===-1)c.push(d);else{const y=p.slice(0,_);l.set(y,(l.get(y)||0)+1)}}return{dirs:[...l.entries()].map(([d,h])=>({name:d,path:r+d,count:h})).sort((d,h)=>d.name.localeCompare(h.name)),leaves:c.sort((d,h)=>d.path.localeCompare(h.path))}}function Of(a,s){const r=String(a||"");if(!r.startsWith("dm:")||!s)return"";const l=r.slice(3);return l.startsWith(`${s}--`)?l.slice(s.length+2):l.endsWith(`--${s}`)?l.slice(0,l.length-s.length-2):""}function Ry(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function Ly(a){const s=new Map;for(const l of a)l.id&&s.set(l.id,String(l.sender||""));const r=new Set;for(const l of a){const c=l.reply_to?String(l.reply_to):"";if(!c)continue;const d=s.get(c);(d===void 0||d!==String(l.sender||""))&&r.add(c)}return r}const My=/(?:^|[\s("'`])((?:[A-Za-z0-9_][A-Za-z0-9_.-]*\/)+[A-Za-z0-9_][A-Za-z0-9_.-]*\.(?:md|markdown|txt|json|yaml|yml|csv|log))\b/g,zy=4;function Py(a){const s=[];for(const r of String(a||"").matchAll(My)){const l=r[1],c=r.index===void 0?-1:r.index,d=c>=0?String(a).slice(Math.max(0,c-12),c+1):"";if(!(d.includes("://")||/\/api\//.test(d))&&(s.includes(l)||s.push(l),s.length>=zy))break}return s}function Iy(a,s,r){var c,d;const l=a.split("/").pop()||a;if(s!=null&&s.has(a))return{kind:"fs",path:a,rewritten:!1};for(let h=0;h<r.length;h++)if(String(((c=r[h])==null?void 0:c.filename)||"")===a)return{kind:"attachment",attachment_index:h};if(s){const h=[];for(const p of s)(p===l||p.endsWith(`/${l}`))&&h.push(p);if(h.length===1)return{kind:"fs",path:h[0],rewritten:h[0]!==a}}for(let h=0;h<r.length;h++){const p=String(((d=r[h])==null?void 0:d.filename)||"");if(p&&(p===l||p.split("/").pop()===l))return{kind:"attachment",attachment_index:h}}return null}const Df=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function Du(a){const s=[];for(const l of a.matchAll(Df)){const c=l[1].toLowerCase();s.includes(c)||s.push(c)}return{title:a.replace(Df," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:s}}function Fu(a){const s=[];for(const r of String(a||"").split(/[\s,;]+/)){const l=r.replace(/^@/,"").toLowerCase();!l||!/^[a-z0-9][a-z0-9_.-]*$/.test(l)||s.includes(l)||s.push(l)}return s}function qu(a,s){let r=a.toLowerCase().replace(/[^a-z0-9_.-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"");r||(r="group"),r=r.slice(0,40).replace(/[-.]+$/g,"");let l=r,c=1;for(;s.has(l);)c+=1,l=`${r}-${c}`;return l}const Ff=400,qf=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Bf=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Oy(a){if(!a||a.length<Ff)return a;const s=a.split(/(```[\s\S]*?(?:```|$))/),r=[];for(const l of s){if(l.startsWith("```")){r.push(l);continue}const c=l.split(/(\n{2,})/);for(const d of c){if(/\n/.test(d)||d.length<Ff){r.push(d);continue}const h=d.split(/(`[^`\n]*`)/);let p=0;for(const _ of h)_.startsWith("`")||(p+=(_.match(qf)||[]).length+(_.match(Bf)||[]).length);if(p<2){r.push(d);continue}r.push(h.map(_=>_.startsWith("`")?_:_.replace(qf,`$1
93
-
94
- $2 `).replace(Bf,`$1
95
-
96
- `)).join(""))}}return r.join("")}const Dy=/https?:\/\/[^\s<>()[\]{}"'`]+/g,Fy=/\.(png|jpe?g|gif|webp)$/i;function qy(a,s){if(!s)return a;const r=s.replace(/\/+$/,"");if(!a.startsWith(r+"/"))return a;const c=a.slice(r.length).match(/^\/channels\/([^/]+)\/attachments\/([A-Za-z0-9_.-]+)$/);return c?`api/hub/channels/${c[1]}/attachments/${c[2]}`:a}function By(a,s){if(!a||!/https?:\/\//.test(a))return a;const r=(s==null?void 0:s.hub_base)||"",l=(s==null?void 0:s.app_origin)||"",c=a.split(/(```[\s\S]*?(?:```|$))/),d=[];for(let h=0;h<c.length;h++){const p=c[h];if(p.startsWith("```")){d.push(p);continue}const _=p.split(/(`[^`\n]*`)/);for(let y=0;y<_.length;y++){const b=_[y];if(b.startsWith("`")){d.push(b);continue}d.push(b.replace(Dy,(x,N)=>{const E=b.slice(Math.max(0,N-2),N);if(E.endsWith("](")||E.endsWith("("))return x;const I=x.replace(/[.,;:!?]+$/,""),C=x.slice(I.length);let M="";try{M=new URL(I).pathname}catch{return x}const O=qy(I,r),D=Fy.test(M),F=O!==I||l!==""&&O.startsWith(l+"/");return D&&F?`![image](${O})${C}`:`[${I}](${O})${C}`}))}}return d.join("")}const Uy=/^api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function Wy(a){const s=a.trim(),r=s.replace(/^\.\//,"").replace(/^\//,"");return r.startsWith("api/")?s.startsWith("/")||/\s/.test(r)||r.includes("..")?!0:!Uy.test(r):!1}function Pl(a){if(!a||!a.includes("api/"))return a;const s=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(s,(r,l,c,d)=>Wy(String(d))?"`"+(String(c||"").trim()||String(d)).replace(/`/g,"")+" (blocked link)`":r)}function vd(a){let s=0;for(let r=0;r<a.length;r++)s=s*31+a.charCodeAt(r)>>>0;return s%360}function Hy(a){var d,h,p,_;const s=Array.isArray(a.to)&&a.to.length?` to=[${a.to.join(",")}]`:"",r=(h=(d=a.data)==null?void 0:d.asks)!=null&&h.length?` asks=${a.data.asks.map(y=>`${y.id}:"${y.text}"`).join("; ")}`:"",l=(_=(p=a.data)==null?void 0:p.answers)!=null&&_.length?` answers=[${a.data.answers.join(",")}]`:"",c=a.reply_to?` reply_to=${a.reply_to}`:"";return`#${a.seq} [${a.sender}] (${a.status})${s}${c}${r}${l}
97
- ${a.title?`title: ${a.title}
98
- `:""}${String(a.body||"").trim()}`}function Uf(a,s){const r=Bh,c=[...a].sort((_,y)=>(_.seq||0)-(y.seq||0)).map(Hy),{kept:d,report:h}=jy(c,wy,r),p=[`TRANSCRIPT WINDOW: ${h.replayed_messages} of ${h.total_messages} message(s), ~${h.replayed_tokens} tokens (the newest whole messages up to ${r} tokens).`];return h.dropped_messages>0&&p.push(`#TRUNCATION: the ${h.dropped_messages} oldest message(s) (~${h.dropped_tokens} tokens) were dropped by the history window (the newest whole messages up to ${r} tokens; abstractcontinuum team_model); this transcript starts mid-conversation.`),{text:`${p.join(`
99
- `)}
100
-
101
- ${d.join(`
102
-
103
- `)}`,report:h}}function Wf(a){const s=r=>`message${r===1?"":"s"}`;return a.dropped_messages<=0?`${a.replayed_messages} ${s(a.replayed_messages)}`:`${a.replayed_messages} of ${a.total_messages} ${s(a.total_messages)} (${a.dropped_messages} oldest dropped by the ${a.max_tokens.toLocaleString("en-US")}-token history window)`}function Vy(a,s){let r=Number(a.up||0),l=Number(a.down||0),c=Number(a.mine||0);return s===void 0?{up:r,down:l,mine:c,caught_up:!1}:s===c?{up:r,down:l,mine:c,caught_up:!0}:(c>0?r-=1:c<0&&(l-=1),s>0?r+=1:s<0&&(l+=1),{up:Math.max(0,r),down:Math.max(0,l),mine:s,caught_up:!1})}function Gy(a,s){const r=Array.from(String(a??"")),l=(s??[]).filter(h=>Array.isArray(h)&&h.length>=2&&Number.isFinite(h[0])&&Number.isFinite(h[1])&&h[0]>=0&&h[1]>0).sort((h,p)=>h[0]-p[0]),c=[];let d=0;for(const[h,p]of l){if(h>=r.length)break;const _=Math.max(h,d),y=Math.min(h+p,r.length);y<=_||(_>d&&c.push({text:r.slice(d,_).join(""),hit:!1}),c.push({text:r.slice(_,y).join(""),hit:!0}),d=y)}return d<r.length&&c.push({text:r.slice(d).join(""),hit:!1}),!c.length&&r.length&&c.push({text:r.join(""),hit:!1}),c}const Yo=[{id:"decisions",label:"Decisions",kind:"decision"},{id:"open_threads",label:"Open threads",kind:null},{id:"work",label:"Work",kind:"work"},{id:"people",label:"People",kind:"agent"},{id:"files",label:"Files",kind:"file"},{id:"messages",label:"Messages",kind:"message"}],Ky=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Lr(a,s){const r=a.toLowerCase().split(".").pop()||"",l=String(s||"").toLowerCase();if(r==="md"||r==="markdown"||l==="text/markdown")return"md";if(Ky.has(l))return"image";const c=new Set(["txt","json","yaml","yml","csv","log","ts","tsx","js","py","sh","toml","ini","env"]);return!(l.includes("html")||l.includes("xml")||l.includes("svg"))&&(l.startsWith("text/")||c.has(r))?"text":"download"}function Qy({url:a,name:s}){const[r,l]=Wt.useState(!1);return r?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("p",{className:"muted team_note",children:"The image failed to decode in the browser — the bytes may be corrupt or mistyped."}),e.jsxs("a",{className:"btn primary",href:a,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",s]})]}):e.jsx("img",{className:"team_fileview_img",src:a,alt:s,onError:()=>l(!0)})}function Jy({view:a,onClose:s}){if(!a)return null;const r=a.url?e.jsxs("a",{className:"btn primary",href:a.url,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",a.name]}):null;return e.jsxs(Ya,{open:!0,title:a.name,onClose:s,variant:"default",children:[a.meta?e.jsx("div",{className:"muted team_note",style:{marginBottom:8},children:a.meta}):null,a.loading?e.jsx("div",{className:"muted team_note",children:"Loading…"}):a.error?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("div",{className:"page_error mono",children:a.error}),r]}):a.mode==="md"?e.jsx("div",{className:"team_fileview_md",children:hy(a.text||"").map((l,c)=>l.kind==="mermaid"?e.jsx(xy,{text:l.text},c):e.jsx(ls,{className:"md_doc",text:Pl(l.text)},c))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(Qy,{url:a.url,name:a.name},a.url):e.jsxs("div",{className:"team_fileview_dl",children:[e.jsxs("p",{className:"muted team_note",children:["Inline preview isn't available for this file type",a.content_type?` (${a.content_type})`:"","."]}),r]})]})}const Yy=Wt.memo(ls),Xy=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Hf(a){let s='"';for(let r=0;r<a.length;r++){const l=a.charCodeAt(r),c=a[r];c==='"'?s+='\\"':c==="\\"?s+="\\\\":l===8?s+="\\b":l===9?s+="\\t":l===10?s+="\\n":l===12?s+="\\f":l===13?s+="\\r":l<32||l>126?s+="\\u"+l.toString(16).padStart(4,"0"):s+=c}return s+'"'}class Wh{constructor(s){this.value=s}}function Vf(a){if(!Number.isFinite(a))throw new Error("py_float_repr: non-finite");if(Object.is(a,-0))return"-0.0";if(a===0)return"0.0";const s=a<0,r=Math.abs(a),c=r.toExponential().match(/^(\d)(?:\.(\d+))?e([+-]\d+)$/);if(!c)return(s?"-":"")+String(r);const d=c[1]+(c[2]||""),p=parseInt(c[3],10)+1;let _;if(p<=-4||p>16){const y=d.length>1?`${d[0]}.${d.slice(1)}`:d[0],b=p-1,x=(b<0?"-":"+")+String(Math.abs(b)).padStart(2,"0");_=`${y}e${x}`}else p<=0?_="0."+"0".repeat(-p)+d:p>=d.length?_=d+"0".repeat(p-d.length)+".0":_=d.slice(0,p)+"."+d.slice(p);return(s?"-":"")+_}function rd(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof Wh){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Vf(a.value)}if(typeof a=="number"){if(!Number.isFinite(a))throw new Error("canonical_json: non-finite number");return Number.isInteger(a)&&!Object.is(a,-0)?String(a):Vf(a)}if(typeof a=="string")return Hf(a);if(Array.isArray(a))return"["+a.map(rd).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Hf(r)+":"+rd(a[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof a}`)}async function Zy(a){const s=new TextEncoder().encode(a),r=await crypto.subtle.digest("SHA-256",s);return[...new Uint8Array(r)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function ex(a,s,r){const l={};for(const c of Xy)c!=="channel"&&(l[c]=s[c]??null);return l.channel=r,typeof l.created_at=="number"&&(l.created_at=new Wh(l.created_at)),await Zy(a+`
104
- `+rd(l))}async function tx(a){const s=a.channel;let r="",l=0,c=0,d=null,h="";for(const _ of a.turns){if(_.hash===null||_.hash===void 0){l>0&&d===null&&(d=_.seq),c+=1,r="";continue}const y=await ex(r,_,s);y!==_.hash&&d===null&&(d=_.seq),r=_.hash,h=y,l+=1}const p=d===null&&String(a.head||"")!==h;return{ok:d===null&&!p,broken_at:d,head_mismatch:p,computed_head:h,hashed:l,legacy:c}}const nx=5e3,sx=6,fa=200,ax=50,Xo=380,Gf=240,Kf=2,rx=12,Al=8,Qf=16*1024*1024,ix=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Ol=256*1024;function lx(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M1.8 4a1 1 0 0 1 1-1h3.4l1.6 1.8h6.4a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H2.8a1 1 0 0 1-1-1z"})})}function Jf(){return e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M4.2 1.8h5.2l2.8 2.8v9a.9.9 0 0 1-.9.9H4.2a.9.9 0 0 1-.9-.9V2.7a.9.9 0 0 1 .9-.9z"}),e.jsx("path",{d:"M9.2 1.8v3h3"})]})}function Zo(a){return a.length<=Ol?a:a.slice(0,Ol)+`
105
-
106
- ---
107
- #TRUNCATION: preview clamped at ${Vn(Ol)} of ${Vn(a.length)} — download the file for the full content.`}function Bu(a,s){try{return JSON.stringify(a)===JSON.stringify(s)}catch{return!1}}function Uu(a,s){const r=Object.keys(a);if(r.length!==Object.keys(s).length)return!1;for(const l of r){const c=a[l],d=s[l];if(!d||c.size!==d.size)return!1;for(const h of c)if(!d.has(h))return!1}return!0}function Vn(a){if(!Number.isFinite(a)||a<0)return"—";if(a<1024)return`${a} B`;const s=a/1024;return s<1024?`${Math.round(s)} KiB`:`${(a/(1024*1024)).toFixed(1)} MiB`}const Hh="abstractcontinuum_team_drafts_v1";function ox(){try{const a=window.localStorage.getItem(Hh),s=a?JSON.parse(a):{};return s&&typeof s=="object"?s:{}}catch{return{}}}function Rl(a){try{window.localStorage.setItem(Hh,JSON.stringify(a))}catch{}}const ec="agora/0.4";function Ll(a){if(!a)return"";const s=Math.max(0,Math.floor(Date.now()/1e3-a));return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function Ml(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function Yf(a){return{color:`hsl(${vd(a)}, 60%, 55%)`}}function Ga(a){const s=vd(a),r=s>=40&&s<=190?36:45;return{background:`hsl(${s}, 55%, ${r}%)`,color:"#fff"}}const ki=[{id:"trust",label:"Trust",help:"Claim ↔ action: does it say what it does, and do what it says?"},{id:"wisdom",label:"Wisdom",help:"Often right — takes the right decisions and leads by example."},{id:"thorough",label:"Thorough",help:"Takes a task end-to-end and doesn't stop until it is fully resolved and functional, with proofs."},{id:"helper",label:"Helper",help:"Contributes to OTHERS' work — detects issues, contributes positively."}],cx=[{id:"ruling",help:"May decide in the operator's name — seats treat its rulings as operator rulings while the grant stands."},{id:"operational",help:"Day-to-day operational writes (queues, coordination surfaces) in the operator's name."},{id:"reporting",help:"Receives and reads operator-grade reports and status surfaces."},{id:"moderation",help:"Moderation acts (pause, kick, retire) in the operator's name."}],Xf={general:"Message thumbs — every standing ±1 on this agent's messages counts (operator ruling dm#161: a vote is a vote; a flip revises its own message, never stacks).",...Object.fromEntries(ki.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function zl(a){const s=ki.find(r=>r.id===a);return s?s.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function ux(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function dx(a){var Tt,bs,an,gn,Ds,la;const s=a.gateway,r=!!a.gateway_connected,l=f.useMemo(()=>new gd,[]),c=f.useMemo(()=>{if(a.advisor)return a.advisor;if(!r||!s)return;const u=a.advisor_agent;return async(v,S)=>{const k=[...S.map(re=>({role:re.role,content:re.content})),{role:"user",content:v}],T=await s.backlog_advisor({messages:k,agent:u||null});return String((T==null?void 0:T.reply)||"").trim()||"(the model returned an empty reply)"}},[a.advisor,s,r,a.advisor_agent]),d=!!c,[h,p]=f.useState(""),[_,y]=f.useState(()=>nd()),[b,x]=f.useState(""),N=f.useRef(_);N.current=_;const E=f.useRef({});f.useEffect(()=>{if(!r||!s){p("");return}let u=!0;return(async()=>{try{const v=await ud("abstractcontinuum_team_voice");u&&p(v)}catch{u&&p("")}})(),typeof s.capability_defaults=="function"&&Promise.resolve().then(()=>s.capability_defaults()).then(v=>{u&&(E.current=qh(v))}).catch(()=>{u&&(E.current={})}),()=>{u=!1}},[s,r]),f.useEffect(()=>{const u=()=>y(nd());return window.addEventListener(sd,u),window.addEventListener("storage",u),()=>{window.removeEventListener(sd,u),window.removeEventListener("storage",u)}},[]);const I=f.useMemo(()=>{const u=String(h||"").trim();if(!(!r||!s||!u))return v=>{const S=s.voice_stream_transport(u,{text:v,...E.current,...Fh(N.current)});return W_({path:S.path,body:S.body,headers:S.headers})}},[s,r,h]),C=rh({tts_stream:I,on_error:x});f.useEffect(()=>{if(!b)return;J(b);const u=setTimeout(()=>x(""),6e3);return()=>clearTimeout(u)},[b]);const[M,O]=f.useState(null),D=f.useRef(null);f.useEffect(()=>{D.current=M},[M]);const[F,H]=f.useState(""),[$,ae]=f.useState(null),[fe,oe]=f.useState([]),[Ne,Me]=f.useState({}),[be,ye]=f.useState({}),[ue,q]=f.useState({}),[R,V]=f.useState({}),[ne,Y]=f.useState(null),[me,A]=f.useState(""),w=f.useRef(0),L=f.useRef(!1),X=f.useRef(!1);async function ge(){if(!L.current&&!(Date.now()-w.current<3e4)){w.current=Date.now();try{const u=await l.desk();Y(v=>v==="loading"?v:u),u.rows.length&&!X.current&&Qn(v=>v!==""?v:(X.current=!0,"desk"))}catch(u){((u==null?void 0:u.status)===403||(u==null?void 0:u.status)===404)&&(L.current=!0)}}}async function de(){Y("loading"),A("");try{const u=await l.desk();Y(u),w.current=Date.now(),L.current=!1}catch(u){Y(null),A((u==null?void 0:u.status)===403?"The desk serves operators and reporting delegates only — this console's seat is neither.":(u==null?void 0:u.status)===404?'The hub does not answer GET /desk (older hub build) — the amber "needs reply" pills on messages still mark what waits on you.':`The desk read failed (${String((u==null?void 0:u.message)||u||"network error").slice(0,120)}) — transient; Refresh retries.`)}}const[P,je]=f.useState(""),[Ae,Fe]=f.useState("channels"),[Ve,lt]=f.useState(!1),[pe,Ie]=f.useState([]),[ke,Z]=f.useState("all"),K=f.useRef(null),[xe,Ee]=f.useState(null),De=f.useRef(""),[te,J]=f.useState(""),[ve,G]=f.useState(!1),[Se,Ge]=f.useState({}),[ze,Qe]=f.useState({}),[ee,U]=f.useState({}),se=f.useRef(new Set),le=f.useRef(0),[Ue,ut]=f.useState(""),[mt,ot]=f.useState(""),[dt,bt]=f.useState([]),[Re,rt]=f.useState(!1),vt=f.useRef(null),[zt,wt]=f.useState(!1),tn=f.useRef(null);f.useEffect(()=>{const u=tn.current;u&&(u.style.height="auto",u.style.height=`${Math.min(u.scrollHeight+2,160)}px`)},[Ue,P]);const[_e,Ce]=f.useState("fyi"),[Ye,_t]=f.useState(""),[ht,jt]=f.useState(""),[st,Cn]=f.useState(null),[Cs,Xa]=f.useState({}),[$s,os]=f.useState(""),nn=f.useRef(ox()),Vs=f.useRef(""),[Gs,Es]=f.useState(!1),[$i,Ts]=f.useState(!1),[Or,ct]=f.useState(""),[Ht,Za]=f.useState(null),[Mt,er]=f.useState(null),[Ei,Bl]=f.useState({});function Ti(u,v){v.length&&Bl(S=>{const k={...S},T=new Set(k[u]||[]);for(const re of v)T.add(re);return k[u]=T,k})}function It(u,v){const S=new Set(v.map(k=>String(k.agent_id||"")).filter(Boolean));S.size&&Bl(k=>{const T=k[u];if(!T||![...T].some(we=>S.has(we)))return k;const re=new Set([...T].filter(we=>!S.has(we))),B={...k};return re.size?B[u]=re:delete B[u],B})}const Dr=f.useRef(0),[Fr,tr]=f.useState(""),[Ks,Ul]=f.useState(null),[qr,cs]=f.useState(""),[hn,Br]=f.useState(!1),[pn,Wl]=f.useState(""),[pa,Hl]=f.useState([]);function _a(){l.delegations().then(u=>{Ul(u),cs("")}).catch(u=>{Ul([]);const v=String((u==null?void 0:u.message)||u);cs((u==null?void 0:u.status)===404||/allowlist/i.test(v)?"Delegation needs the updated console/hub — restart the stack to pick it up.":v)})}async function Ur(){if(!(!pn||!pa.length||hn)){Br(!0),cs("");try{await l.set_delegation(pn,pa),Wl(""),Hl([]),_a()}catch(u){cs(String((u==null?void 0:u.message)||u||"delegation failed"))}finally{Br(!1)}}}async function nr(u){if(!hn){Br(!0),cs("");try{await l.revoke_delegation(u),_a()}catch(v){cs(String((v==null?void 0:v.message)||v||"resign failed"))}finally{Br(!1)}}}const[bn,Qs]=f.useState(null),[Wr,As]=f.useState(null),[Vt,Xt]=f.useState(""),[Rs,ga]=f.useState(null),[Ls,kt]=f.useState([]),[Gt,us]=f.useState(""),[Hr,zn]=f.useState(""),[Vr,Ai]=f.useState(""),[sr,ar]=f.useState(!1),[ds,Kn]=f.useState(""),[$n,Ms]=f.useState({open:!1,name:"",is_private:!1}),[on,_n]=f.useState(!1),[lc,va]=f.useState({}),[Et,Qn]=f.useState(""),[Pn,ya]=f.useState(null),[Gr,Vl]=f.useState(""),[wn,xa]=f.useState("channel"),[ms,rr]=f.useState(""),[Ri,ir]=f.useState(null),[Kr,lr]=f.useState(""),[or,Li]=f.useState(""),[In,fs]=f.useState(""),[Js,Qr]=f.useState(null),[ba,wa]=f.useState(""),[Ys,sn]=f.useState(""),[ja,Kt]=f.useState(null),[zs,Mi]=f.useState([]),[Jr,cr]=f.useState(""),[Xs,ka]=f.useState(!1),[zi,Pi]=f.useState(""),[Gl,Kl]=f.useState(""),Yr=f.useRef(null),Ql=f.useRef(0),Ii=f.useRef(!1),Jl=f.useRef(0),[Oi,Di]=f.useState(!1),Fi=f.useRef(""),On=f.useRef([]),Ps=f.useRef([]),Is=f.useRef(null),qi=f.useRef(!1),ur=f.useRef(null);Fi.current=P,On.current=fe,Ps.current=pe,f.useEffect(()=>{for(const u of pe){const v=mr.current[u.id];v!==void 0&&u.ratings&&Number(u.ratings.mine||0)===v&&delete mr.current[u.id]}},[pe]);const Bi=f.useRef(!1);async function oc(u){var v;try{const S=await l.inbox(),k=Cy(S),T=$y(S);ye(He=>Uu(He,T)?He:T);const re=Ey(S,((v=D.current)==null?void 0:v.seat)||"");q(He=>Uu(He,re)?He:re);const B=Ty(S);V(He=>Uu(He,B)?He:B),ge();const we=u.slice(0,rx),Pe=await Promise.allSettled(we.map(He=>l.digest(He.name))),qe={};for(const He of u)qe[He.name]={unread:k[He.name]||0,open_questions:0};Pe.forEach((He,$t)=>{var jn;const Pt=we[$t].name;if(He.status==="fulfilled"){const yt=(jn=He.value)==null?void 0:jn.counts;qe[Pt]={...qe[Pt],open_questions:Number((yt==null?void 0:yt.open_questions)||0)}}}),Me(He=>Bu(He,qe)?He:qe)}catch{}}async function Sa(u){if(qi.current){ur.current=u;return}qi.current=!0;let v=u;try{for(;v;)ur.current=null,await oc(v),v=ur.current}finally{qi.current=!1}}async function Na(){const v=[...await l.channels()];return v.sort((S,k)=>(k.last_at||0)-(S.last_at||0)),oe(S=>Bu(S,v)?S:v),On.current=v,v}async function hs(){try{const[u,v]=await Promise.all([l.meta(),l.channels()]);O({seat:u.seat,seat_key_present:u.seat_key_present}),H(String(u.hub_url||"")),l.healthz().then(T=>ae(T)).catch(()=>ae(null)),l.presence().then(T=>{const re=[...new Set(T.map(B=>String(B.agent_id||"")).filter(B=>B&&B!==u.seat))].sort();kt(re)}).catch(()=>kt([]));const S=[...v];S.sort((T,re)=>(re.last_at||0)-(T.last_at||0)),oe(S);const k=S.filter(T=>!T.name.startsWith("dm:"));!P&&k.length&&je(k[0].name),J(""),Sa(S)}catch(u){J(String((u==null?void 0:u.message)||u||"Hub unreachable"))}}async function Zs(u,v){var k,T,re;if(!u)return;const S=le.current;v!=null&&v.background||G(!0);try{const B=Ps.current.length&&Ps.current[Ps.current.length-1].seq||0,we=((k=On.current.find(at=>at.name===u))==null?void 0:k.last_seq)||0;let Pe=we,qe=null;if(!(v!=null&&v.background))if(we>0)qe=Na().catch(()=>null);else try{const at=await Na();if(S!==le.current)return;Pe=((T=at.find(Rt=>Rt.name===u))==null?void 0:T.last_seq)||0}catch{}const He=Math.max(0,Pe-fa),$t=v!=null&&v.background&&B>0?Math.max(0,B-ax):He,Pt=await l.messages(u,{since:$t,limit:fa});if(S!==le.current)return;const jn=new Set(Ps.current.map(at=>at.id)),yt=Pt.some(at=>!jn.has(at.id));if(v!=null&&v.background&&!yt&&B>0){const at=Date.now();if(at-Jl.current>1e4){Jl.current=at;try{const Rt=await Na();if(S!==le.current)return;const pt=((re=Rt.find(Be=>Be.name===u))==null?void 0:re.last_seq)||0;if(pt>0&&pt<B){const Be=Math.max(0,pt-fa),St=await l.messages(u,{since:Be,limit:fa});if(S!==le.current)return;St.sort((Dt,Bt)=>(Dt.seq||0)-(Bt.seq||0)),Ie(St),J("");return}}catch{}}}Pt.sort((at,Rt)=>(at.seq||0)-(Rt.seq||0)),Ie(at=>{if(v!=null&&v.background&&at.length){if(!Pt.length)return at;const Rt=new Set(at.map(Zt=>Zt.id)),pt=Pt.filter(Zt=>!Rt.has(Zt.id)),Be=new Map(Pt.map(Zt=>[Zt.id,Zt]));let St=0;const Dt=at.map(Zt=>{const Lt=Be.get(Zt.id);if(!Lt)return Zt;const Jt=JSON.stringify(Lt.ratings??null)!==JSON.stringify(Zt.ratings??null)||(Lt.has_resolved_reply??null)!==(Zt.has_resolved_reply??null)||JSON.stringify(Lt.pending_asks??null)!==JSON.stringify(Zt.pending_asks??null)||!!Lt.retracted!=!!Zt.retracted;return Jt&&St++,Jt?Lt:Zt});if(!pt.length&&!St)return at;const Bt=[...St?Dt:at,...pt];return Bt.length>fa*2?Bt.slice(Bt.length-fa*2):Bt}return Pt}),J(""),!(v!=null&&v.background)&&qe&&(async()=>{var at;try{const Rt=await qe;if(S!==le.current||!Rt)return;const pt=((at=Rt.find(Be=>Be.name===u))==null?void 0:at.last_seq)||0;if(pt>0&&pt!==we){const Be=Math.max(0,pt-fa),St=await l.messages(u,{since:Be,limit:fa});if(S!==le.current)return;St.sort((Dt,Bt)=>(Dt.seq||0)-(Bt.seq||0)),Ie(Dt=>Bu(Dt,St)?Dt:St)}}catch{}})()}catch(B){if(S!==le.current)return;J(String((B==null?void 0:B.message)||B||"Failed to load messages"))}finally{!(v!=null&&v.background)&&S===le.current&&G(!1)}}f.useEffect(()=>{hs()},[]),f.useEffect(()=>{let u=null,v=!1,S=0,k=0;const T=()=>{if(!v){try{u=new WebSocket(l.ws_url())}catch{Di(!1),S+=1,setTimeout(T,Math.min(15e3,1e3*Math.max(1,S)));return}u.onopen=()=>{Di(!0),k=Date.now(),(!On.current.length||!D.current)&&hs()},u.onmessage=re=>{var B;try{const we=JSON.parse(String(re.data||"{}"));if((we==null?void 0:we.type)!=="envelope")return;const Pe=String(((B=we.envelope)==null?void 0:B.channel)||"");Pe&&Pe===Fi.current&&Zs(Pe,{background:!0}),Pe&&!On.current.some(qe=>qe.name===Pe)&&Na(),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Sa(On.current),800)}catch{}},u.onclose=()=>{Di(!1),v||(k&&Date.now()-k>=15e3?S=0:S+=1,k=0,setTimeout(T,Math.min(15e3,1e3*Math.max(1,S))))},u.onerror=()=>{try{u==null||u.close()}catch{}}}};return T(),()=>{v=!0,Is.current&&clearTimeout(Is.current);try{u==null||u.close()}catch{}}},[]),f.useEffect(()=>{le.current+=1,Ge({}),Qe({}),U({}),se.current=new Set,Za(null),er(null);try{C.stop_tts()}catch{}Dr.current=0,mr.current={},Ct("recency"),Ta(null),yr(""),Qr(null),wa(""),sn(""),Kt(null),Qs(null),As(null),ga(null),Xt(""),zn(""),va({}),Mi([]),Pi(""),Kl(""),ka(!1),cr(""),Ie([]),Z(K.current||"all"),K.current=null,Cn(null),Xa({}),os(""),bt([]),Vs.current&&Vs.current!==P&&(Ue||mt?nn.current[Vs.current]={text:Ue,title:mt,kind:_e}:delete nn.current[Vs.current],Rl(nn.current));const u=nn.current[P];if(ut((u==null?void 0:u.text)||""),ot((u==null?void 0:u.title)||""),Ce((u==null?void 0:u.kind)||"fyi"),Vs.current=P,Bi.current=!0,Zs(P),!P)return;Et==="files"&&Ki(),Et==="members"&&dr();const v=setInterval(()=>{Ql.current+=1,Ii.current||(Ii.current=!0,Zs(P,{background:!0}).finally(()=>{Ii.current=!1})),Ql.current%sx===0&&(Na().then(S=>Sa(S)).catch(()=>Sa(On.current)),l.healthz().then(ae).catch(()=>{}),l.meta().then(S=>O(S)).catch(()=>{}))},nx);return()=>clearInterval(v)},[P]);const Yl=f.useRef({text:"",title:"",kind:"fyi",selected:""});Yl.current={text:Ue,title:mt,kind:_e,selected:P},f.useEffect(()=>{if(!P)return;const u=setTimeout(()=>{Ue||mt?nn.current[P]={text:Ue,title:mt,kind:_e}:delete nn.current[P],Rl(nn.current)},300);return()=>clearTimeout(u)},[Ue,mt,_e,P]),f.useEffect(()=>{const u=()=>{const v=Yl.current;v.selected&&(v.text||v.title?nn.current[v.selected]={text:v.text,title:v.title,kind:v.kind}:delete nn.current[v.selected],Rl(nn.current))};return window.addEventListener("pagehide",u),window.addEventListener("beforeunload",u),()=>{window.removeEventListener("pagehide",u),window.removeEventListener("beforeunload",u),u()}},[]),f.useEffect(()=>{const u=Yr.current;if(!u||!pe.length)return;if(Bi.current){Bi.current=!1,u.scrollTop=u.scrollHeight;return}u.scrollHeight-u.scrollTop-u.clientHeight<240&&(u.scrollTop=u.scrollHeight)},[pe]),f.useEffect(()=>{if(ke!=="unread"||!P){Ee(null);return}const u=be[P];Ee(new Set(u||[])),De.current=""},[ke,P]),f.useEffect(()=>{if(ke!=="unread"||!P||!xe||!xe.size)return;const u=Math.min(...xe),v=pe.length&&pe[0].seq||0;if(!u||!v||v<=u)return;const S=`${P}:${u}`;if(De.current===S)return;De.current=S;const k=le.current;l.messages(P,{since:Math.max(0,u-1),limit:fa}).then(T=>{k!==le.current||!T.length||Ie(re=>{const B=new Set(re.map(Pe=>Pe.id)),we=T.filter(Pe=>!B.has(Pe.id));return we.length?[...re,...we].sort((Pe,qe)=>(Pe.seq||0)-(qe.seq||0)):re})}).catch(()=>{k===le.current&&(ct("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ct(""),6e3))})},[ke,P,xe,pe]);function Xl(u){se.current.has(u.id)||(se.current.add(u.id),l.read_message(u.channel,u.id).catch(()=>{}),l.ack(u.channel,u.seq).catch(()=>{}),ye(v=>{const S=v[u.channel];if(!S||!S.has(u.seq))return v;const k=new Set(S);return k.delete(u.seq),{...v,[u.channel]:k}}),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Sa(On.current),500),u.critical&&(ct(`Read recorded for critical #${u.seq}.`),setTimeout(()=>ct(""),2500)))}function Zl(u){const v=!Se[u.id];Ge(S=>({...S,[u.id]:v})),v&&Xl(u)}function cc(u){const v=window.getSelection();if(v&&!v.isCollapsed)return;const S=String(u.body||""),k=u.status==="reply"?Gf:Xo;S.length>k?Zl(u):Xl(u)}async function uc(){if(!P||Ht==="running")return;const u=le.current;Za("running");try{const v=await l.ledger(P),S=await tx(v);if(u!==le.current)return;Za(S)}catch(v){if(u!==le.current)return;Za({error:String((v==null?void 0:v.message)||v||"verification failed")})}}function dr(){{const u=le.current;er("loading"),Qs(null),tr(""),As(null),l.channel_info(P).then(v=>{u===le.current&&er(v)}).catch(v=>{u===le.current&&er({error:String((v==null?void 0:v.message)||v||"info failed")})}),l.members(P).then(v=>{u===le.current&&(Qs(v),tr(""),It(P,v))}).catch(v=>{u===le.current&&(Qs([]),tr(String((v==null?void 0:v.message)||v||"members unavailable")))}),l.list_blocks().then(v=>{u===le.current&&As(v)}).catch(()=>{u===le.current&&As([])}),l.retired_agents().then(v=>{u===le.current&&ga(v)}).catch(()=>{u===le.current&&ga([])})}}function ns(u){const v=Et===u?"":u;if(Qn(v),v==="files"&&Ki(),v==="members"){let S=0;for(const k of Ps.current)String(k.sender||"")==="hub"&&(k.seq||0)>S&&(S=k.seq||0);Dr.current=S,dr(),_a()}v==="leaderboard"&&Ui(wn),v==="desk"&&de()}function Ui(u){const v=le.current;ya(null),Vl(""),rr(""),ir(null),fs(""),(u==="hub"?l.reputation_hub():l.reputation(P)).then(k=>{v===le.current&&ya(k)}).catch(k=>{if(v!==le.current)return;const T=Number((k==null?void 0:k.status)||0);Vl(T===404||T===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((k==null?void 0:k.message)||k||"failed to load leaderboard"))})}function Wi(u){const v=ms===u?"":u;if(rr(v),ir(null),fs(""),!v||wn==="hub")return;const S=le.current;l.reputation_votes(P,v).then(k=>{S===le.current&&ir(k)}).catch(k=>{S===le.current&&(ir(null),fs(`votes list failed: ${String((k==null?void 0:k.message)||k||"fetch failed")}`))})}const[Xr,Hi]=f.useState(""),[ea,Zr]=f.useState("");f.useEffect(()=>{if(!ea)return;const u=setTimeout(()=>Zr(""),6e3);return()=>clearTimeout(u)},[ea]);async function Ca(u){if(ea!==u.id){Zr(u.id);return}Zr("");try{const v=Array.isArray(u.pending_asks)?u.pending_asks.filter(Boolean):[];await l.post_message(u.channel,{body:`Declined on the record by ${(M==null?void 0:M.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:u.id,to:u.sender?[u.sender]:void 0,...v.length?{answers:v}:{}}),q(S=>{const k=S[u.channel];if(!(k!=null&&k.has(u.seq)))return S;const T=new Set(k);return T.delete(u.seq),{...S,[u.channel]:T}})}catch(v){J(String((v==null?void 0:v.message)||v||"decline failed"))}}const mr=f.useRef({});function Vi(u){const v=u.ratings;return v?Vy(v,mr.current[u.id]):null}async function eo(u,v){var T,re;const S=(M==null?void 0:M.seat)||"";if(!u||!S||Xr)return;const k=Ps.current.find(B=>B.id===u)||((T=Aa.current)==null?void 0:T.find(B=>B.id===u));if(k){Hi(`${u}:${v}`),fs("");try{const B=((re=Vi(k))==null?void 0:re.mine)??0;B===v?await l.unrate_message(P,u):await l.rate_message(P,u,v),mr.current[u]=B===v?0:v}catch(B){fs(String((B==null?void 0:B.message)||B||"rating failed"))}finally{Hi("")}}}async function Gi(u,v,S){if(!or){Li(`${u}:${v}:${S}`),fs("");try{await l.rate(P,u,v,S,Kr.trim()),lr("");const k=le.current,[T,re]=await Promise.all([l.reputation(P),l.reputation_votes(P,u)]);k===le.current&&(ya(T),ir(re))}catch(k){fs(String((k==null?void 0:k.message)||k||"vote failed"))}finally{Li("")}}}function Ki(){const u=le.current;Qr(null),wa(""),sn(""),l.fs_list(P).then(v=>{u===le.current&&Qr(v)}).catch(v=>{u===le.current&&wa(String((v==null?void 0:v.message)||v||"failed to list files"))})}async function fr(u){const v=le.current,S=Lr(u.path,"text/markdown"),k=`${u.updated_by||"?"} · ${Ml(u.updated_at)} · v${u.version}`;Kt({name:u.path,mode:S==="image"?"text":S,meta:k,loading:!0});try{const T=await l.fs_read(P,u.path);if(v!==le.current)return;const re=Lr(u.path,T.mime);Kt({name:u.path,mode:re==="image"?"text":re,text:Zo(T.content),content_type:T.mime,meta:k,loading:!1})}catch(T){if(v!==le.current)return;Kt({name:u.path,mode:"text",meta:k,error:String((T==null?void 0:T.message)||T||"failed to read file")})}}const Jn=f.useRef(null);function hr(){const u=Jn.current,v=Ps.current;if(!u||!v.length)return;if(u.message_id?v.some(k=>k.id===u.message_id):!1){Jn.current=null,requestAnimationFrame(()=>{const k=document.getElementById(`hubmsg-${u.message_id}`);k==null||k.scrollIntoView({block:"center"}),k==null||k.classList.add("hit"),setTimeout(()=>k==null?void 0:k.classList.remove("hit"),2500)});return}if(u.seq&&Number.isFinite(u.seq)){const k=le.current,T=u.seq;Jn.current={...u,seq:void 0},l.messages(P,{since:Math.max(0,T-3),limit:10}).then(re=>{k!==le.current||!re.length||Ie(B=>{const we=new Set(B.map(qe=>qe.id)),Pe=re.filter(qe=>!we.has(qe.id));return Pe.length?[...B,...Pe].sort((qe,He)=>(qe.seq||0)-(He.seq||0)):B})}).catch(()=>{})}}f.useEffect(()=>{var k;if(!a.focus)return;const{channel:u,message_id:v,seq:S}=a.focus;(k=a.on_focus_consumed)==null||k.call(a),u&&(Jn.current={message_id:v,seq:S},Fe("thread"),u===P?hr():je(u))},[a.focus]),f.useEffect(()=>{hr()},[pe]),f.useEffect(()=>{if(Et!=="members"||!P)return;let u=0,v="";for(const k of pe){if(k.channel&&k.channel!==P||String(k.sender||"")!=="hub")continue;const T=`${String(k.title||"")} ${String(k.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(T)&&(k.seq||0)>u&&(u=k.seq||0,v=T)}if(!u||u<=Dr.current)return;const S=le.current;l.members(P).then(k=>{S===le.current&&(Dr.current=u,Qs(k),tr(""),It(P,k))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(v)&&l.list_blocks(P).then(k=>{S===le.current&&As(k)}).catch(()=>{})},[pe,Et,P]);const[ei,ti]=f.useState(null),ni=f.useRef(0);f.useEffect(()=>{if(ti(null),ni.current=0,!P)return;const u=le.current;l.fs_list(P).then(v=>{u===le.current&&ti(new Set(v.map(S=>String(S.path||"")).filter(Boolean)))}).catch(()=>{u===le.current&&ti(null)})},[P]),f.useEffect(()=>{const u=pe.reduce((S,k)=>{if(k.channel&&k.channel!==P)return S;const T=String(k.title||"");return(T.startsWith("fs:put")||T.startsWith("fs:delete"))&&(k.seq||0)>S?k.seq||0:S},0);if(!u||u<=ni.current)return;const v=le.current;l.fs_list(P).then(S=>{v===le.current&&(ni.current=u,ti(new Set(S.map(k=>String(k.path||"")).filter(Boolean))))}).catch(()=>{})},[pe,P]);async function Qi(u){const v=le.current,S=Lr(u,"text/markdown");Kt({name:u,mode:S==="image"?"text":S,loading:!0});try{const k=await l.fs_read(P,u);if(v!==le.current)return;const T=Lr(u,k.mime),re=k.updated_by?`${k.updated_by} · ${Ml(k.updated_at)} · v${k.version??"?"}`:void 0;Kt({name:u,mode:T==="image"?"text":T,text:Zo(k.content),content_type:k.mime,meta:re,loading:!1})}catch(k){if(v!==le.current)return;Kt({name:u,mode:"text",error:String((k==null?void 0:k.message)||k||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function $a(u,v){const S=le.current,k=l.attachment_url(u,v.id),T=Lr(v.filename,v.content_type);if(T==="image"){Kt({name:v.filename,mode:"image",url:k,content_type:v.content_type,size:v.size});return}if(T==="md"||T==="text"){if(v.size>Ol){Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size,error:`too large to preview inline (${Vn(v.size)} > ${Vn(Ol)}) — download to view`});return}Kt({name:v.filename,mode:T,url:k,content_type:v.content_type,size:v.size,loading:!0});try{const re=await fetch(k);if(!re.ok)throw new Error(`fetch failed (${re.status})`);const B=await re.text();if(S!==le.current)return;Kt({name:v.filename,mode:T,url:k,content_type:v.content_type,size:v.size,text:Zo(B)})}catch(re){if(S!==le.current)return;Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size,error:String((re==null?void 0:re.message)||re||"failed to load")})}return}Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size})}async function pr(u,v,S="channel"){if(!Gt){us(`${S}:${v}:${u}`),zn("");try{S==="hub"?v==="unblock"?await l.hub_unblock(u):await l.hub_block(u,v==="kick"?{seconds:3600,reason:"hub kick (Continuum Team page)"}:{reason:"hub ban (Continuum Team page)"}):v==="unblock"?await l.unblock(P,u):await l.block(P,u,v==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ct(`${S==="hub"?"hub ":""}${v} → ${u} applied.`),setTimeout(()=>ct(""),3e3);const k=le.current,T=await l.members(P).catch(()=>null);T&&k===le.current&&Qs(T);const re=await l.list_blocks().catch(()=>null);re&&k===le.current&&As(re)}catch(k){zn(String((k==null?void 0:k.message)||k||"moderation refused"))}finally{us("")}}}async function to(u){if(!Gt){us(`retire:${u}`),zn("");try{await l.retire_agent(u,"decommissioned via Continuum Team page"),Xt(""),ct(`${u} retired (decommissioned — not banned).`),setTimeout(()=>ct(""),3500);const v=le.current,S=await l.members(P).catch(()=>null);S&&v===le.current&&Qs(S);const k=await l.retired_agents().catch(()=>null);k&&v===le.current&&ga(k)}catch(v){const S=v==null?void 0:v.status,k=String((v==null?void 0:v.message)||v||"");S===404||/not found|hub_route_not_allowed/i.test(k)?(ct("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ct(""),6e3)):zn(k||"retire refused")}finally{us("")}}}async function no(u){if(!Gt){us(`unretire:${u}`),zn("");try{await l.unretire_agent(u),Xt(""),ct(`${u} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ct(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ga(v)}catch(v){zn(String((v==null?void 0:v.message)||v||"un-retire refused"))}finally{us("")}}}async function dc(u){if(!Gt){us(`delete:${u}`),zn("");try{await l.delete_agent(u),Xt(""),ct(`${u} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ct(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ga(v)}catch(v){const S=String((v==null?void 0:v.message)||v);zn((v==null?void 0:v.status)===404||/not found|allowlist/i.test(S)?"Delete needs the updated hub/console (0.12.41+) — restart the stack to pick it up.":/409|active/i.test(S)?`${u} is still active — retire it first, then delete.`:S||"delete refused")}finally{us("")}}}async function so(u){if(!on){_n(!0),zn("");try{let v={state:u},S;try{const k=await l.channel_meta(P);k&&typeof k.value=="object"&&k.value&&(v={...k.value,state:u}),typeof(k==null?void 0:k.version)=="number"&&(S=k.version)}catch{}await l.put_channel_meta(P,v,S),ct(u==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ct(""),3500),dr(),hs()}catch(v){zn(String((v==null?void 0:v.message)||v||"channel state change refused"))}finally{_n(!1)}}}const[mc,ao]=f.useState("");async function fc(u){if(!on){_n(!0),J("");try{await l.leave(u),ao(""),P===u&&je(""),await hs(),ct("Direct message removed from your list."),setTimeout(()=>ct(""),3e3)}catch(v){J(String((v==null?void 0:v.message)||v||"leave refused"))}finally{_n(!1)}}}const[Yn,ta]=f.useState("");async function ro(u){if(!on){_n(!0),J("");try{await l.archive(u),ta(""),P===u&&je(""),await hs(),ct(`Channel #${u} archived (history preserved).`),setTimeout(()=>ct(""),3500)}catch(v){const S=String((v==null?void 0:v.message)||v||"");(v==null?void 0:v.status)===404||/not found|hub_route_not_allowed/i.test(S)?(ta(""),ct("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ct(""),6e3)):J(S||"archive refused")}finally{_n(!1)}}}async function Ji(){const u=$n.name.trim();if(!(!u||on)){_n(!0),J("");try{await l.create_channel(u,$n.is_private),Ms({open:!1,name:"",is_private:!1}),await hs(),je(u),ct(`Channel #${u} created.`),setTimeout(()=>ct(""),3e3)}catch(v){J(String((v==null?void 0:v.message)||v||"channel create refused"))}finally{_n(!1)}}}async function Yi(u,v){if(!c)throw new Error("AI advisor is not available");return c(u,v)}async function io(u){if(!d)return;const v=u.root.id,S=le.current,k=u.replies.length+1;va(T=>{var re;return{...T,[v]:{busy:!0,text:((re=T[v])==null?void 0:re.text)||"",error:"",count:k}}});try{const T=Uf([u.root,...u.replies]),re=`Summarize this hub discussion thread in at most 5 short bullet points: the question or claim, the positions taken, decisions reached, and anything still open. Be concrete — name senders and receipts.
108
-
109
- THREAD TRANSCRIPT:
110
- ${T.text}`,B=await Yi(re,[]);if(S!==le.current)return;const we=Wf(T.report);va(Pe=>({...Pe,[v]:{busy:!1,text:B,error:"",count:k,window:we}}))}catch(T){if(S!==le.current)return;va(re=>({...re,[v]:{busy:!1,text:"",error:String((T==null?void 0:T.message)||T||"summary failed"),count:k}}))}}async function si(u){const v=u.trim();if(!v||Xs||!d)return;const S=le.current;Qn("assistant"),ka(!0),Pi(""),Mi(k=>[...k,{role:"user",content:v}]);try{const k=Uf(pe);Kl(Wf(k.report));const T=`You are the operator's analyst for the agora hub channel #${P}. Answer from the transcript below — strategies used, deviations, who owes what, timeline of decisions. Cite message seqs like #123. If the transcript does not contain the answer, say so plainly.
111
-
112
- CHANNEL TRANSCRIPT (window):
113
- ${k.text}
114
-
115
- QUESTION: ${v}`,re=await Yi(T,zs);if(S!==le.current)return;Mi(B=>[...B,{role:"assistant",content:re}])}catch(k){if(S!==le.current)return;Pi(String((k==null?void 0:k.message)||k||"assistant failed"))}finally{S===le.current&&ka(!1)}}const[ai,lo]=f.useState(""),[ps,ri]=f.useState("");async function _r(u){if(!Gs){Es(!0),J("");try{await l.retract_message(P,u.id),ri(""),ct(`#${u.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ct(""),4e3),await Zs(P,{background:!0})}catch(v){const S=String((v==null?void 0:v.message)||v||"retract failed");J(/404|not found/i.test(S)?"Retraction ships with the hub's next bounce (0.12.16) — the running hub predates the verb. Nothing was changed.":S)}finally{Es(!1)}}}async function Xi(u){if(!Gs){Es(!0),J("");try{const v=Of(P,gt);await l.post_message(P,{body:"Resolved.",status:"resolved",to:v?[v]:void 0,reply_to:u.id}),lo(""),ct(`Marked #${u.seq} resolved.`),setTimeout(()=>ct(""),3e3),await Zs(P,{background:!0})}catch(v){J(String((v==null?void 0:v.message)||v||"Resolve failed"))}finally{Es(!1)}}}async function Zi(u){if(!u||!u.length||Re)return;const v=Array.from(u);if(dt.length+v.length>Al){J(`At most ${Al} attachments per message.`);return}const S=v.find(B=>B.size>Qf);if(S){J(`"${S.name}" is ${Vn(S.size)} — the limit is ${Vn(Qf)}.`);return}const k=le.current,T=P;rt(!0),J("");let re=0;try{for(const B of v){const we=await l.upload_attachment(T,B);if(k!==le.current||P!==T)return;bt(Pe=>[...Pe,we]),re+=1}}catch(B){const we=B==null?void 0:B.status,Pe=String((B==null?void 0:B.message)||B||"");if(we===404||/not found|hub_route_not_allowed/i.test(Pe))ct("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ct(""),6e3);else{const qe=v.length>1?` (${re} of ${v.length} attached before this)`:"";J(`${Pe||"attachment upload failed"}${qe}`)}}finally{rt(!1),vt.current&&(vt.current.value="")}}function ii(u){var S;Cn(u);const v=((S=u.data)==null?void 0:S.asks)||[];Xa(v.length===1?{[v[0].id]:!0}:{}),os(""),Ce("fyi")}function na(){Cn(null),Xa({}),os("")}async function el(u){const{title:v,members:S}=Du(u);if(!S.length){J("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const k=v||`focused work with ${S.join(", ")}`;await nl({title:k,members:S})}async function tl(u,v,S){const k=[],T=[];for(const re of S)try{const B=await fetch(l.attachment_url(u,re.id));if(!B.ok)throw new Error(`fetch ${B.status}`);const we=await B.blob(),Pe=new File([we],re.filename||"attachment",{type:re.content_type||we.type||"application/octet-stream"}),qe=await l.upload_attachment(v,Pe);k.push({id:qe.id,filename:qe.filename||re.filename})}catch(B){T.push(`${re.filename||re.id.slice(0,8)} (${String((B==null?void 0:B.message)||B)})`)}return{migrated:k,att_failed:T}}async function gr(u,v,S){try{const k=await l.create_invite(u,v);return await l.send_dm(v,{title:`invite to ${u}${S?`: ${S}`:""}`.slice(0,120),body:`You are invited to '${u}'${S?` — ${S}`:""}. Join with join_channel(channel='${u}', invite_token='${k}'), read the recent messages, and work the topic THERE.`}),null}catch(k){return String((k==null?void 0:k.message)||k)}}async function oo(u){var v,S;if(!(!P||!u)){ar(!0),Kn("");try{const k=Mt&&typeof Mt=="object"&&"meta"in Mt?String(((v=Mt.meta)==null?void 0:v.purpose)||""):"",T=!!((S=On.current.find(B=>B.name===P))!=null&&S.private);let re=null;if(T)re=await gr(P,u,k||void 0);else try{await l.send_dm(u,{title:`join ${P}${k?`: ${k}`:""}`.slice(0,120),body:`You are invited to '${P}' (public)${k?` — ${k}`:""}. Join with join_channel(channel='${P}'), read the recent messages, and work the topic THERE.`})}catch(B){re=String((B==null?void 0:B.message)||B)}re?Kn(re.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${re}`):(Kn(`Invited @${u} — join pointer DM'd.`),Ai(""),Ti(P,[u]))}finally{ar(!1),setTimeout(()=>Kn(""),8e3)}}}async function co(u,v){var S;try{const k=Du(v).members;if(!k.length)return;const T=await l.members(u),re=new Set(T.map(He=>String(He.agent_id||""))),B=k.filter(He=>!re.has(He)&&Ls.includes(He)&&He!==gt);if(!B.length)return;const we=!!((S=On.current.find(He=>He.name===u))!=null&&S.private),Pe=[],qe=[];for(const He of B)if(we){const $t=await gr(u,He);$t?qe.push(`${He} (${$t})`):Pe.push(He)}else try{await l.send_dm(He,{title:`you were mentioned in #${u}`.slice(0,120),body:`You were mentioned in #${u} (public). Join with join_channel(channel='${u}') and read the recent messages.`}),Pe.push(He)}catch($t){qe.push(`${He} (${String(($t==null?void 0:$t.message)||$t)})`)}Pe.length&&(Ti(u,Pe),ct(`Posted — @${Pe.join(", @")} ${we?"invited":"nudged"} (mentioned, not yet member${Pe.length===1?"":"s"}).`)),qe.length&&J(qe.some(He=>He.includes("outside the Team page allowlist"))?"Posted; inviting mentioned non-members needs the updated console server (one stack restart).":`Posted; invite failed for ${qe.join("; ")}.`)}catch{}}async function nl(u){var re,B;const{title:v,members:S}=u,k=[...dt],T=P;Es(!0),J("");try{const we=new Set(On.current.map(yt=>yt.name)),Pe=qu(v,we);let qe=[],He=[],$t=!1;try{const yt=await l.create_group({name:Pe,members:S,purpose:v,opening_post:((re=u.opening_body)==null?void 0:re.trim())||v,private:!0});$t=!0,qe=Array.isArray(yt==null?void 0:yt.invited)?yt.invited.map(String):S,He=Array.isArray(yt==null?void 0:yt.failed)?yt.failed.map(at=>typeof at=="string"?at:`${(at==null?void 0:at.agent)||(at==null?void 0:at.member)||(at==null?void 0:at.peer)||"?"} (${String((at==null?void 0:at.error)||(at==null?void 0:at.detail)||"failed")})`):[]}catch(yt){const at=String((yt==null?void 0:yt.message)||yt||"");if(!((yt==null?void 0:yt.status)===404||at.includes("outside the Team page allowlist")||at.includes("Not Found")))throw yt;try{await l.create_invite("__group-preflight__",S[0])}catch(pt){if(String((pt==null?void 0:pt.message)||pt).includes("outside the Team page allowlist")){J("/group needs the updated console server — this process predates the invite route. Restart the console (next stack restart picks it up) and retry; nothing was created.");return}}await l.create_channel(Pe,!0),await l.put_channel_meta(Pe,{purpose:v},0);for(const pt of S)try{const Be=await l.create_invite(Pe,pt);await l.send_dm(pt,{title:`invite to ${Pe}: ${v}`.slice(0,120),body:`You are invited to '${Pe}' — focused room: ${v}. Join with join_channel(channel='${Pe}', invite_token='${Be}'), read the opening post, and work the topic THERE (not in commons).`}),qe.push(pt)}catch(Be){He.push(`${pt} (${String((Be==null?void 0:Be.message)||Be)})`)}}const{migrated:Pt,att_failed:jn}=await tl(T,Pe,k);$t?Pt.length&&await l.post_message(Pe,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Pt}):await l.post_message(Pe,{body:((B=u.opening_body)==null?void 0:B.trim())||v,title:v.slice(0,120),status:"open",attachments:Pt.length?Pt:void 0}),Ti(Pe,qe),ct(`Room '${Pe}' created — private, ${qe.length} invited${qe.length?`: ${qe.join(", ")}`:""}.`+(Pt.length?` ${Pt.length} attachment(s) carried over.`:"")+(He.length?` Invite FAILED for ${He.join("; ")}.`:"")),He.length&&J(`Some invites failed — ${He.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),jn.length&&J(`Attachment carry-over failed for ${jn.join("; ")} — the room and post were created; re-attach in the new room.`),ut(""),ot(""),jt(""),Ce("fyi"),bt([]),delete nn.current[P],Rl(nn.current),await hs(),je(Pe),setTimeout(()=>ct(""),6e3)}catch(we){J(`group creation failed: ${String((we==null?void 0:we.message)||we)}`)}finally{Es(!1)}}async function sl(){var re;const u=Ue.trim(),v=dt.length>0,S=!st&&!P.startsWith("dm:")&&_e==="group";if(!u&&!v&&!S||Gs||!P)return;if(S){const B=Fu(ht);if(!B.length){J("Group needs at least one member — write their names like: @entity @assistant");return}const we=mt.trim()||(u?u.split(`
116
- `)[0].slice(0,80):`focused work with ${B.join(", ")}`);await nl({title:we,members:B,opening_body:u});return}if(/^\/assistant(?=\s|$)/i.test(u)){if(!d){J("AI advisor is not configured — connect a gateway or inject an advisor.");return}const B=u.replace(/^\/assistant/i,"").trim();ut(""),B?si(B):Qn("assistant");return}if(/^\/group(?=\s|$)/i.test(u)){await el(u.replace(/^\/group/i,"").trim());return}if(/^\//.test(u)){J(`Unknown command "${u.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const k=Object.entries(Cs).filter(([,B])=>B).map(([B])=>B),T=P.startsWith("dm:");if(st&&(((re=st.data)==null?void 0:re.asks)||[]).length&&!k.length&&$s!=="void_reply"){os("void_reply");return}if(!st&&!T&&_e==="ask"&&!mt.trim()&&$s!=="untitled_open"){os("untitled_open");return}if(!st&&!T&&_e==="dm"&&!Ye.trim()){J("Pick a recipient for the direct message.");return}Es(!0),J("");try{if(!st&&!T&&_e==="dm"){const B=Ye.trim(),we=[...dt],Pe=P;await l.send_dm(B,{body:u||(we.length?`(${we.length} attachment${we.length===1?"":"s"})`:u),title:mt.trim()||void 0});const qe=`dm:${[gt,B].sort().join("--")}`;if(we.length){const{migrated:He,att_failed:$t}=await tl(Pe,qe,we);He.length&&await l.post_message(qe,{body:"",to:[B],attachments:He}),ct(`DM sent to ${B}${He.length?` with ${He.length} attachment(s)`:""}.`),$t.length&&J(`Attachment carry-over failed for ${$t.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ct(`DM sent to ${B}.`);await hs(),je(qe)}else{const B=dt.map(qe=>({id:qe.id,filename:qe.filename})),we=T?Of(P,gt):"";T&&!we&&J(`#FALLBACK this dm's pair does not include seat '${gt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const Pe={body:u,title:mt.trim()||void 0,status:Ry({is_reply:!!st,in_dm:T,kind:_e}),to:we?[we]:void 0,reply_to:st==null?void 0:st.id,answers:st&&k.length?k:void 0,attachments:B.length?B:void 0};try{await l.post_message(P,Pe)}catch(qe){if(we&&/address non-members/i.test(String((qe==null?void 0:qe.message)||qe)))await l.post_message(P,{...Pe,to:void 0}),J(`#FALLBACK '${we}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw qe}ct(T?"Sent.":"Posted."),await Zs(P,{background:!0}),!T&&u&&co(P,u)}ut(""),ot(""),bt([]),Cn(null),Xa({}),Ce("fyi"),_t(""),os(""),delete nn.current[P],Rl(nn.current),setTimeout(()=>ct(""),3e3)}catch(B){J(String((B==null?void 0:B.message)||B||"Post failed"))}finally{Es(!1)}}async function uo(u){if(!(!P||!u||$i||ve)){Ts(!0);try{await l.ack(P,u),ct(`Marked read to #${u}.`),setTimeout(()=>ct(""),3e3),Sa(On.current)}catch(v){J(String((v==null?void 0:v.message)||v||"Ack failed"))}finally{Ts(!1)}}}const En=!!(M!=null&&M.seat_key_present)&&!($!=null&&$.paused),gt=(M==null?void 0:M.seat)||"",Qt=P.startsWith("dm:"),vr=(()=>{if(!Qt)return"";const u=P.slice(3);return gt&&u.startsWith(`${gt}--`)?u.slice(gt.length+2):gt&&u.endsWith(`--${gt}`)?u.slice(0,u.length-gt.length-2):u||P})(),hc=f.useMemo(()=>Ly(pe),[pe]),Os=f.useMemo(()=>({seat:gt,unread_seqs:be[P],unread_snapshot_seqs:ke==="unread"&&xe||void 0,escalated_seqs:R[P]}),[gt,be,P,ke,xe,R]),Dn=f.useMemo(()=>{if(st)return null;const u=new Set(fe.map(S=>S.name)),v=Ue.trimStart();if(/^\/group(\s|$)/i.test(v)){const{title:S,members:k}=Du(v.replace(/^\/group/i,"").trim()),T=S||(k.length?`focused work with ${k.join(", ")}`:"");return{name:T?qu(T,u):"group",members:k,source:"slash"}}if(_e==="group"&&!P.startsWith("dm:")){const S=Fu(ht),k=mt.trim()||(S.length?`focused work with ${S.join(", ")}`:"");return{name:k?qu(k,u):"group",members:S,source:"kind"}}return null},[Ue,st,fe,_e,ht,mt,P]),_s=f.useMemo(()=>Sy(pe),[pe]),sa=f.useMemo(()=>If(_s,ke,Os),[_s,ke,Os]),[Ea,Ct]=f.useState("recency"),[aa,Ta]=f.useState(null),Aa=f.useRef(null);f.useEffect(()=>{Aa.current=aa},[aa]);const[al,yr]=f.useState("");function xr(){const u=le.current;Ta(null),yr(""),l.messages(P,{sort:"votes",limit:50}).then(v=>{u===le.current&&Ta(v)}).catch(v=>{if(u!==le.current)return;const S=String((v==null?void 0:v.message)||v);yr((v==null?void 0:v.status)===400||(v==null?void 0:v.status)===404||/allowlist/i.test(S)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":S)})}function li(u){Jn.current={message_id:u.id,seq:u.seq},Ct("recency"),requestAnimationFrame(()=>hr())}const[ra,rl]=f.useState(""),[Ra,pc]=f.useState("all"),[Tn,La]=f.useState(""),[An,Ma]=f.useState(null),[br,Xn]=f.useState(null),Fn=f.useRef(0);function oi(u,v,S){if(!u&&!S)return;const k=++Fn.current;Xn(null),Ma({q:u,report:null,error:"",busy:!0}),l.search({q:u,channel:v==="channel"&&P?[P]:void 0,rated:S||void 0,sort:!u&&S?"votes":void 0}).then(T=>{k===Fn.current&&Ma({q:u,report:T,error:"",busy:!1})}).catch(T=>{if(k!==Fn.current)return;const re=String((T==null?void 0:T.message)||T);Ma({q:u,report:null,busy:!1,error:(T==null?void 0:T.status)===404||/allowlist/i.test(re)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":re})})}function mo(u){oi(u.trim(),Ra,Tn)}function il(){Fn.current+=1,Ma(null),Xn(null),La("")}function _c(u,v){const S=(An==null?void 0:An.q)||"";if(!S&&!Tn)return;const k=++Fn.current;Xn({label:u,kind:v,hits:[],total:0,cursor:null,busy:!0,error:""}),l.search({q:S,kind:v,sort:"recent",limit:50,rated:Tn||void 0,channel:Ra==="channel"&&P?[P]:void 0}).then(T=>{if(k!==Fn.current)return;const re=gs(T,v);Xn({label:u,kind:v,hits:re.hits,total:re.total,cursor:T.next_cursor??null,busy:!1,error:""})}).catch(T=>{k===Fn.current&&Xn({label:u,kind:v,hits:[],total:0,cursor:null,busy:!1,error:String((T==null?void 0:T.message)||T)})})}function ll(){const u=br,v=(An==null?void 0:An.q)||"";if(!u||!u.cursor||u.busy||!v&&!Tn)return;const S=Fn.current;Xn({...u,busy:!0}),l.search({q:v,kind:u.kind,sort:"recent",limit:50,cursor:u.cursor,rated:Tn||void 0,channel:Ra==="channel"&&P?[P]:void 0}).then(k=>{if(S!==Fn.current)return;const T=gs(k,u.kind);Xn(re=>re&&re.kind===u.kind?{...re,hits:[...re.hits,...T.hits],cursor:k.next_cursor??null,busy:!1}:re)}).catch(k=>{S===Fn.current&&Xn(T=>T&&T.kind===u.kind?{...T,busy:!1,error:String((k==null?void 0:k.message)||k)}:T)})}function gs(u,v){const S=Yo.find(T=>T.kind===v),k=S?u[S.id]:void 0;return k?{hits:k.hits||[],total:k.total||0}:{hits:[],total:0}}function fo(u){const v=String(u.channel||"");v&&(Jn.current={message_id:u.kind==="message"?u.ref:void 0,seq:u.seq??void 0},il(),Ct("recency"),v===P?hr():je(v))}async function za(u){const v=String(u.channel||""),S=String(u.ref||"");if(!v||!S)return;const k=Lr(S,"text/markdown");Kt({name:S,mode:k==="image"?"text":k,meta:`#${v}`,loading:!0});try{const T=await l.fs_read(v,S),re=Lr(S,T.mime);Kt({name:S,mode:re==="image"?"text":re,text:Zo(T.content),content_type:T.mime,meta:`#${v} · ${T.updated_by||"?"} · v${T.version??"?"}`,loading:!1})}catch(T){Kt({name:S,mode:"text",meta:`#${v}`,error:String((T==null?void 0:T.message)||T||"failed to read file")})}}function Zn(u){const v=u.kind==="message"&&!!u.channel,S=u.kind==="file"&&!!u.channel,k=v||S,T=Gy(String(u.snippet||""),u.highlights),re=u.ratings,B=String(u.channel||""),we=B?B.startsWith("dm:")?B:`#${B}`:"";return e.jsxs("div",{className:`team_search_hit${k?" clickable":""}`,onClick:k?()=>S?void za(u):fo(u):void 0,role:k?"button":void 0,title:v?"Open this message in its thread":S?"Open this file":void 0,children:[e.jsxs("div",{className:"team_search_hit_head",children:[u.kind!=="message"?e.jsx("span",{className:"team_search_kind mono",children:u.kind}):null,we?e.jsx("span",{className:"team_search_chan mono",children:we}):null,u.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${vd(String(u.sender))}, 60%, 55%)`},children:u.sender}):null,typeof u.seq=="number"&&u.seq>0?e.jsxs("span",{className:"muted mono",children:["#",u.seq]}):null,u.status==="open"||u.status==="blocked"?e.jsx("span",{className:"team_search_status mono",title:"This thread still carries an unresolved obligation",children:u.status}):null,typeof u.thread_hits=="number"&&u.thread_hits>1?e.jsxs("span",{className:"muted",title:"More matches in the same thread",children:[u.thread_hits," in thread"]}):null,re&&(re.up||re.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",re.up," ▽",re.down]}):null,u.created_at?e.jsx("span",{className:"muted team_search_time",children:Ml(u.created_at)}):null]}),String(u.title||"").trim()?e.jsx("div",{className:"team_search_title",children:u.title}):null,T.length?e.jsx("div",{className:"team_search_snippet",children:T.map((Pe,qe)=>Pe.hit?e.jsx("mark",{children:Pe.text},qe):e.jsx(Wt.Fragment,{children:Pe.text},qe))}):null,!v&&!S&&u.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:u.ref}):null]},`${u.kind}:${B}:${u.ref}`)}const wr=f.useMemo(()=>{let u=0;for(const v of sa)for(const S of[v.root,...v.replies])u=Math.max(u,S.seq||0);return u},[sa]),vs=f.useMemo(()=>{const u={};for(const v of["asks","vigilance","fyi","resolved","to_me"])u[v]=If(_s,v,Os).length;return u.unread=pe.filter(v=>{var S,k;return((S=Os.unread_seqs)==null?void 0:S.has(v.seq))||((k=Os.unread_snapshot_seqs)==null?void 0:k.has(v.seq))}).length,u},[_s,pe,Os]);function ol(){var u,v;return Mt==="loading"?e.jsx("span",{className:"muted team_note",children:"Loading channel info…"}):Mt&&typeof Mt=="object"&&"error"in Mt?e.jsx("span",{className:"page_error mono",children:Mt.error}):Mt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_info_row",children:[Mt.state?e.jsx(Hn,{tone:Mt.state==="open"?"success":"warning",size:"sm",children:Mt.state}):null,(u=Mt.channel)!=null&&u.private?e.jsx(Hn,{tone:"muted",size:"sm",children:"private"}):e.jsx(Hn,{tone:"muted",size:"sm",children:"public"}),Mt.response_sla_minutes?e.jsxs(Hn,{tone:"muted",size:"sm",title:"Expected response SLA",children:["SLA ",Math.round(Number(Mt.response_sla_minutes)/60),"h"]}):null,e.jsxs("span",{className:"muted team_note",children:[(bn??Mt.members??[]).length," members"]})]}),(v=Mt.meta)!=null&&v.purpose?e.jsx("div",{className:"team_info_purpose",children:Mt.meta.purpose}):null,Mt.charter?e.jsxs("div",{className:"team_info_charter",children:[e.jsx("div",{className:"muted team_note",style:{marginBottom:4},children:"Charter"}),e.jsx(ls,{className:"md_doc",text:Pl(String(Mt.charter))})]}):e.jsx("div",{className:"muted team_note",children:"No charter set for this channel."}),e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Members ",bn?`(${bn.length})`:""]}),!Qt&&bn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Vr,onChange:S=>Ai(S.target.value),disabled:!!sr,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Ls.filter(S=>!(bn||[]).some(k=>String(k.agent_id||"")===S)).filter(S=>!(Ei[P]||new Set).has(S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),e.jsx("button",{className:"btn",disabled:!Vr||!!sr,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void oo(Vr),children:sr?"Inviting…":"Invite"})]}):null,ds?e.jsx("div",{className:"muted team_note",children:ds}):null,(()=>{const S=[...Ei[P]||[]].filter(k=>!(bn||[]).some(T=>String(T.agent_id||"")===k));return!S.length||bn===null?null:S.map(k=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:k}),e.jsx("span",{className:"chip mono warn",title:"The invite DM is in their inbox (status=open, owed) — agents join on their next wake; this row clears itself when they do.",children:"invited — awaiting join"})]},`inv:${k}`))})(),Fr?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Fr.slice(0,100),") — an empty list below means the FETCH failed, not an empty channel. Reopen the drawer to retry."]}):null,bn===null?e.jsx("span",{className:"muted team_note",children:"Loading members…"}):bn.map(S=>{const k=String(S.agent_id||"");return k?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(S.about||""),children:k}),k!==gt&&!Qt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void pr(k,"kick"),children:Gt===`channel:kick:${k}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Vt===`channel:ban:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Vt===`channel:ban:${k}`?(Xt(""),pr(k,"ban")):Xt(`channel:ban:${k}`)},children:Gt===`channel:ban:${k}`?"banning…":Vt===`channel:ban:${k}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`hub:ban:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Vt===`hub:ban:${k}`?(Xt(""),pr(k,"ban","hub")):Xt(`hub:ban:${k}`)},children:Gt===`hub:ban:${k}`?"hub-banning…":Vt===`hub:ban:${k}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`retire:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Retire: decommission this agent WITHOUT blame — removed from all channels/rosters, the id is reserved (never reused), never shown as blocked (operator-only). Two clicks to confirm.",onClick:()=>{Vt===`retire:${k}`?(Xt(""),to(k)):Xt(`retire:${k}`)},children:Gt===`retire:${k}`?"retiring…":Vt===`retire:${k}`?"confirm retire":"retire"})]}):k===gt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},k):null})]}),!Qt&&Wr&&Wr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",Wr.length,")"]}),Wr.map(S=>{const k=String(S.agent_id||S.agent||"");if(!k)return null;const T=String(S.scope||""),re=T==="hub",B=re?"hub":"channel",we=S.expires_at?` · until ${new Date(Number(S.expires_at)*1e3).toLocaleString()}`:" · indefinite",Pe=re?"hub-wide":`#${T}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[k,e.jsxs("span",{className:"muted team_note",children:[Pe,we]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:re?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void pr(k,"unblock",B),children:Gt===`${B}:unblock:${k}`?"unblocking…":"unblock"})})]},`blocked:${T}:${k}`)})]}):null,!Qt&&Rs&&Rs.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Rs.length,")"]}),Rs.map(S=>{const k=String(S.id||"");if(!k)return null;const T=S.retired_at?` · ${new Date(Number(S.retired_at)*1e3).toLocaleDateString()}`:"";return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[k,e.jsxs("span",{className:"muted team_note",children:["decommissioned",T]})]}),e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:`team_row_expand ${Vt===`unretire:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Vt===`unretire:${k}`?(Xt(""),no(k)):Xt(`unretire:${k}`)},children:Gt===`unretire:${k}`?"un-retiring…":Vt===`unretire:${k}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Vt===`delete:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Delete from the hub: irreversible cleanup — removes this agent from every roster and board (its votes/ratings purged), id stays reserved. History keeps its old messages. Two clicks to confirm.",onClick:()=>{Vt===`delete:${k}`?(Xt(""),dc(k)):Xt(`delete:${k}`)},children:Gt===`delete:${k}`?"deleting…":Vt===`delete:${k}`?"confirm delete":"delete"})]})]},`retired:${k}`)})]}):null,e.jsxs("div",{className:"team_delegation",children:[e.jsxs("div",{className:"muted team_note team_delegation_head",children:["Hub delegation ",e.jsx("span",{title:"Hub-wide, not per-channel: a delegate holds named powers in the operator's name until the grant expires or is resigned. Every seat can verify who holds what (the list is public).",children:"ⓘ"})]}),Ks===null?e.jsx("span",{className:"muted team_note",children:qr||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Ks.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Ks.map(S=>{const k=String(S.agent_id||""),T=Array.isArray(S.powers)?S.powers.map(String):[],re=Number(S.expires_at||S.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:k}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(S.note||""),children:[T.join(" + ")||"(no powers?)",re?` · until ${new Date(re*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Vt===`resign:${k}`?"team_danger":""}`,disabled:hn,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Vt===`resign:${k}`?(Xt(""),nr(k)):Xt(`resign:${k}`)},children:hn?"resigning…":Vt===`resign:${k}`?"confirm resign":"resign"})]},k)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pn,onChange:S=>Wl(S.target.value),title:"Assign a delegate: any registered agent except operators and current delegates",children:[e.jsx("option",{value:"",children:"assign a delegate…"}),(bn??Mt.members??[]).map(S=>String(typeof S=="string"?S:(S==null?void 0:S.agent_id)||(S==null?void 0:S.id)||"")).filter(S=>S&&S!==gt&&!Ks.some(k=>String(k.agent_id)===S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),pn?e.jsxs("div",{className:"team_delegation_powers_pick",children:[cx.map(S=>e.jsxs("label",{className:"team_delegation_power",title:S.help,children:[e.jsx("input",{type:"checkbox",checked:pa.includes(S.id),onChange:k=>Hl(T=>k.target.checked?[...T,S.id]:T.filter(re=>re!==S.id))}),S.id]},S.id)),e.jsx("button",{className:"btn",disabled:hn||!pa.length,title:pa.length?`Grant ${pn} the powers: ${pa.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Ur(),children:hn?"Assigning…":"Assign"})]}):null]}),qr?e.jsx("div",{className:"page_error mono",children:qr}):null]})]}),Qt?null:e.jsx("div",{className:"team_chan_admin",children:At?String(Mt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:on,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void so("closed"),children:on?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:on,title:"Reopen this channel for member posts",onClick:()=>void so("open"),children:on?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",xs||"unknown",")."]})}),Hr?e.jsx("div",{className:"page_error mono",children:Hr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function gc(u){var S;const v=((S=u.data)==null?void 0:S.attachments)||u.attachments||[];return v.length?e.jsx("div",{className:"team_attachments",children:v.map((k,T)=>{const re=`${k.id}:${T}`,B=l.attachment_url(u.channel,k.id);return ix.has(String(k.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${k.filename} · ${Vn(k.size)} — click to preview`,onClick:()=>void $a(u.channel,k),children:[e.jsx("img",{className:"team_attach_img",src:B,alt:k.filename,loading:"lazy",onError:Pe=>{var $t;const qe=Pe.currentTarget;qe.style.display="none";const He=($t=qe.parentElement)==null?void 0:$t.querySelector(".team_attach_fallback");He&&(He.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(et,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:k.filename}),e.jsx("span",{className:"muted",children:Vn(k.size)})]})]},re):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${k.content_type} · ${Vn(k.size)} — click to preview`,onClick:()=>void $a(u.channel,k),children:[e.jsx(et,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:k.filename}),e.jsx("span",{className:"muted",children:Vn(k.size)})]},re)})}):null}function vc(u,v){var we;const S=[],k=String(u.status||"").toLowerCase();(k==="open"||k==="blocked")&&(u.has_resolved_reply===!0||(u.id?hc.has(u.id):!1))?S.push(e.jsx(Hn,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):k==="open"||k==="blocked"?S.push(e.jsx(Hn,{tone:k==="blocked"?"error":"warning",size:"sm",children:k},"st")):k==="resolved"&&v&&S.push(e.jsx(Hn,{tone:"success",size:"sm",children:"resolved"},"st")),u.critical&&S.push(e.jsx(Hn,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const re=((we=u.data)==null?void 0:we.answers)||[];k==="reply"&&re.length&&S.push(e.jsxs(Hn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${re.join(", ")} of its parent.`,children:["✓ answers ",re.join(",")]},"dis"));const B=u.to||[];for(const Pe of B.slice(0,2))S.push(e.jsxs(Hn,{tone:"muted",size:"sm",children:["@",Pe]},`to:${Pe}`));return B.length>2&&S.push(e.jsxs(Hn,{tone:"muted",size:"sm",title:B.map(Pe=>`@${Pe}`).join(" "),children:["+",B.length-2]},"to+")),S}function ys(u,v){return e.jsx(Ph,{resetKey:`${u.retracted?1:0}:${(u.body||"").length}:${(u.title||"").length}`,fallback:e.jsx("div",{className:"team_row team_row_broken",id:`hubmsg-${u.id}`,children:e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[e.jsx("span",{className:"team_row_sender",style:Yf(u.sender),children:u.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",u.seq," · ",Ll(u.created_at)]}),e.jsx("span",{className:"chip mono warn",title:"This message failed to render; showing its raw text so nothing is hidden.",children:"render failed"})]}),e.jsx("pre",{className:"team_row_raw",children:(u.title?u.title+`
117
- `:"")+String(u.body||"(no text)")})]})}),children:jr(u,v)},u.id)}function jr(u,v){var yt,at,Rt,pt;const S=!!Se[u.id],k=String(u.body||""),T=v.is_root?Xo:Gf,re=k.length>T,B=re&&!S,we=((yt=u.data)==null?void 0:yt.asks)||[],Pe=!!((at=Os.unread_seqs)!=null&&at.has(u.seq)),qe=ke!=="all"&&Ny(u,ke,Os),He=String(u.title||"").trim(),$t=((Rt=k.trim().split(`
118
- `)[0])==null?void 0:Rt.trim())||"",Pt=He&&(He===k.trim()||He===$t),jn=(st==null?void 0:st.id)===u.id;return e.jsxs("div",{className:`team_row ${u.sender===gt?"own":""} ${qe?"hit":""} ${jn?"replying":""} ${Pe?"unread":""} ${u.retracted?"retracted":""}`,id:`hubmsg-${u.id}`,onClick:()=>cc(u),title:re?void 0:u.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Ga(u.sender),"aria-hidden":"true",children:(u.sender[0]||"?").toUpperCase()}),e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[(pt=ue[u.channel])!=null&&pt.has(u.seq)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_chip_debt",title:"Pinned by the hub until answered: this is an open ask or a directive addressed to you — reading is not answering; reply, Decline, or Resolve the thread to clear it",children:"needs reply"}),e.jsx("button",{className:`team_chip_decline ${ea===u.id?"armed":""}`,title:ea===u.id?"Click again to decline on the record (posts a closing reply)":"Decline: close this ask without answering — posts an on-the-record reply so it stops showing everywhere",onClick:Be=>{Be.stopPropagation(),Ca(u)},children:ea===u.id?"sure? declines on the record":"decline"})]}):Pe?e.jsx("span",{className:"team_chip_new",title:"Unread — your seat has not read past this message yet; clicking the row records the read",children:"new"}):u.read===!1&&v.is_root?e.jsx("span",{className:"team_chip_seen",title:"Swept read by the cursor but never opened — you caught the tail of a burst and this one was marked read without being seen. Click to actually read it.",children:"missed?"}):null,e.jsx("span",{className:"team_row_sender",style:Yf(u.sender),children:u.sender}),vc(u,v.is_root),(()=>{const Be=Vi(u);return!Be||!Be.up&&!Be.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${Be.mine>0?"pos":Be.mine<0?"neg":""}`,title:"±1 ratings feed the sender's reputation (one system). Green/red tint = YOUR standing vote on this message; counts refresh with the poll.",children:[Be.up?`▲${Be.up}`:"",Be.up&&Be.down?" ":"",Be.down?`▼${Be.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:Ml(u.created_at),children:["#",u.seq," · ",Ll(u.created_at)]})]}),He&&!Pt?e.jsx("div",{className:"team_row_title",children:He}):null,e.jsx("div",{className:`team_row_body ${B?v.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(Yy,{className:"md_doc",text:Pl(By(Oy(k),{hub_base:F}))})}),gc(u),(()=>{var Zt;const Be=Py(`${String(u.title||"")}
119
- ${k}`),St=((Zt=u.data)==null?void 0:Zt.attachments)||u.attachments||[],Dt=Be.map(Lt=>({mention:Lt,res:Iy(Lt,ei,St)})).filter(Lt=>Lt.res!==null).filter(Lt=>{var Jt;return!(Lt.res.kind==="attachment"&&String(((Jt=St[Lt.res.attachment_index])==null?void 0:Jt.filename)||"")===Lt.mention)}),Bt=a.on_open_board?Zg(`${String(u.title||"")}
120
- ${k}`):[];return!Dt.length&&!Bt.length?null:e.jsxs("div",{className:"team_fs_chips",children:[Dt.map(({mention:Lt,res:Jt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Jt.kind==="fs"?Jt.rewritten?`Opens ${Jt.path} (the mention's path moved — matched by name in #${P}'s files)`:`Open ${Jt.path} from #${P}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:cn=>{cn.stopPropagation(),Jt.kind==="fs"?Qi(Jt.path):$a(u.channel,St[Jt.attachment_index])},children:[e.jsx(Jf,{}),e.jsx("span",{className:"team_attach_name",children:Lt}),Jt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Jt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},Lt)),Bt.map(Lt=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${Lt} — open the Board filtered to it`,onClick:Jt=>{var cn;Jt.stopPropagation(),(cn=a.on_open_board)==null||cn.call(a,Lt)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:Lt})]},`w:${Lt}`))]})})(),we.length?e.jsx("div",{className:"team_row_asks",children:we.map(Be=>e.jsxs("span",{className:"team_ask",title:Be.text,children:["ask ",Be.id,": ",Be.text.length>90?Be.text.slice(0,90)+"…":Be.text]},Be.id))}):null,re?e.jsx("button",{className:"team_row_expand",onClick:Be=>{Be.stopPropagation(),Zl(u)},children:S?"collapse":"show more"}):null]}),En?e.jsxs("div",{className:"team_row_rail",children:[u.id&&u.sender!==gt&&u.sender!=="hub"&&!u.retracted?(()=>{const Be=Vi(u);return Be?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${Be.mine>0?"up_on":""}`,title:Be.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!Xr,onClick:St=>{St.stopPropagation(),eo(u.id,1)},children:[e.jsx(et,{name:Be.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),Be.up?e.jsx("span",{className:"team_thumb_count",children:Be.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${Be.mine<0?"down_on":""}`,title:Be.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!Xr,onClick:St=>{St.stopPropagation(),eo(u.id,-1)},children:[e.jsx(et,{name:Be.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),Be.down?e.jsx("span",{className:"team_thumb_count",children:Be.down}):null]})]}):null})():null,C.tts_supported&&u.id?(()=>{const Be=C.tts_playback.key===u.id&&C.tts_playback.status==="playing",St=C.tts_playback.key===u.id&&C.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${Be||St?"team_speak_on":""}`,title:Be?"Pause":St?"Synthesizing…":_.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":Be?"Pause reading":"Read this message aloud",onClick:Dt=>{Dt.stopPropagation();const Bt=ay(u.body||u.title||"");Bt?C.toggle_tts(u.id,Bt):J("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(et,{name:Be?"pause":St?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:we.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:Be=>{Be.stopPropagation(),ii(u)},children:"↩ Reply"}),u.sender===gt&&!u.retracted?e.jsx("button",{className:`btn btn_icon ${ps===u.id?"team_danger":""}`,title:ps===u.id?"Click again to retract: the words are redacted for every reader and the message stops demanding anything":"Retract this message (agents and entities will never read the words; two clicks)",onClick:Be=>{Be.stopPropagation(),ps===u.id?_r(u):ri(u.id)},children:ps===u.id?"⌫ confirm retract":"⌫ Retract"}):null,v.is_root&&(String(u.status||"").toLowerCase()==="open"||String(u.status||"").toLowerCase()==="blocked")?e.jsx("button",{className:`btn btn_icon ${ai===u.id?"team_danger":""}`,title:ai===u.id?"Click again to close this topic (posts a resolved reply)":"Mark this topic resolved — closes the thread on the hub (two clicks)",onClick:Be=>{Be.stopPropagation(),ai===u.id?Xi(u):lo(u.id)},children:ai===u.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},u.id)}function Pa(u){const v=u.replies.length,S=!!ee[u.root.id],k=!!ze[u.root.id],T=S?[]:k||ke!=="all"||v<=Kf+1?u.replies:u.replies.slice(v-Kf),re=S?v:v-T.length,B=lc[u.root.id];return e.jsxs("div",{className:`team_thread_group ${v?"has_replies":""}`,children:[u.orphan?e.jsx("div",{className:"team_orphan mono",title:"The parent message is older than the fetched window — the trail starts mid-flight.",children:"↩ reply to an earlier message (outside the window)"}):null,ys(u.root,{is_root:!0}),re>0||v>0||String(u.root.body||"").length>Xo?e.jsxs("div",{className:"team_trail_bar",children:[v>0?e.jsx("button",{className:"team_replies_more",onClick:()=>U(we=>({...we,[u.root.id]:!we[u.root.id]})),children:S?`show ${v} repl${v===1?"y":"ies"}`:"fold thread"}):null,!S&&re>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>Qe(we=>({...we,[u.root.id]:!0})),children:["↓ ",re," earlier repl",re===1?"y":"ies"]}):null,!S&&d&&(v>0||String(u.root.body||"").length>Xo)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(B!=null&&B.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void io(u),children:B!=null&&B.busy?"✦ summarizing…":`✦ Summarize (${v+1})`}):null]}):null,!S&&v>0?e.jsx("div",{className:"team_replies",children:T.map(we=>ys(we,{is_root:!1}))}):null,!S&&(B!=null&&B.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",B.window||`${B.count} message${B.count===1?"":"s"}`]}),e.jsx("button",{className:"team_row_expand",onClick:()=>va(we=>({...we,[u.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(ls,{className:"md_doc",text:Pl(B.text)})]}):null,B!=null&&B.error?e.jsx("div",{className:"page_error mono",children:B.error}):null]},u.root.id)}const ci=pe.length?pe[pe.length-1].seq:0,cl=Math.max(ci,((Tt=fe.find(u=>u.name===P))==null?void 0:Tt.last_seq)||0),ia=((bs=fe.find(u=>u.name===P))==null?void 0:bs.member_count)||0,xs=((an=(bn||[]).find(u=>String(u.role||"")==="owner"))==null?void 0:an.agent_id)||"",At=!!gt&&xs===gt;return e.jsxs("div",{className:"page page_pad team_page",onDragOver:u=>{var v;Array.from(((v=u.dataTransfer)==null?void 0:v.types)||[]).includes("Files")&&(u.preventDefault(),En&&!Re&&wt(!0))},onDragLeave:u=>{u.currentTarget.contains(u.relatedTarget)||wt(!1)},onDrop:u=>{var v,S;(S=(v=u.dataTransfer)==null?void 0:v.files)!=null&&S.length&&(u.preventDefault(),wt(!1),!(!En||Re)&&Zi(u.dataTransfer.files))},children:[zt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Qt?vr:`#${P}`]})}):null,$!=null&&$.protocol&&$.protocol!==ec||$!=null&&$.paused||te||In||Or||M&&!M.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[M&&!M.seat_key_present?e.jsx("span",{className:"chip mono warn",title:"No hub key for this seat — read-only until Continuum can read one (the seat's entry in ~/.agora/keys.json, or --hub-token-file at launch). The seat itself is set in Settings.",children:"read-only (no seat key)"}):null,$!=null&&$.protocol&&$.protocol!==ec?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${$.protocol}; this page was written against ${ec}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",$.protocol," ≠ ",ec]}):null,$!=null&&$.paused?e.jsx("span",{className:"chip mono warn",title:"The operator paused the hub — posting resumes when it does.",children:"hub paused"}):null,te?e.jsx("span",{className:"page_error mono",children:te}):null,In?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",In]}):null,Or?e.jsx("span",{className:"chip mono ok",children:Or}):null]}):null,e.jsxs("div",{className:`team_layout ${Et?"with_drawer":""} ${Et==="leaderboard"?"drawer_wide":""} team_mobile_${Ae} ${Ve?"team_tools_open":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",onClickCapture:u=>{var v,S;(S=(v=u.target)==null?void 0:v.closest)!=null&&S.call(v,".team_channel")&&Fe("thread")},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:fe.filter(u=>!u.name.startsWith("dm:")).length}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",title:"Create a channel (you become its owner)","aria-label":"New channel",onClick:()=>Ms(u=>({...u,open:!u.open})),children:e.jsx(et,{name:"plus",size:14})})})]}),$n.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:$n.name,onChange:u=>Ms(v=>({...v,name:u.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:u=>{u.key==="Enter"&&Ji()}}),e.jsxs("label",{title:"Private channels need invites; public ones are joinable by any registered agent.",children:[e.jsx("input",{type:"checkbox",checked:$n.is_private,onChange:u=>Ms(v=>({...v,is_private:u.target.checked}))}),"private"]}),e.jsx("button",{className:"btn primary",disabled:!$n.name.trim()||on,onClick:()=>void Ji(),children:on?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[fe.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:te?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),fe.filter(u=>!u.name.startsWith("dm:")).map(u=>{const v=Ne[u.name],S=Yn===u.name;return e.jsxs("div",{className:`team_channel team_dm_row ${P===u.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>je(u.name),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&je(u.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${v!=null&&v.unread?"has_unread":""}`,children:["#",u.name]}),e.jsxs("span",{className:"team_channel_badges",children:[v!=null&&v.unread?e.jsx("span",{className:"team_badge unread",role:"button",tabIndex:0,title:`${v.unread>=100?"100 or more":v.unread} unread message(s) for your seat — the Unread tab shows the same number. Click to open with the Unread filter.`,onClick:k=>{k.stopPropagation(),u.name!==P&&(K.current="unread"),je(u.name),Z("unread")},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.stopPropagation(),u.name!==P&&(K.current="unread"),je(u.name),Z("unread"))},children:v.unread>=100?"99+":v.unread}):null,v!=null&&v.open_questions?e.jsx("span",{className:"team_badge asks",role:"button",tabIndex:0,title:`${v.open_questions} open question(s) in this room still awaiting answers (channel digest) — click to open with the Asks filter`,onClick:k=>{k.stopPropagation(),u.name!==P&&(K.current="asks"),je(u.name),Z("asks")},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.stopPropagation(),u.name!==P&&(K.current="asks"),je(u.name),Z("asks"))},children:v.open_questions}):null,e.jsx("button",{className:`team_dm_trash ${S?"arming":""}`,title:S?"Click again to archive this channel (evicts members; history preserved)":"Archive this channel — evicts everyone and drops it off rails; messages are preserved (owner/operator)","aria-label":S?"Confirm archive channel":"Archive channel",disabled:on,onClick:k=>{k.stopPropagation(),S?ro(u.name):ta(u.name)},children:e.jsx(et,{name:S?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:S?"archive? click ✕":`${u.member_count} seats · ${Ll(u.last_at)}`})]},u.name)}),(()=>{const u=fe.filter(v=>v.name.startsWith("dm:"));return u.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"team_rail_section",children:"Direct messages"}),u.map(v=>{const S=Ne[v.name],k=v.name.replace(/^dm:/,"").split("--").filter(re=>re!==gt).join("")||v.name,T=mc===v.name;return e.jsxs("div",{className:`team_channel team_dm_row ${P===v.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>je(v.name),onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&je(v.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${S!=null&&S.unread?"has_unread":""}`,children:["@",k]}),e.jsxs("span",{className:"team_channel_badges",children:[S!=null&&S.unread?e.jsx("span",{className:"team_badge unread",title:`${S.unread>=100?"100 or more":S.unread} unread message(s)`,children:S.unread>=100?"99+":S.unread}):null,e.jsx("button",{className:`team_dm_trash ${T?"arming":""}`,title:T?"Click again to remove this DM from your list":"Remove this DM from your list (history is kept; it reopens if they message you)","aria-label":T?"Confirm remove direct message":"Remove direct message",disabled:on,onClick:re=>{re.stopPropagation(),T?fc(v.name):ao(v.name)},children:e.jsx(et,{name:T?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:T?"remove? click ✕":Ll(v.last_at)})]},v.name)})]}):null})()]})]}),e.jsxs("div",{className:"pane team_thread_pane",children:[e.jsxs("div",{className:"pane_header team_thread_header",children:[e.jsx("button",{type:"button",className:"btn team_back_btn",onClick:()=>{Fe("channels"),lt(!1),Et&&Qn("")},"aria-label":"Back to channels",title:"Back to channels",children:"← Channels"}),e.jsx("button",{type:"button",className:"btn team_tools_btn",onClick:()=>lt(u=>!u),"aria-expanded":Ve,"aria-label":Ve?"Hide thread tools":"Show thread tools (filters, search, panels)",title:"Filters, search, panels and actions",children:Ve?"Less":"More"}),e.jsx("span",{className:"pane_title team_pane_title",children:P?Qt?`@${vr} — direct`:`#${P}`:"Select a channel"}),P&&ia?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{Et!=="members"&&ns("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[ia," members"]}):null,ve?e.jsx("span",{className:"muted team_note",children:"loading…"}):null,e.jsxs("span",{className:"pane_header_actions",children:[C.tts_playback.status!=="idle"?e.jsx("button",{className:"btn team_speak_stop",title:"Stop reading aloud",onClick:()=>C.stop_tts(),children:"◼ Stop reading"}):null,(()=>{const u=ke==="all"?cl:wr;return e.jsx("button",{className:"btn",onClick:()=>void uo(u),disabled:!P||!pe.length||!u||$i||ve,title:ke==="all"?"Moves your inbox cursor for this channel to the latest message in the window. The ONE explicit 'I have seen this' act (nothing acks on render).":"Moves your inbox cursor to the last message VISIBLE under this filter — messages newer than it stay unread. (The cursor is a single high-water mark: hidden rows BELOW it are cleared too.)",children:$i?"Marking…":`Mark read → #${u||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{hs(),Zs(P)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(et,{name:"refresh",size:14})}),Ht&&Ht!=="running"&&typeof Ht=="object"&&"ok"in Ht?Ht.ok?e.jsxs(Hn,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Ht.hashed} hashed turns (${Ht.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Ht.hashed,")"]}):e.jsxs(Hn,{tone:"error",size:"sm",title:Ht.broken_at!==null?`Recomputed chain diverges at seq ${Ht.broken_at} — a hashed turn was edited, inserted, or reordered.`:"Chain internally consistent but the served head does not match the last turn — the hub is presenting a different commitment.",children:["TAMPERED",Ht.broken_at!==null?` at #${Ht.broken_at}`:" (head mismatch)"]}):null,Ht&&typeof Ht=="object"&&"error"in Ht?e.jsx(Hn,{tone:"warning",size:"sm",title:Ht.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void uc(),disabled:!P||Ht==="running",title:"Fetch the channel's verbatim ledger and recompute the sha256 hash chain in this browser — independent of the hub's own verified flag.",children:Ht==="running"?"Verifying…":"Verify transcript"})]})]}),e.jsxs("div",{className:"team_filterbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Message filters",children:Pf.map(u=>{const v=ke===u.id,S=vs[u.id];return e.jsxs("button",{className:`seg_btn ${v?"active":""}`,"aria-pressed":v,title:u.title,onClick:()=>Z(u.id),children:[u.label,typeof S=="number"&&S>0?e.jsx("span",{className:"team_filter_count",children:S}):null]},u.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:u=>{u.preventDefault();const v=ra.trim();if(!v&&!Tn){La("down"),oi("",Ra,"down");return}mo(v)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:ra,onChange:u=>rl(u.target.value),onKeyDown:u=>{u.key==="Escape"&&(An&&il(),rl(""))},title:"Search everything your seat can read (Enter). Served as a grouped report: decisions, open threads, work, people, files, messages. Enter on an empty box browses rated messages (most-downvoted first).","aria-label":"Search the hub"}),An?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:il,title:"Close search results (Esc)","aria-label":"Close search results",children:"✕"}):null]}),e.jsxs("div",{className:"seg",role:"group","aria-label":"Sort order",children:[e.jsx("button",{className:`seg_btn ${Ea==="recency"?"active":""}`,"aria-pressed":Ea==="recency",title:"Threads by last activity (default)",onClick:()=>Ct("recency"),children:"Recency"}),e.jsx("button",{className:`seg_btn ${Ea==="votes"?"active":""}`,"aria-pressed":Ea==="votes",title:"The channel's most-voted messages — whole channel, ranked by net standing ±1 (hub-served order)",onClick:()=>{Ct("votes"),xr()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Oi?"on":""}`,title:Oi?"Live: agents' posts push instantly over a websocket. Your own posts from OTHER windows arrive with the 5s poll (the hub skips echoing your seat's frames back).":"Polling every 5s — the live socket is down (it reconnects automatically).",children:Oi?"● live":"◌ polling"})," · ",sa.length!==_s.length?`${sa.length} of ${_s.length} threads`:_s.length?`${_s.length} threads`:"",M!=null&&M.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",M.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:Yr,children:An?(()=>{const u=An;if(u.error)return e.jsx("div",{className:"muted team_note",children:u.error});if(u.busy||!u.report)return e.jsx("div",{className:"muted team_note",children:u.q?`Searching “${u.q}”…`:"Browsing rated messages…"});const v=u.report;if(br){const T=br;return e.jsxs("div",{className:"team_search_results",children:[e.jsxs("div",{className:"team_search_meta",children:[e.jsx("button",{className:"team_replies_more",onClick:()=>Xn(null),children:"← All results"}),e.jsxs("span",{className:"muted",children:[T.label," matching “",u.q,"” — newest first",T.total?` · ${T.hits.length} of ${T.total}`:""]})]}),T.error?e.jsx("div",{className:"muted team_note",children:T.error}):null,T.hits.map(re=>Zn(re)),T.busy?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,!T.busy&&T.cursor?e.jsx("button",{className:"team_replies_more team_search_more",onClick:ll,children:"Load more"}):null,!T.busy&&!T.hits.length&&!T.error?e.jsxs("div",{className:"muted team_note",children:["Nothing in ",T.label.toLowerCase()," matches “",u.q,"”."]}):null]})}const S=Yo.filter(T=>{var re;return!((((re=v[T.id])==null?void 0:re.total)??0)>0)}),k=S.length<Yo.length;return e.jsxs("div",{className:"team_search_results",children:[v.relaxed&&(!v.mode_used||v.mode_used==="lexical")?e.jsx("div",{className:"team_search_relaxed",title:"The strict query (all terms) found nothing, so the hub re-ran it as ANY-term (OR). Matches below are looser than what you typed.",children:"No exact matches — showing loosened (any-term) matches instead."}):null,v.notice?e.jsx("div",{className:"team_search_notice",title:"Served by the hub while search is degraded — quote this text in anything you conclude from these results.",children:v.notice}):null,e.jsxs("div",{className:"team_search_meta",children:[e.jsxs("span",{className:"muted",children:[u.q?`“${u.q}”`:`rated messages${Tn?` (${Tn==="down"?"↓ downvoted":"↑ upvoted"}, net-vote order)`:""}`," · ",v.channels_searched??0," channel",(v.channels_searched??0)===1?"":"s"," searched",v.mode_used?e.jsxs("span",{className:"team_search_mode mono",title:"Which search engine answered: fused = word + meaning matches blended; lexical = words only; semantic = meaning only. Served verbatim by the hub.",children:[" ","· ",v.mode_used,typeof v.semantic_coverage=="number"?` (${Math.round(v.semantic_coverage*100)}% embedded)`:""]}):null]}),e.jsx("span",{className:"seg team_search_rated",role:"group","aria-label":"Rated filter",children:["up","down"].map(T=>e.jsx("button",{className:`seg_btn ${Tn===T?"active":""}`,"aria-pressed":Tn===T,title:T==="up"?"Only messages with net-positive standing ratings (toggle re-runs)":"Only messages with net-negative standing ratings — where displeasure lives (toggle re-runs)",onClick:()=>{const re=Tn===T?"":T;La(re),oi(u.q,Ra,re)},children:T==="up"?"▲ rated":"▼ rated"},T))}),e.jsxs("label",{className:"team_search_scope",title:"Limit the search to the channel currently open in the rail (re-runs the query)",children:[e.jsx("input",{type:"checkbox",checked:Ra==="channel",onChange:T=>{const re=T.target.checked?"channel":"all";pc(re),oi(u.q,re,Tn)}}),"this channel only"]})]}),Yo.map(T=>{const re=v[T.id],B=(re==null?void 0:re.shown)??0,we=(re==null?void 0:re.total)??0,Pe=(re==null?void 0:re.hits)??[];return!re||!we&&!Pe.length?null:e.jsxs("div",{className:"team_search_section",children:[e.jsxs("div",{className:"team_search_section_head",children:[e.jsx("span",{className:"team_search_section_label",children:T.label}),e.jsx("span",{className:"muted mono",children:B<we?`showing ${B} of ${we}`:`${we}`}),B<we&&T.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>_c(T.label,T.kind),title:`All ${we} ${T.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Pe.map(qe=>Zn(qe))]},T.id)}),k?S.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",S.map(T=>T.label.toLowerCase()).join(", ")]}):null:e.jsx("div",{className:"muted team_note",children:u.q?`Nothing matches “${u.q}” in the channels this seat can read.`:"No rated messages match this lens."})]})})():Ea==="votes"?al?e.jsx("div",{className:"muted team_note",children:al}):aa===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):aa.length?aa.map((u,v)=>e.jsxs("div",{className:"team_top_row",children:[e.jsxs("div",{className:"team_top_rank_line",children:[e.jsxs("span",{className:"team_top_rank mono",title:"Rank by net standing rating (hub-served order)",children:["#",v+1]}),e.jsx("button",{className:"team_replies_more",onClick:()=>li(u),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),ys(u,{is_root:!0})]},u.id)):e.jsx("div",{className:"muted team_note",children:"No rated messages in this channel yet — cast the first ±1 from any message's thumbs."}):e.jsxs(e.Fragment,{children:[(()=>{const u=[];let v="";for(const S of sa){const k=S.replies.length?S.replies[S.replies.length-1]:S.root,T=ux(k.created_at);T&&T!==v&&(v=T,u.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:T})},`day:${T}:${S.root.id}`))),u.push(Pa(S))}return u})(),!sa.length&&P&&!ve?e.jsx("div",{className:"muted team_note",children:_s.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((gn=Pf.find(u=>u.id===ke))==null?void 0:gn.label)||ke})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>Z("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:u=>{u.key==="Escape"&&st&&na()},children:[st?e.jsxs("div",{className:"team_reply_banner",children:[e.jsxs("button",{className:"team_reply_target",title:"Jump to the message you are replying to",onClick:()=>{var u;(u=document.getElementById(`hubmsg-${st.id}`))==null||u.scrollIntoView({block:"center"})},children:["↩ #",st.seq," (",st.sender,") —"," ",(String(st.title||"").trim()||String(st.body||"").trim()).slice(0,80)||"(no text)"]}),(((Ds=st.data)==null?void 0:Ds.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((la=st.data)==null?void 0:la.asks)||[]).map(u=>e.jsxs("label",{title:u.text,children:[e.jsx("input",{type:"checkbox",checked:!!Cs[u.id],onChange:v=>Xa(S=>({...S,[u.id]:v.target.checked}))}),e.jsxs("span",{className:"team_reply_ask_text",children:["ask ",u.id,": ",u.text.length>70?u.text.slice(0,70)+"…":u.text]})]},u.id))}):null,e.jsx("button",{className:"team_row_expand",onClick:na,children:"cancel (Esc)"})]}):null,$s==="void_reply"?e.jsxs("div",{className:"team_nudge",children:["This reply discharges NO asks — the parent stays formally open on the hub. Check an ask above, or press ",st?"Reply":"Post"," again to send as-is."]}):null,$s==="untitled_open"?e.jsxs("div",{className:"team_nudge",children:["An ",e.jsx("code",{children:"open"})," post without a title — receivers triage by headline (hub etiquette). Add one, or press Ask again to send untitled."]}):null,Dn?e.jsx("div",{className:"team_group_preview",title:"Creates a private room, DMs invites to the mentioned seats, posts the topic as the opening open message, and switches you in",children:Dn.members.length?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_group_label",children:"group room"}),e.jsxs("span",{className:"mono team_group_name",children:["#",Dn.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",Dn.members.map(u=>`@${u}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:Dn.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!st&&!Qt&&(_e==="ask"||_e==="group")?e.jsx("input",{className:"team_ask_title",value:mt,onChange:u=>ot(u.target.value),placeholder:_e==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!En}):null,!st&&!Qt&&_e==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:ht,onChange:u=>jt(u.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!En,list:"team_roster_options"}):null,!st&&!Qt&&_e==="group"&&Ls.length?e.jsx("datalist",{id:"team_roster_options",children:Ls.map(u=>e.jsx("option",{value:`@${u}`},u))}):null,dt.length?e.jsx("div",{className:"team_attach_pending",children:dt.map(u=>e.jsxs("span",{className:"team_attach_chip",title:`${u.content_type} · ${Vn(u.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void $a(P,u),"aria-label":`Preview ${u.filename}`,children:[e.jsx(et,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:u.filename}),e.jsx("span",{className:"muted",children:Vn(u.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${u.filename}`,title:"Remove this attachment",onClick:()=>bt(v=>v.filter(S=>S.id!==u.id)),children:e.jsx(et,{name:"x",size:10})})]},u.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!st&&!Qt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:_e,onChange:u=>{const v=u.target.value,S=v==="ask"?"ask":v==="dm"?"dm":v==="group"?"group":"fyi";Ce(S),S!=="ask"&&S!=="group"&&ot(""),S!=="group"&&jt("")},disabled:!En,title:"fyi = informational · ask = expects replies (posts as status=open) · dm = private direct message · group = focused private room with invited members",children:[e.jsx("option",{value:"fyi",children:"fyi"}),e.jsx("option",{value:"ask",children:"ask"}),e.jsx("option",{value:"dm",children:"dm"}),e.jsx("option",{value:"group",children:"group"})]}):null,!st&&!Qt&&_e==="dm"?Ls.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:Ye,onChange:u=>_t(u.target.value),disabled:!En,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Ls.map(u=>e.jsx("option",{value:u,children:u},u))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:Ye,onChange:u=>_t(u.target.value),placeholder:"to: agent id",disabled:!En,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:tn,className:"team_compose_text",rows:2,value:Ue,onChange:u=>ut(u.target.value),placeholder:En?st?`Reply to #${st.seq} in #${P}…`:Qt?`Message ${vr}…`:_e==="dm"?`Direct message${Ye.trim()?` to ${Ye.trim()}`:""}…`:d?`Message #${P||"…"} as ${(M==null?void 0:M.seat)||"operator"} — or /assistant <question>`:`Message #${P||"…"} as ${(M==null?void 0:M.seat)||"operator"}`:$!=null&&$.paused?"The hub is paused by the operator — posting resumes when it does.":"Read-only: the proxy has no operator seat key.",disabled:!En,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),!Gs&&(Ue.trim()||dt.length)&&sl())}}),e.jsx("input",{ref:vt,type:"file",multiple:!0,style:{display:"none"},onChange:u=>void Zi(u.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!En||Re||dt.length>=Al,title:dt.length>=Al?`Attachment limit (${Al}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var u;return(u=vt.current)==null?void 0:u.click()},children:e.jsx(et,{name:"paperclip",size:14})}),e.jsxs("button",{className:"btn primary team_send",disabled:!En||Gs||!Ue.trim()&&!dt.length&&!(_e==="group"&&!st&&!Qt&&Fu(ht).length>0),onClick:()=>void sl(),"aria-label":Gs?"Sending":void 0,children:[e.jsx("span",{className:"team_send_icon","aria-hidden":"true",children:e.jsx(et,{name:"send",size:16})}),e.jsx("span",{className:"team_send_label",children:Gs?"Sending…":Dn!=null&&Dn.members.length||!st&&!Qt&&_e==="group"?"Create room":st?"Reply":Qt||_e==="dm"?"Send DM":_e==="ask"?"Ask":"Send"})]})]})]})]}),Et==="assistant"?e.jsxs("div",{className:"pane team_drawer team_ai_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Assistant"}),e.jsxs("span",{className:"pane_count",children:["#",P]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[zs.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",P," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",pe.length," messages) and cites seqs. It never posts to the room."]}),zs.map((u,v)=>e.jsxs("div",{className:`team_ai_turn ${u.role}`,children:[e.jsx("div",{className:"team_ai_role mono",children:u.role==="user"?"you":"analyst"}),e.jsx(ls,{className:"md_doc",text:Pl(u.content)})]},v)),zs.length&&Gl?e.jsxs("div",{className:"muted team_note",children:["Last answer read ",Gl,"."]}):null,Xs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,zi?e.jsx("div",{className:"page_error mono",children:zi}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(ic,{value:Jr,onChange:cr,onSubmit:()=>{const u=Jr;cr(""),si(u)},placeholder:d?`Ask about #${P}…`:"AI advisor is not configured for this shell.",disabled:!d,busy:Xs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,Et==="members"?e.jsxs("div",{className:"pane team_drawer team_members_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Members"}),e.jsxs("span",{className:"pane_count",children:["#",P]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:ol()})]}):null,Et==="files"?e.jsxs("div",{className:"pane team_drawer team_files_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Files"}),e.jsxs("span",{className:"pane_count",children:["#",P]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${Ys===""?"active":""}`,onClick:()=>sn(""),title:"Channel root",children:["#",P||"…"]}),Ys?Ys.split("/").map((u,v,S)=>{const k=S.slice(0,v+1).join("/");return e.jsxs(Wt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${v===S.length-1?"active":""}`,onClick:()=>sn(k),children:u})]},k)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:Js===null&&!ba?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):ba?e.jsx("div",{className:"page_error mono",children:ba}):Js&&Js.length?(()=>{const{dirs:u,leaves:v}=Ay(Js,Ys);return!u.length&&!v.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[u.map(S=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>sn(S.path),title:`${S.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(lx,{})}),e.jsx("span",{className:"team_file_path",children:S.name}),e.jsx("span",{className:"team_file_meta mono",children:S.count})]},S.path)),v.map(S=>e.jsxs("button",{className:"team_file_row",onClick:()=>void fr(S),title:`${S.updated_by||"?"} · ${Ml(S.updated_at)} · v${S.version} · ${Vn(S.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Jf,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:S.path.slice(Ys?Ys.length+1:0)}),S.description?e.jsx("span",{className:"team_file_desc muted",children:S.description}):null]}),e.jsxs("span",{className:"team_file_meta mono",children:[Vn(S.size)," · ",Ll(S.updated_at)]})]},S.path))]})})():e.jsx("div",{className:"muted team_note",children:"No files in this channel's virtual filesystem yet."})})]}):null,Et==="leaderboard"?e.jsxs("div",{className:"pane team_drawer team_lb_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Leaderboard"}),e.jsx("span",{className:"pane_count",children:wn==="hub"?"hub-wide":`#${P}`}),e.jsxs("span",{className:"pane_header_actions",children:[e.jsxs("span",{className:"team_lb_scope",role:"tablist","aria-label":"Leaderboard scope",children:[e.jsx("button",{className:`team_lb_scope_btn ${wn==="channel"?"active":""}`,onClick:()=>{xa("channel"),Ui("channel")},disabled:!P,title:`This channel's board (#${P||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${wn==="hub"?"active":""}`,onClick:()=>{xa("hub"),Ui("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:Pn===null&&!Gr?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Gr?e.jsx("div",{className:"muted team_note",children:Gr}):!Pn||Pn.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(Pn==null?void 0:Pn.categories)?`No reputation yet${wn==="channel"?" in this channel":""}. Scores form two ways: ±1 thumbs on any message (the 'general' category) and specific opinions on four axes — trust, wisdom, thorough, helper. Every standing vote counts: score = upvotes − downvotes. Be the first to rate.`:`No reputation votes yet${wn==="channel"?" in this channel":""}. Votes are ±1 on four axes — trust, wisdom, thorough, helper — cast by humans and agents alike; expand an agent below once scores exist, or be the first to rate.`}):e.jsx(e.Fragment,{children:(()=>{var k;const u=Array.isArray(Pn.categories)||Pn.leaderboard.some(T=>T.breakdown!=null||typeof T.score=="number"),v=u?(k=Pn.categories)!=null&&k.length?Pn.categories:["general",...ki.map(T=>T.id)]:[],S=u&&v.length!==5?{gridTemplateColumns:`20px 22px minmax(70px, 1.5fr) minmax(40px, 0.7fr) repeat(${v.length}, minmax(40px, 0.8fr))`}:void 0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_lb_legend","aria-hidden":"true",style:S,children:[e.jsx("span",{className:"team_lb_legend_rank",children:"#"}),e.jsx("span",{className:"team_lb_legend_avatar"}),e.jsx("span",{className:"team_lb_legend_agent",children:"Agent"}),u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"THE reputation score (operator ruling dm#129): one number — sum of every category's score. Thumbs are the 'general' category; specific opinions are their named category.",children:"Score"}),v.map(T=>e.jsx("span",{className:"team_lb_legend_axis",title:Xf[T]||`${zl(T)} — reputation category.`,children:zl(T)},T))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),ki.map(T=>e.jsx("span",{className:"team_lb_legend_axis",title:T.help,children:T.label},T.id)),e.jsx("span",{className:"team_lb_legend_axis",title:"Message ratings, collapsed per rater (agora-0122): each rater contributes ONE net sign across the agent's messages — flips cancel, farming doesn't count. ▲ raters up · ▼ raters down.",children:"Msgs"})]})]}),Pn.leaderboard.map((T,re)=>e.jsxs(Wt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${ms===T.target?"open":""}`,style:S,onClick:()=>Wi(T.target),role:"button",tabIndex:0,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),Wi(T.target))},title:wn==="hub"?`${T.target}: rated in ${T.channels||0} channel(s) by ${T.raters} rater(s)`:u?`${T.target}: ${T.raters} rater(s) — click for attributed OPINION votes (general/thumbs live on the messages themselves)`:`${T.target}: ${T.raters} rater(s) — click for the votes behind the score`,children:[e.jsx("span",{className:`team_lb_rank ${re<3?`top${re+1}`:""}`,"aria-hidden":"true",children:re<3?"●":re+1}),e.jsx("span",{className:"team_avatar",style:Ga(T.target),"aria-hidden":"true",children:T.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:T.target}),u?e.jsxs(e.Fragment,{children:[(()=>{const B=Number(T.score||0),we=T.votes;return e.jsxs("span",{className:`team_lb_total ${B>0?"pos":B<0?"neg":""}`,title:(()=>{const Pe=Object.entries(T.breakdown||{}).filter(([,qe])=>qe&&Number(qe.score||0)!==0).map(([qe,He])=>`${zl(qe)} ${Number(He.score)>0?"+":""}${Number(He.score)}`).join(" · ");return`${T.target}: score ${B>0?"+":""}${B} = ${Pe||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${we?` — total: ${we.up} up, ${we.down} down`:""}`})(),children:[B>0?`+${B}`:B,we&&(we.up||we.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[we.up,"↑"]}),e.jsxs("span",{className:we.down>0?"rv_down_hot":"rv_down",children:[we.down,"↓"]})]}):null]})})(),v.map(B=>{var He;const we=(He=T.breakdown)==null?void 0:He[B],Pe=Number((we==null?void 0:we.score)||0),qe=!!(we&&(we.up||we.down||we.raters));return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:qe?`${zl(B)}: ${Pe>0?"+":""}${Pe} (▲${we.up} ▼${we.down} voices · ${we.raters} engaged colleague${we.raters===1?"":"s"}) — ${Xf[B]||"reputation category"}`:`${zl(B)}: no standing input`,children:qe?Pe>0?`+${Pe}`:Pe:"·"},B)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`team_lb_total ${(T.total||0)>0?"pos":(T.total||0)<0?"neg":""}`,children:(T.total||0)>0?`+${T.total}`:T.total||0}),ki.map(B=>{var qe;const we=(qe=T.axes)==null?void 0:qe[B.id],Pe=(we==null?void 0:we.score)||0;return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:we?`${B.label}: ${we.up} up, ${we.down} down`:`${B.label}: no votes`,children:we?Pe>0?`+${Pe}`:Pe:"·"},B.id)}),(()=>{const B=T.messages,we=B?B.up-B.down:0;return e.jsx("span",{className:`team_lb_axis ${we>0?"pos":we<0?"neg":""}`,title:B&&(B.up||B.down)?`Message ratings: ${B.up} rater(s) net-up, ${B.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:B&&(B.up||B.down)?`▲${B.up}${B.down?` ▼${B.down}`:""}`:"·"})})()]})]}),ms===T.target&&wn==="channel"?e.jsxs("div",{className:"team_lb_detail",children:[e.jsxs("div",{className:"team_lb_cast",children:[e.jsxs("span",{className:"team_lb_cast_label",title:`Your standing vote as ${gt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",gt||"operator",":"]}),ki.map(B=>e.jsxs("span",{className:"team_lb_cast_axis",title:B.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:B.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!or||T.target===gt,onClick:we=>{we.stopPropagation(),Gi(T.target,B.id,1)},title:`+1 ${B.label} for ${T.target}`,children:e.jsx(et,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!or||T.target===gt,onClick:we=>{we.stopPropagation(),Gi(T.target,B.id,-1)},title:`-1 ${B.label} for ${T.target}`,children:e.jsx(et,{name:"thumbsDown",size:12})})]},B.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Kr,maxLength:280,onChange:B=>lr(B.target.value),onClick:B=>B.stopPropagation()}),In?e.jsx("div",{className:"team_lb_error",children:In}):null,Ri===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Ri.length===0?e.jsx("div",{className:"muted team_note",children:u?"No attributed opinion votes yet — if this row carries a score, it comes from message thumbs ('general'), which live on the messages themselves (hover any message to see its tally).":"No attributed votes yet."}):Ri.map(B=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Ga(B.rater),"aria-hidden":"true",children:B.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:B.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:B.axis}),e.jsx(et,{name:B.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${B.value>0?"pos":"neg"}`,title:B.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:B.note,children:B.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${B.rater}:${B.axis}`))]}):null,ms===T.target&&wn==="hub"?e.jsx("div",{className:"team_lb_detail",children:e.jsx("div",{className:"muted team_note",children:u?"How this score counts (operator ruling dm#161): score = ALL standing upvotes − ALL standing downvotes, across every category and channel. A flip revises its own vote; withdrawing removes it. Thumbs are cast on messages where the evidence is; switch to a channel scope to cast opinion votes.":"Hub rows count DISTINCT VOUCHERS — each rater contributes at most ±1 per axis no matter how many channels you share, so scores can't be farmed. Switch to a channel scope to see attributed votes and cast yours."})}):null]},T.target)),e.jsx("div",{className:"muted team_lb_footnote",children:u?"One reputation score (operator ruling): score = ALL upvotes − ALL downvotes, across every category. Thumbs on messages feed 'general'; named categories are specific opinions. Expand a row to cast opinions; self-votes refused.":"Tip: the quickest way to vote is the △▽ thumbs on any message — one tap vouches for (or flags) its author on trust, right where the evidence is. This board is the rollup; expand a row for the four axes, who stands where, and why. ±1 per rater per axis, revising replaces, self-votes refused."})]})})()})})]}):null,Et==="desk"?e.jsxs("div",{className:"pane team_drawer_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Operator desk"}),e.jsxs("span",{className:"pane_header_actions",style:{marginLeft:"auto",display:"inline-flex",gap:6},children:[e.jsx("button",{className:"btn",onClick:()=>void de(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[ne==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,ne===null&&me?e.jsx("div",{className:"muted team_note",children:me}):null,ne!==null&&ne!=="loading"?e.jsxs(e.Fragment,{children:[ne.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),ne.rows.map((u,v)=>{const S=Number(u.age_minutes),k=Number.isFinite(S)?S<60?`${Math.max(1,Math.round(S))}m`:S<2880?`${Math.round(S/60)}h`:`${Math.round(S/1440)}d`:"";return e.jsxs("div",{className:"team_desk_row",children:[e.jsxs("div",{className:"team_desk_row_head",children:[e.jsx("span",{className:`chip mono ${String(u.kind)==="ask"?"warn":""}`,children:String(u.kind||"ask")}),e.jsx("span",{className:"mono muted",children:String(u.who_waits||"?")}),e.jsx("span",{className:"muted",style:{marginLeft:"auto"},title:"Waiting since (oldest first)",children:k})]}),e.jsx("div",{className:"team_desk_row_what",children:String(u.what||"")}),u.one_action?e.jsxs("div",{className:"team_desk_row_needed muted",children:["→ ",String(u.one_action)]}):null,u.channel?e.jsx("button",{className:"team_row_expand",onClick:()=>{Jn.current={message_id:u.id?String(u.id):void 0,seq:Number(u.seq)||void 0},String(u.channel)===P?hr():je(String(u.channel)),Qn("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(u.id||u.key||v))}),ne.satisfied.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"muted team_note team_desk_satisfied_head",children:"Satisfied — the hub observed each item's done-condition; these clear themselves:"}),ne.satisfied.map((u,v)=>e.jsxs("div",{className:"team_desk_row satisfied",children:[e.jsxs("div",{className:"team_desk_row_head",children:[e.jsx("span",{className:"chip mono ok",children:"done"}),e.jsx("span",{className:"mono muted",children:String(u.who_waits||"")})]}),e.jsx("div",{className:"team_desk_row_what muted",children:String(u.what||"")})]},String(u.key||v)))]}):null]}):null]})]}):null,e.jsxs("div",{className:"team_drawer_rail",children:[d?e.jsx("button",{className:`team_drawer_tab ${Et==="assistant"?"active":""}`,onClick:()=>ns("assistant"),disabled:!P,"aria-pressed":Et==="assistant",title:"Channel assistant — ask an LLM about this channel (also: type /assistant in the composer)",children:"Assistant"}):null,e.jsx("button",{className:`team_drawer_tab ${Et==="members"?"active":""}`,onClick:()=>ns("members"),disabled:!P,"aria-pressed":Et==="members","aria-label":"Open channel members drawer",title:"Channel members — roster, moderation, and channel lifecycle",children:"Members"}),e.jsx("button",{className:`team_drawer_tab ${Et==="files"?"active":""}`,onClick:()=>ns("files"),disabled:!P,"aria-pressed":Et==="files","aria-label":"Open channel files drawer",title:"Channel files — browse this channel's virtual filesystem (/fs)",children:"Files"}),e.jsx("button",{className:`team_drawer_tab ${Et==="leaderboard"?"active":""}`,onClick:()=>ns("leaderboard"),disabled:!P,"aria-pressed":Et==="leaderboard","aria-label":"Open reputation leaderboard drawer",title:"Reputation leaderboard — trust, wisdom, thorough, helper; per-channel and hub-wide",children:"Leaderboard"}),(()=>{const u=ne!==null&&ne!=="loading"?ne:null,v=u?u.rows.length:0,S=u?u.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${Et==="desk"?"active":""}`,onClick:()=>ns("desk"),"aria-pressed":Et==="desk","aria-label":v?`Open the operator desk — ${v} item(s) wait on you`:"Open the operator desk",title:"Operator desk — everything blocked on YOU, with age (asks addressed to you, queue items, escalations)",children:["Desk",v?e.jsx("span",{className:"team_desk_tab_badge",children:v>99?"99+":v}):null,!v&&S?e.jsx("span",{className:"team_desk_tab_badge ok",title:"Satisfied queue items — waits you can close",children:S>99?"99+":S}):null]})})()]})]}),e.jsx(Jy,{view:ja,onClose:()=>Kt(null)})]})}const Zf=[{id:"board",label:"Board",icon:"board"},{id:"executions",label:"Executions",icon:"playCircle"},{id:"backlog",label:"Backlog",icon:"list"},{id:"agents",label:"Agents & Entities",icon:"agent"},{id:"team",label:"Team",icon:"chat"},{id:"inbox",label:"Inbox",icon:"inbox"},{id:"services",label:"Services",icon:"server"},{id:"settings",label:"Settings",icon:"gear"}],id="abstractcontinuum_settings_v1";function mx(){try{const a=window.localStorage.getItem(id)||"{}",s=JSON.parse(a);if(s&&(s.auth_token||s.gateway_url)){delete s.auth_token,delete s.gateway_url;try{window.localStorage.setItem(id,JSON.stringify(s))}catch{}}return{maintenance_ai_provider:String((s==null?void 0:s.maintenance_ai_provider)||""),maintenance_ai_model:String((s==null?void 0:s.maintenance_ai_model)||""),maintenance_ai_reasoning:String((s==null?void 0:s.maintenance_ai_reasoning)||""),backlog_advisor_agent:String((s==null?void 0:s.backlog_advisor_agent)||""),default_execution_mode:(s==null?void 0:s.default_execution_mode)==="inplace"?"inplace":"uat"}}catch{return{maintenance_ai_provider:"",maintenance_ai_model:"",maintenance_ai_reasoning:"",backlog_advisor_agent:"",default_execution_mode:"uat"}}}function fx(){var Z;const[a,s]=f.useState("board"),r=Bp("(max-width: 1023.98px)"),[l,c]=f.useState(!1),d=f.useRef(null),h=f.useRef(null),p=f.useRef(!1);f.useEffect(()=>{r||c(!1)},[r]),f.useEffect(()=>{var K,xe;if(r){if(l){const Ee=window.setTimeout(()=>{var te;const De=(te=h.current)==null?void 0:te.querySelector(".shell_nav_item.active, .shell_nav_item");De==null||De.focus()},0);return()=>window.clearTimeout(Ee)}p.current&&(document.activeElement===document.body||!document.activeElement||(K=h.current)!=null&&K.contains(document.activeElement))&&((xe=d.current)==null||xe.focus())}},[l,r]),f.useEffect(()=>{p.current=l},[l]);function _(K){s(K),c(!1)}const[y,b]=f.useState(null),[x,N]=f.useState(null),[E,I]=f.useState(()=>mx()),[C,M]=f.useState(!1),[O,D]=f.useState(!1),[F,H]=f.useState(0),[$,ae]=f.useState(!1),[fe,oe]=f.useState(!1),[Ne,Me]=B_("continuum"),[be,ye]=f.useState(0),[ue,q]=f.useState(null),[R,V]=f.useState("");f.useEffect(()=>{if(!ue)return;const K=setTimeout(()=>q(null),8e3);return()=>clearTimeout(K)},[ue]);const[ne,Y]=f.useState(!1);f.useEffect(()=>{var J;const K=((J=document.querySelector('script[type="module"][src*="assets/"]'))==null?void 0:J.getAttribute("src"))||"";if(!K)return;let xe=!1;async function Ee(){try{const ve=await fetch("./",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!ve.ok)return;const Se=(await ve.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),Ge=(Se==null?void 0:Se[1])||"";!xe&&Ge&&K&&Ge!==K&&Y(!0)}catch{}}const De=()=>void Ee();window.addEventListener("focus",De);const te=setInterval(()=>void Ee(),300*1e3);return Ee(),()=>{xe=!0,window.removeEventListener("focus",De),clearInterval(te)}},[]);function me(K){V(String(K||"")),s("executions")}f.useEffect(()=>{const K=xe=>{var Ee;Array.from(((Ee=xe.dataTransfer)==null?void 0:Ee.types)||[]).includes("Files")&&xe.preventDefault()};return window.addEventListener("dragover",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragover",K),window.removeEventListener("drop",K)}},[]);const[A,w]=f.useState(!1);f.useEffect(()=>{a==="team"&&w(!0)},[a]);function L(K){var te;const xe=K.target,Ee=(te=xe==null?void 0:xe.closest)==null?void 0:te.call(xe,"a[href]");if(!Ee||Ee.target==="_blank"||Ee.hasAttribute("download"))return;const De=Ee.getAttribute("href")||"";De.startsWith("/")&&(K.preventDefault(),window.open(De,"_blank","noopener"))}f.useEffect(()=>{try{window.localStorage.setItem(id,JSON.stringify(E))}catch{}},[E]);const X=f.useMemo(()=>new Rg({base_url:""}),[]),ge=w_({appName:"AbstractContinuum",connectionPath:Ci,onStatusChange:()=>H(K=>K+1)}),de=ge.status,P=f.useMemo(()=>A_("abstractcontinuum",$g),[]),[je,Ae]=f.useState(vf),Fe=f.useRef(0);function Ve(){const K=++Fe.current;Ae(vf),Mg(X).then(xe=>{K===Fe.current&&Ae(xe)})}const lt=f.useRef(0);f.useEffect(()=>{let K=!1,xe;return(async()=>{try{await X.list_processes(),K||(lt.current=0,M(!0))}catch{if(K)return;lt.current+=1,lt.current>=2?M(!1):xe=window.setTimeout(()=>{K||H(Ee=>Ee+1)},2e3)}})(),()=>{K=!0,xe!==void 0&&window.clearTimeout(xe)}},[X,a,F]);const pe=f.useRef(C);f.useEffect(()=>{pe.current&&!C&&(de!=null&&de.has_session)&&ge.refresh(),pe.current=C},[C,de==null?void 0:de.has_session]);async function Ie(K,xe){const Ee=[...xe.history.map(te=>({role:te.role,content:te.content})),{role:"user",content:K}],De=await X.backlog_advisor({messages:Ee,agent:E.backlog_advisor_agent||null});return String((De==null?void 0:De.reply)||"").trim()||"(the advisor returned an empty reply)"}const ke=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shell_brand",title:"AbstractContinuum — continuous development console",children:[e.jsx("span",{className:"shell_brand_mark",children:"∞"}),e.jsx("span",{className:"shell_brand_name",children:"Continuum"})]}),e.jsx("nav",{className:"shell_nav","aria-label":"Pages",children:Zf.map(K=>e.jsxs("button",{className:`shell_nav_item ${a===K.id?"active":""}`,onClick:()=>_(K.id),title:K.label,"aria-current":a===K.id?"page":void 0,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(et,{name:K.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:K.label})]},K.id))})]});return e.jsxs("div",{className:"shell",onClickCapture:L,children:[r?null:e.jsx("aside",{className:"shell_sidebar",children:ke}),e.jsxs("div",{className:"shell_main",...r&&l?{inert:""}:{},children:[e.jsxs("header",{className:"shell_header",children:[r?e.jsx("button",{ref:d,type:"button",className:"btn btn_icon shell_menu_btn","aria-label":"Open navigation","aria-expanded":l,title:"Pages",onClick:()=>c(K=>!K),children:e.jsx(et,{name:"list",size:18})}):null,e.jsx("div",{className:"shell_header_title",children:((Z=Zf.find(K=>K.id===a))==null?void 0:Z.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(D_,{assistant:{open:$,onToggle:()=>ae(K=>!K)},appearance:{onOpen:()=>oe(!0)},about:{identity:P,extraRows:je,onOpen:Ve},extraActions:e.jsxs("button",{className:"btn primary shell_newtask_btn",onClick:()=>D(!0),disabled:!C,"aria-label":"+ New task",title:"New task",children:["+",e.jsx("span",{className:"shell_newtask_label",children:" New task"})]}),connection:{phase:ge.phase,signingOut:ge.signingOut,onConnect:ge.openModal,onDisconnect:()=>void ge.signOut()}})})]}),!C&&a!=="settings"?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"Gateway unreachable or not signed in."}),e.jsx("button",{className:"btn",onClick:ge.openModal,children:"Connect"})]}):null,ge.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",ge.signOutError," — the session may still be live."]})}):null,ue?e.jsxs("div",{className:`shell_banner ${ue.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:ue.text}),e.jsx("button",{className:"btn",onClick:()=>q(null),children:"Dismiss"})]}):null,ne?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"This tab is running an older build of the console — features may render wrong until you reload."}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload now"})]}):null,e.jsxs("main",{className:"shell_content",children:[a==="board"?e.jsx(Lv,{gateway:X,gateway_connected:C,data_nonce:be,on_mutated:()=>ye(K=>K+1),on_open_executions:me,default_execution_mode:E.default_execution_mode,query_preset:y,on_query_preset_consumed:()=>b(null),on_open_team:K=>{N(K),s("team")},on_new_task:()=>D(!0)}):null,a==="executions"?e.jsx(Kv,{gateway:X,gateway_connected:C,focus_request_id:R,on_focus_consumed:()=>V(""),on_open_settings:()=>s("settings")}):null,a==="backlog"?e.jsx(xv,{gateway:X,gateway_connected:C,maintenance_ai_provider:E.maintenance_ai_provider,maintenance_ai_model:E.maintenance_ai_model,maintenance_ai_reasoning:E.maintenance_ai_reasoning,backlog_advisor_agent:E.backlog_advisor_agent,default_execution_mode:E.default_execution_mode,on_open_executions:me}):null,a==="agents"?e.jsx(Kg,{gateway:X,gateway_connected:C,backlog_advisor_agent:E.backlog_advisor_agent,on_open_assistant:()=>ae(!0),on_open_team:()=>s("team"),on_open_executions:()=>me()}):null,A?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(Ph,{fallback:K=>e.jsx("div",{className:"page page_pad",children:e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("strong",{children:"The Team view hit a render error."}),e.jsx("div",{className:"muted",style:{margin:"6px 0"},children:String(K.message||K)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(dx,{gateway:X,gateway_connected:C,advisor:C?async(K,xe)=>{const Ee=[...xe.map(te=>({role:te.role,content:te.content})),{role:"user",content:K}],De=await X.backlog_advisor({messages:Ee,agent:E.backlog_advisor_agent||null});return String((De==null?void 0:De.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:E.backlog_advisor_agent,on_open_board:K=>{b(K||null),s("board")},focus:x,on_focus_consumed:()=>N(null)})})}):null,a==="inbox"?e.jsx(Zv,{gateway:X,gateway_connected:C,enable_triage:!0}):null,a==="services"?e.jsx(Yv,{gateway:X,gateway_connected:C}):null,a==="settings"?e.jsx(my,{gateway:X,gateway_connected:C,settings:E,set_settings:I,connection:de}):null]})]}),e.jsx(x_,{...ge.modalProps}),r?e.jsx(lf,{open:l,onClose:()=>c(!1),label:"Navigation",side:"left",backdrop:!0,width:260,className:"shell_nav_drawer",children:e.jsxs("div",{ref:h,className:"shell_nav_drawer_body",children:[ke,e.jsx("button",{type:"button",className:"btn shell_nav_close",onClick:()=>c(!1),children:"Close menu"})]})}):null,e.jsx(lf,{open:$,onClose:()=>ae(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(Ng,{ask:Ie,assistantName:"Continuum advisor",blockedNotice:C?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(U_,{open:fe,onClose:()=>oe(!1),value:Ne,onChange:Me}),e.jsx(bv,{open:O,gateway:X,can_use_gateway:C,maint_provider:E.maintenance_ai_provider,maint_model:E.maintenance_ai_model,maint_reasoning:E.maintenance_ai_reasoning,on_close:()=>D(!1),on_created:async(K,xe,Ee)=>{ye(te=>te+1);const De=String(K||"");s(De==="recurrent"?"backlog":"board"),q(Ee?{text:`Task created (${xe}), but attachments failed: ${Ee}`,tone:"warn"}:{text:`Task created: ${xe} (${De||"?"})${De==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}Wp();const Vh=document.getElementById("root");if(!Vh)throw new Error("root element missing");Ip.createRoot(Vh).render(e.jsx(Wt.StrictMode,{children:e.jsx(fx,{})}));export{gy as _,Ep as g};
121
- //# sourceMappingURL=index-Ca1Qebcu.js.map