@abstractframework/continuum 0.3.2 → 0.5.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 (73) hide show
  1. package/README.md +41 -7
  2. package/bin/cli.js +16 -160
  3. package/bin/hub_proxy.js +52 -43
  4. package/bin/request_gate.js +43 -0
  5. package/bin/server.js +232 -0
  6. package/bin/settings.js +45 -28
  7. package/dist/assets/{abnfDiagram-VRR7QNED-C3nZSPxd.js → abnfDiagram-VRR7QNED-E9lbmtBV.js} +2 -2
  8. package/dist/assets/{arc-Co6CTENJ.js → arc-XVGGKtJ-.js} +2 -2
  9. package/dist/assets/{architectureDiagram-ZJ3FMSHR-CEz8QvCN.js → architectureDiagram-ZJ3FMSHR-GRV2Ej0c.js} +2 -2
  10. package/dist/assets/{blockDiagram-677ZJIJ3-B_5v6oR-.js → blockDiagram-677ZJIJ3-Dz8wPMHC.js} +2 -2
  11. package/dist/assets/{c4Diagram-LMCZKHZV-B2dYGCte.js → c4Diagram-LMCZKHZV-CAHne5Am.js} +2 -2
  12. package/dist/assets/channel-BbrZydfX.js +2 -0
  13. package/dist/assets/{chunk-2Q5K7J3B-2eGZLgzu.js → chunk-2Q5K7J3B-DFXMgoy3.js} +2 -2
  14. package/dist/assets/{chunk-32BRIVSS-szXiGdYg.js → chunk-32BRIVSS-D9T7Whin.js} +2 -2
  15. package/dist/assets/{chunk-5VM5RSS4-F7rd4WOC.js → chunk-5VM5RSS4-D8jr-VV1.js} +2 -2
  16. package/dist/assets/{chunk-EX3LRPZG-BBaSONus.js → chunk-EX3LRPZG-BSkCDWzU.js} +2 -2
  17. package/dist/assets/{chunk-JWPE2WC7-BzQLSiNr.js → chunk-JWPE2WC7-iYmSeuV1.js} +2 -2
  18. package/dist/assets/{chunk-MOJQB5TN-CV4r6R-P.js → chunk-MOJQB5TN-BxgBSbz5.js} +2 -2
  19. package/dist/assets/{chunk-RYQCIY6F-lSwdPTG2.js → chunk-RYQCIY6F-D5JkyQAc.js} +2 -2
  20. package/dist/assets/{chunk-V7JOEXUC-BVe47Wh6.js → chunk-V7JOEXUC-B_6OmmFi.js} +2 -2
  21. package/dist/assets/{chunk-VR4S4FIN-Xsn7KCEd.js → chunk-VR4S4FIN-BsoDEIUS.js} +2 -2
  22. package/dist/assets/{chunk-XXDRQBXY-DdG9ww2-.js → chunk-XXDRQBXY-DG-goPoO.js} +2 -2
  23. package/dist/assets/classDiagram-OUVF2IWQ-BvV49U6G.js +2 -0
  24. package/dist/assets/classDiagram-v2-EOCWNBFH-BvV49U6G.js +2 -0
  25. package/dist/assets/{cose-bilkent-JH36ORCC-DDdy2AQ-.js → cose-bilkent-JH36ORCC-C95YoC9P.js} +2 -2
  26. package/dist/assets/{cynefin-VYW2F7L2-PkaGuTvX.js → cynefin-VYW2F7L2-A7Vh09t2.js} +3 -3
  27. package/dist/assets/{cynefinDiagram-TSTJHNR4-BHIvz7Or.js → cynefinDiagram-TSTJHNR4-BI8-04G-.js} +2 -2
  28. package/dist/assets/{dagre-VKFMJZFB-Dt336PVs.js → dagre-VKFMJZFB-owAzFOdh.js} +2 -2
  29. package/dist/assets/{diagram-FQU43EPY-DrmE36bq.js → diagram-FQU43EPY-B8FPxd72.js} +2 -2
  30. package/dist/assets/{diagram-G47NLZAW-tpUlukyV.js → diagram-G47NLZAW-CwooMJF9.js} +2 -2
  31. package/dist/assets/{diagram-NH7WQ7WH-CO5Zb4_d.js → diagram-NH7WQ7WH-Cr-bMH-G.js} +2 -2
  32. package/dist/assets/{diagram-OA4YK3LP-B0FwAFRE.js → diagram-OA4YK3LP-3rHTMgXR.js} +2 -2
  33. package/dist/assets/{diagram-WEI45ONY-CcLxvhZ0.js → diagram-WEI45ONY-BG4PjrBn.js} +2 -2
  34. package/dist/assets/{ebnfDiagram-CCIWWBDH-CdGlfEot.js → ebnfDiagram-CCIWWBDH-B6uukG4X.js} +2 -2
  35. package/dist/assets/{erDiagram-Q63AITRT-CxYfUHK8.js → erDiagram-Q63AITRT-D3OgqYHT.js} +2 -2
  36. package/dist/assets/{flowDiagram-23GEKE2U-fW4F9z69.js → flowDiagram-23GEKE2U-CxTaDERr.js} +2 -2
  37. package/dist/assets/{ganttDiagram-NO4QXBWP-BWM-HcND.js → ganttDiagram-NO4QXBWP-CN7iAeQh.js} +2 -2
  38. package/dist/assets/{gitGraphDiagram-IHSO6WYX-BlcnohGg.js → gitGraphDiagram-IHSO6WYX-DbvcWmmM.js} +2 -2
  39. package/dist/assets/index-Ca1Qebcu.js +121 -0
  40. package/dist/assets/index-fh60G2KG.css +1 -0
  41. package/dist/assets/{infoDiagram-FWYZ7A6U-pJSOWVdi.js → infoDiagram-FWYZ7A6U-DX4NPNgR.js} +2 -2
  42. package/dist/assets/{ishikawaDiagram-FXEZZL3T-CpvrrPMQ.js → ishikawaDiagram-FXEZZL3T-DtL3v287.js} +2 -2
  43. package/dist/assets/{journeyDiagram-5HDEW3XC-DzFKBKHk.js → journeyDiagram-5HDEW3XC-CtAZFiGl.js} +2 -2
  44. package/dist/assets/{kanban-definition-HUTT4EX6-BPmBQCPR.js → kanban-definition-HUTT4EX6-CvrCkrKt.js} +2 -2
  45. package/dist/assets/{linear-DmNa6TPI.js → linear-CbLBdTPp.js} +2 -2
  46. package/dist/assets/{mermaid.core-_-YW0o95.js → mermaid.core-zt0bcQ8D.js} +6 -6
  47. package/dist/assets/{mindmap-definition-LN4V7U3C-Bdwo0rlk.js → mindmap-definition-LN4V7U3C-DU-r_mE6.js} +2 -2
  48. package/dist/assets/{pegDiagram-2B236MQR-CHZoedfQ.js → pegDiagram-2B236MQR-CoiPuGzc.js} +2 -2
  49. package/dist/assets/{pieDiagram-ENE6RG2P-Blp676Hr.js → pieDiagram-ENE6RG2P-ClUZORQg.js} +2 -2
  50. package/dist/assets/{quadrantDiagram-ABIIQ3AL-DhWHDdBX.js → quadrantDiagram-ABIIQ3AL-D0i0p2xo.js} +2 -2
  51. package/dist/assets/{railroadDiagram-RFXS5EU6-CEgbBDEg.js → railroadDiagram-RFXS5EU6-wI6Hdpa5.js} +2 -2
  52. package/dist/assets/{requirementDiagram-TGXJPOKE-Ds8x8FbV.js → requirementDiagram-TGXJPOKE-Bm4qvEra.js} +2 -2
  53. package/dist/assets/{sankeyDiagram-HTMAVEWB-yKIsBDhP.js → sankeyDiagram-HTMAVEWB-DX8is9uB.js} +2 -2
  54. package/dist/assets/{sequenceDiagram-DBY2YBRQ-DAgYlOsI.js → sequenceDiagram-DBY2YBRQ-5RpIQiJh.js} +2 -2
  55. package/dist/assets/{sizeCapture-X5ZJPWSS-C-LAlxdw.js → sizeCapture-X5ZJPWSS-ChX6cFSk.js} +2 -2
  56. package/dist/assets/{stateDiagram-2N3HPSRC-BLiS6piZ.js → stateDiagram-2N3HPSRC-Tea20pcW.js} +2 -2
  57. package/dist/assets/stateDiagram-v2-6OUMAXLB-CCBRDLbX.js +2 -0
  58. package/dist/assets/swimlanes-5IMT3BWC-BY7gSBH7.js +3 -0
  59. package/dist/assets/swimlanesDiagram-G3AALYLV-Dtz4rZCK.js +9 -0
  60. package/dist/assets/{timeline-definition-FHXFAJF6-BrJ5JJYj.js → timeline-definition-FHXFAJF6-Bq52M8-r.js} +2 -2
  61. package/dist/assets/{vennDiagram-L72KCM5P-BT9M9-9s.js → vennDiagram-L72KCM5P-BGBcMmhw.js} +2 -2
  62. package/dist/assets/{wardleyDiagram-EHGQE667-CukiKHz8.js → wardleyDiagram-EHGQE667-T3JqsmMn.js} +2 -2
  63. package/dist/assets/{xychartDiagram-FW5EYKEG-CIidttLL.js → xychartDiagram-FW5EYKEG-B0yTh8-d.js} +2 -2
  64. package/dist/index.html +7 -3
  65. package/package.json +5 -3
  66. package/dist/assets/channel-D3yEdLfb.js +0 -2
  67. package/dist/assets/classDiagram-OUVF2IWQ-DJJxVI5p.js +0 -2
  68. package/dist/assets/classDiagram-v2-EOCWNBFH-DJJxVI5p.js +0 -2
  69. package/dist/assets/index-CFGJJTR4.js +0 -123
  70. package/dist/assets/index-DAHZ6K6R.css +0 -1
  71. package/dist/assets/stateDiagram-v2-6OUMAXLB-CdmuVCk9.js +0 -2
  72. package/dist/assets/swimlanes-5IMT3BWC-Bj_dHHPI.js +0 -3
  73. package/dist/assets/swimlanesDiagram-G3AALYLV-CYrgsk-L.js +0 -9
@@ -1,123 +0,0 @@
1
- var gp=Object.defineProperty;var vp=(a,s,r)=>s in a?gp(a,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[s]=r;var kr=(a,s,r)=>vp(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 f of c)if(f.type==="childList")for(const d of f.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function r(c){const f={};return c.integrity&&(f.integrity=c.integrity),c.referrerPolicy&&(f.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?f.credentials="include":c.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function l(c){if(c.ep)return;c.ep=!0;const f=r(c);fetch(c.href,f)}})();function yp(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var pu={exports:{}},pl={},_u={exports:{}},ut={};/**
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 Wm;function xp(){if(Wm)return ut;Wm=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"),f=Symbol.for("react.provider"),d=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(j){return j===null||typeof j!="object"?null:(j=x&&j[x]||j["@@iterator"],typeof j=="function"?j:null)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},I=Object.assign,E={};function P(j,R,ee){this.props=j,this.context=R,this.refs=E,this.updater=ee||C}P.prototype.isReactComponent={},P.prototype.setState=function(j,R){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,R,"setState")},P.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function U(){}U.prototype=P.prototype;function D(j,R,ee){this.props=j,this.context=R,this.refs=E,this.updater=ee||C}var F=D.prototype=new U;F.constructor=D,I(F,P.prototype),F.isPureReactComponent=!0;var Q=Array.isArray,$=Object.prototype.hasOwnProperty,Z={current:null},oe={key:!0,ref:!0,__self:!0,__source:!0};function le(j,R,ee){var _e,he={},O=null,je=null;if(R!=null)for(_e in R.ref!==void 0&&(je=R.ref),R.key!==void 0&&(O=""+R.key),R)$.call(R,_e)&&!oe.hasOwnProperty(_e)&&(he[_e]=R[_e]);var te=arguments.length-2;if(te===1)he.children=ee;else if(1<te){for(var ke=Array(te),Ce=0;Ce<te;Ce++)ke[Ce]=arguments[Ce+2];he.children=ke}if(j&&j.defaultProps)for(_e in te=j.defaultProps,te)he[_e]===void 0&&(he[_e]=te[_e]);return{$$typeof:a,type:j,key:O,ref:je,props:he,_owner:Z.current}}function pe(j,R){return{$$typeof:a,type:j.type,key:R,ref:j.ref,props:j.props,_owner:j._owner}}function Ae(j){return typeof j=="object"&&j!==null&&j.$$typeof===a}function Me(j){var R={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(ee){return R[ee]})}var ve=/\/+/g;function ce(j,R){return typeof j=="object"&&j!==null&&j.key!=null?Me(""+j.key):R.toString(36)}function q(j,R,ee,_e,he){var O=typeof j;(O==="undefined"||O==="boolean")&&(j=null);var je=!1;if(j===null)je=!0;else switch(O){case"string":case"number":je=!0;break;case"object":switch(j.$$typeof){case a:case s:je=!0}}if(je)return je=j,he=he(je),j=_e===""?"."+ce(je,0):_e,Q(he)?(ee="",j!=null&&(ee=j.replace(ve,"$&/")+"/"),q(he,R,ee,"",function(Ce){return Ce})):he!=null&&(Ae(he)&&(he=pe(he,ee+(!he.key||je&&je.key===he.key?"":(""+he.key).replace(ve,"$&/")+"/")+j)),R.push(he)),1;if(je=0,_e=_e===""?".":_e+":",Q(j))for(var te=0;te<j.length;te++){O=j[te];var ke=_e+ce(O,te);je+=q(O,R,ee,ke,he)}else if(ke=N(j),typeof ke=="function")for(j=ke.call(j),te=0;!(O=j.next()).done;)O=O.value,ke=_e+ce(O,te++),je+=q(O,R,ee,ke,he);else if(O==="object")throw R=String(j),Error("Objects are not valid as a React child (found: "+(R==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":R)+"). If you meant to render a collection of children, use an array instead.");return je}function L(j,R,ee){if(j==null)return j;var _e=[],he=0;return q(j,_e,"","",function(O){return R.call(ee,O,he++)}),_e}function W(j){if(j._status===-1){var R=j._result;R=R(),R.then(function(ee){(j._status===0||j._status===-1)&&(j._status=1,j._result=ee)},function(ee){(j._status===0||j._status===-1)&&(j._status=2,j._result=ee)}),j._status===-1&&(j._status=0,j._result=R)}if(j._status===1)return j._result.default;throw j._result}var X={current:null},M={transition:null},ue={ReactCurrentDispatcher:X,ReactCurrentBatchConfig:M,ReactCurrentOwner:Z};function V(){throw Error("act(...) is not supported in production builds of React.")}return ut.Children={map:L,forEach:function(j,R,ee){L(j,function(){R.apply(this,arguments)},ee)},count:function(j){var R=0;return L(j,function(){R++}),R},toArray:function(j){return L(j,function(R){return R})||[]},only:function(j){if(!Ae(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},ut.Component=P,ut.Fragment=r,ut.Profiler=c,ut.PureComponent=D,ut.StrictMode=l,ut.Suspense=_,ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ue,ut.act=V,ut.cloneElement=function(j,R,ee){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var _e=I({},j.props),he=j.key,O=j.ref,je=j._owner;if(R!=null){if(R.ref!==void 0&&(O=R.ref,je=Z.current),R.key!==void 0&&(he=""+R.key),j.type&&j.type.defaultProps)var te=j.type.defaultProps;for(ke in R)$.call(R,ke)&&!oe.hasOwnProperty(ke)&&(_e[ke]=R[ke]===void 0&&te!==void 0?te[ke]:R[ke])}var ke=arguments.length-2;if(ke===1)_e.children=ee;else if(1<ke){te=Array(ke);for(var Ce=0;Ce<ke;Ce++)te[Ce]=arguments[Ce+2];_e.children=te}return{$$typeof:a,type:j.type,key:he,ref:O,props:_e,_owner:je}},ut.createContext=function(j){return j={$$typeof:d,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},j.Provider={$$typeof:f,_context:j},j.Consumer=j},ut.createElement=le,ut.createFactory=function(j){var R=le.bind(null,j);return R.type=j,R},ut.createRef=function(){return{current:null}},ut.forwardRef=function(j){return{$$typeof:p,render:j}},ut.isValidElement=Ae,ut.lazy=function(j){return{$$typeof:b,_payload:{_status:-1,_result:j},_init:W}},ut.memo=function(j,R){return{$$typeof:y,type:j,compare:R===void 0?null:R}},ut.startTransition=function(j){var R=M.transition;M.transition={};try{j()}finally{M.transition=R}},ut.unstable_act=V,ut.useCallback=function(j,R){return X.current.useCallback(j,R)},ut.useContext=function(j){return X.current.useContext(j)},ut.useDebugValue=function(){},ut.useDeferredValue=function(j){return X.current.useDeferredValue(j)},ut.useEffect=function(j,R){return X.current.useEffect(j,R)},ut.useId=function(){return X.current.useId()},ut.useImperativeHandle=function(j,R,ee){return X.current.useImperativeHandle(j,R,ee)},ut.useInsertionEffect=function(j,R){return X.current.useInsertionEffect(j,R)},ut.useLayoutEffect=function(j,R){return X.current.useLayoutEffect(j,R)},ut.useMemo=function(j,R){return X.current.useMemo(j,R)},ut.useReducer=function(j,R,ee){return X.current.useReducer(j,R,ee)},ut.useRef=function(j){return X.current.useRef(j)},ut.useState=function(j){return X.current.useState(j)},ut.useSyncExternalStore=function(j,R,ee){return X.current.useSyncExternalStore(j,R,ee)},ut.useTransition=function(){return X.current.useTransition()},ut.version="18.3.1",ut}var Hm;function ad(){return Hm||(Hm=1,_u.exports=xp()),_u.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 Vm;function bp(){if(Vm)return pl;Vm=1;var a=ad(),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,f={key:!0,ref:!0,__self:!0,__source:!0};function d(p,_,y){var b,x={},N=null,C=null;y!==void 0&&(N=""+y),_.key!==void 0&&(N=""+_.key),_.ref!==void 0&&(C=_.ref);for(b in _)l.call(_,b)&&!f.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:C,props:x,_owner:c.current}}return pl.Fragment=r,pl.jsx=d,pl.jsxs=d,pl}var Gm;function wp(){return Gm||(Gm=1,pu.exports=bp()),pu.exports}var e=wp(),h=ad();const Ht=yp(h);var qo={},gu={exports:{}},In={},vu={exports:{}},yu={};/**
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 Km;function jp(){return Km||(Km=1,(function(a){function s(M,ue){var V=M.length;M.push(ue);e:for(;0<V;){var j=V-1>>>1,R=M[j];if(0<c(R,ue))M[j]=ue,M[V]=R,V=j;else break e}}function r(M){return M.length===0?null:M[0]}function l(M){if(M.length===0)return null;var ue=M[0],V=M.pop();if(V!==ue){M[0]=V;e:for(var j=0,R=M.length,ee=R>>>1;j<ee;){var _e=2*(j+1)-1,he=M[_e],O=_e+1,je=M[O];if(0>c(he,V))O<R&&0>c(je,he)?(M[j]=je,M[O]=V,j=O):(M[j]=he,M[_e]=V,j=_e);else if(O<R&&0>c(je,V))M[j]=je,M[O]=V,j=O;else break e}}return ue}function c(M,ue){var V=M.sortIndex-ue.sortIndex;return V!==0?V:M.id-ue.id}if(typeof performance=="object"&&typeof performance.now=="function"){var f=performance;a.unstable_now=function(){return f.now()}}else{var d=Date,p=d.now();a.unstable_now=function(){return d.now()-p}}var _=[],y=[],b=1,x=null,N=3,C=!1,I=!1,E=!1,P=typeof setTimeout=="function"?setTimeout:null,U=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(M){for(var ue=r(y);ue!==null;){if(ue.callback===null)l(y);else if(ue.startTime<=M)l(y),ue.sortIndex=ue.expirationTime,s(_,ue);else break;ue=r(y)}}function Q(M){if(E=!1,F(M),!I)if(r(_)!==null)I=!0,W($);else{var ue=r(y);ue!==null&&X(Q,ue.startTime-M)}}function $(M,ue){I=!1,E&&(E=!1,U(le),le=-1),C=!0;var V=N;try{for(F(ue),x=r(_);x!==null&&(!(x.expirationTime>ue)||M&&!Me());){var j=x.callback;if(typeof j=="function"){x.callback=null,N=x.priorityLevel;var R=j(x.expirationTime<=ue);ue=a.unstable_now(),typeof R=="function"?x.callback=R:x===r(_)&&l(_),F(ue)}else l(_);x=r(_)}if(x!==null)var ee=!0;else{var _e=r(y);_e!==null&&X(Q,_e.startTime-ue),ee=!1}return ee}finally{x=null,N=V,C=!1}}var Z=!1,oe=null,le=-1,pe=5,Ae=-1;function Me(){return!(a.unstable_now()-Ae<pe)}function ve(){if(oe!==null){var M=a.unstable_now();Ae=M;var ue=!0;try{ue=oe(!0,M)}finally{ue?ce():(Z=!1,oe=null)}}else Z=!1}var ce;if(typeof D=="function")ce=function(){D(ve)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,L=q.port2;q.port1.onmessage=ve,ce=function(){L.postMessage(null)}}else ce=function(){P(ve,0)};function W(M){oe=M,Z||(Z=!0,ce())}function X(M,ue){le=P(function(){M(a.unstable_now())},ue)}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(M){M.callback=null},a.unstable_continueExecution=function(){I||C||(I=!0,W($))},a.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):pe=0<M?Math.floor(1e3/M):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_getFirstCallbackNode=function(){return r(_)},a.unstable_next=function(M){switch(N){case 1:case 2:case 3:var ue=3;break;default:ue=N}var V=N;N=ue;try{return M()}finally{N=V}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(M,ue){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var V=N;N=M;try{return ue()}finally{N=V}},a.unstable_scheduleCallback=function(M,ue,V){var j=a.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?j+V:j):V=j,M){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=V+R,M={id:b++,callback:ue,priorityLevel:M,startTime:V,expirationTime:R,sortIndex:-1},V>j?(M.sortIndex=V,s(y,M),r(_)===null&&M===r(y)&&(E?(U(le),le=-1):E=!0,X(Q,V-j))):(M.sortIndex=R,s(_,M),I||C||(I=!0,W($))),M},a.unstable_shouldYield=Me,a.unstable_wrapCallback=function(M){var ue=N;return function(){var V=N;N=ue;try{return M.apply(this,arguments)}finally{N=V}}}})(yu)),yu}var Qm;function kp(){return Qm||(Qm=1,vu.exports=jp()),vu.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 Jm;function Sp(){if(Jm)return In;Jm=1;var a=ad(),s=kp();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 f(t,n){d(t,n),d(t+"Capture",n)}function d(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 C(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"||C(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 E(t,n,i,o,m,g,k){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=k}var P={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){P[t]=new E(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];P[n]=new E(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){P[t]=new E(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){P[t]=new E(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){P[t]=new E(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){P[t]=new E(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){P[t]=new E(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){P[t]=new E(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){P[t]=new E(t,5,!1,t.toLowerCase(),null,!1,!1)});var U=/[\-:]([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(U,D);P[n]=new E(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(U,D);P[n]=new E(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(U,D);P[n]=new E(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){P[t]=new E(t,1,!1,t.toLowerCase(),null,!1,!1)}),P.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){P[t]=new E(t,1,!1,t.toLowerCase(),null,!0,!0)});function F(t,n,i,o){var m=P.hasOwnProperty(n)?P[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 Q=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),Z=Symbol.for("react.portal"),oe=Symbol.for("react.fragment"),le=Symbol.for("react.strict_mode"),pe=Symbol.for("react.profiler"),Ae=Symbol.for("react.provider"),Me=Symbol.for("react.context"),ve=Symbol.for("react.forward_ref"),ce=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),M=Symbol.iterator;function ue(t){return t===null||typeof t!="object"?null:(t=M&&t[M]||t["@@iterator"],typeof t=="function"?t:null)}var V=Object.assign,j;function R(t){if(j===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);j=n&&n[1]||""}return`
34
- `+j+t}var ee=!1;function _e(t,n){if(!t||ee)return"";ee=!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(de){var o=de}Reflect.construct(t,[],n)}else{try{n.call()}catch(de){o=de}t.call(n.prototype)}else{try{throw Error()}catch(de){o=de}t()}}catch(de){if(de&&o&&typeof de.stack=="string"){for(var m=de.stack.split(`
35
- `),g=o.stack.split(`
36
- `),k=m.length-1,z=g.length-1;1<=k&&0<=z&&m[k]!==g[z];)z--;for(;1<=k&&0<=z;k--,z--)if(m[k]!==g[z]){if(k!==1||z!==1)do if(k--,z--,0>z||m[k]!==g[z]){var H=`
37
- `+m[k].replace(" at new "," at ");return t.displayName&&H.includes("<anonymous>")&&(H=H.replace("<anonymous>",t.displayName)),H}while(1<=k&&0<=z);break}}}finally{ee=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?R(t):""}function he(t){switch(t.tag){case 5:return R(t.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return t=_e(t.type,!1),t;case 11:return t=_e(t.type.render,!1),t;case 1:return t=_e(t.type,!0),t;default:return""}}function O(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 oe:return"Fragment";case Z:return"Portal";case pe:return"Profiler";case le:return"StrictMode";case ce:return"Suspense";case q:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Me:return(t.displayName||"Context")+".Consumer";case Ae:return(t._context.displayName||"Context")+".Provider";case ve:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case L:return n=t.displayName||null,n!==null?n:O(t.type)||"Memo";case W:n=t._payload,t=t._init;try{return O(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 O(n);case 8:return n===le?"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 te(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ke(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ce(t){var n=ke(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(k){o=""+k,g.call(this,k)}}),Object.defineProperty(t,n,{enumerable:i.enumerable}),{getValue:function(){return o},setValue:function(k){o=""+k},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function We(t){t._valueTracker||(t._valueTracker=Ce(t))}function me(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),o="";return t&&(o=ke(t)?t.checked?"true":"false":t.value),t=o,t!==i?(n.setValue(t),!0):!1}function Re(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 Pe(t,n){var i=n.checked;return V({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function se(t,n){var i=n.defaultValue==null?"":n.defaultValue,o=n.checked!=null?n.checked:n.defaultChecked;i=te(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 ye(t,n){n=n.checked,n!=null&&F(t,"checked",n,!1)}function ge(t,n){ye(t,n);var i=te(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")?Ye(t,n.type,i):n.hasOwnProperty("defaultValue")&&Ye(t,n.type,te(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function qe(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 Ye(t,n,i){(n!=="number"||Re(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var ie=Array.isArray;function fe(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=""+te(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 be(t,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return V({},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(ie(i)){if(1<i.length)throw Error(r(93));i=i[0]}n=i}n==null&&(n=""),i=n}t._wrapperState={initialValue:te(i)}}function Se(t,n){var i=te(n.value),o=te(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 Xe(t){var n=t.textContent;n===t._wrapperState.initialValue&&n!==""&&n!==null&&(t.value=n)}function J(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 A(t,n){return t==null||t==="http://www.w3.org/1999/xhtml"?J(n):t==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Y,Ne=(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(Y=Y||document.createElement("div"),Y.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=Y.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function ze(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var Ke={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},tt=["Webkit","ms","Moz","O"];Object.keys(Ke).forEach(function(t){tt.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),Ke[n]=Ke[t]})});function dt(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||Ke.hasOwnProperty(t)&&Ke[t]?(""+n).trim():n+"px"}function yt(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var o=i.indexOf("--")===0,m=dt(i,n[i],o);i==="float"&&(i="cssFloat"),o?t.setProperty(i,m):t[i]=m}}var pt=V({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 Tt(t,n){if(n){if(pt[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 qt(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 Oe=null;function it(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var et=null,kt=null,ht=null;function Qt(t){if(t=fr(t)){if(typeof et!="function")throw Error(r(280));var n=t.stateNode;n&&(n=hr(n),et(t.stateNode,t.type,n))}}function we(t){kt?ht?ht.push(t):ht=[t]:kt=t}function Ee(){if(kt){var t=kt,n=ht;if(ht=kt=null,Qt(t),n)for(t=0;t<n.length;t++)Qt(n[t])}}function Ie(t,n){return t(n)}function mt(){}var _t=!1;function gt(t,n,i){if(_t)return t(n,i);_t=!0;try{return Ie(t,n,i)}finally{_t=!1,(kt!==null||ht!==null)&&(mt(),Ee())}}function Xt(t,n){var i=t.stateNode;if(i===null)return null;var o=hr(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 mn=!1;if(p)try{var Bt={};Object.defineProperty(Bt,"passive",{get:function(){mn=!0}}),window.addEventListener("test",Bt,Bt),window.removeEventListener("test",Bt,Bt)}catch{mn=!1}function Ba(t,n,i,o,m,g,k,z,H){var de=Array.prototype.slice.call(arguments,3);try{n.apply(i,de)}catch(Te){this.onError(Te)}}var Qn=!1,qn=null,ha=!1,Tr=null,wi={onError:function(t){Qn=!0,qn=t}};function ot(t,n,i,o,m,g,k,z,H){Qn=!1,qn=null,Ba.apply(wi,arguments)}function Vt(t,n,i,o,m,g,k,z,H){if(ot.apply(this,arguments),Qn){if(Qn){var de=qn;Qn=!1,qn=null}else throw Error(r(198));ha||(ha=!0,Tr=de)}}function Jn(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 Rt(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 Ua(t){if(Jn(t)!==t)throw Error(r(188))}function Rl(t){var n=t.alternate;if(!n){if(n=Jn(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 Ua(m),t;if(g===o)return Ua(m),n;g=g.sibling}throw Error(r(188))}if(i.return!==o.return)i=m,o=g;else{for(var k=!1,z=m.child;z;){if(z===i){k=!0,i=m,o=g;break}if(z===o){k=!0,o=m,i=g;break}z=z.sibling}if(!k){for(z=g.child;z;){if(z===i){k=!0,i=g,o=m;break}if(z===o){k=!0,o=g,i=m;break}z=z.sibling}if(!k)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 ji(t){return t=Rl(t),t!==null?Ar(t):null}function Ar(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var n=Ar(t);if(n!==null)return n;t=t.sibling}return null}var ki=s.unstable_scheduleCallback,Wa=s.unstable_cancelCallback,Ll=s.unstable_shouldYield,Rr=s.unstable_requestPaint,Lt=s.unstable_now,Ml=s.unstable_getCurrentPriorityLevel,Ha=s.unstable_ImmediatePriority,Fs=s.unstable_UserBlockingPriority,is=s.unstable_NormalPriority,Lr=s.unstable_LowPriority,pa=s.unstable_IdlePriority,Va=null,fn=null;function zl(t){if(fn&&typeof fn.onCommitFiberRoot=="function")try{fn.onCommitFiberRoot(Va,t,void 0,(t.current.flags&128)===128)}catch{}}var Sn=Math.clz32?Math.clz32:Bn,tc=Math.log,nc=Math.LN2;function Bn(t){return t>>>=0,t===0?32:31-(tc(t)/nc|0)|0}var Yn=64,qs=4194304;function Xn(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 Ot(t,n){var i=t.pendingLanes;if(i===0)return 0;var o=0,m=t.suspendedLanes,g=t.pingedLanes,k=i&268435455;if(k!==0){var z=k&~m;z!==0?o=Xn(z):(g&=k,g!==0&&(o=Xn(g)))}else k=i&~m,k!==0?o=Xn(k):g!==0&&(o=Xn(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-Sn(n),m=1<<i,o|=t[i],n&=~m;return o}function sn(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 Mr(t,n){for(var i=t.suspendedLanes,o=t.pingedLanes,m=t.expirationTimes,g=t.pendingLanes;0<g;){var k=31-Sn(g),z=1<<k,H=m[k];H===-1?((z&i)===0||(z&o)!==0)&&(m[k]=sn(z,n)):H<=n&&(t.expiredLanes|=z),g&=~z}}function ws(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Bs(){var t=Yn;return Yn<<=1,(Yn&4194240)===0&&(Yn=64),t}function zr(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function Pt(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-Sn(n),t[n]=i}function js(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-Sn(i),g=1<<m;n[m]=0,o[m]=-1,t[m]=-1,i&=~g}}function Pr(t,n){var i=t.entangledLanes|=n;for(t=t.entanglements;i;){var o=31-Sn(i),m=1<<o;m&n|t[o]&n&&(t[o]|=n),i&=~m}}var ct=0;function Ir(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var Si,Ga,Ni,Ci,Ka,ks=!1,Us=[],Gt=null,hn=null,Ss=null,ls=new Map,St=new Map,Zt=[],Un="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 Or(t,n){switch(t){case"focusin":case"focusout":Gt=null;break;case"dragenter":case"dragleave":hn=null;break;case"mouseover":case"mouseout":Ss=null;break;case"pointerover":case"pointerout":ls.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":St.delete(n.pointerId)}}function Ws(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=fr(n),n!==null&&Ga(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,m!==null&&n.indexOf(m)===-1&&n.push(m),t)}function Pl(t,n,i,o,m){switch(n){case"focusin":return Gt=Ws(Gt,t,n,i,o,m),!0;case"dragenter":return hn=Ws(hn,t,n,i,o,m),!0;case"mouseover":return Ss=Ws(Ss,t,n,i,o,m),!0;case"pointerover":var g=m.pointerId;return ls.set(g,Ws(ls.get(g)||null,t,n,i,o,m)),!0;case"gotpointercapture":return g=m.pointerId,St.set(g,Ws(St.get(g)||null,t,n,i,o,m)),!0}return!1}function Wn(t){var n=Ls(t.target);if(n!==null){var i=Jn(n);if(i!==null){if(n=i.tag,n===13){if(n=Rt(i),n!==null){t.blockedOn=n,Ka(t.priority,function(){Ni(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 Qa(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var i=_a(t.domEventName,t.eventSystemFlags,n[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var o=new i.constructor(i.type,i);Oe=o,i.target.dispatchEvent(o),Oe=null}else return n=fr(i),n!==null&&Ga(n),t.blockedOn=i,!1;n.shift()}return!0}function Ja(t,n,i){Qa(t)&&i.delete(n)}function Il(){ks=!1,Gt!==null&&Qa(Gt)&&(Gt=null),hn!==null&&Qa(hn)&&(hn=null),Ss!==null&&Qa(Ss)&&(Ss=null),ls.forEach(Ja),St.forEach(Ja)}function Hs(t,n){t.blockedOn===n&&(t.blockedOn=null,ks||(ks=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Il)))}function os(t){function n(m){return Hs(m,t)}if(0<Us.length){Hs(Us[0],t);for(var i=1;i<Us.length;i++){var o=Us[i];o.blockedOn===t&&(o.blockedOn=null)}}for(Gt!==null&&Hs(Gt,t),hn!==null&&Hs(hn,t),Ss!==null&&Hs(Ss,t),ls.forEach(n),St.forEach(n),i=0;i<Zt.length;i++)o=Zt[i],o.blockedOn===t&&(o.blockedOn=null);for(;0<Zt.length&&(i=Zt[0],i.blockedOn===null);)Wn(i),i.blockedOn===null&&Zt.shift()}var Vs=Q.ReactCurrentBatchConfig,Ya=!0;function $i(t,n,i,o){var m=ct,g=Vs.transition;Vs.transition=null;try{ct=1,Gs(t,n,i,o)}finally{ct=m,Vs.transition=g}}function Ol(t,n,i,o){var m=ct,g=Vs.transition;Vs.transition=null;try{ct=4,Gs(t,n,i,o)}finally{ct=m,Vs.transition=g}}function Gs(t,n,i,o){if(Ya){var m=_a(t,n,i,o);if(m===null)Qi(t,n,o,Zn,i),Or(t,o);else if(Pl(m,t,n,i,o))o.stopPropagation();else if(Or(t,o),n&4&&-1<Un.indexOf(t)){for(;m!==null;){var g=fr(m);if(g!==null&&Si(g),g=_a(t,n,i,o),g===null&&Qi(t,n,o,Zn,i),g===m)break;m=g}m!==null&&o.stopPropagation()}else Qi(t,n,o,null,i)}}var Zn=null;function _a(t,n,i,o){if(Zn=null,t=it(o),t=Ls(t),t!==null)if(n=Jn(t),n===null)t=null;else if(i=n.tag,i===13){if(t=Rt(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 Zn=t,null}function Dr(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(Ml()){case Ha:return 1;case Fs:return 4;case is:case Lr:return 16;case pa:return 536870912;default:return 16}default:return 16}}var es=null,Xa=null,cs=null;function ga(){if(cs)return cs;var t,n=Xa,i=n.length,o,m="value"in es?es.value:es.textContent,g=m.length;for(t=0;t<i&&n[t]===m[t];t++);var k=i-t;for(o=1;o<=k&&n[i-o]===m[g-o];o++);return cs=m.slice(t,1<o?1-o:void 0)}function Fr(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 Ut(){return!0}function qr(){return!1}function pn(t){function n(i,o,m,g,k){this._reactName=i,this._targetInst=m,this.type=o,this.nativeEvent=g,this.target=k,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)?Ut:qr,this.isPropagationStopped=qr,this}return V(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=Ut)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Ut)},persist:function(){},isPersistent:Ut}),n}var Ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Za=pn(Ks),Qs=V({},Ks,{view:0,detail:0}),Ei=pn(Qs),Br,er,va,tr=V({},Qs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ds,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!==va&&(va&&t.type==="mousemove"?(Br=t.screenX-va.screenX,er=t.screenY-va.screenY):er=Br=0,va=t),Br)},movementY:function(t){return"movementY"in t?t.movementY:er}}),Ur=pn(tr),Dl=V({},tr,{dataTransfer:0}),Ti=pn(Dl),Ai=V({},Qs,{relatedTarget:0}),Wr=pn(Ai),En=V({},Ks,{animationName:0,elapsedTime:0,pseudoElement:0}),Ns=pn(En),Cs=V({},Ks,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Ri=pn(Cs),Li=V({},Ks,{data:0}),Hr=pn(Li),sc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ya={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"},nr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function us(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=nr[t])?!!n[t]:!1}function ds(){return us}var Fl=V({},Qs,{key:function(t){if(t.key){var n=sc[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=Fr(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?ya[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ds,charCode:function(t){return t.type==="keypress"?Fr(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Fr(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),ql=pn(Fl),Bl=V({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ul=pn(Bl),ac=V({},Qs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ds}),Mi=pn(ac),xa=V({},Ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),zi=pn(xa),Wl=V({},tr,{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}),Pi=pn(Wl),Hl=[9,13,27,32],$s=p&&"CompositionEvent"in window,Js=null;p&&"documentMode"in document&&(Js=document.documentMode);var rc=p&&"TextEvent"in window&&!Js,ba=p&&(!$s||Js&&8<Js&&11>=Js),Vr=" ",Ii=!1;function Oi(t,n){switch(t){case"keyup":return Hl.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Di(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var wa=!1;function Ys(t,n){switch(t){case"compositionend":return Di(n);case"keypress":return n.which!==32?null:(Ii=!0,Vr);case"textInput":return t=n.data,t===Vr&&Ii?null:t;default:return null}}function sr(t,n){if(wa)return t==="compositionend"||!$s&&Oi(t,n)?(t=ga(),cs=Xa=es=null,wa=!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 ba&&n.locale!=="ko"?null:n.data;default:return null}}var ic={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 ar(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!ic[t.type]:n==="textarea"}function Gr(t,n,i,o){we(o),n=Sa(n,"onChange"),0<n.length&&(i=new Za("onChange","change",null,i,o),t.push({event:i,listeners:n}))}var rr=null,Es=null;function Kr(t){ti(t,0)}function Qr(t){var n=aa(t);if(me(n))return t}function lc(t,n){if(t==="change")return n}var Vl=!1;if(p){var Jr;if(p){var Fi="oninput"in document;if(!Fi){var qi=document.createElement("div");qi.setAttribute("oninput","return;"),Fi=typeof qi.oninput=="function"}Jr=Fi}else Jr=!1;Vl=Jr&&(!document.documentMode||9<document.documentMode)}function Gl(){rr&&(rr.detachEvent("onpropertychange",Kl),Es=rr=null)}function Kl(t){if(t.propertyName==="value"&&Qr(Es)){var n=[];Gr(n,Es,t,it(t)),gt(Kr,n)}}function Bi(t,n,i){t==="focusin"?(Gl(),rr=n,Es=i,rr.attachEvent("onpropertychange",Kl)):t==="focusout"&&Gl()}function oc(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Qr(Es)}function Ql(t,n){if(t==="click")return Qr(n)}function Jl(t,n){if(t==="input"||t==="change")return Qr(n)}function cc(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var Tn=typeof Object.is=="function"?Object.is:cc;function Ts(t,n){if(Tn(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)||!Tn(t[m],n[m]))return!1}return!0}function Ui(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function ir(t,n){var i=Ui(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=Ui(i)}}function Wi(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Wi(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Yl(){for(var t=window,n=Re();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Re(t.document)}return n}function Hi(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 Xl(t){var n=Yl(),i=t.focusedElem,o=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&Wi(i.ownerDocument.documentElement,i)){if(o!==null&&Hi(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=ir(i,g);var k=ir(i,o);m&&k&&(t.rangeCount!==1||t.anchorNode!==m.node||t.anchorOffset!==m.offset||t.focusNode!==k.node||t.focusOffset!==k.offset)&&(n=n.createRange(),n.setStart(m.node,m.offset),t.removeAllRanges(),g>o?(t.addRange(n),t.extend(k.node,k.offset)):(n.setEnd(k.node,k.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 uc=p&&"documentMode"in document&&11>=document.documentMode,Xs=null,Vi=null,ja=null,Yr=!1;function Zl(t,n,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Yr||Xs==null||Xs!==Re(o)||(o=Xs,"selectionStart"in o&&Hi(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}),ja&&Ts(ja,o)||(ja=o,o=Sa(Vi,"onSelect"),0<o.length&&(n=new Za("onSelect","select",null,n,i),t.push({event:n,listeners:o}),n.target=Xs)))}function Xr(t,n){var i={};return i[t.toLowerCase()]=n.toLowerCase(),i["Webkit"+t]="webkit"+n,i["Moz"+t]="moz"+n,i}var Zs={animationend:Xr("Animation","AnimationEnd"),animationiteration:Xr("Animation","AnimationIteration"),animationstart:Xr("Animation","AnimationStart"),transitionend:Xr("Transition","TransitionEnd")},Zr={},eo={};p&&(eo=document.createElement("div").style,"AnimationEvent"in window||(delete Zs.animationend.animation,delete Zs.animationiteration.animation,delete Zs.animationstart.animation),"TransitionEvent"in window||delete Zs.transitionend.transition);function _n(t){if(Zr[t])return Zr[t];if(!Zs[t])return t;var n=Zs[t],i;for(i in n)if(n.hasOwnProperty(i)&&i in eo)return Zr[t]=n[i];return t}var Nt=_n("animationend"),Jt=_n("animationiteration"),ei=_n("animationstart"),to=_n("transitionend"),ms=new Map,fs="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 an(t,n){ms.set(t,n),f(n,[t])}for(var As=0;As<fs.length;As++){var ea=fs[As],lr=ea.toLowerCase(),or=ea[0].toUpperCase()+ea.slice(1);an(lr,"on"+or)}an(Nt,"onAnimationEnd"),an(Jt,"onAnimationIteration"),an(ei,"onAnimationStart"),an("dblclick","onDoubleClick"),an("focusin","onFocus"),an("focusout","onBlur"),an(to,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),f("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),f("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),f("onBeforeInput",["compositionend","keypress","textInput","paste"]),f("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),f("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),f("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ta="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(" "),no=new Set("cancel close invalid load scroll toggle".split(" ").concat(ta));function Gi(t,n,i){var o=t.type||"unknown-event";t.currentTarget=i,Vt(o,n,void 0,t),t.currentTarget=null}function ti(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 k=o.length-1;0<=k;k--){var z=o[k],H=z.instance,de=z.currentTarget;if(z=z.listener,H!==g&&m.isPropagationStopped())break e;Gi(m,z,de),g=H}else for(k=0;k<o.length;k++){if(z=o[k],H=z.instance,de=z.currentTarget,z=z.listener,H!==g&&m.isPropagationStopped())break e;Gi(m,z,de),g=H}}}if(ha)throw t=Tr,ha=!1,Tr=null,t}function At(t,n){var i=n[el];i===void 0&&(i=n[el]=new Set);var o=t+"__bubble";i.has(o)||(na(n,t,2,!1),i.add(o))}function Ki(t,n,i){var o=0;n&&(o|=4),na(i,t,o,n)}var cr="_reactListening"+Math.random().toString(36).slice(2);function ka(t){if(!t[cr]){t[cr]=!0,l.forEach(function(i){i!=="selectionchange"&&(no.has(i)||Ki(i,!1,t),Ki(i,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[cr]||(n[cr]=!0,Ki("selectionchange",!1,n))}}function na(t,n,i,o){switch(Dr(n)){case 1:var m=$i;break;case 4:m=Ol;break;default:m=Gs}i=m.bind(null,n,i,t),m=void 0,!mn||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 Qi(t,n,i,o,m){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var k=o.tag;if(k===3||k===4){var z=o.stateNode.containerInfo;if(z===m||z.nodeType===8&&z.parentNode===m)break;if(k===4)for(k=o.return;k!==null;){var H=k.tag;if((H===3||H===4)&&(H=k.stateNode.containerInfo,H===m||H.nodeType===8&&H.parentNode===m))return;k=k.return}for(;z!==null;){if(k=Ls(z),k===null)return;if(H=k.tag,H===5||H===6){o=g=k;continue e}z=z.parentNode}}o=o.return}gt(function(){var de=g,Te=it(i),Le=[];e:{var $e=ms.get(t);if($e!==void 0){var Ve=Za,Qe=t;switch(t){case"keypress":if(Fr(i)===0)break e;case"keydown":case"keyup":Ve=ql;break;case"focusin":Qe="focus",Ve=Wr;break;case"focusout":Qe="blur",Ve=Wr;break;case"beforeblur":case"afterblur":Ve=Wr;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":Ve=Ur;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ve=Ti;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ve=Mi;break;case Nt:case Jt:case ei:Ve=Ns;break;case to:Ve=zi;break;case"scroll":Ve=Ei;break;case"wheel":Ve=Pi;break;case"copy":case"cut":case"paste":Ve=Ri;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ve=Ul}var Je=(n&4)!==0,Kt=!Je&&t==="scroll",ae=Je?$e!==null?$e+"Capture":null:$e;Je=[];for(var K=de,re;K!==null;){re=K;var Fe=re.stateNode;if(re.tag===5&&Fe!==null&&(re=Fe,ae!==null&&(Fe=Xt(K,ae),Fe!=null&&Je.push(rn(K,Fe,re)))),Kt)break;K=K.return}0<Je.length&&($e=new Ve($e,Qe,null,i,Te),Le.push({event:$e,listeners:Je}))}}if((n&7)===0){e:{if($e=t==="mouseover"||t==="pointerover",Ve=t==="mouseout"||t==="pointerout",$e&&i!==Oe&&(Qe=i.relatedTarget||i.fromElement)&&(Ls(Qe)||Qe[ps]))break e;if((Ve||$e)&&($e=Te.window===Te?Te:($e=Te.ownerDocument)?$e.defaultView||$e.parentWindow:window,Ve?(Qe=i.relatedTarget||i.toElement,Ve=de,Qe=Qe?Ls(Qe):null,Qe!==null&&(Kt=Jn(Qe),Qe!==Kt||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(Ve=null,Qe=de),Ve!==Qe)){if(Je=Ur,Fe="onMouseLeave",ae="onMouseEnter",K="mouse",(t==="pointerout"||t==="pointerover")&&(Je=Ul,Fe="onPointerLeave",ae="onPointerEnter",K="pointer"),Kt=Ve==null?$e:aa(Ve),re=Qe==null?$e:aa(Qe),$e=new Je(Fe,K+"leave",Ve,i,Te),$e.target=Kt,$e.relatedTarget=re,Fe=null,Ls(Te)===de&&(Je=new Je(ae,K+"enter",Qe,i,Te),Je.target=re,Je.relatedTarget=Kt,Fe=Je),Kt=Fe,Ve&&Qe)t:{for(Je=Ve,ae=Qe,K=0,re=Je;re;re=gn(re))K++;for(re=0,Fe=ae;Fe;Fe=gn(Fe))re++;for(;0<K-re;)Je=gn(Je),K--;for(;0<re-K;)ae=gn(ae),re--;for(;K--;){if(Je===ae||ae!==null&&Je===ae.alternate)break t;Je=gn(Je),ae=gn(ae)}Je=null}else Je=null;Ve!==null&&ur(Le,$e,Ve,Je,!1),Qe!==null&&Kt!==null&&ur(Le,Kt,Qe,Je,!0)}}e:{if($e=de?aa(de):window,Ve=$e.nodeName&&$e.nodeName.toLowerCase(),Ve==="select"||Ve==="input"&&$e.type==="file")var Ze=lc;else if(ar($e))if(Vl)Ze=Jl;else{Ze=oc;var nt=Bi}else(Ve=$e.nodeName)&&Ve.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(Ze=Ql);if(Ze&&(Ze=Ze(t,de))){Gr(Le,Ze,i,Te);break e}nt&&nt(t,$e,de),t==="focusout"&&(nt=$e._wrapperState)&&nt.controlled&&$e.type==="number"&&Ye($e,"number",$e.value)}switch(nt=de?aa(de):window,t){case"focusin":(ar(nt)||nt.contentEditable==="true")&&(Xs=nt,Vi=de,ja=null);break;case"focusout":ja=Vi=Xs=null;break;case"mousedown":Yr=!0;break;case"contextmenu":case"mouseup":case"dragend":Yr=!1,Zl(Le,i,Te);break;case"selectionchange":if(uc)break;case"keydown":case"keyup":Zl(Le,i,Te)}var st;if($s)e:{switch(t){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else wa?Oi(t,i)&&(lt="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(lt="onCompositionStart");lt&&(ba&&i.locale!=="ko"&&(wa||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&wa&&(st=ga()):(es=Te,Xa="value"in es?es.value:es.textContent,wa=!0)),nt=Sa(de,lt),0<nt.length&&(lt=new Hr(lt,t,null,i,Te),Le.push({event:lt,listeners:nt}),st?lt.data=st:(st=Di(i),st!==null&&(lt.data=st)))),(st=rc?Ys(t,i):sr(t,i))&&(de=Sa(de,"onBeforeInput"),0<de.length&&(Te=new Hr("onBeforeInput","beforeinput",null,i,Te),Le.push({event:Te,listeners:de}),Te.data=st))}ti(Le,n)})}function rn(t,n,i){return{instance:t,listener:n,currentTarget:i}}function Sa(t,n){for(var i=n+"Capture",o=[];t!==null;){var m=t,g=m.stateNode;m.tag===5&&g!==null&&(m=g,g=Xt(t,i),g!=null&&o.unshift(rn(t,g,m)),g=Xt(t,n),g!=null&&o.push(rn(t,g,m))),t=t.return}return o}function gn(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function ur(t,n,i,o,m){for(var g=n._reactName,k=[];i!==null&&i!==o;){var z=i,H=z.alternate,de=z.stateNode;if(H!==null&&H===o)break;z.tag===5&&de!==null&&(z=de,m?(H=Xt(i,g),H!=null&&k.unshift(rn(i,H,z))):m||(H=Xt(i,g),H!=null&&k.push(rn(i,H,z)))),i=i.return}k.length!==0&&t.push({event:n,listeners:k})}var Ji=/\r\n?/g,hs=/\u0000|\uFFFD/g;function Hn(t){return(typeof t=="string"?t:""+t).replace(Ji,`
38
- `).replace(hs,"")}function sa(t,n,i){if(n=Hn(n),Hn(t)!==n&&i)throw Error(r(425))}function ni(){}var dr=null,Yi=null;function Xi(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 si=typeof setTimeout=="function"?setTimeout:void 0,dc=typeof clearTimeout=="function"?clearTimeout:void 0,so=typeof Promise=="function"?Promise:void 0,ao=typeof queueMicrotask=="function"?queueMicrotask:typeof so<"u"?function(t){return so.resolve(null).then(t).catch(mc)}:si;function mc(t){setTimeout(function(){throw t})}function Zi(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),os(n);return}o--}else i!=="$"&&i!=="$?"&&i!=="$!"||o++;i=m}while(i);os(n)}function Rs(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 ro(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 Na=Math.random().toString(36).slice(2),An="__reactFiber$"+Na,mr="__reactProps$"+Na,ps="__reactContainer$"+Na,el="__reactEvents$"+Na,fc="__reactListeners$"+Na,io="__reactHandles$"+Na;function Ls(t){var n=t[An];if(n)return n;for(var i=t.parentNode;i;){if(n=i[ps]||i[An]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(t=ro(t);t!==null;){if(i=t[An])return i;t=ro(t)}return n}t=i,i=t.parentNode}return null}function fr(t){return t=t[An]||t[ps],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function aa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function hr(t){return t[mr]||null}var ai=[],ra=-1;function _s(t){return{current:t}}function $t(t){0>ra||(t.current=ai[ra],ai[ra]=null,ra--)}function u(t,n){ra++,ai[ra]=t.current,t.current=n}var v={},S=_s(v),w=_s(!1),T=v;function ne(t,n){var i=t.type.contextTypes;if(!i)return v;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 B(t){return t=t.childContextTypes,t!=null}function xe(){$t(w),$t(S)}function De(t,n,i){if(S.current!==v)throw Error(r(168));u(S,n),u(w,i)}function Be(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 V({},i,o)}function Ue(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||v,T=S.current,u(S,t),u(w,w.current),!0}function Mt(t,n,i){var o=t.stateNode;if(!o)throw Error(r(169));i?(t=Be(t,n,T),o.__reactInternalMemoizedMergedChildContext=t,$t(w),$t(S),u(S,t)):$t(w),u(w,i)}var Et=null,Rn=!1,xt=!1;function rt(t){Et===null?Et=[t]:Et.push(t)}function bn(t){Rn=!0,rt(t)}function bt(){if(!xt&&Et!==null){xt=!0;var t=0,n=ct;try{var i=Et;for(ct=1;t<i.length;t++){var o=i[t];do o=o(!0);while(o!==null)}Et=null,Rn=!1}catch(m){throw Et!==null&&(Et=Et.slice(t+1)),ki(Ha,bt),m}finally{ct=n,xt=!1}}return null}var He=[],Ct=0,ln=null,en=0,jt=[],ft=0,zt=null,Ln=1,ia="";function pr(t,n){He[Ct++]=en,He[Ct++]=ln,ln=t,en=n}function _d(t,n,i){jt[ft++]=Ln,jt[ft++]=ia,jt[ft++]=zt,zt=t;var o=Ln;t=ia;var m=32-Sn(o)-1;o&=~(1<<m),i+=1;var g=32-Sn(n)+m;if(30<g){var k=m-m%5;g=(o&(1<<k)-1).toString(32),o>>=k,m-=k,Ln=1<<32-Sn(n)+m|i<<m|o,ia=g+t}else Ln=1<<g|i<<m|o,ia=t}function hc(t){t.return!==null&&(pr(t,1),_d(t,1,0))}function pc(t){for(;t===ln;)ln=He[--Ct],He[Ct]=null,en=He[--Ct],He[Ct]=null;for(;t===zt;)zt=jt[--ft],jt[ft]=null,ia=jt[--ft],jt[ft]=null,Ln=jt[--ft],jt[ft]=null}var Vn=null,Gn=null,It=!1,gs=null;function gd(t,n){var i=as(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 vd(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,Vn=t,Gn=Rs(n.firstChild),!0):!1;case 6:return n=t.pendingProps===""||n.nodeType!==3?null:n,n!==null?(t.stateNode=n,Vn=t,Gn=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=zt!==null?{id:Ln,overflow:ia}:null,t.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=as(18,null,null,0),i.stateNode=n,i.return=t,t.child=i,Vn=t,Gn=null,!0):!1;default:return!1}}function _c(t){return(t.mode&1)!==0&&(t.flags&128)===0}function gc(t){if(It){var n=Gn;if(n){var i=n;if(!vd(t,n)){if(_c(t))throw Error(r(418));n=Rs(i.nextSibling);var o=Vn;n&&vd(t,n)?gd(o,i):(t.flags=t.flags&-4097|2,It=!1,Vn=t)}}else{if(_c(t))throw Error(r(418));t.flags=t.flags&-4097|2,It=!1,Vn=t}}}function yd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Vn=t}function lo(t){if(t!==Vn)return!1;if(!It)return yd(t),It=!0,!1;var n;if((n=t.tag!==3)&&!(n=t.tag!==5)&&(n=t.type,n=n!=="head"&&n!=="body"&&!Xi(t.type,t.memoizedProps)),n&&(n=Gn)){if(_c(t))throw xd(),Error(r(418));for(;n;)gd(t,n),n=Rs(n.nextSibling)}if(yd(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){Gn=Rs(t.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}t=t.nextSibling}Gn=null}}else Gn=Vn?Rs(t.stateNode.nextSibling):null;return!0}function xd(){for(var t=Gn;t;)t=Rs(t.nextSibling)}function ri(){Gn=Vn=null,It=!1}function vc(t){gs===null?gs=[t]:gs.push(t)}var Ih=Q.ReactCurrentBatchConfig;function tl(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(k){var z=m.refs;k===null?delete z[g]:z[g]=k},n._stringRef=g,n)}if(typeof t!="string")throw Error(r(284));if(!i._owner)throw Error(r(290,t))}return t}function oo(t,n){throw t=Object.prototype.toString.call(n),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t))}function bd(t){var n=t._init;return n(t._payload)}function wd(t){function n(ae,K){if(t){var re=ae.deletions;re===null?(ae.deletions=[K],ae.flags|=16):re.push(K)}}function i(ae,K){if(!t)return null;for(;K!==null;)n(ae,K),K=K.sibling;return null}function o(ae,K){for(ae=new Map;K!==null;)K.key!==null?ae.set(K.key,K):ae.set(K.index,K),K=K.sibling;return ae}function m(ae,K){return ae=Ma(ae,K),ae.index=0,ae.sibling=null,ae}function g(ae,K,re){return ae.index=re,t?(re=ae.alternate,re!==null?(re=re.index,re<K?(ae.flags|=2,K):re):(ae.flags|=2,K)):(ae.flags|=1048576,K)}function k(ae){return t&&ae.alternate===null&&(ae.flags|=2),ae}function z(ae,K,re,Fe){return K===null||K.tag!==6?(K=cu(re,ae.mode,Fe),K.return=ae,K):(K=m(K,re),K.return=ae,K)}function H(ae,K,re,Fe){var Ze=re.type;return Ze===oe?Te(ae,K,re.props.children,Fe,re.key):K!==null&&(K.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===W&&bd(Ze)===K.type)?(Fe=m(K,re.props),Fe.ref=tl(ae,K,re),Fe.return=ae,Fe):(Fe=Lo(re.type,re.key,re.props,null,ae.mode,Fe),Fe.ref=tl(ae,K,re),Fe.return=ae,Fe)}function de(ae,K,re,Fe){return K===null||K.tag!==4||K.stateNode.containerInfo!==re.containerInfo||K.stateNode.implementation!==re.implementation?(K=uu(re,ae.mode,Fe),K.return=ae,K):(K=m(K,re.children||[]),K.return=ae,K)}function Te(ae,K,re,Fe,Ze){return K===null||K.tag!==7?(K=jr(re,ae.mode,Fe,Ze),K.return=ae,K):(K=m(K,re),K.return=ae,K)}function Le(ae,K,re){if(typeof K=="string"&&K!==""||typeof K=="number")return K=cu(""+K,ae.mode,re),K.return=ae,K;if(typeof K=="object"&&K!==null){switch(K.$$typeof){case $:return re=Lo(K.type,K.key,K.props,null,ae.mode,re),re.ref=tl(ae,null,K),re.return=ae,re;case Z:return K=uu(K,ae.mode,re),K.return=ae,K;case W:var Fe=K._init;return Le(ae,Fe(K._payload),re)}if(ie(K)||ue(K))return K=jr(K,ae.mode,re,null),K.return=ae,K;oo(ae,K)}return null}function $e(ae,K,re,Fe){var Ze=K!==null?K.key:null;if(typeof re=="string"&&re!==""||typeof re=="number")return Ze!==null?null:z(ae,K,""+re,Fe);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case $:return re.key===Ze?H(ae,K,re,Fe):null;case Z:return re.key===Ze?de(ae,K,re,Fe):null;case W:return Ze=re._init,$e(ae,K,Ze(re._payload),Fe)}if(ie(re)||ue(re))return Ze!==null?null:Te(ae,K,re,Fe,null);oo(ae,re)}return null}function Ve(ae,K,re,Fe,Ze){if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number")return ae=ae.get(re)||null,z(K,ae,""+Fe,Ze);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case $:return ae=ae.get(Fe.key===null?re:Fe.key)||null,H(K,ae,Fe,Ze);case Z:return ae=ae.get(Fe.key===null?re:Fe.key)||null,de(K,ae,Fe,Ze);case W:var nt=Fe._init;return Ve(ae,K,re,nt(Fe._payload),Ze)}if(ie(Fe)||ue(Fe))return ae=ae.get(re)||null,Te(K,ae,Fe,Ze,null);oo(K,Fe)}return null}function Qe(ae,K,re,Fe){for(var Ze=null,nt=null,st=K,lt=K=0,un=null;st!==null&&lt<re.length;lt++){st.index>lt?(un=st,st=null):un=st.sibling;var wt=$e(ae,st,re[lt],Fe);if(wt===null){st===null&&(st=un);break}t&&st&&wt.alternate===null&&n(ae,st),K=g(wt,K,lt),nt===null?Ze=wt:nt.sibling=wt,nt=wt,st=un}if(lt===re.length)return i(ae,st),It&&pr(ae,lt),Ze;if(st===null){for(;lt<re.length;lt++)st=Le(ae,re[lt],Fe),st!==null&&(K=g(st,K,lt),nt===null?Ze=st:nt.sibling=st,nt=st);return It&&pr(ae,lt),Ze}for(st=o(ae,st);lt<re.length;lt++)un=Ve(st,ae,lt,re[lt],Fe),un!==null&&(t&&un.alternate!==null&&st.delete(un.key===null?lt:un.key),K=g(un,K,lt),nt===null?Ze=un:nt.sibling=un,nt=un);return t&&st.forEach(function(za){return n(ae,za)}),It&&pr(ae,lt),Ze}function Je(ae,K,re,Fe){var Ze=ue(re);if(typeof Ze!="function")throw Error(r(150));if(re=Ze.call(re),re==null)throw Error(r(151));for(var nt=Ze=null,st=K,lt=K=0,un=null,wt=re.next();st!==null&&!wt.done;lt++,wt=re.next()){st.index>lt?(un=st,st=null):un=st.sibling;var za=$e(ae,st,wt.value,Fe);if(za===null){st===null&&(st=un);break}t&&st&&za.alternate===null&&n(ae,st),K=g(za,K,lt),nt===null?Ze=za:nt.sibling=za,nt=za,st=un}if(wt.done)return i(ae,st),It&&pr(ae,lt),Ze;if(st===null){for(;!wt.done;lt++,wt=re.next())wt=Le(ae,wt.value,Fe),wt!==null&&(K=g(wt,K,lt),nt===null?Ze=wt:nt.sibling=wt,nt=wt);return It&&pr(ae,lt),Ze}for(st=o(ae,st);!wt.done;lt++,wt=re.next())wt=Ve(st,ae,lt,wt.value,Fe),wt!==null&&(t&&wt.alternate!==null&&st.delete(wt.key===null?lt:wt.key),K=g(wt,K,lt),nt===null?Ze=wt:nt.sibling=wt,nt=wt);return t&&st.forEach(function(_p){return n(ae,_p)}),It&&pr(ae,lt),Ze}function Kt(ae,K,re,Fe){if(typeof re=="object"&&re!==null&&re.type===oe&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case $:e:{for(var Ze=re.key,nt=K;nt!==null;){if(nt.key===Ze){if(Ze=re.type,Ze===oe){if(nt.tag===7){i(ae,nt.sibling),K=m(nt,re.props.children),K.return=ae,ae=K;break e}}else if(nt.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===W&&bd(Ze)===nt.type){i(ae,nt.sibling),K=m(nt,re.props),K.ref=tl(ae,nt,re),K.return=ae,ae=K;break e}i(ae,nt);break}else n(ae,nt);nt=nt.sibling}re.type===oe?(K=jr(re.props.children,ae.mode,Fe,re.key),K.return=ae,ae=K):(Fe=Lo(re.type,re.key,re.props,null,ae.mode,Fe),Fe.ref=tl(ae,K,re),Fe.return=ae,ae=Fe)}return k(ae);case Z:e:{for(nt=re.key;K!==null;){if(K.key===nt)if(K.tag===4&&K.stateNode.containerInfo===re.containerInfo&&K.stateNode.implementation===re.implementation){i(ae,K.sibling),K=m(K,re.children||[]),K.return=ae,ae=K;break e}else{i(ae,K);break}else n(ae,K);K=K.sibling}K=uu(re,ae.mode,Fe),K.return=ae,ae=K}return k(ae);case W:return nt=re._init,Kt(ae,K,nt(re._payload),Fe)}if(ie(re))return Qe(ae,K,re,Fe);if(ue(re))return Je(ae,K,re,Fe);oo(ae,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,K!==null&&K.tag===6?(i(ae,K.sibling),K=m(K,re),K.return=ae,ae=K):(i(ae,K),K=cu(re,ae.mode,Fe),K.return=ae,ae=K),k(ae)):i(ae,K)}return Kt}var ii=wd(!0),jd=wd(!1),co=_s(null),uo=null,li=null,yc=null;function xc(){yc=li=uo=null}function bc(t){var n=co.current;$t(co),t._currentValue=n}function wc(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 oi(t,n){uo=t,yc=li=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&(Mn=!0),t.firstContext=null)}function ts(t){var n=t._currentValue;if(yc!==t)if(t={context:t,memoizedValue:n,next:null},li===null){if(uo===null)throw Error(r(308));li=t,uo.dependencies={lanes:0,firstContext:t}}else li=li.next=t;return n}var _r=null;function jc(t){_r===null?_r=[t]:_r.push(t)}function kd(t,n,i,o){var m=n.interleaved;return m===null?(i.next=i,jc(n)):(i.next=m.next,m.next=i),n.interleaved=i,la(t,o)}function la(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 Ca=!1;function kc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sd(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 oa(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function $a(t,n,i){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(vt&2)!==0){var m=o.pending;return m===null?n.next=n:(n.next=m.next,m.next=n),o.pending=n,la(t,i)}return m=o.interleaved,m===null?(n.next=n,jc(o)):(n.next=m.next,m.next=n),o.interleaved=n,la(t,i)}function mo(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,Pr(t,i)}}function Nd(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 k={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?m=g=k:g=g.next=k,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 fo(t,n,i,o){var m=t.updateQueue;Ca=!1;var g=m.firstBaseUpdate,k=m.lastBaseUpdate,z=m.shared.pending;if(z!==null){m.shared.pending=null;var H=z,de=H.next;H.next=null,k===null?g=de:k.next=de,k=H;var Te=t.alternate;Te!==null&&(Te=Te.updateQueue,z=Te.lastBaseUpdate,z!==k&&(z===null?Te.firstBaseUpdate=de:z.next=de,Te.lastBaseUpdate=H))}if(g!==null){var Le=m.baseState;k=0,Te=de=H=null,z=g;do{var $e=z.lane,Ve=z.eventTime;if((o&$e)===$e){Te!==null&&(Te=Te.next={eventTime:Ve,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Qe=t,Je=z;switch($e=n,Ve=i,Je.tag){case 1:if(Qe=Je.payload,typeof Qe=="function"){Le=Qe.call(Ve,Le,$e);break e}Le=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Je.payload,$e=typeof Qe=="function"?Qe.call(Ve,Le,$e):Qe,$e==null)break e;Le=V({},Le,$e);break e;case 2:Ca=!0}}z.callback!==null&&z.lane!==0&&(t.flags|=64,$e=m.effects,$e===null?m.effects=[z]:$e.push(z))}else Ve={eventTime:Ve,lane:$e,tag:z.tag,payload:z.payload,callback:z.callback,next:null},Te===null?(de=Te=Ve,H=Le):Te=Te.next=Ve,k|=$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&&(H=Le),m.baseState=H,m.firstBaseUpdate=de,m.lastBaseUpdate=Te,n=m.shared.interleaved,n!==null){m=n;do k|=m.lane,m=m.next;while(m!==n)}else g===null&&(m.shared.lanes=0);yr|=k,t.lanes=k,t.memoizedState=Le}}function Cd(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 nl={},Ms=_s(nl),sl=_s(nl),al=_s(nl);function gr(t){if(t===nl)throw Error(r(174));return t}function Sc(t,n){switch(u(al,n),u(sl,t),u(Ms,nl),t=n.nodeType,t){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:A(null,"");break;default:t=t===8?n.parentNode:n,n=t.namespaceURI||null,t=t.tagName,n=A(n,t)}$t(Ms),u(Ms,n)}function ci(){$t(Ms),$t(sl),$t(al)}function $d(t){gr(al.current);var n=gr(Ms.current),i=A(n,t.type);n!==i&&(u(sl,t),u(Ms,i))}function Nc(t){sl.current===t&&($t(Ms),$t(sl))}var Dt=_s(0);function ho(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 Cc=[];function $c(){for(var t=0;t<Cc.length;t++)Cc[t]._workInProgressVersionPrimary=null;Cc.length=0}var po=Q.ReactCurrentDispatcher,Ec=Q.ReactCurrentBatchConfig,vr=0,Ft=null,tn=null,on=null,_o=!1,rl=!1,il=0,Oh=0;function wn(){throw Error(r(321))}function Tc(t,n){if(n===null)return!1;for(var i=0;i<n.length&&i<t.length;i++)if(!Tn(t[i],n[i]))return!1;return!0}function Ac(t,n,i,o,m,g){if(vr=g,Ft=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,po.current=t===null||t.memoizedState===null?Bh:Uh,t=i(o,m),rl){g=0;do{if(rl=!1,il=0,25<=g)throw Error(r(301));g+=1,on=tn=null,n.updateQueue=null,po.current=Wh,t=i(o,m)}while(rl)}if(po.current=yo,n=tn!==null&&tn.next!==null,vr=0,on=tn=Ft=null,_o=!1,n)throw Error(r(300));return t}function Rc(){var t=il!==0;return il=0,t}function zs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return on===null?Ft.memoizedState=on=t:on=on.next=t,on}function ns(){if(tn===null){var t=Ft.alternate;t=t!==null?t.memoizedState:null}else t=tn.next;var n=on===null?Ft.memoizedState:on.next;if(n!==null)on=n,tn=t;else{if(t===null)throw Error(r(310));tn=t,t={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},on===null?Ft.memoizedState=on=t:on=on.next=t}return on}function ll(t,n){return typeof n=="function"?n(t):n}function Lc(t){var n=ns(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=tn,m=o.baseQueue,g=i.pending;if(g!==null){if(m!==null){var k=m.next;m.next=g.next,g.next=k}o.baseQueue=m=g,i.pending=null}if(m!==null){g=m.next,o=o.baseState;var z=k=null,H=null,de=g;do{var Te=de.lane;if((vr&Te)===Te)H!==null&&(H=H.next={lane:0,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),o=de.hasEagerState?de.eagerState:t(o,de.action);else{var Le={lane:Te,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null};H===null?(z=H=Le,k=o):H=H.next=Le,Ft.lanes|=Te,yr|=Te}de=de.next}while(de!==null&&de!==g);H===null?k=o:H.next=z,Tn(o,n.memoizedState)||(Mn=!0),n.memoizedState=o,n.baseState=k,n.baseQueue=H,i.lastRenderedState=o}if(t=i.interleaved,t!==null){m=t;do g=m.lane,Ft.lanes|=g,yr|=g,m=m.next;while(m!==t)}else m===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Mc(t){var n=ns(),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 k=m=m.next;do g=t(g,k.action),k=k.next;while(k!==m);Tn(g,n.memoizedState)||(Mn=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),i.lastRenderedState=g}return[g,o]}function Ed(){}function Td(t,n){var i=Ft,o=ns(),m=n(),g=!Tn(o.memoizedState,m);if(g&&(o.memoizedState=m,Mn=!0),o=o.queue,zc(Ld.bind(null,i,o,t),[t]),o.getSnapshot!==n||g||on!==null&&on.memoizedState.tag&1){if(i.flags|=2048,ol(9,Rd.bind(null,i,o,m,n),void 0,null),cn===null)throw Error(r(349));(vr&30)!==0||Ad(i,n,m)}return m}function Ad(t,n,i){t.flags|=16384,t={getSnapshot:n,value:i},n=Ft.updateQueue,n===null?(n={lastEffect:null,stores:null},Ft.updateQueue=n,n.stores=[t]):(i=n.stores,i===null?n.stores=[t]:i.push(t))}function Rd(t,n,i,o){n.value=i,n.getSnapshot=o,Md(n)&&zd(t)}function Ld(t,n,i){return i(function(){Md(n)&&zd(t)})}function Md(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!Tn(t,i)}catch{return!0}}function zd(t){var n=la(t,1);n!==null&&bs(n,t,1,-1)}function Pd(t){var n=zs();return typeof t=="function"&&(t=t()),n.memoizedState=n.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ll,lastRenderedState:t},n.queue=t,t=t.dispatch=qh.bind(null,Ft,t),[n.memoizedState,t]}function ol(t,n,i,o){return t={tag:t,create:n,destroy:i,deps:o,next:null},n=Ft.updateQueue,n===null?(n={lastEffect:null,stores:null},Ft.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 Id(){return ns().memoizedState}function go(t,n,i,o){var m=zs();Ft.flags|=t,m.memoizedState=ol(1|n,i,void 0,o===void 0?null:o)}function vo(t,n,i,o){var m=ns();o=o===void 0?null:o;var g=void 0;if(tn!==null){var k=tn.memoizedState;if(g=k.destroy,o!==null&&Tc(o,k.deps)){m.memoizedState=ol(n,i,g,o);return}}Ft.flags|=t,m.memoizedState=ol(1|n,i,g,o)}function Od(t,n){return go(8390656,8,t,n)}function zc(t,n){return vo(2048,8,t,n)}function Dd(t,n){return vo(4,2,t,n)}function Fd(t,n){return vo(4,4,t,n)}function qd(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 Bd(t,n,i){return i=i!=null?i.concat([t]):null,vo(4,4,qd.bind(null,n,t),i)}function Pc(){}function Ud(t,n){var i=ns();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Tc(n,o[1])?o[0]:(i.memoizedState=[t,n],t)}function Wd(t,n){var i=ns();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Tc(n,o[1])?o[0]:(t=t(),i.memoizedState=[t,n],t)}function Hd(t,n,i){return(vr&21)===0?(t.baseState&&(t.baseState=!1,Mn=!0),t.memoizedState=i):(Tn(i,n)||(i=Bs(),Ft.lanes|=i,yr|=i,t.baseState=!0),n)}function Dh(t,n){var i=ct;ct=i!==0&&4>i?i:4,t(!0);var o=Ec.transition;Ec.transition={};try{t(!1),n()}finally{ct=i,Ec.transition=o}}function Vd(){return ns().memoizedState}function Fh(t,n,i){var o=Ra(t);if(i={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null},Gd(t))Kd(n,i);else if(i=kd(t,n,i,o),i!==null){var m=Cn();bs(i,t,o,m),Qd(i,n,o)}}function qh(t,n,i){var o=Ra(t),m={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null};if(Gd(t))Kd(n,m);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var k=n.lastRenderedState,z=g(k,i);if(m.hasEagerState=!0,m.eagerState=z,Tn(z,k)){var H=n.interleaved;H===null?(m.next=m,jc(n)):(m.next=H.next,H.next=m),n.interleaved=m;return}}catch{}finally{}i=kd(t,n,m,o),i!==null&&(m=Cn(),bs(i,t,o,m),Qd(i,n,o))}}function Gd(t){var n=t.alternate;return t===Ft||n!==null&&n===Ft}function Kd(t,n){rl=_o=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function Qd(t,n,i){if((i&4194240)!==0){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,Pr(t,i)}}var yo={readContext:ts,useCallback:wn,useContext:wn,useEffect:wn,useImperativeHandle:wn,useInsertionEffect:wn,useLayoutEffect:wn,useMemo:wn,useReducer:wn,useRef:wn,useState:wn,useDebugValue:wn,useDeferredValue:wn,useTransition:wn,useMutableSource:wn,useSyncExternalStore:wn,useId:wn,unstable_isNewReconciler:!1},Bh={readContext:ts,useCallback:function(t,n){return zs().memoizedState=[t,n===void 0?null:n],t},useContext:ts,useEffect:Od,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,go(4194308,4,qd.bind(null,n,t),i)},useLayoutEffect:function(t,n){return go(4194308,4,t,n)},useInsertionEffect:function(t,n){return go(4,2,t,n)},useMemo:function(t,n){var i=zs();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var o=zs();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=Fh.bind(null,Ft,t),[o.memoizedState,t]},useRef:function(t){var n=zs();return t={current:t},n.memoizedState=t},useState:Pd,useDebugValue:Pc,useDeferredValue:function(t){return zs().memoizedState=t},useTransition:function(){var t=Pd(!1),n=t[0];return t=Dh.bind(null,t[1]),zs().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var o=Ft,m=zs();if(It){if(i===void 0)throw Error(r(407));i=i()}else{if(i=n(),cn===null)throw Error(r(349));(vr&30)!==0||Ad(o,n,i)}m.memoizedState=i;var g={value:i,getSnapshot:n};return m.queue=g,Od(Ld.bind(null,o,g,t),[t]),o.flags|=2048,ol(9,Rd.bind(null,o,g,i,n),void 0,null),i},useId:function(){var t=zs(),n=cn.identifierPrefix;if(It){var i=ia,o=Ln;i=(o&~(1<<32-Sn(o)-1)).toString(32)+i,n=":"+n+"R"+i,i=il++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=Oh++,n=":"+n+"r"+i.toString(32)+":";return t.memoizedState=n},unstable_isNewReconciler:!1},Uh={readContext:ts,useCallback:Ud,useContext:ts,useEffect:zc,useImperativeHandle:Bd,useInsertionEffect:Dd,useLayoutEffect:Fd,useMemo:Wd,useReducer:Lc,useRef:Id,useState:function(){return Lc(ll)},useDebugValue:Pc,useDeferredValue:function(t){var n=ns();return Hd(n,tn.memoizedState,t)},useTransition:function(){var t=Lc(ll)[0],n=ns().memoizedState;return[t,n]},useMutableSource:Ed,useSyncExternalStore:Td,useId:Vd,unstable_isNewReconciler:!1},Wh={readContext:ts,useCallback:Ud,useContext:ts,useEffect:zc,useImperativeHandle:Bd,useInsertionEffect:Dd,useLayoutEffect:Fd,useMemo:Wd,useReducer:Mc,useRef:Id,useState:function(){return Mc(ll)},useDebugValue:Pc,useDeferredValue:function(t){var n=ns();return tn===null?n.memoizedState=t:Hd(n,tn.memoizedState,t)},useTransition:function(){var t=Mc(ll)[0],n=ns().memoizedState;return[t,n]},useMutableSource:Ed,useSyncExternalStore:Td,useId:Vd,unstable_isNewReconciler:!1};function vs(t,n){if(t&&t.defaultProps){n=V({},n),t=t.defaultProps;for(var i in t)n[i]===void 0&&(n[i]=t[i]);return n}return n}function Ic(t,n,i,o){n=t.memoizedState,i=i(o,n),i=i==null?n:V({},n,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var xo={isMounted:function(t){return(t=t._reactInternals)?Jn(t)===t:!1},enqueueSetState:function(t,n,i){t=t._reactInternals;var o=Cn(),m=Ra(t),g=oa(o,m);g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,m),n!==null&&(bs(n,t,m,o),mo(n,t,m))},enqueueReplaceState:function(t,n,i){t=t._reactInternals;var o=Cn(),m=Ra(t),g=oa(o,m);g.tag=1,g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,m),n!==null&&(bs(n,t,m,o),mo(n,t,m))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var i=Cn(),o=Ra(t),m=oa(i,o);m.tag=2,n!=null&&(m.callback=n),n=$a(t,m,o),n!==null&&(bs(n,t,o,i),mo(n,t,o))}};function Jd(t,n,i,o,m,g,k){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,g,k):n.prototype&&n.prototype.isPureReactComponent?!Ts(i,o)||!Ts(m,g):!0}function Yd(t,n,i){var o=!1,m=v,g=n.contextType;return typeof g=="object"&&g!==null?g=ts(g):(m=B(n)?T:S.current,o=n.contextTypes,g=(o=o!=null)?ne(t,m):v),n=new n(i,g),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=xo,t.stateNode=n,n._reactInternals=t,o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=m,t.__reactInternalMemoizedMaskedChildContext=g),n}function Xd(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&&xo.enqueueReplaceState(n,n.state,null)}function Oc(t,n,i,o){var m=t.stateNode;m.props=i,m.state=t.memoizedState,m.refs={},kc(t);var g=n.contextType;typeof g=="object"&&g!==null?m.context=ts(g):(g=B(n)?T:S.current,m.context=ne(t,g)),m.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(Ic(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&&xo.enqueueReplaceState(m,m.state,null),fo(t,i,m,o),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308)}function ui(t,n){try{var i="",o=n;do i+=he(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 Dc(t,n,i){return{value:t,source:null,stack:i??null,digest:n??null}}function Fc(t,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Hh=typeof WeakMap=="function"?WeakMap:Map;function Zd(t,n,i){i=oa(-1,i),i.tag=3,i.payload={element:null};var o=n.value;return i.callback=function(){Co||(Co=!0,tu=o),Fc(t,n)},i}function em(t,n,i){i=oa(-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(){Fc(t,n)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){Fc(t,n),typeof o!="function"&&(Ta===null?Ta=new Set([this]):Ta.add(this));var k=n.stack;this.componentDidCatch(n.value,{componentStack:k!==null?k:""})}),i}function tm(t,n,i){var o=t.pingCache;if(o===null){o=t.pingCache=new Hh;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=rp.bind(null,t,n,i),n.then(t,t))}function nm(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 sm(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=oa(-1,1),n.tag=2,$a(i,n,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=m,t)}var Vh=Q.ReactCurrentOwner,Mn=!1;function Nn(t,n,i,o){n.child=t===null?jd(n,null,i,o):ii(n,t.child,i,o)}function am(t,n,i,o,m){i=i.render;var g=n.ref;return oi(n,m),o=Ac(t,n,i,o,g,m),i=Rc(),t!==null&&!Mn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~m,ca(t,n,m)):(It&&i&&hc(n),n.flags|=1,Nn(t,n,o,m),n.child)}function rm(t,n,i,o,m){if(t===null){var g=i.type;return typeof g=="function"&&!ou(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,im(t,n,g,o,m)):(t=Lo(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 k=g.memoizedProps;if(i=i.compare,i=i!==null?i:Ts,i(k,o)&&t.ref===n.ref)return ca(t,n,m)}return n.flags|=1,t=Ma(g,o),t.ref=n.ref,t.return=n,n.child=t}function im(t,n,i,o,m){if(t!==null){var g=t.memoizedProps;if(Ts(g,o)&&t.ref===n.ref)if(Mn=!1,n.pendingProps=o=g,(t.lanes&m)!==0)(t.flags&131072)!==0&&(Mn=!0);else return n.lanes=t.lanes,ca(t,n,m)}return qc(t,n,i,o,m)}function lm(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},u(mi,Kn),Kn|=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,u(mi,Kn),Kn|=t,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},o=g!==null?g.baseLanes:i,u(mi,Kn),Kn|=o}else g!==null?(o=g.baseLanes|i,n.memoizedState=null):o=i,u(mi,Kn),Kn|=o;return Nn(t,n,m,i),n.child}function om(t,n){var i=n.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function qc(t,n,i,o,m){var g=B(i)?T:S.current;return g=ne(n,g),oi(n,m),i=Ac(t,n,i,o,g,m),o=Rc(),t!==null&&!Mn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~m,ca(t,n,m)):(It&&o&&hc(n),n.flags|=1,Nn(t,n,i,m),n.child)}function cm(t,n,i,o,m){if(B(i)){var g=!0;Ue(n)}else g=!1;if(oi(n,m),n.stateNode===null)wo(t,n),Yd(n,i,o),Oc(n,i,o,m),o=!0;else if(t===null){var k=n.stateNode,z=n.memoizedProps;k.props=z;var H=k.context,de=i.contextType;typeof de=="object"&&de!==null?de=ts(de):(de=B(i)?T:S.current,de=ne(n,de));var Te=i.getDerivedStateFromProps,Le=typeof Te=="function"||typeof k.getSnapshotBeforeUpdate=="function";Le||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(z!==o||H!==de)&&Xd(n,k,o,de),Ca=!1;var $e=n.memoizedState;k.state=$e,fo(n,o,k,m),H=n.memoizedState,z!==o||$e!==H||w.current||Ca?(typeof Te=="function"&&(Ic(n,i,Te,o),H=n.memoizedState),(z=Ca||Jd(n,i,z,o,$e,H,de))?(Le||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(n.flags|=4194308)):(typeof k.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=H),k.props=o,k.state=H,k.context=de,o=z):(typeof k.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{k=n.stateNode,Sd(t,n),z=n.memoizedProps,de=n.type===n.elementType?z:vs(n.type,z),k.props=de,Le=n.pendingProps,$e=k.context,H=i.contextType,typeof H=="object"&&H!==null?H=ts(H):(H=B(i)?T:S.current,H=ne(n,H));var Ve=i.getDerivedStateFromProps;(Te=typeof Ve=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(z!==Le||$e!==H)&&Xd(n,k,o,H),Ca=!1,$e=n.memoizedState,k.state=$e,fo(n,o,k,m);var Qe=n.memoizedState;z!==Le||$e!==Qe||w.current||Ca?(typeof Ve=="function"&&(Ic(n,i,Ve,o),Qe=n.memoizedState),(de=Ca||Jd(n,i,de,o,$e,Qe,H)||!1)?(Te||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(o,Qe,H),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(o,Qe,H)),typeof k.componentDidUpdate=="function"&&(n.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof k.componentDidUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=Qe),k.props=o,k.state=Qe,k.context=H,o=de):(typeof k.componentDidUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||z===t.memoizedProps&&$e===t.memoizedState||(n.flags|=1024),o=!1)}return Bc(t,n,i,o,g,m)}function Bc(t,n,i,o,m,g){om(t,n);var k=(n.flags&128)!==0;if(!o&&!k)return m&&Mt(n,i,!1),ca(t,n,g);o=n.stateNode,Vh.current=n;var z=k&&typeof i.getDerivedStateFromError!="function"?null:o.render();return n.flags|=1,t!==null&&k?(n.child=ii(n,t.child,null,g),n.child=ii(n,null,z,g)):Nn(t,n,z,g),n.memoizedState=o.state,m&&Mt(n,i,!0),n.child}function um(t){var n=t.stateNode;n.pendingContext?De(t,n.pendingContext,n.pendingContext!==n.context):n.context&&De(t,n.context,!1),Sc(t,n.containerInfo)}function dm(t,n,i,o,m){return ri(),vc(m),n.flags|=256,Nn(t,n,i,o),n.child}var Uc={dehydrated:null,treeContext:null,retryLane:0};function Wc(t){return{baseLanes:t,cachePool:null,transitions:null}}function mm(t,n,i){var o=n.pendingProps,m=Dt.current,g=!1,k=(n.flags&128)!==0,z;if((z=k)||(z=t!==null&&t.memoizedState===null?!1:(m&2)!==0),z?(g=!0,n.flags&=-129):(t===null||t.memoizedState!==null)&&(m|=1),u(Dt,m&1),t===null)return gc(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):(k=o.children,t=o.fallback,g?(o=n.mode,g=n.child,k={mode:"hidden",children:k},(o&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=k):g=Mo(k,o,0,null),t=jr(t,o,i,null),g.return=n,t.return=n,g.sibling=t,n.child=g,n.child.memoizedState=Wc(i),n.memoizedState=Uc,t):Hc(n,k));if(m=t.memoizedState,m!==null&&(z=m.dehydrated,z!==null))return Gh(t,n,k,o,z,m,i);if(g){g=o.fallback,k=n.mode,m=t.child,z=m.sibling;var H={mode:"hidden",children:o.children};return(k&1)===0&&n.child!==m?(o=n.child,o.childLanes=0,o.pendingProps=H,n.deletions=null):(o=Ma(m,H),o.subtreeFlags=m.subtreeFlags&14680064),z!==null?g=Ma(z,g):(g=jr(g,k,i,null),g.flags|=2),g.return=n,o.return=n,o.sibling=g,n.child=o,o=g,g=n.child,k=t.child.memoizedState,k=k===null?Wc(i):{baseLanes:k.baseLanes|i,cachePool:null,transitions:k.transitions},g.memoizedState=k,g.childLanes=t.childLanes&~i,n.memoizedState=Uc,o}return g=t.child,t=g.sibling,o=Ma(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 Hc(t,n){return n=Mo({mode:"visible",children:n},t.mode,0,null),n.return=t,t.child=n}function bo(t,n,i,o){return o!==null&&vc(o),ii(n,t.child,null,i),t=Hc(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function Gh(t,n,i,o,m,g,k){if(i)return n.flags&256?(n.flags&=-257,o=Dc(Error(r(422))),bo(t,n,k,o)):n.memoizedState!==null?(n.child=t.child,n.flags|=128,null):(g=o.fallback,m=n.mode,o=Mo({mode:"visible",children:o.children},m,0,null),g=jr(g,m,k,null),g.flags|=2,o.return=n,g.return=n,o.sibling=g,n.child=o,(n.mode&1)!==0&&ii(n,t.child,null,k),n.child.memoizedState=Wc(k),n.memoizedState=Uc,g);if((n.mode&1)===0)return bo(t,n,k,null);if(m.data==="$!"){if(o=m.nextSibling&&m.nextSibling.dataset,o)var z=o.dgst;return o=z,g=Error(r(419)),o=Dc(g,o,void 0),bo(t,n,k,o)}if(z=(k&t.childLanes)!==0,Mn||z){if(o=cn,o!==null){switch(k&-k){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|k))!==0?0:m,m!==0&&m!==g.retryLane&&(g.retryLane=m,la(t,m),bs(o,t,m,-1))}return lu(),o=Dc(Error(r(421))),bo(t,n,k,o)}return m.data==="$?"?(n.flags|=128,n.child=t.child,n=ip.bind(null,t),m._reactRetry=n,null):(t=g.treeContext,Gn=Rs(m.nextSibling),Vn=n,It=!0,gs=null,t!==null&&(jt[ft++]=Ln,jt[ft++]=ia,jt[ft++]=zt,Ln=t.id,ia=t.overflow,zt=n),n=Hc(n,o.children),n.flags|=4096,n)}function fm(t,n,i){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),wc(t.return,n,i)}function Vc(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 hm(t,n,i){var o=n.pendingProps,m=o.revealOrder,g=o.tail;if(Nn(t,n,o.children,i),o=Dt.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&&fm(t,i,n);else if(t.tag===19)fm(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(u(Dt,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&&ho(t)===null&&(m=i),i=i.sibling;i=m,i===null?(m=n.child,n.child=null):(m=i.sibling,i.sibling=null),Vc(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&&ho(t)===null){n.child=m;break}t=m.sibling,m.sibling=i,i=m,m=t}Vc(n,!0,i,null,g);break;case"together":Vc(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function wo(t,n){(n.mode&1)===0&&t!==null&&(t.alternate=null,n.alternate=null,n.flags|=2)}function ca(t,n,i){if(t!==null&&(n.dependencies=t.dependencies),yr|=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=Ma(t,t.pendingProps),n.child=i,i.return=n;t.sibling!==null;)t=t.sibling,i=i.sibling=Ma(t,t.pendingProps),i.return=n;i.sibling=null}return n.child}function Kh(t,n,i){switch(n.tag){case 3:um(n),ri();break;case 5:$d(n);break;case 1:B(n.type)&&Ue(n);break;case 4:Sc(n,n.stateNode.containerInfo);break;case 10:var o=n.type._context,m=n.memoizedProps.value;u(co,o._currentValue),o._currentValue=m;break;case 13:if(o=n.memoizedState,o!==null)return o.dehydrated!==null?(u(Dt,Dt.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?mm(t,n,i):(u(Dt,Dt.current&1),t=ca(t,n,i),t!==null?t.sibling:null);u(Dt,Dt.current&1);break;case 19:if(o=(i&n.childLanes)!==0,(t.flags&128)!==0){if(o)return hm(t,n,i);n.flags|=128}if(m=n.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),u(Dt,Dt.current),o)break;return null;case 22:case 23:return n.lanes=0,lm(t,n,i)}return ca(t,n,i)}var pm,Gc,_m,gm;pm=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}},Gc=function(){},_m=function(t,n,i,o){var m=t.memoizedProps;if(m!==o){t=n.stateNode,gr(Ms.current);var g=null;switch(i){case"input":m=Pe(t,m),o=Pe(t,o),g=[];break;case"select":m=V({},m,{value:void 0}),o=V({},o,{value:void 0}),g=[];break;case"textarea":m=be(t,m),o=be(t,o),g=[];break;default:typeof m.onClick!="function"&&typeof o.onClick=="function"&&(t.onclick=ni)}Tt(i,o);var k;i=null;for(de in m)if(!o.hasOwnProperty(de)&&m.hasOwnProperty(de)&&m[de]!=null)if(de==="style"){var z=m[de];for(k in z)z.hasOwnProperty(k)&&(i||(i={}),i[k]="")}else de!=="dangerouslySetInnerHTML"&&de!=="children"&&de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&de!=="autoFocus"&&(c.hasOwnProperty(de)?g||(g=[]):(g=g||[]).push(de,null));for(de in o){var H=o[de];if(z=m!=null?m[de]:void 0,o.hasOwnProperty(de)&&H!==z&&(H!=null||z!=null))if(de==="style")if(z){for(k in z)!z.hasOwnProperty(k)||H&&H.hasOwnProperty(k)||(i||(i={}),i[k]="");for(k in H)H.hasOwnProperty(k)&&z[k]!==H[k]&&(i||(i={}),i[k]=H[k])}else i||(g||(g=[]),g.push(de,i)),i=H;else de==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,z=z?z.__html:void 0,H!=null&&z!==H&&(g=g||[]).push(de,H)):de==="children"?typeof H!="string"&&typeof H!="number"||(g=g||[]).push(de,""+H):de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&(c.hasOwnProperty(de)?(H!=null&&de==="onScroll"&&At("scroll",t),g||z===H||(g=[])):(g=g||[]).push(de,H))}i&&(g=g||[]).push("style",i);var de=g;(n.updateQueue=de)&&(n.flags|=4)}},gm=function(t,n,i,o){i!==o&&(n.flags|=4)};function cl(t,n){if(!It)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 jn(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 Qh(t,n,i){var o=n.pendingProps;switch(pc(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jn(n),null;case 1:return B(n.type)&&xe(),jn(n),null;case 3:return o=n.stateNode,ci(),$t(w),$t(S),$c(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(t===null||t.child===null)&&(lo(n)?n.flags|=4:t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,gs!==null&&(au(gs),gs=null))),Gc(t,n),jn(n),null;case 5:Nc(n);var m=gr(al.current);if(i=n.type,t!==null&&n.stateNode!=null)_m(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 jn(n),null}if(t=gr(Ms.current),lo(n)){o=n.stateNode,i=n.type;var g=n.memoizedProps;switch(o[An]=n,o[mr]=g,t=(n.mode&1)!==0,i){case"dialog":At("cancel",o),At("close",o);break;case"iframe":case"object":case"embed":At("load",o);break;case"video":case"audio":for(m=0;m<ta.length;m++)At(ta[m],o);break;case"source":At("error",o);break;case"img":case"image":case"link":At("error",o),At("load",o);break;case"details":At("toggle",o);break;case"input":se(o,g),At("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!g.multiple},At("invalid",o);break;case"textarea":G(o,g),At("invalid",o)}Tt(i,g),m=null;for(var k in g)if(g.hasOwnProperty(k)){var z=g[k];k==="children"?typeof z=="string"?o.textContent!==z&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,z,t),m=["children",z]):typeof z=="number"&&o.textContent!==""+z&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,z,t),m=["children",""+z]):c.hasOwnProperty(k)&&z!=null&&k==="onScroll"&&At("scroll",o)}switch(i){case"input":We(o),qe(o,g,!0);break;case"textarea":We(o),Xe(o);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(o.onclick=ni)}o=m,n.updateQueue=o,o!==null&&(n.flags|=4)}else{k=m.nodeType===9?m:m.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=J(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=k.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof o.is=="string"?t=k.createElement(i,{is:o.is}):(t=k.createElement(i),i==="select"&&(k=t,o.multiple?k.multiple=!0:o.size&&(k.size=o.size))):t=k.createElementNS(t,i),t[An]=n,t[mr]=o,pm(t,n,!1,!1),n.stateNode=t;e:{switch(k=qt(i,o),i){case"dialog":At("cancel",t),At("close",t),m=o;break;case"iframe":case"object":case"embed":At("load",t),m=o;break;case"video":case"audio":for(m=0;m<ta.length;m++)At(ta[m],t);m=o;break;case"source":At("error",t),m=o;break;case"img":case"image":case"link":At("error",t),At("load",t),m=o;break;case"details":At("toggle",t),m=o;break;case"input":se(t,o),m=Pe(t,o),At("invalid",t);break;case"option":m=o;break;case"select":t._wrapperState={wasMultiple:!!o.multiple},m=V({},o,{value:void 0}),At("invalid",t);break;case"textarea":G(t,o),m=be(t,o),At("invalid",t);break;default:m=o}Tt(i,m),z=m;for(g in z)if(z.hasOwnProperty(g)){var H=z[g];g==="style"?yt(t,H):g==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,H!=null&&Ne(t,H)):g==="children"?typeof H=="string"?(i!=="textarea"||H!=="")&&ze(t,H):typeof H=="number"&&ze(t,""+H):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(c.hasOwnProperty(g)?H!=null&&g==="onScroll"&&At("scroll",t):H!=null&&F(t,g,H,k))}switch(i){case"input":We(t),qe(t,o,!1);break;case"textarea":We(t),Xe(t);break;case"option":o.value!=null&&t.setAttribute("value",""+te(o.value));break;case"select":t.multiple=!!o.multiple,g=o.value,g!=null?fe(t,!!o.multiple,g,!1):o.defaultValue!=null&&fe(t,!!o.multiple,o.defaultValue,!0);break;default:typeof m.onClick=="function"&&(t.onclick=ni)}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 jn(n),null;case 6:if(t&&n.stateNode!=null)gm(t,n,t.memoizedProps,o);else{if(typeof o!="string"&&n.stateNode===null)throw Error(r(166));if(i=gr(al.current),gr(Ms.current),lo(n)){if(o=n.stateNode,i=n.memoizedProps,o[An]=n,(g=o.nodeValue!==i)&&(t=Vn,t!==null))switch(t.tag){case 3:sa(o.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&sa(o.nodeValue,i,(t.mode&1)!==0)}g&&(n.flags|=4)}else o=(i.nodeType===9?i:i.ownerDocument).createTextNode(o),o[An]=n,n.stateNode=o}return jn(n),null;case 13:if($t(Dt),o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(It&&Gn!==null&&(n.mode&1)!==0&&(n.flags&128)===0)xd(),ri(),n.flags|=98560,g=!1;else if(g=lo(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[An]=n}else ri(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;jn(n),g=!1}else gs!==null&&(au(gs),gs=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||(Dt.current&1)!==0?nn===0&&(nn=3):lu())),n.updateQueue!==null&&(n.flags|=4),jn(n),null);case 4:return ci(),Gc(t,n),t===null&&ka(n.stateNode.containerInfo),jn(n),null;case 10:return bc(n.type._context),jn(n),null;case 17:return B(n.type)&&xe(),jn(n),null;case 19:if($t(Dt),g=n.memoizedState,g===null)return jn(n),null;if(o=(n.flags&128)!==0,k=g.rendering,k===null)if(o)cl(g,!1);else{if(nn!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(k=ho(t),k!==null){for(n.flags|=128,cl(g,!1),o=k.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,k=g.alternate,k===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=k.childLanes,g.lanes=k.lanes,g.child=k.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=k.memoizedProps,g.memoizedState=k.memoizedState,g.updateQueue=k.updateQueue,g.type=k.type,t=k.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return u(Dt,Dt.current&1|2),n.child}t=t.sibling}g.tail!==null&&Lt()>fi&&(n.flags|=128,o=!0,cl(g,!1),n.lanes=4194304)}else{if(!o)if(t=ho(k),t!==null){if(n.flags|=128,o=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),cl(g,!0),g.tail===null&&g.tailMode==="hidden"&&!k.alternate&&!It)return jn(n),null}else 2*Lt()-g.renderingStartTime>fi&&i!==1073741824&&(n.flags|=128,o=!0,cl(g,!1),n.lanes=4194304);g.isBackwards?(k.sibling=n.child,n.child=k):(i=g.last,i!==null?i.sibling=k:n.child=k,g.last=k)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Lt(),n.sibling=null,i=Dt.current,u(Dt,o?i&1|2:i&1),n):(jn(n),null);case 22:case 23:return iu(),o=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==o&&(n.flags|=8192),o&&(n.mode&1)!==0?(Kn&1073741824)!==0&&(jn(n),n.subtreeFlags&6&&(n.flags|=8192)):jn(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function Jh(t,n){switch(pc(n),n.tag){case 1:return B(n.type)&&xe(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return ci(),$t(w),$t(S),$c(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return Nc(n),null;case 13:if($t(Dt),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(r(340));ri()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return $t(Dt),null;case 4:return ci(),null;case 10:return bc(n.type._context),null;case 22:case 23:return iu(),null;case 24:return null;default:return null}}var jo=!1,kn=!1,Yh=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function di(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(o){Wt(t,n,o)}else i.current=null}function Kc(t,n,i){try{i()}catch(o){Wt(t,n,o)}}var vm=!1;function Xh(t,n){if(dr=Ya,t=Yl(),Hi(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 k=0,z=-1,H=-1,de=0,Te=0,Le=t,$e=null;t:for(;;){for(var Ve;Le!==i||m!==0&&Le.nodeType!==3||(z=k+m),Le!==g||o!==0&&Le.nodeType!==3||(H=k+o),Le.nodeType===3&&(k+=Le.nodeValue.length),(Ve=Le.firstChild)!==null;)$e=Le,Le=Ve;for(;;){if(Le===t)break t;if($e===i&&++de===m&&(z=k),$e===g&&++Te===o&&(H=k),(Ve=Le.nextSibling)!==null)break;Le=$e,$e=Le.parentNode}Le=Ve}i=z===-1||H===-1?null:{start:z,end:H}}else i=null}i=i||{start:0,end:0}}else i=null;for(Yi={focusedElem:t,selectionRange:i},Ya=!1,Ge=n;Ge!==null;)if(n=Ge,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Ge=t;else for(;Ge!==null;){n=Ge;try{var Qe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Je=Qe.memoizedProps,Kt=Qe.memoizedState,ae=n.stateNode,K=ae.getSnapshotBeforeUpdate(n.elementType===n.type?Je:vs(n.type,Je),Kt);ae.__reactInternalSnapshotBeforeUpdate=K}break;case 3:var re=n.stateNode.containerInfo;re.nodeType===1?re.textContent="":re.nodeType===9&&re.documentElement&&re.removeChild(re.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Fe){Wt(n,n.return,Fe)}if(t=n.sibling,t!==null){t.return=n.return,Ge=t;break}Ge=n.return}return Qe=vm,vm=!1,Qe}function ul(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&&Kc(n,i,g)}m=m.next}while(m!==o)}}function ko(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 Qc(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 ym(t){var n=t.alternate;n!==null&&(t.alternate=null,ym(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[An],delete n[mr],delete n[el],delete n[fc],delete n[io])),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 xm(t){return t.tag===5||t.tag===3||t.tag===4}function bm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||xm(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 Jc(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=ni));else if(o!==4&&(t=t.child,t!==null))for(Jc(t,n,i),t=t.sibling;t!==null;)Jc(t,n,i),t=t.sibling}function Yc(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(Yc(t,n,i),t=t.sibling;t!==null;)Yc(t,n,i),t=t.sibling}var vn=null,ys=!1;function Ea(t,n,i){for(i=i.child;i!==null;)wm(t,n,i),i=i.sibling}function wm(t,n,i){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(Va,i)}catch{}switch(i.tag){case 5:kn||di(i,n);case 6:var o=vn,m=ys;vn=null,Ea(t,n,i),vn=o,ys=m,vn!==null&&(ys?(t=vn,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):vn.removeChild(i.stateNode));break;case 18:vn!==null&&(ys?(t=vn,i=i.stateNode,t.nodeType===8?Zi(t.parentNode,i):t.nodeType===1&&Zi(t,i),os(t)):Zi(vn,i.stateNode));break;case 4:o=vn,m=ys,vn=i.stateNode.containerInfo,ys=!0,Ea(t,n,i),vn=o,ys=m;break;case 0:case 11:case 14:case 15:if(!kn&&(o=i.updateQueue,o!==null&&(o=o.lastEffect,o!==null))){m=o=o.next;do{var g=m,k=g.destroy;g=g.tag,k!==void 0&&((g&2)!==0||(g&4)!==0)&&Kc(i,n,k),m=m.next}while(m!==o)}Ea(t,n,i);break;case 1:if(!kn&&(di(i,n),o=i.stateNode,typeof o.componentWillUnmount=="function"))try{o.props=i.memoizedProps,o.state=i.memoizedState,o.componentWillUnmount()}catch(z){Wt(i,n,z)}Ea(t,n,i);break;case 21:Ea(t,n,i);break;case 22:i.mode&1?(kn=(o=kn)||i.memoizedState!==null,Ea(t,n,i),kn=o):Ea(t,n,i);break;default:Ea(t,n,i)}}function jm(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new Yh),n.forEach(function(o){var m=lp.bind(null,t,o);i.has(o)||(i.add(o),o.then(m,m))})}}function xs(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,k=n,z=k;e:for(;z!==null;){switch(z.tag){case 5:vn=z.stateNode,ys=!1;break e;case 3:vn=z.stateNode.containerInfo,ys=!0;break e;case 4:vn=z.stateNode.containerInfo,ys=!0;break e}z=z.return}if(vn===null)throw Error(r(160));wm(g,k,m),vn=null,ys=!1;var H=m.alternate;H!==null&&(H.return=null),m.return=null}catch(de){Wt(m,n,de)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)km(n,t),n=n.sibling}function km(t,n){var i=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(xs(n,t),Ps(t),o&4){try{ul(3,t,t.return),ko(3,t)}catch(Je){Wt(t,t.return,Je)}try{ul(5,t,t.return)}catch(Je){Wt(t,t.return,Je)}}break;case 1:xs(n,t),Ps(t),o&512&&i!==null&&di(i,i.return);break;case 5:if(xs(n,t),Ps(t),o&512&&i!==null&&di(i,i.return),t.flags&32){var m=t.stateNode;try{ze(m,"")}catch(Je){Wt(t,t.return,Je)}}if(o&4&&(m=t.stateNode,m!=null)){var g=t.memoizedProps,k=i!==null?i.memoizedProps:g,z=t.type,H=t.updateQueue;if(t.updateQueue=null,H!==null)try{z==="input"&&g.type==="radio"&&g.name!=null&&ye(m,g),qt(z,k);var de=qt(z,g);for(k=0;k<H.length;k+=2){var Te=H[k],Le=H[k+1];Te==="style"?yt(m,Le):Te==="dangerouslySetInnerHTML"?Ne(m,Le):Te==="children"?ze(m,Le):F(m,Te,Le,de)}switch(z){case"input":ge(m,g);break;case"textarea":Se(m,g);break;case"select":var $e=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!g.multiple;var Ve=g.value;Ve!=null?fe(m,!!g.multiple,Ve,!1):$e!==!!g.multiple&&(g.defaultValue!=null?fe(m,!!g.multiple,g.defaultValue,!0):fe(m,!!g.multiple,g.multiple?[]:"",!1))}m[mr]=g}catch(Je){Wt(t,t.return,Je)}}break;case 6:if(xs(n,t),Ps(t),o&4){if(t.stateNode===null)throw Error(r(162));m=t.stateNode,g=t.memoizedProps;try{m.nodeValue=g}catch(Je){Wt(t,t.return,Je)}}break;case 3:if(xs(n,t),Ps(t),o&4&&i!==null&&i.memoizedState.isDehydrated)try{os(n.containerInfo)}catch(Je){Wt(t,t.return,Je)}break;case 4:xs(n,t),Ps(t);break;case 13:xs(n,t),Ps(t),m=t.child,m.flags&8192&&(g=m.memoizedState!==null,m.stateNode.isHidden=g,!g||m.alternate!==null&&m.alternate.memoizedState!==null||(eu=Lt())),o&4&&jm(t);break;case 22:if(Te=i!==null&&i.memoizedState!==null,t.mode&1?(kn=(de=kn)||Te,xs(n,t),kn=de):xs(n,t),Ps(t),o&8192){if(de=t.memoizedState!==null,(t.stateNode.isHidden=de)&&!Te&&(t.mode&1)!==0)for(Ge=t,Te=t.child;Te!==null;){for(Le=Ge=Te;Ge!==null;){switch($e=Ge,Ve=$e.child,$e.tag){case 0:case 11:case 14:case 15:ul(4,$e,$e.return);break;case 1:di($e,$e.return);var Qe=$e.stateNode;if(typeof Qe.componentWillUnmount=="function"){o=$e,i=$e.return;try{n=o,Qe.props=n.memoizedProps,Qe.state=n.memoizedState,Qe.componentWillUnmount()}catch(Je){Wt(o,i,Je)}}break;case 5:di($e,$e.return);break;case 22:if($e.memoizedState!==null){Cm(Le);continue}}Ve!==null?(Ve.return=$e,Ge=Ve):Cm(Le)}Te=Te.sibling}e:for(Te=null,Le=t;;){if(Le.tag===5){if(Te===null){Te=Le;try{m=Le.stateNode,de?(g=m.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(z=Le.stateNode,H=Le.memoizedProps.style,k=H!=null&&H.hasOwnProperty("display")?H.display:null,z.style.display=dt("display",k))}catch(Je){Wt(t,t.return,Je)}}}else if(Le.tag===6){if(Te===null)try{Le.stateNode.nodeValue=de?"":Le.memoizedProps}catch(Je){Wt(t,t.return,Je)}}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:xs(n,t),Ps(t),o&4&&jm(t);break;case 21:break;default:xs(n,t),Ps(t)}}function Ps(t){var n=t.flags;if(n&2){try{e:{for(var i=t.return;i!==null;){if(xm(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&&(ze(m,""),o.flags&=-33);var g=bm(t);Yc(t,g,m);break;case 3:case 4:var k=o.stateNode.containerInfo,z=bm(t);Jc(t,z,k);break;default:throw Error(r(161))}}catch(H){Wt(t,t.return,H)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function Zh(t,n,i){Ge=t,Sm(t)}function Sm(t,n,i){for(var o=(t.mode&1)!==0;Ge!==null;){var m=Ge,g=m.child;if(m.tag===22&&o){var k=m.memoizedState!==null||jo;if(!k){var z=m.alternate,H=z!==null&&z.memoizedState!==null||kn;z=jo;var de=kn;if(jo=k,(kn=H)&&!de)for(Ge=m;Ge!==null;)k=Ge,H=k.child,k.tag===22&&k.memoizedState!==null?$m(m):H!==null?(H.return=k,Ge=H):$m(m);for(;g!==null;)Ge=g,Sm(g),g=g.sibling;Ge=m,jo=z,kn=de}Nm(t)}else(m.subtreeFlags&8772)!==0&&g!==null?(g.return=m,Ge=g):Nm(t)}}function Nm(t){for(;Ge!==null;){var n=Ge;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:kn||ko(5,n);break;case 1:var o=n.stateNode;if(n.flags&4&&!kn)if(i===null)o.componentDidMount();else{var m=n.elementType===n.type?i.memoizedProps:vs(n.type,i.memoizedProps);o.componentDidUpdate(m,i.memoizedState,o.__reactInternalSnapshotBeforeUpdate)}var g=n.updateQueue;g!==null&&Cd(n,g,o);break;case 3:var k=n.updateQueue;if(k!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}Cd(n,k,i)}break;case 5:var z=n.stateNode;if(i===null&&n.flags&4){i=z;var H=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":H.autoFocus&&i.focus();break;case"img":H.src&&(i.src=H.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var de=n.alternate;if(de!==null){var Te=de.memoizedState;if(Te!==null){var Le=Te.dehydrated;Le!==null&&os(Le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}kn||n.flags&512&&Qc(n)}catch($e){Wt(n,n.return,$e)}}if(n===t){Ge=null;break}if(i=n.sibling,i!==null){i.return=n.return,Ge=i;break}Ge=n.return}}function Cm(t){for(;Ge!==null;){var n=Ge;if(n===t){Ge=null;break}var i=n.sibling;if(i!==null){i.return=n.return,Ge=i;break}Ge=n.return}}function $m(t){for(;Ge!==null;){var n=Ge;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{ko(4,n)}catch(H){Wt(n,i,H)}break;case 1:var o=n.stateNode;if(typeof o.componentDidMount=="function"){var m=n.return;try{o.componentDidMount()}catch(H){Wt(n,m,H)}}var g=n.return;try{Qc(n)}catch(H){Wt(n,g,H)}break;case 5:var k=n.return;try{Qc(n)}catch(H){Wt(n,k,H)}}}catch(H){Wt(n,n.return,H)}if(n===t){Ge=null;break}var z=n.sibling;if(z!==null){z.return=n.return,Ge=z;break}Ge=n.return}}var ep=Math.ceil,So=Q.ReactCurrentDispatcher,Xc=Q.ReactCurrentOwner,ss=Q.ReactCurrentBatchConfig,vt=0,cn=null,Yt=null,yn=0,Kn=0,mi=_s(0),nn=0,dl=null,yr=0,No=0,Zc=0,ml=null,zn=null,eu=0,fi=1/0,ua=null,Co=!1,tu=null,Ta=null,$o=!1,Aa=null,Eo=0,fl=0,nu=null,To=-1,Ao=0;function Cn(){return(vt&6)!==0?Lt():To!==-1?To:To=Lt()}function Ra(t){return(t.mode&1)===0?1:(vt&2)!==0&&yn!==0?yn&-yn:Ih.transition!==null?(Ao===0&&(Ao=Bs()),Ao):(t=ct,t!==0||(t=window.event,t=t===void 0?16:Dr(t.type)),t)}function bs(t,n,i,o){if(50<fl)throw fl=0,nu=null,Error(r(185));Pt(t,i,o),((vt&2)===0||t!==cn)&&(t===cn&&((vt&2)===0&&(No|=i),nn===4&&La(t,yn)),Pn(t,o),i===1&&vt===0&&(n.mode&1)===0&&(fi=Lt()+500,Rn&&bt()))}function Pn(t,n){var i=t.callbackNode;Mr(t,n);var o=Ot(t,t===cn?yn:0);if(o===0)i!==null&&Wa(i),t.callbackNode=null,t.callbackPriority=0;else if(n=o&-o,t.callbackPriority!==n){if(i!=null&&Wa(i),n===1)t.tag===0?bn(Tm.bind(null,t)):rt(Tm.bind(null,t)),ao(function(){(vt&6)===0&&bt()}),i=null;else{switch(Ir(o)){case 1:i=Ha;break;case 4:i=Fs;break;case 16:i=is;break;case 536870912:i=pa;break;default:i=is}i=Om(i,Em.bind(null,t))}t.callbackPriority=n,t.callbackNode=i}}function Em(t,n){if(To=-1,Ao=0,(vt&6)!==0)throw Error(r(327));var i=t.callbackNode;if(hi()&&t.callbackNode!==i)return null;var o=Ot(t,t===cn?yn:0);if(o===0)return null;if((o&30)!==0||(o&t.expiredLanes)!==0||n)n=Ro(t,o);else{n=o;var m=vt;vt|=2;var g=Rm();(cn!==t||yn!==n)&&(ua=null,fi=Lt()+500,br(t,n));do try{sp();break}catch(z){Am(t,z)}while(!0);xc(),So.current=g,vt=m,Yt!==null?n=0:(cn=null,yn=0,n=nn)}if(n!==0){if(n===2&&(m=ws(t),m!==0&&(o=m,n=su(t,m))),n===1)throw i=dl,br(t,0),La(t,o),Pn(t,Lt()),i;if(n===6)La(t,o);else{if(m=t.current.alternate,(o&30)===0&&!tp(m)&&(n=Ro(t,o),n===2&&(g=ws(t),g!==0&&(o=g,n=su(t,g))),n===1))throw i=dl,br(t,0),La(t,o),Pn(t,Lt()),i;switch(t.finishedWork=m,t.finishedLanes=o,n){case 0:case 1:throw Error(r(345));case 2:wr(t,zn,ua);break;case 3:if(La(t,o),(o&130023424)===o&&(n=eu+500-Lt(),10<n)){if(Ot(t,0)!==0)break;if(m=t.suspendedLanes,(m&o)!==o){Cn(),t.pingedLanes|=t.suspendedLanes&m;break}t.timeoutHandle=si(wr.bind(null,t,zn,ua),n);break}wr(t,zn,ua);break;case 4:if(La(t,o),(o&4194240)===o)break;for(n=t.eventTimes,m=-1;0<o;){var k=31-Sn(o);g=1<<k,k=n[k],k>m&&(m=k),o&=~g}if(o=m,o=Lt()-o,o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*ep(o/1960))-o,10<o){t.timeoutHandle=si(wr.bind(null,t,zn,ua),o);break}wr(t,zn,ua);break;case 5:wr(t,zn,ua);break;default:throw Error(r(329))}}}return Pn(t,Lt()),t.callbackNode===i?Em.bind(null,t):null}function su(t,n){var i=ml;return t.current.memoizedState.isDehydrated&&(br(t,n).flags|=256),t=Ro(t,n),t!==2&&(n=zn,zn=i,n!==null&&au(n)),t}function au(t){zn===null?zn=t:zn.push.apply(zn,t)}function tp(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(!Tn(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 La(t,n){for(n&=~Zc,n&=~No,t.suspendedLanes|=n,t.pingedLanes&=~n,t=t.expirationTimes;0<n;){var i=31-Sn(n),o=1<<i;t[i]=-1,n&=~o}}function Tm(t){if((vt&6)!==0)throw Error(r(327));hi();var n=Ot(t,0);if((n&1)===0)return Pn(t,Lt()),null;var i=Ro(t,n);if(t.tag!==0&&i===2){var o=ws(t);o!==0&&(n=o,i=su(t,o))}if(i===1)throw i=dl,br(t,0),La(t,n),Pn(t,Lt()),i;if(i===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=n,wr(t,zn,ua),Pn(t,Lt()),null}function ru(t,n){var i=vt;vt|=1;try{return t(n)}finally{vt=i,vt===0&&(fi=Lt()+500,Rn&&bt())}}function xr(t){Aa!==null&&Aa.tag===0&&(vt&6)===0&&hi();var n=vt;vt|=1;var i=ss.transition,o=ct;try{if(ss.transition=null,ct=1,t)return t()}finally{ct=o,ss.transition=i,vt=n,(vt&6)===0&&bt()}}function iu(){Kn=mi.current,$t(mi)}function br(t,n){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,dc(i)),Yt!==null)for(i=Yt.return;i!==null;){var o=i;switch(pc(o),o.tag){case 1:o=o.type.childContextTypes,o!=null&&xe();break;case 3:ci(),$t(w),$t(S),$c();break;case 5:Nc(o);break;case 4:ci();break;case 13:$t(Dt);break;case 19:$t(Dt);break;case 10:bc(o.type._context);break;case 22:case 23:iu()}i=i.return}if(cn=t,Yt=t=Ma(t.current,null),yn=Kn=n,nn=0,dl=null,Zc=No=yr=0,zn=ml=null,_r!==null){for(n=0;n<_r.length;n++)if(i=_r[n],o=i.interleaved,o!==null){i.interleaved=null;var m=o.next,g=i.pending;if(g!==null){var k=g.next;g.next=m,o.next=k}i.pending=o}_r=null}return t}function Am(t,n){do{var i=Yt;try{if(xc(),po.current=yo,_o){for(var o=Ft.memoizedState;o!==null;){var m=o.queue;m!==null&&(m.pending=null),o=o.next}_o=!1}if(vr=0,on=tn=Ft=null,rl=!1,il=0,Xc.current=null,i===null||i.return===null){nn=1,dl=n,Yt=null;break}e:{var g=t,k=i.return,z=i,H=n;if(n=yn,z.flags|=32768,H!==null&&typeof H=="object"&&typeof H.then=="function"){var de=H,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 Ve=nm(k);if(Ve!==null){Ve.flags&=-257,sm(Ve,k,z,g,n),Ve.mode&1&&tm(g,de,n),n=Ve,H=de;var Qe=n.updateQueue;if(Qe===null){var Je=new Set;Je.add(H),n.updateQueue=Je}else Qe.add(H);break e}else{if((n&1)===0){tm(g,de,n),lu();break e}H=Error(r(426))}}else if(It&&z.mode&1){var Kt=nm(k);if(Kt!==null){(Kt.flags&65536)===0&&(Kt.flags|=256),sm(Kt,k,z,g,n),vc(ui(H,z));break e}}g=H=ui(H,z),nn!==4&&(nn=2),ml===null?ml=[g]:ml.push(g),g=k;do{switch(g.tag){case 3:g.flags|=65536,n&=-n,g.lanes|=n;var ae=Zd(g,H,n);Nd(g,ae);break e;case 1:z=H;var K=g.type,re=g.stateNode;if((g.flags&128)===0&&(typeof K.getDerivedStateFromError=="function"||re!==null&&typeof re.componentDidCatch=="function"&&(Ta===null||!Ta.has(re)))){g.flags|=65536,n&=-n,g.lanes|=n;var Fe=em(g,z,n);Nd(g,Fe);break e}}g=g.return}while(g!==null)}Mm(i)}catch(Ze){n=Ze,Yt===i&&i!==null&&(Yt=i=i.return);continue}break}while(!0)}function Rm(){var t=So.current;return So.current=yo,t===null?yo:t}function lu(){(nn===0||nn===3||nn===2)&&(nn=4),cn===null||(yr&268435455)===0&&(No&268435455)===0||La(cn,yn)}function Ro(t,n){var i=vt;vt|=2;var o=Rm();(cn!==t||yn!==n)&&(ua=null,br(t,n));do try{np();break}catch(m){Am(t,m)}while(!0);if(xc(),vt=i,So.current=o,Yt!==null)throw Error(r(261));return cn=null,yn=0,nn}function np(){for(;Yt!==null;)Lm(Yt)}function sp(){for(;Yt!==null&&!Ll();)Lm(Yt)}function Lm(t){var n=Im(t.alternate,t,Kn);t.memoizedProps=t.pendingProps,n===null?Mm(t):Yt=n,Xc.current=null}function Mm(t){var n=t;do{var i=n.alternate;if(t=n.return,(n.flags&32768)===0){if(i=Qh(i,n,Kn),i!==null){Yt=i;return}}else{if(i=Jh(i,n),i!==null){i.flags&=32767,Yt=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{nn=6,Yt=null;return}}if(n=n.sibling,n!==null){Yt=n;return}Yt=n=t}while(n!==null);nn===0&&(nn=5)}function wr(t,n,i){var o=ct,m=ss.transition;try{ss.transition=null,ct=1,ap(t,n,i,o)}finally{ss.transition=m,ct=o}return null}function ap(t,n,i,o){do hi();while(Aa!==null);if((vt&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(js(t,g),t===cn&&(Yt=cn=null,yn=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||$o||($o=!0,Om(is,function(){return hi(),null})),g=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||g){g=ss.transition,ss.transition=null;var k=ct;ct=1;var z=vt;vt|=4,Xc.current=null,Xh(t,i),km(i,t),Xl(Yi),Ya=!!dr,Yi=dr=null,t.current=i,Zh(i),Rr(),vt=z,ct=k,ss.transition=g}else t.current=i;if($o&&($o=!1,Aa=t,Eo=m),g=t.pendingLanes,g===0&&(Ta=null),zl(i.stateNode),Pn(t,Lt()),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(Co)throw Co=!1,t=tu,tu=null,t;return(Eo&1)!==0&&t.tag!==0&&hi(),g=t.pendingLanes,(g&1)!==0?t===nu?fl++:(fl=0,nu=t):fl=0,bt(),null}function hi(){if(Aa!==null){var t=Ir(Eo),n=ss.transition,i=ct;try{if(ss.transition=null,ct=16>t?16:t,Aa===null)var o=!1;else{if(t=Aa,Aa=null,Eo=0,(vt&6)!==0)throw Error(r(331));var m=vt;for(vt|=4,Ge=t.current;Ge!==null;){var g=Ge,k=g.child;if((Ge.flags&16)!==0){var z=g.deletions;if(z!==null){for(var H=0;H<z.length;H++){var de=z[H];for(Ge=de;Ge!==null;){var Te=Ge;switch(Te.tag){case 0:case 11:case 15:ul(8,Te,g)}var Le=Te.child;if(Le!==null)Le.return=Te,Ge=Le;else for(;Ge!==null;){Te=Ge;var $e=Te.sibling,Ve=Te.return;if(ym(Te),Te===de){Ge=null;break}if($e!==null){$e.return=Ve,Ge=$e;break}Ge=Ve}}}var Qe=g.alternate;if(Qe!==null){var Je=Qe.child;if(Je!==null){Qe.child=null;do{var Kt=Je.sibling;Je.sibling=null,Je=Kt}while(Je!==null)}}Ge=g}}if((g.subtreeFlags&2064)!==0&&k!==null)k.return=g,Ge=k;else e:for(;Ge!==null;){if(g=Ge,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:ul(9,g,g.return)}var ae=g.sibling;if(ae!==null){ae.return=g.return,Ge=ae;break e}Ge=g.return}}var K=t.current;for(Ge=K;Ge!==null;){k=Ge;var re=k.child;if((k.subtreeFlags&2064)!==0&&re!==null)re.return=k,Ge=re;else e:for(k=K;Ge!==null;){if(z=Ge,(z.flags&2048)!==0)try{switch(z.tag){case 0:case 11:case 15:ko(9,z)}}catch(Ze){Wt(z,z.return,Ze)}if(z===k){Ge=null;break e}var Fe=z.sibling;if(Fe!==null){Fe.return=z.return,Ge=Fe;break e}Ge=z.return}}if(vt=m,bt(),fn&&typeof fn.onPostCommitFiberRoot=="function")try{fn.onPostCommitFiberRoot(Va,t)}catch{}o=!0}return o}finally{ct=i,ss.transition=n}}return!1}function zm(t,n,i){n=ui(i,n),n=Zd(t,n,1),t=$a(t,n,1),n=Cn(),t!==null&&(Pt(t,1,n),Pn(t,n))}function Wt(t,n,i){if(t.tag===3)zm(t,t,i);else for(;n!==null;){if(n.tag===3){zm(n,t,i);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ta===null||!Ta.has(o))){t=ui(i,t),t=em(n,t,1),n=$a(n,t,1),t=Cn(),n!==null&&(Pt(n,1,t),Pn(n,t));break}}n=n.return}}function rp(t,n,i){var o=t.pingCache;o!==null&&o.delete(n),n=Cn(),t.pingedLanes|=t.suspendedLanes&i,cn===t&&(yn&i)===i&&(nn===4||nn===3&&(yn&130023424)===yn&&500>Lt()-eu?br(t,0):Zc|=i),Pn(t,n)}function Pm(t,n){n===0&&((t.mode&1)===0?n=1:(n=qs,qs<<=1,(qs&130023424)===0&&(qs=4194304)));var i=Cn();t=la(t,n),t!==null&&(Pt(t,n,i),Pn(t,i))}function ip(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Pm(t,i)}function lp(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),Pm(t,i)}var Im;Im=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||w.current)Mn=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return Mn=!1,Kh(t,n,i);Mn=(t.flags&131072)!==0}else Mn=!1,It&&(n.flags&1048576)!==0&&_d(n,en,n.index);switch(n.lanes=0,n.tag){case 2:var o=n.type;wo(t,n),t=n.pendingProps;var m=ne(n,S.current);oi(n,i),m=Ac(null,n,o,t,m,i);var g=Rc();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,B(o)?(g=!0,Ue(n)):g=!1,n.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,kc(n),m.updater=xo,n.stateNode=m,m._reactInternals=n,Oc(n,o,t,i),n=Bc(null,n,o,!0,g,i)):(n.tag=0,It&&g&&hc(n),Nn(null,n,m,i),n=n.child),n;case 16:o=n.elementType;e:{switch(wo(t,n),t=n.pendingProps,m=o._init,o=m(o._payload),n.type=o,m=n.tag=cp(o),t=vs(o,t),m){case 0:n=qc(null,n,o,t,i);break e;case 1:n=cm(null,n,o,t,i);break e;case 11:n=am(null,n,o,t,i);break e;case 14:n=rm(null,n,o,vs(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:vs(o,m),qc(t,n,o,m,i);case 1:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:vs(o,m),cm(t,n,o,m,i);case 3:e:{if(um(n),t===null)throw Error(r(387));o=n.pendingProps,g=n.memoizedState,m=g.element,Sd(t,n),fo(n,o,null,i);var k=n.memoizedState;if(o=k.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){m=ui(Error(r(423)),n),n=dm(t,n,o,i,m);break e}else if(o!==m){m=ui(Error(r(424)),n),n=dm(t,n,o,i,m);break e}else for(Gn=Rs(n.stateNode.containerInfo.firstChild),Vn=n,It=!0,gs=null,i=jd(n,null,o,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ri(),o===m){n=ca(t,n,i);break e}Nn(t,n,o,i)}n=n.child}return n;case 5:return $d(n),t===null&&gc(n),o=n.type,m=n.pendingProps,g=t!==null?t.memoizedProps:null,k=m.children,Xi(o,m)?k=null:g!==null&&Xi(o,g)&&(n.flags|=32),om(t,n),Nn(t,n,k,i),n.child;case 6:return t===null&&gc(n),null;case 13:return mm(t,n,i);case 4:return Sc(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=ii(n,null,o,i):Nn(t,n,o,i),n.child;case 11:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:vs(o,m),am(t,n,o,m,i);case 7:return Nn(t,n,n.pendingProps,i),n.child;case 8:return Nn(t,n,n.pendingProps.children,i),n.child;case 12:return Nn(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(o=n.type._context,m=n.pendingProps,g=n.memoizedProps,k=m.value,u(co,o._currentValue),o._currentValue=k,g!==null)if(Tn(g.value,k)){if(g.children===m.children&&!w.current){n=ca(t,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var z=g.dependencies;if(z!==null){k=g.child;for(var H=z.firstContext;H!==null;){if(H.context===o){if(g.tag===1){H=oa(-1,i&-i),H.tag=2;var de=g.updateQueue;if(de!==null){de=de.shared;var Te=de.pending;Te===null?H.next=H:(H.next=Te.next,Te.next=H),de.pending=H}}g.lanes|=i,H=g.alternate,H!==null&&(H.lanes|=i),wc(g.return,i,n),z.lanes|=i;break}H=H.next}}else if(g.tag===10)k=g.type===n.type?null:g.child;else if(g.tag===18){if(k=g.return,k===null)throw Error(r(341));k.lanes|=i,z=k.alternate,z!==null&&(z.lanes|=i),wc(k,i,n),k=g.sibling}else k=g.child;if(k!==null)k.return=g;else for(k=g;k!==null;){if(k===n){k=null;break}if(g=k.sibling,g!==null){g.return=k.return,k=g;break}k=k.return}g=k}Nn(t,n,m.children,i),n=n.child}return n;case 9:return m=n.type,o=n.pendingProps.children,oi(n,i),m=ts(m),o=o(m),n.flags|=1,Nn(t,n,o,i),n.child;case 14:return o=n.type,m=vs(o,n.pendingProps),m=vs(o.type,m),rm(t,n,o,m,i);case 15:return im(t,n,n.type,n.pendingProps,i);case 17:return o=n.type,m=n.pendingProps,m=n.elementType===o?m:vs(o,m),wo(t,n),n.tag=1,B(o)?(t=!0,Ue(n)):t=!1,oi(n,i),Yd(n,o,m),Oc(n,o,m,i),Bc(null,n,o,!0,t,i);case 19:return hm(t,n,i);case 22:return lm(t,n,i)}throw Error(r(156,n.tag))};function Om(t,n){return ki(t,n)}function op(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 as(t,n,i,o){return new op(t,n,i,o)}function ou(t){return t=t.prototype,!(!t||!t.isReactComponent)}function cp(t){if(typeof t=="function")return ou(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ve)return 11;if(t===L)return 14}return 2}function Ma(t,n){var i=t.alternate;return i===null?(i=as(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 Lo(t,n,i,o,m,g){var k=2;if(o=t,typeof t=="function")ou(t)&&(k=1);else if(typeof t=="string")k=5;else e:switch(t){case oe:return jr(i.children,m,g,n);case le:k=8,m|=8;break;case pe:return t=as(12,i,n,m|2),t.elementType=pe,t.lanes=g,t;case ce:return t=as(13,i,n,m),t.elementType=ce,t.lanes=g,t;case q:return t=as(19,i,n,m),t.elementType=q,t.lanes=g,t;case X:return Mo(i,m,g,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Ae:k=10;break e;case Me:k=9;break e;case ve:k=11;break e;case L:k=14;break e;case W:k=16,o=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return n=as(k,i,n,m),n.elementType=t,n.type=o,n.lanes=g,n}function jr(t,n,i,o){return t=as(7,t,o,n),t.lanes=i,t}function Mo(t,n,i,o){return t=as(22,t,o,n),t.elementType=X,t.lanes=i,t.stateNode={isHidden:!1},t}function cu(t,n,i){return t=as(6,t,null,n),t.lanes=i,t}function uu(t,n,i){return n=as(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function up(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=zr(0),this.expirationTimes=zr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=zr(0),this.identifierPrefix=o,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function du(t,n,i,o,m,g,k,z,H){return t=new up(t,n,i,z,H),n===1?(n=1,g===!0&&(n|=8)):n=0,g=as(3,null,null,n),t.current=g,g.stateNode=t,g.memoizedState={element:o,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},kc(g),t}function dp(t,n,i){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Z,key:o==null?null:""+o,children:t,containerInfo:n,implementation:i}}function Dm(t){if(!t)return v;t=t._reactInternals;e:{if(Jn(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(B(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(B(i))return Be(t,i,n)}return n}function Fm(t,n,i,o,m,g,k,z,H){return t=du(i,o,!0,t,m,g,k,z,H),t.context=Dm(null),i=t.current,o=Cn(),m=Ra(i),g=oa(o,m),g.callback=n??null,$a(i,g,m),t.current.lanes=m,Pt(t,m,o),Pn(t,o),t}function zo(t,n,i,o){var m=n.current,g=Cn(),k=Ra(m);return i=Dm(i),n.context===null?n.context=i:n.pendingContext=i,n=oa(g,k),n.payload={element:t},o=o===void 0?null:o,o!==null&&(n.callback=o),t=$a(m,n,k),t!==null&&(bs(t,m,k,g),mo(t,m,k)),k}function Po(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 qm(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<n?i:n}}function mu(t,n){qm(t,n),(t=t.alternate)&&qm(t,n)}function mp(){return null}var Bm=typeof reportError=="function"?reportError:function(t){console.error(t)};function fu(t){this._internalRoot=t}Io.prototype.render=fu.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(r(409));zo(t,n,null,null)},Io.prototype.unmount=fu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;xr(function(){zo(null,t,null,null)}),n[ps]=null}};function Io(t){this._internalRoot=t}Io.prototype.unstable_scheduleHydration=function(t){if(t){var n=Ci();t={blockedOn:null,target:t,priority:n};for(var i=0;i<Zt.length&&n!==0&&n<Zt[i].priority;i++);Zt.splice(i,0,t),i===0&&Wn(t)}};function hu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Oo(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Um(){}function fp(t,n,i,o,m){if(m){if(typeof o=="function"){var g=o;o=function(){var de=Po(k);g.call(de)}}var k=Fm(n,o,t,0,null,!1,!1,"",Um);return t._reactRootContainer=k,t[ps]=k.current,ka(t.nodeType===8?t.parentNode:t),xr(),k}for(;m=t.lastChild;)t.removeChild(m);if(typeof o=="function"){var z=o;o=function(){var de=Po(H);z.call(de)}}var H=du(t,0,!1,null,null,!1,!1,"",Um);return t._reactRootContainer=H,t[ps]=H.current,ka(t.nodeType===8?t.parentNode:t),xr(function(){zo(n,H,i,o)}),H}function Do(t,n,i,o,m){var g=i._reactRootContainer;if(g){var k=g;if(typeof m=="function"){var z=m;m=function(){var H=Po(k);z.call(H)}}zo(n,k,t,m)}else k=fp(i,n,t,m,o);return Po(k)}Si=function(t){switch(t.tag){case 3:var n=t.stateNode;if(n.current.memoizedState.isDehydrated){var i=Xn(n.pendingLanes);i!==0&&(Pr(n,i|1),Pn(n,Lt()),(vt&6)===0&&(fi=Lt()+500,bt()))}break;case 13:xr(function(){var o=la(t,1);if(o!==null){var m=Cn();bs(o,t,1,m)}}),mu(t,1)}},Ga=function(t){if(t.tag===13){var n=la(t,134217728);if(n!==null){var i=Cn();bs(n,t,134217728,i)}mu(t,134217728)}},Ni=function(t){if(t.tag===13){var n=Ra(t),i=la(t,n);if(i!==null){var o=Cn();bs(i,t,n,o)}mu(t,n)}},Ci=function(){return ct},Ka=function(t,n){var i=ct;try{return ct=t,n()}finally{ct=i}},et=function(t,n,i){switch(n){case"input":if(ge(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=hr(o);if(!m)throw Error(r(90));me(o),ge(o,m)}}}break;case"textarea":Se(t,i);break;case"select":n=i.value,n!=null&&fe(t,!!i.multiple,n,!1)}},Ie=ru,mt=xr;var hp={usingClientEntryPoint:!1,Events:[fr,aa,hr,we,Ee,ru]},hl={findFiberByHostInstance:Ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},pp={bundleType:hl.bundleType,version:hl.version,rendererPackageName:hl.rendererPackageName,rendererConfig:hl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Q.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=ji(t),t===null?null:t.stateNode},findFiberByHostInstance:hl.findFiberByHostInstance||mp,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 Fo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fo.isDisabled&&Fo.supportsFiber)try{Va=Fo.inject(pp),fn=Fo}catch{}}return In.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=hp,In.createPortal=function(t,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!hu(n))throw Error(r(200));return dp(t,n,null,i)},In.createRoot=function(t,n){if(!hu(t))throw Error(r(299));var i=!1,o="",m=Bm;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(m=n.onRecoverableError)),n=du(t,1,!1,null,null,i,!1,o,m),t[ps]=n.current,ka(t.nodeType===8?t.parentNode:t),new fu(n)},In.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=ji(n),t=t===null?null:t.stateNode,t},In.flushSync=function(t){return xr(t)},In.hydrate=function(t,n,i){if(!Oo(n))throw Error(r(200));return Do(null,t,n,!0,i)},In.hydrateRoot=function(t,n,i){if(!hu(t))throw Error(r(405));var o=i!=null&&i.hydratedSources||null,m=!1,g="",k=Bm;if(i!=null&&(i.unstable_strictMode===!0&&(m=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(k=i.onRecoverableError)),n=Fm(n,null,t,1,i??null,m,!1,g,k),t[ps]=n.current,ka(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 Io(n)},In.render=function(t,n,i){if(!Oo(n))throw Error(r(200));return Do(null,t,n,!1,i)},In.unmountComponentAtNode=function(t){if(!Oo(t))throw Error(r(40));return t._reactRootContainer?(xr(function(){Do(null,null,t,!1,function(){t._reactRootContainer=null,t[ps]=null})}),!0):!1},In.unstable_batchedUpdates=ru,In.unstable_renderSubtreeIntoContainer=function(t,n,i,o){if(!Oo(i))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Do(t,n,i,!1,o)},In.version="18.3.1-next-f1338f8080-20240426",In}var Ym;function Gf(){if(Ym)return gu.exports;Ym=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(),gu.exports=Sp(),gu.exports}var Xm;function Np(){if(Xm)return qo;Xm=1;var a=Gf();return qo.createRoot=a.createRoot,qo.hydrateRoot=a.hydrateRoot,qo}var Cp=Np();const Kf=[{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"]}];Kf.map(a=>({id:a.id,label:a.label}));function $p(a){return`theme-${String(a||"").trim()||"dark"}`}function Zm(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($p(a))}catch{}}const qu=[{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}],Bu=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Ep(a){const s=String(a).trim();return qu.find(r=>r.id===s)||qu[1]}function Tp(a){const s=String(a).trim();return Bu.find(r=>r.id===s)||Bu[1]}function ef(a){try{const s=document.documentElement,r=Ep(a.font_scale||"md"),l=Tp(a.header_density||"standard");s.style.setProperty("--font-scale",String(r.scale)),s.style.setProperty("--header-density",String(l.density))}catch{}}var Qf=Gf();function pi(...a){return a.filter(Boolean).join(" ")}function Er({value:a,options:s,placeholder:r="Select…",disabled:l=!1,loading:c=!1,searchable:f=!0,searchPlaceholder:d="Search…",allowCustom:p=!1,clearable:_=!1,minPopoverWidth:y=240,variant:b="panel",className:x,triggerClassName:N,ariaLabel:C,id:I,includeValueOption:E=!1,onOpen:P,customOptionLabel:U,validateCustomValue:D,onChange:F,renderOption:Q,renderValue:$}){const Z=h.useRef(null),oe=h.useRef(null),le=h.useRef(null),pe=h.useRef(P),Ae=h.useId(),Me=I||`af-select-${Ae.replace(/[^a-zA-Z0-9_-]/g,"")}`,ve=`${Me}-listbox`,[ce,q]=h.useState(!1),[L,W]=h.useState(""),[X,M]=h.useState(0),[ue,V]=h.useState("bottom"),[j,R]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{pe.current=P},[P]);const ee=h.useMemo(()=>{if(!E)return s;const ie=String(a??"").trim();return!ie||s.some(fe=>fe.value===ie)?s:[...s,{value:ie,label:ie}]},[E,s,a]),_e=h.useMemo(()=>{const ie=String(a??"");return ee.find(fe=>fe.value===ie)||null},[ee,a]),he=h.useMemo(()=>(_e==null?void 0:_e.label)||String(a||"").trim()||"",[_e,a]),O=h.useMemo(()=>{const ie=L.trim().toLowerCase();return ie?ee.filter(fe=>fe.label.toLowerCase().includes(ie)||fe.value.toLowerCase().includes(ie)):ee},[ee,L]),je=h.useMemo(()=>{if(!p)return null;const ie=L.trim();if(!ie||ee.some(G=>G.value===ie))return null;const be=(D==null?void 0:D(ie,{options:ee}))||"";return{value:ie,label:U?U(ie):`Use "${ie}"`,disabled:!!be,reason:be}},[p,U,ee,L,D]),te=h.useMemo(()=>{const ie=je?[je,...O]:O;if(ie.length>0)return ie;const fe=String(a??"").trim();return c&&fe?[{value:fe,label:he||fe}]:ie},[je,O,c,he,a]),ke=h.useCallback(()=>{const ie=Z.current;if(!ie)return;const fe=ie.getBoundingClientRect(),be=Math.max(fe.width,y),G=Math.max(8,Math.min(fe.left,window.innerWidth-be-8)),Se=window.innerHeight-fe.bottom,Xe=fe.top,J=Se>=220||Se>=Xe?"bottom":"top";V(J);const A=J==="bottom"?fe.bottom+6:fe.top-6;R({left:G,top:A,width:be})},[y]),Ce=h.useCallback(()=>{q(!1),W("")},[]);h.useEffect(()=>{var ie;ce&&((ie=pe.current)==null||ie.call(pe))},[ce]),h.useEffect(()=>{if(!ce)return;ke();const ie=()=>ke();return window.addEventListener("resize",ie),window.addEventListener("scroll",ie,!0),()=>{window.removeEventListener("resize",ie),window.removeEventListener("scroll",ie,!0)}},[ce,ke]),h.useEffect(()=>{if(!ce)return;const ie=fe=>{var G,Se;const be=fe.target;be&&((G=Z.current)!=null&&G.contains(be)||(Se=oe.current)!=null&&Se.contains(be)||Ce())};return document.addEventListener("mousedown",ie,!0),()=>document.removeEventListener("mousedown",ie,!0)},[ce,Ce]),h.useEffect(()=>{if(!ce)return;const ie=Math.max(0,te.findIndex(fe=>fe.value===a));M(ie===-1?0:ie),f&&setTimeout(()=>{var fe;return(fe=le.current)==null?void 0:fe.focus()},0)},[ce,f,a,te]);const We=ie=>{var be;const fe=te.find(G=>G.value===ie);fe!=null&&fe.disabled||(F(ie),Ce(),(be=Z.current)==null||be.focus())},me=ie=>{var fe,be;if(ie.key==="Escape")return ie.preventDefault(),Ce(),(fe=Z.current)==null||fe.focus(),!0;if(ie.key==="Tab")return Ce(),(be=Z.current)==null||be.focus(),!1;if(ie.key==="ArrowDown")return ie.preventDefault(),M(G=>Math.min(G+1,Math.max(0,te.length-1))),!0;if(ie.key==="ArrowUp")return ie.preventDefault(),M(G=>Math.max(G-1,0)),!0;if(ie.key==="Home")return ie.preventDefault(),M(0),!0;if(ie.key==="End")return ie.preventDefault(),M(Math.max(0,te.length-1)),!0;if(ie.key==="Enter"){ie.preventDefault();const G=te[X];return G&&We(G.value),!0}return!1},Re=ie=>{if(!l){if(ce){if(me(ie))return;if(ie.key===" "&&!f){ie.preventDefault();const fe=te[X];fe&&We(fe.value)}return}(ie.key==="Enter"||ie.key===" "||ie.key==="ArrowDown"||ie.key==="ArrowUp")&&(ie.preventDefault(),q(!0))}},Pe=!!String(a||"").trim(),se=Pe?he:r,ye=je!=null&&je.disabled?je.reason||"Unavailable":"",ge=ce&&te.length>0?`${Me}-opt-${X}`:void 0,qe=e.jsx("span",{className:pi("af-select-value",!Pe&&"af-select-value--placeholder"),children:c&&!Pe?"Loading…":se}),Ye=$?$(_e,String(a||"")):qe;return e.jsxs("span",{className:pi("af-select",b==="pin"?"af-select--pin":"af-select--panel",x),children:[e.jsxs("button",{ref:Z,id:Me,type:"button",className:pi("af-select-trigger",_&&Pe&&"af-select-trigger--clearable",N),disabled:l,onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),!l&&q(fe=>!fe)},onKeyDown:Re,role:f?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":ce,"aria-controls":ce?ve:void 0,"aria-activedescendant":f?void 0:ge,"aria-label":C,children:[Ye,e.jsx("span",{className:pi("af-select-caret",ce&&"af-select-caret--open"),children:"▾"})]}),_&&Pe?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:l,onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:ie=>{var fe;ie.preventDefault(),ie.stopPropagation(),F(""),Ce(),(fe=Z.current)==null||fe.focus()},title:"Clear",children:"×"}):null,ce?Qf.createPortal(e.jsxs("div",{ref:oe,className:pi("af-select-popover",ue==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${j.left}px`,top:`${j.top}px`,width:`${j.width}px`},onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),onWheel:ie=>ie.stopPropagation(),onKeyDown:me,tabIndex:-1,children:[f?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:le,className:"af-select-search-input",value:L,onChange:ie=>W(ie.target.value),placeholder:d,onKeyDown:me,role:"combobox","aria-expanded":!0,"aria-controls":ve,"aria-activedescendant":ge,"aria-invalid":!!ye,"aria-describedby":ye?`${Me}-custom-error`:void 0}),ye?e.jsx("div",{id:`${Me}-custom-error`,className:"af-select-custom-error",role:"alert",children:ye}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:ve,"aria-label":C,children:c&&te.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):te.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):te.map((ie,fe)=>{var A;const be=ie.value===a,G=fe===X,Se=String(ie.group||"").trim(),Xe=fe>0?String(((A=te[fe-1])==null?void 0:A.group)||"").trim():"",J=!!Se&&Se!==Xe;return e.jsxs(Ht.Fragment,{children:[J?e.jsx("div",{className:"af-select-group",role:"presentation",children:Se}):null,e.jsx("div",{id:`${Me}-opt-${fe}`,role:"option","aria-selected":be,className:pi("af-select-option",be&&"af-select-option--selected",G&&"af-select-option--highlighted",ie.disabled&&"af-select-option--disabled"),title:ie.disabled?ie.reason||"Unavailable":void 0,onMouseEnter:()=>M(fe),onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation()},onClick:()=>We(ie.value),"aria-disabled":ie.disabled?!0:void 0,children:Q?Q(ie,{selected:be,highlighted:G}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:ie.label}),ie.reason?e.jsx("small",{className:"af-select-option-reason",children:ie.reason}):null]}),be?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},ie.value)})})]}),document.body):null]})}function Ap(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 Rp(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 Lp(a){const s=a.disabled===!0,r=a.layout||"stack",l=a.allowGatewayDefault!==!1,c=String(a.gatewayDefaultLabel||"(gateway default)"),f=String(a.providerLabel||"Provider"),d=String(a.modelLabel||"Model"),p=String(a.providerPlaceholder||"(select)"),_=String(a.modelPlaceholder||"(select)"),y=String(a.provider||"").trim(),b=String(a.model||"").trim(),x=Ap(a.providers),N=Rp(a.models),C=s||!!a.loadingProviders,I=s||!!a.loadingModels,E=[...l?[{value:"",label:c}]:[],...x.map(U=>({value:U.name,label:U.display_name?`${U.display_name} (${U.name})`:U.name}))],P=[...l?[{value:"",label:c}]:[],...N.map(U=>({value:U,label:U}))];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:f}),e.jsx(Er,{value:y,options:E,placeholder:l?c:p,disabled:C,loading:!!a.loadingProviders,searchable:!0,allowCustom:a.allowCustomProvider===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:f,onChange:U=>a.onChange({provider:String(U||"").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:d}),e.jsx(Er,{value:b,options:P,placeholder:l?c:_,disabled:I,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:d,onChange:U=>a.onChange({provider:y,model:String(U||"").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 Mp(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 zp(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 tf(a){const s=Mp(a);return s===!1?"off":s?String(s.num_draft_tokens):""}function Pp(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 Ip(a){const s=zp(a.capabilities),r=tf(a.value),l=(s==null?void 0:s.supported_depths.map(String))||[],c=tf(s==null?void 0:s.default),f=a.inheritLabel||"Workflow / Gateway default",d=c?`${f} (${c==="off"?"Off":`depth ${c}`})`:f,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(Er,{ariaLabel:"MTP depth",value:r,placeholder:d,disabled:a.disabled||a.loading,options:[{value:"",label:d},{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(Pp(_))}),p?e.jsx("div",{role:"status",className:"af-pmp__hint",children:p}):null]})}function Op(a){var M,ue;const s=a.disabled===!0,r=a.value||{provider:"",model:""},l=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[c,f]=h.useState(!l),d=l&&!c,p=h.useRef(l);h.useEffect(()=>{l&&!p.current&&f(!1),p.current=l},[l]);const[_,y]=h.useState([]),[b,x]=h.useState(!1),[N,C]=h.useState(""),[I,E]=h.useState([]),[P,U]=h.useState(!1),[D,F]=h.useState(""),Q=h.useRef(a);Q.current=a,h.useEffect(()=>{if(d||s)return;let V=!0;return x(!0),(async()=>{try{const j=await Q.current.fetchProviders();if(!V)return;y(Array.isArray(j)?j:[]),C("")}catch(j){if(!V)return;y([]),C(`#FALLBACK provider discovery failed: ${String((j==null?void 0:j.message)||j)}`)}finally{V&&x(!1)}})(),()=>{V=!1}},[d,s]);const $=String(r.provider||"").trim();h.useEffect(()=>{if(!$||s){E([]),F(""),U(!1);return}let V=!0;return E([]),U(!0),F(""),(async()=>{try{const j=await Q.current.fetchModels($);if(!V)return;E(Array.isArray(j)?j:[])}catch(j){if(!V)return;E([]),F(`#FALLBACK model discovery failed: ${String((j==null?void 0:j.message)||j)}`)}finally{V&&U(!1)}})(),()=>{V=!1}},[$,s]);const Z=h.useMemo(()=>{const V=[..._];return $&&!V.some(j=>j.name===$)&&V.unshift({name:$}),V},[_,$]),oe=String(r.model||"").trim(),le=h.useMemo(()=>{const V=[...I];return oe&&!V.includes(oe)&&V.unshift(oe),V},[I,oe]),pe=a.defaultModeLabel||"Gateway default",Ae=a.customModeLabel||"Custom",Me=$||((M=a.effectiveDefault)==null?void 0:M.provider)||"",ve=oe||($?"":(ue=a.effectiveDefault)==null?void 0:ue.model)||"",[ce,q]=h.useState({levels:[],error:"",loading:!1}),L=!!a.fetchModelCapabilities,[W,X]=h.useState();return h.useEffect(()=>{let V=!0;if(X(void 0),q({levels:[],error:"",loading:L&&!!ve}),!(!L||!ve||s))return Q.current.fetchModelCapabilities(ve,Me).then(j=>{var he;if(!V)return;if(j!=null&&j.error)throw new Error(String(j.error));X(j);const R=(j==null?void 0:j.capabilities)||j||{},ee=R.reasoning_levels||R.thinking_levels,_e=Array.isArray(ee)?[...new Set(ee.filter(O=>typeof O=="string"&&!!O.trim()))]:[];!_e.length&&R.thinking_support===!0&&((he=R.thinking_control)!=null&&he.prompt_disable_token)&&_e.push("off","auto"),q({levels:_e,error:"",loading:!1})}).catch(j=>{V&&q({levels:[],error:`Reasoning options unavailable: ${String((j==null?void 0:j.message)||j)}`,loading:!1})}),()=>{V=!1}},[Me,ve,L,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":d,className:`af-pmp__seg-btn${d?" is-active":""}`,onClick:()=>{f(!1),a.onChange({...r,provider:"",model:"",...L?{reasoning:""}:{}})},disabled:s,children:pe}),e.jsx("button",{type:"button",role:"tab","aria-selected":!d,className:`af-pmp__seg-btn${d?"":" is-active"}`,onClick:()=>{f(!0)},disabled:s,children:Ae})]}),d?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(Lp,{provider:$,model:oe,providers:Z,models:le,disabled:s,loadingProviders:b,loadingModels:P,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:V=>a.onChange({...r,provider:V.provider,model:V.model,...L?{reasoning:""}:{}})}),L&&(ce.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx(Er,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:r.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...ce.levels.map(V=>({value:V,label:V})),...r.reasoning&&!ce.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:s||ce.loading,onChange:V=>a.onChange({...r,reasoning:V})})]}):null,ce.error?e.jsx("div",{role:"status",className:"af-pmp__hint",children:ce.error}):null,a.enableSpeculation?e.jsx(Ip,{value:r.speculation,onChange:V=>a.onChange({...r,speculation:V}),capabilities:W,disabled:s,loading:ce.loading,error:ce.error?ce.error.replace("Reasoning options","MTP options"):void 0}):null]})}function nf(...a){return a.filter(Boolean).join(" ")}function Dp({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:f="token: missing",showGatewayUrl:d=!1,gatewayUrl:p="",gatewayUrlPlaceholder:_="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:b,userPlaceholder:x="admin",onUserIdChange:N,token:C,tokenPlaceholder:I="Paste Gateway user token",showToken:E=!1,onTokenChange:P,onShowTokenChange:U,remember:D=!1,rememberLabel:F="Remember this browser",onRememberChange:Q,loading:$=!1,submitting:Z=!1,submitDisabled:oe=!1,submitLabel:le="Sign in",submittingLabel:pe="Signing in...",closeLabel:Ae="Close",signOutLabel:Me="Sign out",showClose:ve=!1,showSignOut:ce=!1,error:q,message:L,className:W,onSubmit:X,onClose:M,onSignOut:ue}){const V=$||Z,j=V||oe||!String(b||"").trim()||!String(C||"").trim(),R=ee=>{ee.preventDefault(),!j&&X()};return e.jsxs("form",{className:nf("af-gateway-signin",W),onSubmit:R,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:nf("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:l}),f?e.jsx("span",{className:"af-gateway-signin__source",children:f}):null]}),e.jsxs("div",{className:"af-gateway-signin__form",children:[d?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:ee=>y==null?void 0:y(ee.target.value),placeholder:_,autoComplete:"url",disabled:V})]}):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:ee=>N(ee.target.value),placeholder:x,autoComplete:"username",disabled:V}),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:E?"text":"password",value:C,onChange:ee=>P(ee.target.value),placeholder:I,autoComplete:"current-password",disabled:V}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>U==null?void 0:U(!E),disabled:V,children:E?"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:ee=>Q==null?void 0:Q(ee.target.checked),disabled:V}),F]})]}),q?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:q}):null,!q&&L?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:L}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[ve?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:M,disabled:V,children:Ae}):null,ce?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(ue==null?void 0:ue()),disabled:V,children:Me}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:j,children:Z?pe:le})]})]})}function Fp(a){return a==="light"?"Light":"Dark"}function qp(a){const s=a.themes&&a.themes.length?a.themes:Kf,r=a.showSwatches!==!1,l=a.variant||"panel",c=h.useMemo(()=>{const d={};for(const p of s)d[p.id]=p;return d},[s]),f=h.useMemo(()=>s.map(d=>({value:d.id,label:d.label,group:Fp(d.group)})),[s]);return e.jsx(Er,{value:a.value,options:f,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:l,className:a.className,triggerClassName:a.triggerClassName,onChange:d=>a.onChange(String(d||"").trim()),renderValue:(d,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((C,I)=>e.jsx("span",{className:"af-theme-swatch",style:{background:C}},`${_}:${I}`))}):null]})},renderOption:(d,p)=>{const _=String(d.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:d.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 Bp(a){const s=a.scales&&a.scales.length?a.scales:qu,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Er,{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 Up(a){const s=a.densities&&a.densities.length?a.densities:Bu,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Er,{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 Wp=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function Hp(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"})]});default:return null}}function at({name:a,size:s=16,className:r,title:l,...c}){const f=l?void 0:!0,d=Wp.has(a);return e.jsxs("svg",{width:s,height:s,viewBox:d?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:d?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":f,role:l?"img":"presentation",...c,children:[l?e.jsx("title",{children:l}):null,Hp(a)]})}const xu=1;function Oa(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const Vp=["granted","denied","structurally_unavailable","trust_gated"],Gp=["attachable","requires_review","blocked"],Kp=["default","operator","structural"],Qp=["grant","deny","clear"],Jp=new Set(["__proto__","constructor","prototype"]);function Yp(a,s){if(!Oa(a))return{ok:!1,reason:`${s}: cell is not an object`};const r=String(a.availability||"");if(!Vp.includes(r))return{ok:!1,reason:`${s}: unknown availability "${r}"`};const l=String(a.provenance||"");if(!Kp.includes(l))return{ok:!1,reason:`${s}: unknown provenance "${l}"`};let c;if(r==="trust_gated"){const f=String(a.trust_state||"");if(!Gp.includes(f))return{ok:!1,reason:`${s}: trust_gated cell without a valid trust_state ("${f}")`};c=f}for(const f of["assigned","resolved_value","executable"]){const d=a[f];if(d!==void 0&&typeof d!="boolean")return{ok:!1,reason:`${s}: "${f}" 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 Jf(a){if(!Oa(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)!==xu)return{ok:!1,reason:`unsupported schema_version ${s} (this build understands ${xu}); 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 d of a.phases){if(!Oa(d)||typeof d.id!="string"||!d.id.trim())return{ok:!1,reason:"phase without a string id"};const p=d.id.trim();if(Jp.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 d.label=="string"?d.label:void 0,hint:typeof d.hint=="string"?d.hint:void 0})}const c=[],f=new Set;for(const d of a.sections){if(!Oa(d)||typeof d.id!="string"||!d.id.trim())return{ok:!1,reason:"section without a string id"};const p=d.id.trim();if(f.has(p))return{ok:!1,reason:`duplicate section id "${p}"`};if(f.add(p),!Array.isArray(d.items))return{ok:!1,reason:`section "${p}" has no items array`};const _=[],y=new Set;for(const b of d.items){if(!Oa(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&&!Oa(b.cells))return{ok:!1,reason:`section "${p}" item "${x}": cells is not an object`};const N=Object.create(null),C=Oa(b.cells)?b.cells:{};for(const[I,E]of Object.entries(C)){if(!l.has(I))return{ok:!1,reason:`section "${p}" item "${x}": cell for undeclared phase "${I}"`};const P=Yp(E,`section "${p}" item "${x}" phase "${I}"`);if(!P.ok)return P;N[I]=P.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 d.label=="string"?d.label:void 0,items:_})}return{ok:!0,payload:{schema_version:xu,phases:r,sections:c}}}function Xp(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 rd(a,s,r,l,c){const f=a.sections.find(I=>I.id===r),d=f==null?void 0:f.items.find(I=>I.id===l),p=d&&d.cells[c]||null,_=Xp(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 C;return y?C={kind:"blocked",blocked_kind:p.availability==="trust_gated"?"trust":"structural"}:x&&N!==!0?C={kind:"approval"}:C={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:C}}function Zp(a,s,r){const l=rd(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)),f=l.cell;return r.op==="clear"?f.assigned?[...c,r]:c:f.assigned&&f.provenance==="operator"&&f.resolved_value===(r.op==="grant")?c:[...c,r]}function e_(a,s){const r=new Set,l=[];for(const c of s){if(!Oa(c)||!Qp.includes(c.op))continue;const f=`${c.section}\0${c.item}\0${c.phase}`;if(r.has(f))continue;r.add(f);const d=rd(a,[],c.section,c.item,c.phase);!d.cell||!d.interactive||l.push(c)}return l}function t_(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function n_(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,f=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(d=>e.jsx("button",{type:"button","aria-pressed":l.active_op===d,className:`af-matrix__tri-btn is-${d} ${l.active_op===d?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(d),children:t_(d)},d))}),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:f}),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 s_(a){const s=a.disabled===!0,r=h.useMemo(()=>Jf(a.payload),[a.payload]),l=h.useMemo(()=>r.ok?e_(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,f=(d,p,_,y)=>{if(s)return;const b=Zp(c,l,{section:d,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(d=>e.jsxs("th",{className:"af-matrix__phase",title:d.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:d.label||d.id}),d.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:d.hint}):null]},d.id))]})}),c.sections.map(d=>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:d.label||d.id})}),d.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=rd(c,l,d.id,p.id,_.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(n_,{view:y,cellLabel:`${p.label||p.id} — ${_.label||_.id}`,disabled:s,onAct:b=>f(d.id,p.id,_.id,b)})},_.id)})]},p.id)),d.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]},d.id))]})})]})}async function Uu(a="/api/connection/gateway"){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 a_(a,s="/api/connection/gateway"){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 Yf(a="/api/connection/gateway"){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 bu(a){let s=String(a||"").trim();for(let r=0;r<2&&s;r+=1){try{const f=JSON.parse(s);if(typeof f=="string"&&f!==s){s=f.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 r_(a){var f,d;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const s=a.gateway||{},r=(f=s.principal)==null?void 0:f.user_id,l=(d=s.principal)==null?void 0:d.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 i_(a){const s=a.connectionPath||"/api/connection/gateway",[r,l]=h.useState(!1),[c,f]=h.useState(!1),[d,p]=h.useState(null),[_,y]=h.useState(!1);h.useEffect(()=>{a.isOpen||y(!1)},[a.isOpen]);const[b,x]=h.useState(a.defaultGatewayUrl||"http://127.0.0.1:8080"),[N,C]=h.useState("admin"),[I,E]=h.useState(""),[P,U]=h.useState(!1),[D,F]=h.useState(!0),[Q,$]=h.useState(""),[Z,oe]=h.useState(""),le=h.useMemo(()=>r_(d),[d]),pe=ce=>{var q;p(ce),(q=a.onStatusChange)==null||q.call(a,ce)},Ae=h.useRef(!1);if(h.useEffect(()=>{var q;if(!a.isOpen)return;const ce=!Ae.current;if(Ae.current=!0,ce&&a.initialStatus!==void 0&&a.initialStatus!==null){const L=a.initialStatus;pe(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&x(bu(L.gateway_url));const W=(q=L.gateway)==null?void 0:q.principal;W!=null&&W.user_id&&C(W.user_id);return}l(!0),$(""),Uu(s).then(L=>{var X;pe(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&x(bu(L.gateway_url));const W=(X=L.gateway)==null?void 0:X.principal;W!=null&&W.user_id&&C(W.user_id)}).catch(L=>$(`Failed to load connection status: ${String((L==null?void 0:L.message)||L)}`)).finally(()=>l(!1))},[a.isOpen]),h.useEffect(()=>{if(!a.isOpen)return;const ce=q=>{q.key==="Escape"&&!q.defaultPrevented&&!a.blocking&&(q.preventDefault(),a.onClose())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||_)return null;const Me=async()=>{f(!0),$(""),oe("");try{const ce=bu(b);x(ce);const q=await a_({gateway_url:ce,gateway_user_id:N,gateway_token:I,persist:D},s);pe(q),E(""),y(!0),a.onClose()}catch(ce){$(String((ce==null?void 0:ce.message)||ce))}finally{f(!1)}},ve=async()=>{f(!0),$(""),oe("");try{await Yf(s),E("");const ce=await Uu(s).catch(()=>null);pe(ce),oe("Signed out. This browser no longer holds a gateway session.")}catch(ce){$(String((ce==null?void 0:ce.message)||ce))}finally{f(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:ce=>{!a.blocking&&ce.target===ce.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Dp,{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:le.label,statusTone:le.tone,tokenSourceLabel:d!=null&&d.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:b,onGatewayUrlChange:ce=>x(ce),userId:N,onUserIdChange:C,token:I,tokenPlaceholder:d!=null&&d.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:P,onTokenChange:E,onShowTokenChange:U,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&&!!(d!=null&&d.has_session),onSignOut:ve,error:Q,message:Z,onSubmit:Me})})})}function l_(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function o_(a){const s=a||{},r=s.connectionPath||"/api/connection/gateway",l=s.variant||"dismissable",c=h.useRef(s.onStatusChange);c.current=s.onStatusChange;const f=h.useRef(l);f.current=l;const d=h.useRef(!!s.autoOpenMidSession);d.current=!!s.autoOpenMidSession;const[p,_]=h.useState(null),[y,b]=h.useState("loading"),[x,N]=h.useState(!1),C=h.useRef(!1),I=h.useRef(!1),E=h.useRef("loading"),P=h.useRef("none"),U=h.useRef(!1),D=h.useRef(0),F=h.useCallback(q=>{var W;D.current+=1,_(q),(W=c.current)==null||W.call(c,q);const L=l_(q);if(L)b("connected"),E.current="connected",C.current=!1,P.current="none",I.current||N(!1);else if(q!==null){const X=E.current;b("disconnected"),E.current="disconnected",X!=="disconnected"&&(P.current=U.current?"signout":X==="connected"?"mid":"boot");const M=f.current==="blocking"||P.current!=="mid"||d.current;!C.current&&M&&N(!0)}q!==null&&(I.current=L)},[]),Q=h.useCallback(async()=>{const q=D.current;try{const L=await Uu(r);if(D.current!==q)return;F(L)}catch{if(D.current!==q)return;F(null)}},[r,F]),[$,Z]=h.useState(!1),[oe,le]=h.useState(null),pe=h.useCallback(async()=>{Z(!0),le(null),D.current+=1;let q=null;try{await Yf(r)}catch(L){q=String((L==null?void 0:L.message)||L||"Sign-out request failed")}U.current=!0;try{await Q()}finally{U.current=!1}le(q),Z(!1)},[r,Q]),Ae=h.useRef(!1);h.useEffect(()=>{Ae.current||(Ae.current=!0,Q())},[Q]);const Me=h.useCallback(()=>{N(!0)},[]),ve=h.useCallback(()=>{const q=E.current;l==="blocking"&&q==="disconnected"||(q==="disconnected"&&(C.current=!0),N(!1))},[l]),ce=h.useMemo(()=>({isOpen:x,onClose:ve,blocking:l==="blocking"&&y!=="connected",appName:s.appName,connectionPath:r,defaultGatewayUrl:s.defaultGatewayUrl,initialStatus:p,onStatusChange:F}),[x,ve,l,y,s.appName,r,s.defaultGatewayUrl,p,F]);return{status:p,phase:y,connected:y==="connected",modalOpen:x,signingOut:$,signOutError:oe,openModal:Me,refresh:Q,signOut:pe,modalProps:ce}}const wu={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},c_=/^var\(--[a-z0-9-]+\)$/i;function u_(a,s){const r=a||"neutral";if(r==="custom"){const l=String(s||"").trim();return c_.test(l)?l:wu.neutral}return wu[r]||wu.neutral}function d_(a,s,r){return[a,`${a}--${s.tone||"neutral"}`,s.size==="sm"?`${a}--sm`:"",r||"",s.className||""].filter(Boolean).join(" ")}function m_(a){return{"--af-chip-hue":u_(a.tone,a.hue)}}function On(a){return e.jsxs("span",{className:d_("af-chip",a,a.onRemove?"af-chip--removable":""),style:m_(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 f_(a){const s=a.closeOnEscape!==!1,r=h.useRef(null);return h.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]),h.useEffect(()=>{const l=r.current;l&&(a.open?l.removeAttribute("inert"):l.setAttribute("inert",""))},[a.open]),e.jsxs("div",{ref:r,className:`af-drawer${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 h_={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"},p_={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"}},__={framework:h_,apps:p_},Xo=__;function g_(){return Object.keys(Xo.apps).sort()}function v_(a,s){const r=Object.prototype.hasOwnProperty.call(Xo.apps,a)?Xo.apps[a]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${a}" (known: ${g_().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 y_(a,s){const r=Xo.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,f]of s||[])l.push([String(c),String(f)]);return l}function ju(a){return typeof a=="string"?a.trim():""}function sf(a,s){if(s!=null)return[["Gateway",`unavailable (${String(s).trim()||"unknown error"})`]];const r=a&&typeof a=="object"&&!Array.isArray(a)?a:{},l=ju(r.abstractgateway);if(!l)return[["Gateway","unavailable (the gateway did not report its version)"]];const c=ju(r.abstractframework),f=[["Gateway",`AbstractGateway ${l}`],["Gateway framework",c?`AbstractFramework ${c}`:"not installed on the gateway host"]],d=r.packages&&typeof r.packages=="object"&&!Array.isArray(r.packages)?r.packages:{},p=Object.keys(d).filter(_=>_!=="abstractgateway"&&_!=="abstractframework").sort((_,y)=>_<y?-1:_>y?1:0);for(const _ of p){const y=ju(d[_]);y&&f.push([`Gateway package ${_}`,y])}return f}const x_='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function b_(a,s,r){if(a.key!=="Tab"||!s)return;const l=Array.from(s.querySelectorAll(x_));if(l.length===0){a.preventDefault();return}const c=l[0],f=l[l.length-1],d=!!r&&s.contains(r);a.shiftKey?(r===c||!d)&&(a.preventDefault(),f.focus()):(r===f||!d)&&(a.preventDefault(),c.focus())}const w_=/https?:\/\/[^\s<>"]+/g;function j_(a,s){if(a==="Contact")return[{text:s,href:`mailto:${s}`}];const r=[];let l=0;for(const c of s.matchAll(w_)){const f=c.index??0;f>l&&r.push({text:s.slice(l,f)}),r.push({text:c[0],href:c[0]}),l=f+c[0].length}return(l<s.length||r.length===0)&&r.push({text:s.slice(l)}),r}function k_({label:a,value:s}){return e.jsx("span",{children:j_(a,s).map((r,l)=>r.href===void 0?e.jsx(Ht.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 S_(a){const s=h.useRef(null),r=h.useRef(null),l=h.useId(),c=h.useRef(a.onClose);if(c.current=a.onClose,h.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}b_(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 f=a.title||`About ${a.identity.name}`,d=y_(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:f}),e.jsx("dl",{className:"af-about__rows",children:d.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(k_,{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 N_(a){const{connection:s}=a,r=s.phase,l=s.signingOut===!0,[c,f]=h.useState(!1),d=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(at,{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(at,{name:"contrast",size:16})}):null,d?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":d.label||`About ${d.identity.name}`,title:d.label||"About","aria-haspopup":"dialog",onClick:()=>{var y;f(!0),(y=d.onOpen)==null||y.call(d)},children:e.jsx(at,{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})]}),d?e.jsx(S_,{open:c,onClose:()=>f(!1),identity:d.identity,extraRows:d.extraRows}):null]})}const Qo={theme:"dark",font_scale:"md",header_density:"standard"};function C_(a){const s=a&&typeof a=="object"?a:{};return{theme:typeof s.theme=="string"&&s.theme?s.theme:Qo.theme,font_scale:typeof s.font_scale=="string"&&s.font_scale?s.font_scale:Qo.font_scale,header_density:typeof s.header_density=="string"&&s.header_density?s.header_density:Qo.header_density}}function $_(a){return`af_appearance_${a}_v1`}function E_(a,s){const r=$_(a),l=h.useMemo(()=>({...Qo}),[JSON.stringify({})]),[c,f]=h.useState(()=>{let d=l;try{const p=localStorage.getItem(r)??(s!=null&&s.legacyKey?localStorage.getItem(s.legacyKey):null);p&&(d=C_({...l,...JSON.parse(p)}))}catch{}try{Zm(d.theme),ef({font_scale:d.font_scale,header_density:d.header_density})}catch{}return d});return h.useEffect(()=>{Zm(c.theme),ef({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(r,JSON.stringify(c))}catch{}},[r,c]),[c,f]}function T_(a){return h.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(qp,{value:a.value.theme,onChange:s=>a.onChange({...a.value,theme:s})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(Bp,{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(Up,{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*A_(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 d=await r.json().catch(()=>null),p=d&&typeof d=="object"&&d.detail?String(d.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 f="";for(;;){const{done:d,value:p}=await l.read();if(d)break;f+=c.decode(p,{stream:!0});let _;for(;(_=f.indexOf(`
41
- `))>=0;){const y=f.slice(0,_).trim();if(f=f.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),C=new Uint8Array(N.length);for(let I=0;I<N.length;I+=1)C[I]=N.charCodeAt(I);yield C.buffer}if(b&&(b.type==="done"||b.type==="cancelled"))return}}}finally{s.abort()}}function R_(){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 L_(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function M_(){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 ku(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 f=l(r);if(f&&typeof f.then=="function")return await f}catch{}return await new Promise((f,d)=>{try{l(r,f,d)}catch(p){d(p)}})}function z_(a){const s=new Uint8Array(a);if(s.length<44)return null;const r=f=>String.fromCharCode(s[f],s[f+1],s[f+2],s[f+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const l=new DataView(a);let c=12;for(;c+8<=s.length;){const f=r(c),d=l.getUint32(c+4,!0);if(f==="data")return s.slice(0,c+8);c+=8+d+d%2}return null}function P_(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 Xf(a){const s=h.useRef(a);s.current=a;const r=me=>{var Re,Pe;return(Pe=(Re=s.current).on_error)==null?void 0:Pe.call(Re,me)},l=h.useMemo(()=>L_()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),c=h.useMemo(()=>R_()&&typeof a.transcribe=="function",[a.transcribe]),[f,d]=h.useState({key:"",status:"idle"}),p=h.useRef(f),_=h.useCallback(me=>{p.current=me,d(Re=>Re.key===me.key&&Re.status===me.status?Re:me)},[]),y=h.useRef(""),b=h.useRef(""),x=h.useRef(null),N=h.useRef(null),C=h.useRef(null),I=h.useRef(null),E=h.useRef(0),P=h.useRef(0),U=h.useRef(0),D=h.useRef([]),F=h.useRef(0),Q=h.useRef(!0),$=h.useRef(!1),Z=()=>{try{const me=globalThis,Re=(me==null?void 0:me.AudioContext)||(me==null?void 0:me.webkitAudioContext);if(!Re)return null;if(!x.current){const ye=new Re,ge=ye.createGain();ge.gain.value=1,ge.connect(ye.destination),x.current=ye,N.current=ge}const Pe=x.current,se=N.current;if(!Pe||!se)return null;try{Pe.state==="suspended"&&Pe.resume()}catch{}return{ctx:Pe,gain:se}}catch{return null}},oe=h.useCallback(()=>{const me=C.current;if(C.current=null,!!me){try{me.onended=null}catch{}try{me.stop()}catch{}try{me.disconnect()}catch{}}},[]),le=h.useCallback(()=>{oe(),U.current+=1,D.current=[],F.current=0,Q.current=!0,$.current=!1,b.current="",y.current="",I.current=null,E.current=0,P.current=0,_({key:"",status:"idle"})},[oe,_]);h.useEffect(()=>()=>{var me,Re;le();try{(me=N.current)==null||me.disconnect()}catch{}try{(Re=x.current)==null||Re.close()}catch{}x.current=null,N.current=null,I.current=null},[]);const pe=async(me,Re,Pe)=>{const se=U.current,ye=Z();if(!ye)throw new Error("TTS playback is not supported in this browser");const{ctx:ge,gain:qe}=ye;try{ge.state==="suspended"&&await ge.resume()}catch{}if(se!==U.current)return;oe();const Ye=ge.createBufferSource();Ye.buffer=Re,Ye.connect(qe);const ie=Number.isFinite(Number(Re.duration))?Number(Re.duration):0,fe=Math.max(0,Math.min(Number(Pe||0),ie>0?Math.max(0,ie-.01):0));P.current=ge.currentTime-fe,E.current=fe,C.current=Ye,y.current=me,Ye.onended=()=>{C.current===Ye&&(C.current=null,E.current=0,P.current=0,y.current="",_({key:"",status:"idle"}))},Ye.start(0,fe),_({key:me,status:"playing"})},Ae=(me,Re)=>{if(Re!==U.current)return;const Pe=Z();if(!Pe)return;const se=D.current,ye=F.current;if(ye>=se.length){Q.current&&(y.current="",E.current=0,P.current=0,_({key:"",status:"idle"}));return}const ge=se[ye],{ctx:qe,gain:Ye}=Pe;oe();const ie=qe.createBufferSource();ie.buffer=ge,ie.connect(Ye);const fe=Number.isFinite(Number(ge.duration))?Number(ge.duration):0,be=Math.max(0,Math.min(Number(E.current||0),fe>0?Math.max(0,fe-.01):0));P.current=qe.currentTime-be,C.current=ie,y.current=me,ie.onended=()=>{Re===U.current&&C.current===ie&&(C.current=null,F.current=ye+1,E.current=0,Ae(me,Re))};try{qe.state==="suspended"&&qe.resume()}catch{}ie.start(0,be),_({key:me,status:"playing"})},Me=async(me,Re,Pe)=>{const se=Z();if(!se){r==null||r("TTS playback is not supported in this browser.");return}oe();const ye=++U.current;D.current=[],F.current=0,Q.current=!1,$.current=!1,I.current=null,E.current=0,P.current=0,y.current=me,b.current=me,_({key:me,status:"loading"}),r==null||r("");let ge=null;try{for await(const qe of Pe(Re)){if(ye!==U.current)return;let Ye;try{Ye=await ku(se.ctx,qe),ge||(ge=z_(qe))}catch{if(!ge)continue;try{Ye=await ku(se.ctx,P_(ge,qe))}catch{continue}}if(ye!==U.current)return;D.current.push(Ye),!C.current&&!$.current&&(b.current="",Ae(me,ye))}if(ye!==U.current)return;if(Q.current=!0,D.current.length===0){r==null||r("TTS stream produced no audio."),le();return}!C.current&&!$.current&&Ae(me,ye)}catch(qe){if(ye!==U.current)return;r==null||r(String((qe==null?void 0:qe.message)||qe||"TTS stream failed")),le()}},ve=h.useCallback(async(me,Re)=>{const Pe=String(me||"").trim(),se=String(Re||"").trim();if(!Pe||!se)return;const ye=s.current.tts,ge=s.current.tts_stream;if(typeof ye!="function"&&typeof ge!="function"){r==null||r("TTS is not available.");return}const qe=Z();if(!qe){r==null||r("TTS playback is not supported in this browser.");return}const Ye=p.current,ie=Ye.key===Pe;if(ie&&Ye.status==="playing"){if(C.current){const be=Math.max(0,qe.ctx.currentTime-Number(P.current||0));E.current=be}else E.current=0;$.current=!0,oe(),_({key:Pe,status:"paused"});return}if(ie&&Ye.status==="paused"){if(D.current.length>0){r==null||r(""),$.current=!1,_({key:Pe,status:"playing"}),Ae(Pe,U.current);return}const be=I.current;if(be){r==null||r(""),$.current=!1;try{await pe(Pe,be,E.current)}catch(G){r==null||r(String((G==null?void 0:G.message)||G||"TTS play failed")),_({key:"",status:"idle"})}return}}if(ie&&Ye.status==="loading")return;if(typeof ge=="function"){await Me(Pe,se,ge);return}oe(),U.current+=1;const fe=U.current;D.current=[],F.current=0,Q.current=!0,$.current=!1,I.current=null,E.current=0,P.current=0,y.current=Pe,b.current=Pe,_({key:Pe,status:"loading"}),r==null||r("");try{const be=await ye(se);if(b.current!==Pe||U.current!==fe)return;const G=await ku(qe.ctx,be);if(b.current!==Pe||U.current!==fe)return;I.current=G,E.current=0,await pe(Pe,G,0)}catch(be){if(U.current!==fe)return;b.current===Pe&&(b.current="",y.current="",_({key:"",status:"idle"})),r==null||r(String((be==null?void 0:be.message)||be||"TTS failed"))}},[]),[ce,q]=h.useState(!1),[L,W]=h.useState(!1),X=h.useRef(!1),M=h.useRef(c);M.current=c;const ue=h.useCallback(me=>{X.current=me,q(Re=>Re===me?Re:me)},[]),V=h.useRef(!1),j=h.useRef(null),R=h.useRef(null),ee=h.useRef([]),_e=h.useRef(""),he=h.useRef(0),O=h.useRef(!1);function je(){var me,Re;try{(Re=(me=j.current)==null?void 0:me.getTracks)==null||Re.call(me).forEach(Pe=>{try{Pe.stop()}catch{}})}catch{}j.current=null}const te=h.useCallback(()=>{he.current+=1,O.current=!1;const me=R.current;if(me){me.onstop=null,me.ondataavailable=null,me.onerror=null;try{me.stop()}catch{}}R.current=null,je(),ue(!1),V.current=!1,W(!1),ee.current=[]},[ue]);h.useEffect(()=>()=>te(),[te]);async function ke(me,Re){var ye,ge;if(r==null||r(""),!me||!me.size||V.current)return;const Pe=s.current.transcribe;if(typeof Pe!="function"){r==null||r("Transcription is not available.");return}V.current=!0;const se=he.current;W(!0);try{const qe=String(await Pe(me,Re)||"").trim();se===he.current&&qe&&((ge=(ye=s.current).on_transcript)==null||ge.call(ye,qe))}catch(qe){se===he.current&&(r==null||r(String((qe==null?void 0:qe.message)||qe||"Transcription failed")))}finally{se===he.current&&(V.current=!1,W(!1))}}const Ce=h.useCallback(async()=>{if(r==null||r(""),!M.current){r==null||r("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(V.current||O.current||X.current||R.current)return;ee.current=[];const me=he.current;O.current=!0;try{const Re=await navigator.mediaDevices.getUserMedia({audio:!0});if(me!==he.current){Re.getTracks().forEach(ye=>ye.stop());return}j.current=Re;const Pe=M_();_e.current=Pe;const se=Pe?new MediaRecorder(Re,{mimeType:Pe}):new MediaRecorder(Re);R.current=se,se.ondataavailable=ye=>{if(me===he.current)try{ye!=null&&ye.data&&ee.current.push(ye.data)}catch{}},se.onerror=()=>{me===he.current&&(r==null||r("Recording failed."))},se.onstop=()=>{if(me===he.current){ue(!1),je(),R.current=null;try{const ye=new Blob(ee.current,{type:_e.current||""});ke(ye,_e.current)}catch(ye){r==null||r(String((ye==null?void 0:ye.message)||ye||"Failed to build recording"))}}},se.start(),ue(!0)}catch(Re){if(me!==he.current)return;je(),R.current=null,ue(!1);const Pe=String((Re==null?void 0:Re.message)||Re||"Failed to access microphone");r==null||r(Pe.toLowerCase().includes("permission")?`Microphone permission denied: ${Pe}`:Pe)}finally{me===he.current&&(O.current=!1)}},[]),We=h.useCallback(()=>{const me=R.current;if(!(!X.current||!me)){ue(!1);try{me.stop()}catch(Re){r==null||r(String((Re==null?void 0:Re.message)||Re||"Failed to stop recording"))}}},[]);return h.useEffect(()=>{if(!ce)return;const me=()=>We();return window.addEventListener("pointerup",me),window.addEventListener("pointercancel",me),()=>{window.removeEventListener("pointerup",me),window.removeEventListener("pointercancel",me)}},[ce]),{tts_supported:l,tts_playback:f,toggle_tts:ve,stop_tts:le,voice_ptt_supported:c,voice_ptt_recording:ce,voice_ptt_busy:L,start_voice_ptt_recording:Ce,stop_voice_ptt_recording:We,cancel_voice_ptt_recording:te}}function I_(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 dn(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 O_=3,D_=Number.MAX_SAFE_INTEGER;function Zf(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function eh(a){return Array.isArray(a)}function F_(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function vi({kind:a,children:s}){return e.jsx("span",{className:`pc-json-token ${a}`,children:s})}function q_(a){const s=JSON.stringify(a.value),r=s.length>96||s.includes("\\n")||s.includes("\\r")||s.includes("\\t"),[l,c]=h.useState(!r||a.expansionMode==="unfolded");return h.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(f=>!f),"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(vi,{kind:"string",children:s})}function B_(a,s,r){return a===null?e.jsx(vi,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(q_,{value:a,expansionMode:s,expansionVersion:r}):typeof a=="number"?e.jsx(vi,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx(vi,{kind:"boolean",children:a?"true":"false"}):e.jsx(vi,{kind:"string",children:JSON.stringify(String(a))})}function U_(a){return eh(a)?a.length===1?"1 item":`${a.length} items`:Zf(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function th(a){const{label:s,value:r,depth:l,collapseAfterDepth:c,expansionMode:f,expansionVersion:d,trailingComma:p}=a,_=l*14,y=Zf(r),b=eh(r),x=y||b,N=l<c,[C,I]=h.useState(N);h.useEffect(()=>{I(N)},[N,d]);const E=s?e.jsxs(e.Fragment,{children:[e.jsx(vi,{kind:"key",children:JSON.stringify(s)}),": "]}):null;if(!x)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[E,B_(r,f,d),p?",":""]});const P=b?"[":"{",U=b?"]":"}",D=U_(r),F=C?`${P}`:`${P}…${U}${D?` (${D})`:""}`,Q=b?r.map(($,Z)=>({key:String(Z),label:void 0,value:$})):Object.entries(r).map(([$,Z])=>({key:$,label:$,value:Z}));return e.jsxs("details",{className:"pc-json-viewer__details",open:C,onToggle:$=>I($.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:_},children:[E,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:C?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:F}),!C&&p?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),C?e.jsx("div",{className:"pc-json-viewer__children",children:Q.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:U}),p?",":""]}):e.jsxs(e.Fragment,{children:[Q.map(($,Z)=>{const oe=Z===Q.length-1;return e.jsx(th,{label:$.label,value:$.value,depth:l+1,collapseAfterDepth:c,expansionMode:f,expansionVersion:d,trailingComma:!oe},`${l}:${s||"root"}:${$.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:U}),p?",":""]})]})}):null]})}function W_(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 Jo(a){const{value:s,className:r,showCopy:l=!0}=a,[c,f]=h.useState({mode:"folded",version:0}),d=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):O_,p=c.mode==="unfolded"?D_:d,_=h.useMemo(()=>typeof s=="string"?W_(s):s,[s]),y=h.useMemo(()=>F_(s),[s]),b=["pc-json-viewer",r].filter(Boolean).join(" ");h.useEffect(()=>{f(N=>({mode:"folded",version:N.version+1}))},[_]);const x=()=>{f(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 dn(y),children:"Copy JSON"}):null]}),e.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:e.jsx(th,{value:_,depth:0,collapseAfterDepth:p,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function _l(a,s){const r=String(a??"");if(!s||!s.needles.length)return[r];const l=[],c=r.toLowerCase();let f=0;for(;f<r.length;){let d=-1,p="";for(let b=0;b<s.needlesLower.length;b++){const x=s.needlesLower[b];if(!x)continue;const N=c.indexOf(x,f);if(N===-1)continue;const C=s.needles[b]||"";C&&(d===-1||N<d||N===d&&C.length>p.length)&&(d=N,p=C)}if(d===-1||!p){l.push(r.slice(f));break}d>f&&l.push(r.slice(f,d));const _=s.hits===0&&s.id?s.id:void 0,y=r.slice(d,d+p.length);l.push(e.jsx("span",{id:_,className:s.className,children:y},`hl:${s.hits}`)),s.hits+=1,f=d+p.length}return l}function Wu(a){const s=String(a||"").trim();if(s&&/^(https?:|mailto:|tel:|#|\/)/i.test(s))return s}let Cr=null;function H_(a){var l;const s=String(a||"").trim();if(s.startsWith("/")&&!s.startsWith("//")&&!s.startsWith("/\\"))return!0;if(!/^https?:\/\//i.test(s))return!1;const r=typeof window<"u"?(l=window.location)==null?void 0:l.origin:void 0;if(!r||r==="null")return!1;try{return new URL(s).origin===r}catch{return!1}}function nh(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 Da(a,s){const r=[],l=String(a??"");let c=0,f="";const d=()=>{if(f){for(const p of _l(f,s))r.push(p);f=""}};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=Wu(l.slice(_+2,y));if(x&&Cr&&!Cr(x)){d(),r.push(nh(`img:${c}`,x,b)),c=y+1;continue}if(x){d(),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?_l(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=Wu(l.slice(_+2,y));if(x){d(),r.push(e.jsx("a",{className:"pc-md_link",href:x,target:x.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Da(b,s)},`link:${c}`)),c=y+1;continue}}}}if(p==="`"){const _=l.indexOf("`",c+1);if(_!==-1){d();const y=l.slice(c+1,_);r.push(e.jsx("code",{children:s?_l(y,s):y},`code:${c}`)),c=_+1;continue}}if(p==="*"&&l[c+1]==="*"){const _=l.indexOf("**",c+2);if(_!==-1){d();const y=l.slice(c+2,_);r.push(e.jsx("strong",{children:s?_l(y,s):y},`bold:${c}`)),c=_+2;continue}}if(p==="*"&&l[c+1]!=="*"){const _=l.indexOf("*",c+1);if(_!==-1){d();const y=l.slice(c+1,_);r.push(e.jsx("em",{children:s?_l(y,s):y},`em:${c}`)),c=_+1;continue}}f+=p,c+=1}return d(),r}function V_(a){return String(a??"").replace(/\r\n/g,`
42
- `).replace(/\r/g,`
43
- `).split(`
44
- `)}function Yo(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 G_(a){const s=[];for(const c of a){const f=Yo(c);f?s.push(f):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 f=l.length>0?l[l.length-1]:null;if(f&&c.indent>f.indent){const d=f.node.items,p=d[d.length-1];if(p){const _={ordered:c.ordered,start:c.start,items:[]};p.children.push(_),l.push({indent:c.indent,node:_}),f=l[l.length-1]}}else if(f&&f.node.ordered!==c.ordered){l.pop();const d=l.length>0?l[l.length-1]:null,p={ordered:c.ordered,start:c.start,items:[]};if(d){const _=d.node.items,y=_[_.length-1];y?y.children.push(p):d.node.items.push({content:"",children:[p]})}else r.push(p);l.push({indent:c.indent,node:p}),f=l[l.length-1]}if(!f){const d={ordered:c.ordered,start:c.start,items:[]};r.push(d),l.push({indent:c.indent,node:d}),f=l[l.length-1]}f.node.items.push({content:c.content,children:[]})}return r}function sh(a,s,r){const l=a.items.map((c,f)=>e.jsxs("li",{children:[Da(c.content,s),c.children.map((d,p)=>sh(d,s,`${r}:${f}:${p}`))]},`${r}:li:${f}`));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 K_(a,s,r){return G_(a).map((l,c)=>sh(l,s,`${r}:${c}`))}function af(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 rf(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))}function rs(a){const s=Cr;Cr=a.images==="link"?a.inlineImage||H_:null;try{return Q_(a)}finally{Cr=s}}function Q_({text:a,className:s,highlight:r,highlights:l,highlightClassName:c,highlightId:f}){const d=V_(a),p=[],_=[];Array.isArray(l)&&_.push(...l),typeof r=="string"&&r.trim()&&_.push(r);const y=Array.from(new Set(_.map(C=>String(C??"").trim()).filter(Boolean))).filter(C=>C.length>=4),b=y.length?{needles:y,needlesLower:y.map(C=>C.toLowerCase()),className:c||"pc-md_hl",id:f,hits:0}:null;let x=0;for(;x<d.length;){const C=String(d[x]??"");if(!C.trim()){x+=1;continue}const I=C.trim();if(/^([-_*])(\s*\1){2,}$/.test(I)){p.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}const E=C.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(E){const D=Wu(E[2]||"");if(D&&Cr&&!Cr(D)){p.push(e.jsx("p",{className:"pc-md_p",children:nh(`img:${x}`,D,E[1]||"")},`p:${x}`)),x+=1;continue}if(D){const F=E[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:Da(F,b)}):null]},`figure:${x}`)),x+=1;continue}}if(C.trim().startsWith("```")){const F=C.trim().replace(/```/g,"").trim(),Q=[];for(x+=1;x<d.length&&!String(d[x]??"").trim().startsWith("```");)Q.push(String(d[x]??"")),x+=1;x<d.length&&(x+=1);const $=Q.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 P=C.match(/^(#{1,5})\s+(.*)$/);if(P){const D=P[1].length,F=P[2]||"",Q=Da(F,b);D===1?p.push(e.jsx("h1",{children:Q},`h1:${x}`)):D===2?p.push(e.jsx("h2",{children:Q},`h2:${x}`)):D===3?p.push(e.jsx("h3",{children:Q},`h3:${x}`)):D===4?p.push(e.jsx("h4",{children:Q},`h4:${x}`)):p.push(e.jsx("h5",{children:Q},`h5:${x}`)),x+=1;continue}if(C.trimStart().startsWith(">")){const D=[];for(;x<d.length&&String(d[x]??"").trimStart().startsWith(">");){const Q=String(d[x]??"").trimStart();D.push(Q.replace(/^>\s?/,"")),x+=1}p.push(e.jsx("blockquote",{className:"pc-md_quote",children:D.map((F,Q)=>e.jsxs(Ht.Fragment,{children:[Da(F,b),Q<D.length-1?e.jsx("br",{}):null]},`q:${x}:${Q}`))},`quote:${x}`));continue}if(C.includes("|")&&x+1<d.length&&rf(String(d[x+1]??""))){const D=af(C),F=Math.max(1,D.length),Q=[];for(x+=2;x<d.length;){const $=String(d[x]??"");if(!$.trim()||!$.includes("|"))break;const Z=af($),oe=[];for(let le=0;le<F;le++)oe.push(Z[le]??"");Q.push(oe),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(($,Z)=>e.jsx("th",{children:Da($,b)},`th:${x}:${Z}`))})}),e.jsx("tbody",{children:Q.map(($,Z)=>e.jsx("tr",{children:$.map((oe,le)=>e.jsx("td",{children:Da(oe,b)},`td:${x}:${Z}:${le}`))},`tr:${x}:${Z}`))})]})},`table:${x}`));continue}if(Yo(C)){const D=[];for(;x<d.length;){const F=String(d[x]??"");if(!F.trim()||F.trimStart().startsWith("```"))break;if(Yo(F)||/^\s{2,}\S/.test(F)){D.push(F),x+=1;continue}break}p.push(e.jsx(Ht.Fragment,{children:K_(D,b,`list:${x}`)},`list:${x}`));continue}const U=[];for(;x<d.length&&String(d[x]??"").trim()&&!(U.length>0&&Yo(String(d[x]??"")));){const D=String(d[x]??"");if(U.length>0&&D.includes("|")&&x+1<d.length&&rf(String(d[x+1]??"")))break;U.push(D),x+=1}p.push(e.jsx("p",{className:"pc-md_p",children:U.map((D,F)=>e.jsxs(Ht.Fragment,{children:[Da(D,b),F<U.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 J_(a){const s=String(a.text??""),r=h.useMemo(()=>I_(s),[s]),l=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:l,children:e.jsx(Jo,{value:r,collapseAfterDepth:a.jsonCollapseAfterDepth})}):a.renderMarkdown?e.jsx("div",{className:l,children:a.renderMarkdown(s)}):e.jsx("div",{className:l,children:e.jsx(rs,{text:s,images:a.images,inlineImage:a.inlineImage})})}function ah(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function Y_(a){const s=ah(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(f=>r.find(([d])=>d===f)).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 rh({tool:a,showCopy:s=!0}){const[r,l]=h.useState(!1),c=ah(a.arguments),f=Y_(a.arguments),d=["file path","path"].includes(f.label)&&f.value.length>60?`${f.value.split(/[\\/]/).pop()} · ${f.value.slice(0,24)}…`:f.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(at,{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:f.value,children:f.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:f.label}),d]}):"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(at,{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 dn(JSON.stringify(a,null,2))),children:[e.jsx(at,{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(Ht.Fragment,{children:[e.jsx("dt",{children:x}),e.jsx("dd",{children:N&&typeof N=="object"?e.jsx(Jo,{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(Jo,{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(Jo,{value:a.output})})]}):null]})]})}function X_({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(at,{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(rh,{tool:l,showCopy:s},l.id))]})}const xn="not reported",$n=a=>a===void 0?xn:Math.round(a).toLocaleString(),Fn=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`},ih=a=>a===void 0?xn:`${Math.round(a).toLocaleString()} tok/s`,Z_=(a,s)=>s>0?`${Math.round(a/s*100)}%`:"",$r=(a,s,r=`${s}s`)=>`${a.toLocaleString()} ${a===1?s:r}`,eg=a=>{const s=a.split("#")[0].replace(/\/+$/,"");return s.slice(s.lastIndexOf("/")+1)||a};function tg(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 Zo(a){const s=[],r=(a.models||[]).map(eg),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 ng(a){const s=a.modelCalls||[],r=[],l=[{label:"Input",value:$n(a.inputTokens)},{label:"Output",value:$n(a.outputTokens)}];if(a.reasoningTokens!==void 0&&l.push({label:"Reasoning",value:$n(a.reasoningTokens),hint:"part of output"}),l.push({label:"Total",value:$n(a.totalTokens)}),r.push({heading:`Usage · ${$r(a.llmCalls,"model call")}`,rows:l}),a.measuredCacheCalls){const f=a.cachedTokens||0,d=a.fedTokens||0,p=[{label:"Reused from cache",value:`${$n(f)}${f+d?` (${Z_(f,f+d)})`:""}`},{label:"Newly processed",value:$n(a.fedTokens)},{label:"Outcome",value:tg(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(f=>f.inputTokens!==void 0);return c.length===1&&s.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${$n(c[0].inputTokens)} tokens`}]}):c.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${$n(c[0].inputTokens)} → ${$n(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((f,d)=>[String(d+1),$n(f.inputTokens),f.cachedTokens===void 0?"—":$n(f.cachedTokens),f.fedTokens===void 0?"—":$n(f.fedTokens),$n(f.outputTokens),f.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?xn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:Zo(a)}}function Bo(a,s,r,l){if(a===void 0)return xn;const c=[Fn(a)];return s!==void 0&&c.push(`${s.toLocaleString()} ${l}${r!==void 0?` at ${ih(r)}`:""}`),c.join(" · ")}function sg(a){var y,b,x;const s=a.modelCalls||[],r=[],l=a.durationMs,c=[{label:"Wall clock",value:Fn(l)}];if(c.push({label:"Model",value:a.genTimeMs===void 0?xn:`${Fn(a.genTimeMs)} · ${$r(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),c.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Fn(a.toolTimeMs)} · ${$r(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?Fn(N):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:c});const f=[],d=a.ttftCalls||0,p=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?f.push({label:d&&d===p?"Prefill (TTFT)":"Prefill",value:Bo(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:d===p?"measured time to first token":d?`TTFT measured on ${d} of ${p}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?f.push({label:"Prefill",value:Bo(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?f.push({label:"Prefill",value:`${Fn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${ih(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):f.push({label:"Prefill",value:xn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&f.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),f.push({label:"Generation",value:a.generationPhaseMs!==void 0?Bo(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):Bo(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&f.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:f});const _=a.speculation;if(_){const N=(_.draftKinds||[]).map(I=>I.toUpperCase()).join(", "),C=[{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)}% · ${$n(_.acceptedTokens)} of ${$n(_.draftedTokens)} drafted`}];((b=_.draftLengths)!=null&&b.length||_.rounds!==void 0)&&C.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:C})}return a.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Fn(a.toolTimeMs)} · ${$r(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Fn(a.slowestToolBatch.ms)} · ${lh(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,C)=>[String(C+1),N.promptMs===void 0?"—":`${Fn(N.promptMs)}${N.promptSource==="rate"?"*":""}`,N.promptNewTokensPerSecond===void 0?"—":Math.round(N.promptNewTokensPerSecond).toLocaleString(),N.generationMs===void 0?"—":Fn(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:`${Fn(l)} wall clock`,sections:r,footer:Zo(a)}}function lh(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${$r(a.calls,"call")} (${a.tools.join(", ")})`}function ag(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:Zo(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?`${Fn(_.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 f=c.filter(([,p])=>p.errors&&Object.keys(p.errors).length);f.length&&s.push({heading:"Failures",rows:f.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 d=[{label:"Tool time",value:a.toolTimeMs===void 0?xn:`${Fn(a.toolTimeMs)} · ${$r(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&d.push({label:"Slowest batch",value:`${Fn(a.slowestToolBatch.ms)} · ${lh(a.slowestToolBatch)}`}),s.push({heading:"Timing",rows:d,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:`${$r(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:s,footer:Zo(a)}}function Su(a,s){return a==="tokens"?ng(s):a==="time"?sg(s):ag(s)}function rg(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(Ht.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,f)=>e.jsx("tr",{children:c.map((d,p)=>e.jsx("td",{children:d},p))},f))})]}):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 da=8;function ig(a){const[s,r]=h.useState(!!a.defaultOpen),[l,c]=h.useState(null),f=h.useRef(null),d=h.useRef(null),p=h.useRef(null),_=`pc-stat-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=h.useCallback(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=null},[]),b=h.useCallback(()=>{y(),r(!0)},[y]),x=h.useCallback(()=>{y(),p.current=window.setTimeout(()=>r(!1),120)},[y]);h.useEffect(()=>y,[y]),h.useLayoutEffect(()=>{if(!s){c(null);return}const E=()=>{const P=f.current,U=d.current;if(!P||!U)return;const D=P.getBoundingClientRect(),F=U.offsetWidth,Q=U.offsetHeight,$=window.innerWidth,Z=window.innerHeight,oe=D.top-da-Q,le=D.bottom+da,pe=oe>=da?oe:le+Q<=Z-da?le:Math.max(da,Z-da-Q),Ae=Math.min(Math.max(da,D.left),Math.max(da,$-da-F));c({top:pe,left:Ae})};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[s]),h.useEffect(()=>{if(!s)return;const E=P=>{P.key==="Escape"&&r(!1)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[s]);const N=typeof a.onClick=="function",C=N?"button":"span",I=s?e.jsx(rg,{detail:a.detail,id:_,panelRef:d,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(C,{ref:f,...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:E=>{E.key==="Escape"&&r(!1)},onClick:N?()=>{var E;return(E=a.onClick)==null?void 0:E.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"?Qf.createPortal(I,document.body):I]})}function lg(a){const s=a.totalTokens!==void 0?Su("tokens",a):null,r=Su("tools",a),l=a.durationMs!==void 0?Su("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 og(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 cg(a){var U;const s=a.message,r=h.useMemo(()=>og(s),[s.kind,s.level,s.role,s.title]),l=String(s.ts||"").trim(),c=h.useMemo(()=>{if(!l)return"";const D=new Date(l);return Number.isFinite(D.getTime())?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[l]),[f,d]=h.useState("idle"),p=h.useRef(null);h.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&&((U=a.getSpeakState)==null?void 0:U.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)",C=a.showCopy!==!1,I=Array.isArray(a.attachments)?a.attachments:[],E=s.statistics,P=h.useMemo(()=>Array.isArray(a.stats)?a.stats:E?lg(E):[],[a.stats,E]);return s.toolActivity?e.jsx(rh,{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(at,{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(at,{name:x,size:22})}):null,C?e.jsx("button",{className:`pc-chat-icon-btn ${f!=="idle"?`pc-chat-icon-btn--${f}`:""}`.trim(),type:"button","aria-label":"Copy message",title:f==="idle"?"Copy":f==="copied"?"Copied":"Copy failed",onClick:async()=>{const D=await dn(String(s.content||""));d(D?"copied":"failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>d("idle"),900)},children:e.jsx(at,{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(J_,{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 Q=String(D.label||"").trim()||"attachment",$=String(D.target||"").trim(),Z=String(D.title||"").trim(),oe=!!D.disabled||typeof D.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:Z||Q,onClick:oe?void 0:D.onClick,disabled:oe,children:[e.jsx(at,{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:Q})]},D.id||`${Q}:${F}`)})}):null,P.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:P.slice(0,12).map((D,F)=>{const Q=String(D.label||"").trim();if(!Q)return null;if(D.detail)return e.jsx(ig,{label:Q,detail:D.detail,icon:D.icon,onClick:D.onClick},D.id||`${Q}:${F}`);const $=String(D.title||"").trim(),Z=typeof D.onClick=="function",oe=Z?"button":"span";return e.jsxs(oe,{...Z?{type:"button"}:{},className:["pc-chat-stat",Z?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:$||void 0,onClick:Z?()=>{var le;return(le=D.onClick)==null?void 0:le.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:Q})]},D.id||`${Q}:${F}`)})}):null]})}function ug(a,s){const r=Math.max(0,Math.trunc(s));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function id(a){const s=typeof a.autoScrollThresholdPx=="number"&&Number.isFinite(a.autoScrollThresholdPx)?a.autoScrollThresholdPx:120,r=a.autoScroll!==!1,l=h.useRef(null),c=h.useRef(null),[f,d]=h.useState(!0),p=h.useMemo(()=>Array.isArray(a.messages)?a.messages:[],[a.messages]),_=h.useMemo(()=>{var x;const b=[];for(const N of p){const C=b[b.length-1];N.toolActivity&&((x=C==null?void 0:C[0])!=null&&x.toolActivity)&&C[0].runId===N.runId?C.push(N):b.push([N])}return b},[p]);h.useEffect(()=>{if(!r)return;const b=l.current;if(!b)return;const x=()=>{d(ug(b,s))};return b.addEventListener("scroll",x,{passive:!0}),x(),()=>b.removeEventListener("scroll",x)},[r,s]);const y=h.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 h.useEffect(()=>{if(!r||!f)return;const b=l.current;b&&(b.scrollTop=b.scrollHeight)},[r,f,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],C=String(N.id||"")||String(N.ts||"")+":"+String(N.role||"")+":"+x;return N.toolActivity?e.jsx(X_,{tools:b.map(E=>E.toolActivity),showCopy:(I=a.messageProps)==null?void 0:I.showCopy},C):e.jsx(cg,{message:N,...a.messageProps||{}},C)}),a.after,e.jsx("div",{ref:c})]})}const ec=Ht.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,f=!!s.busy,d=!c&&!f&&!!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,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(),d&&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:!d,onClick:()=>s.onSubmit(),children:f?s.busyLabel||"Thinking…":s.sendLabel||"Send"})]}),s.overlay]})});function dg(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function mg(a){const[s,r]=h.useState([]),l=a.messages??s,c=E=>{a.onMessagesChange&&a.onMessagesChange(E),a.messages===void 0&&r(E)},f=h.useRef(l);f.current=l;const[d,p]=h.useState(""),[_,y]=h.useState(!1),b=h.useRef(null),x=a.assistantName||"Assistant",N=!!a.blockedNotice,C=async E=>{const P=String(E||"").trim();if(!P||_||N)return;p("");const U=f.current,D=[...U,{role:"user",content:P,ts:new Date().toISOString()}];c(D),y(!0);const F=new AbortController;b.current=F;try{const Q=a.ask(P,{signal:F.signal,history:U});if(dg(Q)){let $="";const Z=[...D,{role:"assistant",title:x,content:"",ts:new Date().toISOString()}];c(Z);for await(const oe of Q){if(F.signal.aborted)break;$+=String(oe??""),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 Q??"").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(Q){F.signal.aborted||c([...f.current,{role:"assistant",title:x,content:`#FALLBACK assistant request failed: ${String((Q==null?void 0:Q.message)||Q||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{b.current===F&&(b.current=null),y(!1)}},I=h.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(E=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void C(E),disabled:_||N,children:E},E))}):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(id,{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(ec,{value:d,onChange:p,onSubmit:()=>void C(d),placeholder:a.placeholder||"Ask about this app…",disabled:N,busy:_,rows:2,actions:_?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var E;(E=b.current)==null||E.abort()},children:"Stop"}):null})})]})}function fg(a){const s=a.trim();if(!s)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return s}const hg=fg("0.3.2");function _i(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 gl(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 lf="abstractcontinuum_gateway_csrf",pg="x-abstractcontinuum-csrf",_g="x-abstract-csrf";function of(a,s){const r=(a||"").trim().replace(/\/+$/,"");return r?`${r}${s}`:s}function cf(a){var l;const s=(a||"").trim(),r={};s&&(r.Authorization=`Bearer ${s}`);try{const c=(l=document.cookie.split(";").map(f=>f.trim()).find(f=>f.startsWith(`${lf}=`)))==null?void 0:l.slice(`${lf}=`.length);if(c){const f=decodeURIComponent(c);r[pg]=f,r[_g]=f}}catch{}return r}function uf(a){const s={},r=(l,c)=>{const f=String(c||"").trim();f&&(s[l]=f)};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 gg(a){try{const s=await a.text();return s!=null&&s.trim()?s.trim():`${a.status}`}catch{return`${a.status}`}}class oh extends Error{constructor(r,l,c){super(r);kr(this,"status");kr(this,"body");this.name="GatewayRequestError",this.status=l,this.body=c}}const Nu=[15,30,60,120];class vg{constructor(s){kr(this,"_cfg");kr(this,"_backoff_until",0);kr(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(of(this._cfg.base_url,r),{...l,headers:{...l==null?void 0:l.headers,...cf(this._cfg.auth_token)}});if(c.ok)return this._backoff_step=0,this._backoff_until=0,c;const f=await gg(c);let d=null;try{d=JSON.parse(f)}catch{}let p=f;if(d&&typeof d=="object"&&d.detail!==void 0&&(p=typeof d.detail=="string"?d.detail:JSON.stringify(d.detail)),c.status===429||/too many requests|auth lockout|locked/i.test(p)){const y=Nu[Math.min(this._backoff_step,Nu.length-1)];this._backoff_until=Date.now()+y*1e3,this._backoff_step<Nu.length-1&&(this._backoff_step+=1)}throw new oh(`${s} failed: ${p}`,c.status,d)}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(),f=String(r||"").trim();if(!c)throw new Error("download_run_artifact_content: run_id is required");if(!f)throw new Error("download_run_artifact_content: artifact_id is required");const d=String((l==null?void 0:l.access)||"").trim(),p=d?`?access=${encodeURIComponent(d)}`:"";return await(await this._fetch("download_run_artifact_content",`/api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(f)}/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 f=String((l==null?void 0:l.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",d=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,f),p.append("filename",f),d&&p.append("content_type",d);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 d={audio_artifact:c},p=String((r==null?void 0:r.language)||"").trim();p&&(d.language=p);const _=String((r==null?void 0:r.request_id)||"").trim();_&&(d.request_id=_);const y=await this._post_json("audio_transcribe",`/api/gateway/runs/${encodeURIComponent(l)}/audio/transcribe`,d);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 f={text:c,...uf(r)},d=String((r==null?void 0:r.format)||"").trim();d&&(f.format=d),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(f.timeout_s=r.timeout_s);const p=String((r==null?void 0:r.request_id)||"").trim();p&&(f.request_id=p);const _=await this._post_json("voice_tts",`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts`,f);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:of(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...uf(r)},headers:cf(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",df(s,"bug_report_create"))}async feature_report_create(s){return await this._post_json("feature_report_create","/api/gateway/features/report",df(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 f=String((s==null?void 0:s.since)||"").trim();f&&r.set("since",f);const d=String((s==null?void 0:s.status)||"").trim();return d&&r.set("status",d),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,f=String((r==null?void 0:r.account)||"").trim();f&&c.set("account",f);const d=String((r==null?void 0:r.mailbox)||"").trim();d&&c.set("mailbox",d);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 f={action:c};if(c==="defer"){const d=r==null?void 0:r.defer_days;typeof d=="number"&&Number.isFinite(d)&&d>0&&(f.defer_days=Number(d))}return await this._post_json("apply_triage_decision",`/api/gateway/triage/decisions/${encodeURIComponent(l)}/apply`,f)}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)??"")},f=String((s==null?void 0:s.expected_sha256)||"").trim();return f&&(c.expected_sha256=f),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 f={kind:r,package:l,title:c},d=String((s==null?void 0:s.task_type)||"").trim();d&&(f.task_type=d);const p=String((s==null?void 0:s.summary)||"").trim();p&&(f.summary=p);const _=(s==null?void 0:s.content)==null?"":String((s==null?void 0:s.content)??"");return _.trim()&&(f.content=_),await this._post_json("backlog_create","/api/gateway/backlog/create",f)}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(),f=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(f.length<2)throw new Error("backlog_merge: at least 2 items are required");const d={kind:r,package:l,title:c,items:f.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&&(d.task_type=p);const _=String((s==null?void 0:s.summary)||"").trim();return _&&(d.summary=_),await this._post_json("backlog_merge","/api/gateway/backlog/merge",d)}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 f=new FormData;return f.set("overwrite",(s==null?void 0:s.overwrite)===!0?"true":"false"),f.set("file",c,c.name||"attachment"),await this._post_form("backlog_upload_attachment",`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/attachments/upload`,f)}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 f={kind:r,package:l,title:c,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},d=String((s==null?void 0:s.summary)||"").trim();d&&(f.summary=d);const p=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");p.trim()&&(f.draft_markdown=p);const _=String((s==null?void 0:s.provider)||"").trim();_&&(f.provider=_);const y=String((s==null?void 0:s.model)||"").trim();y&&(f.model=y);const b=String((s==null?void 0:s.thinking)||"").trim();return b&&(f.thinking=b),await this._post_json("backlog_assist","/api/gateway/backlog/assist",f)}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(),f=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(!f)throw new Error("backlog_maintain: title is required");const d={kind:r,filename:l,package:c,title:f,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},p=String((s==null?void 0:s.summary)||"").trim();p&&(d.summary=p);const _=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");_.trim()&&(d.draft_markdown=_);const y=String((s==null?void 0:s.provider)||"").trim();y&&(d.provider=y);const b=String((s==null?void 0:s.model)||"").trim();return b&&(d.model=b),await this._post_json("backlog_maintain","/api/gateway/backlog/maintain",d)}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 f=String((s==null?void 0:s.thinking)||"").trim();f&&(r.thinking=f);const d=String((s==null?void 0:s.agent)||"").trim();d&&(r.agent=d),(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,f=String((s==null?void 0:s.execution_mode)||"").trim();f&&c.set("execution_mode",f);const d=String((s==null?void 0:s.executor)||"").trim();d&&c.set("executor",d);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 f=String((s==null?void 0:s.executor)||"").trim();f&&(l.executor=f);const d=String((s==null?void 0:s.target_model)||"").trim();d&&(l.target_model=d);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 f=typeof(s==null?void 0:s.max_bytes)=="number"&&Number.isFinite(s.max_bytes)?Number(s.max_bytes):0;f>0&&l.set("max_bytes",String(Math.floor(f)));const d=typeof(s==null?void 0:s.after_bytes)=="number"&&Number.isFinite(s.after_bytes)?Math.max(0,Math.floor(s.after_bytes)):null;return d!==null&&l.set("after_bytes",String(d)),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 df(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 d of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const p=String((a==null?void 0:a[d])||"").trim();p&&(c[d]=p)}const f=a==null?void 0:a.context;return f&&typeof f=="object"&&(c.context=f),c}const mf=[["Gateway","checking…"]];function yg(a){if(a instanceof oh){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 xg(a){let s;try{s=await a.gateway_about()}catch(r){return sf(null,yg(r))}return sf(s)}const bg=/^[a-zA-Z0-9_-]+$/;function ff(a){return bg.test(String(a||"").trim())}async function wg(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(f=>f.toString(16).padStart(2,"0")).join("")}async function ld(a){const s=String(a||"").trim();if(!s)throw new Error("session_id is required");if(ff(s)){const l=`session_memory_${s}`;if(ff(l))return l}return`session_memory_sha_${(await wg(s)).slice(0,32)}`}const Fa=["bug","feature","improvement","task"];function El(a){return String(a||"").trim().toLowerCase()}function ch(a){return Fa.includes(El(a))}function uh(a){const s=El(a);return ch(s)?s:"task"}function dh(a){return a.toUpperCase()}function mh(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function fh(a){return ch(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Fa.join(" / ")})`}function hh(a){const s=String(a||"").trim();return s.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||s}function fa(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Hu(a=new Date){const s=p=>String(p).padStart(2,"0"),r=-a.getTimezoneOffset(),l=r>=0?"+":"-",c=Math.abs(r),f=s(Math.floor(c/60)),d=s(c%60);return`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())} ${l}${f}${d}`}function jg(a){try{return JSON.parse(a)}catch{return null}}function hf(a,s){return a.scrollHeight-a.scrollTop-a.clientHeight<=s}function Cu(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 Os(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,f=Math.floor(l/60),d=f%24,p=Math.floor(f/24);return p>0?`${p}d ${d}h`:f>0?`${f}h ${c}m`:l>0?`${l}m ${r}s`:`${s}s`}async function Vu(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(f=>f.toString(16).padStart(2,"0")).join("")}function Cl(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 kg(a,s){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&s==="runs"?"completed,promoted":""}function vl(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:{},f=r.executor&&typeof r.executor=="object"?r.executor:{},d=String(c.last_message||"").trim(),p=String(r.target_model||f.model||"").trim(),_=String(r.target_reasoning_effort||f.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:f.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:Sg(d)}}const $u=1200;function Sg(a){const s=String(a||"");return s?s.length<=$u?s:`${s.slice(0,$u)}
47
- … [#TRUNCATION: ${$u} of ${s.length} chars; the full last_message is in the run directory]`:null}function Ng(a){const s=String(a||""),r=s.split(/\r?\n/).filter(f=>String(f||"").trim().length>0),l=[];let c=0;for(let f=0;f<r.length;f+=1){const d=String(r[f]||"").trim(),p=jg(d);if(!p||typeof p!="object"){c+=1,l.push({idx:f,type:"raw",payload:null,raw:d});continue}const _=String(p.type||p.event||"event");l.push({idx:f,type:_,payload:p,raw:d})}return{total:r.length,bad:c,events:l,raw:s}}function Cg(a){if(!a)return null;let s=0,r=0,l=0,c=0,f=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"&&(f+=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:f}}function Tl(a,s=Date.now()){const r=Cu(a==null?void 0:a.created_at),l=Cu(a==null?void 0:a.started_at),c=Cu(a==null?void 0:a.finished_at),f=String((a==null?void 0:a.status)||"").trim().toLowerCase(),d=c??(f==="running"?s:null),p=c!=null,_=r!=null&&l!=null?Math.max(0,l-r):null,y=l!=null&&d!=null?Math.max(0,d-l):null,b=r!=null&&d!=null?Math.max(0,d-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 $g(a,s){const r=String(s.package_name).trim()||"{Package}",l=hh(String(s.title||"").trim()||"{Title}"),c=String(s.summary||"").trim(),f=uh(s.task_type),d=`# {ID}-${r}: [${dh(f)}] ${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 E=String(_[I]||"");if(E.trim().startsWith("# ")){_[I]=d,y=!0;break}if(E.trim())break}y||(_.unshift("",d),_.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: ${f}`.trim();let C=!1;for(let I=0;I<Math.min(_.length,60);I+=1)if(String(_[I]||"").trim().toLowerCase().startsWith("> type:")){_[I]=N,C=!0;break}if(!C){let I=-1;for(let E=0;E<Math.min(_.length,60);E+=1)if(String(_[E]||"").trim().toLowerCase().startsWith("> created:")){I=E;break}if(I>=0){const E=I+1;E<_.length&&!String(_[E]||"").trim()?_.splice(E,0,N):_.splice(E,0,N,"")}else{const E=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(E,0,N,"")}}if(c){for(let I=0;I<_.length;I+=1)if(String(_[I]||"").trim().toLowerCase()==="## summary"){let E=I+1;for(;E<_.length&&!String(_[E]||"").trim();)E+=1;(E<_.length?String(_[E]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?_[E]=c:_.splice(I+1,0,c,"");break}}return p=_.join(`
48
- `),p.endsWith(`
49
- `)||(p+=`
50
- `),p}function Pa(a){return String(a||"").split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function Eg(a){const s=String(a.package_name||"").trim()||"{Package}",r=hh(String(a.title||"").trim()||"{Title}"),l=uh(a.task_type),c=String(a.created_at||"").trim()||Hu(),f=String(a.diagram||"").trim(),d=String(a.context||"").trim(),p=[];return p.push(`# {ID}-${s}: [${dh(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(f||`ASCII diagram of the system change.
51
- Show inputs/outputs and where code lives.`),p.push("```"),p.push(""),p.push("## Context"),p.push(d||"(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 Tg(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()),f=c.findIndex(_=>_.trim()==="## related");if(f<0)return`${String(a||"").trimEnd()}
53
-
54
- ## Related
55
- - Attachments:
56
- ${r.map(y=>` - ${y}`).join(`
57
- `)}
58
- `;let d=-1;for(let _=f+1;_<l.length;_+=1){const y=c[_].trim();if(y.startsWith("## ")||y.startsWith("---"))break;if(y.startsWith("- attachments:")){d=_;break}}const p=["- Attachments:",...r.map(_=>` - ${_}`)];if(d>=0){let _=d+1;for(;_<l.length&&/^\s+-\s/.test(l[_]);)_+=1;l.splice(_,0,...r.map(y=>` - ${y}`))}else{let _=f+1;for(let y=f+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 Ag(a,s){const r=Jf(a);if(!r.ok)return null;const l=r.payload.phases.map(d=>d.id),c=new Map;for(const d of s)c.set(`${d.section}\0${d.item}\0${d.phase}`,d.op);const f=[];for(const d of r.payload.sections)for(const p of d.items){const _=[];for(const y of l){const b=p.cells[y];if(!b)continue;const x=c.get(`${d.id}\0${p.id}\0${y}`);(x?x==="grant":!!b.assigned)&&_.push(y)}_.length&&(_.length===l.length?f.push({name:p.id}):f.push({name:p.id,phases:_}))}return f}function Rg(a){var $,Z;const{gateway:s,entity_name:r}=a,[l,c]=h.useState(null),[f,d]=h.useState(""),[p,_]=h.useState(!1),[y,b]=h.useState([]),[x,N]=h.useState(!1),[C,I]=h.useState(""),[E,P]=h.useState(""),U=h.useCallback(async()=>{_(!0),d("");try{c(await s.entity_skills(r))}catch(oe){c(null),d(String((oe==null?void 0:oe.message)||oe))}finally{_(!1)}},[s,r]);h.useEffect(()=>{b([]),P(""),I(""),U()},[U]);async function D(){if(!(l!=null&&l.matrix))return;const oe=Ag(l.matrix,y);if(oe===null){I("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}N(!0),I("");try{const le=await s.put_entity_skills(r,oe);c(le),b([]),P("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>P(""),5e3)}catch(le){I(String((le==null?void 0:le.message)||le))}finally{N(!1)}}const F=Array.isArray(($=l==null?void 0:l.selection)==null?void 0:$.warnings)?l.selection.warnings.map(String):[],Q=Array.isArray((Z=l==null?void 0:l.resolved)==null?void 0:Z.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 U(),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"})]})]}),f?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",f]}):null,F.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:F.join(" · ")}):null,Q.length?e.jsx("div",{className:"entity_skills_resolved",children:Q.map(oe=>{const le=String((oe==null?void 0:oe.name)||""),pe=!!(oe!=null&&oe.active),Ae=!!(oe!=null&&oe.blocked),Me=!!(oe!=null&&oe.requires_review),ve=oe==null?void 0:oe.requires_unmet,ce=Array.isArray(ve)?ve.map(String):ve&&typeof ve=="object"?Object.entries(ve).map(([X,M])=>`${X}: ${String(M)}`):[],q=pe?"ok":Ae?"danger":ce.length||Me?"warn":"muted",L=pe?"active":Ae?"blocked":ce.length?"requires unmet":Me?"requires review":"inactive",W=[...Array.isArray(oe==null?void 0:oe.reasons)?oe.reasons.map(String):[],...ce].join("; ");return e.jsxs("span",{className:`chip mono ${q}`,title:W||void 0,children:[le," · ",L]},le)})}):null,e.jsx(s_,{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,C?e.jsx("span",{className:"page_error",style:{margin:0},children:C}):null,E?e.jsx("span",{className:"chip mono ok",children:E}):null]})]})}function Lg(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 f=String(r.status||"").toLowerCase();f==="queued"||f==="running"?c.active+=1:f==="promoted"?c.promoted+=1:f==="completed"?c.completed+=1:f==="failed"?c.failed+=1:f==="awaiting_qa"&&(c.awaiting_qa+=1);const d=Tl(r);d.run_ms!=null&&(c.total_run_ms+=d.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 Mg(a){const{gateway:s,gateway_connected:r}=a,l=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[c,f]=h.useState(null),[d,p]=h.useState([]),[_,y]=h.useState([]),[b,x]=h.useState(""),[N,C]=h.useState(null),[I,E]=h.useState(!1),[P,U]=h.useState(""),[D,F]=h.useState(!1),[Q,$]=h.useState(""),[Z,oe]=h.useState(null),le=h.useRef(0);async function pe(){if(!r||I)return;const j=++le.current;E(!0),U("");try{const[R,ee,_e]=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(j!==le.current)return;f(R),p([...Array.isArray(ee==null?void 0:ee.requests)?ee.requests:[],...Array.isArray(_e==null?void 0:_e.requests)?_e.requests:[]])}catch(R){j===le.current&&U(String((R==null?void 0:R.message)||R||"Failed to load agents"))}finally{le.current,E(!1)}try{const R=await s.list_entities();if(j!==le.current)return;y(Array.isArray(R==null?void 0:R.entities)?R.entities:[]),x("")}catch(R){if(j!==le.current)return;y([]),x(`#FALLBACK entity registry unavailable: ${String((R==null?void 0:R.message)||R)}`)}try{const R=await s.admin_executors();if(j!==le.current)return;const ee=Array.isArray(R)?R:Array.isArray(R==null?void 0:R.executors)?R.executors:[];C(ee)}catch{j===le.current&&C(R=>R===null?null:R)}try{const R=await s.admin_runtime_config();j===le.current&&F((R==null?void 0:R.writable)===!0)}catch{j===le.current&&F(!1)}}async function Ae(){le.current+=1;try{const j=await s.list_entities();y(Array.isArray(j==null?void 0:j.entities)?j.entities:[]),x("")}catch(j){x(`#FALLBACK entity registry unavailable: ${String((j==null?void 0:j.message)||j)}`)}}async function Me(){le.current+=1;try{const j=await s.admin_executors(),R=Array.isArray(j)?j:Array.isArray(j==null?void 0:j.executors)?j.executors:[];C(R)}catch{}try{f(await s.backlog_exec_config())}catch{}}async function ve(j){if(Q)return;const R=`executor:${j}`;$(R),oe(null);try{await s.admin_runtime_config_update({executor:j}),await Me()}catch(ee){oe({key:R,text:String((ee==null?void 0:ee.message)||ee||"Executor change refused")})}finally{$("")}}const[ce,q]=h.useState(null);async function L(j,R){if(Q)return;const ee=String(j.slug||j.name||"").trim();if(!ee)return;const _e=`entity:${ee}`;$(_e),oe(null);try{await s.entity_state(ee,{state:R,reason:"by the operator via Continuum (Agents & Entities)"}),await Ae()}catch(he){oe({key:_e,text:String((he==null?void 0:he.message)||he||"State change refused")})}finally{$("")}}h.useEffect(()=>{pe()},[r]);const W=h.useMemo(()=>Lg(d),[d]),X=!!(c!=null&&c.runner_alive),M=String((c==null?void 0:c.executor)||"").trim(),ue=!M||M==="none",V=ue?"No execution agent":M;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."}),P?e.jsx("span",{className:"page_error mono",children:P}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${I?"is_loading":""}`,onClick:()=>void pe(),disabled:!r||I,title:"Refresh","aria-label":"Refresh",children:e.jsx(at,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[N!==null&&N.length?N.map(j=>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(at,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:j.display||j.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",j.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${j.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:j.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(j.models)&&j.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",j.models.slice(0,4).join(", "),j.models.length>4?` +${j.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:j.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:!!Q||j.available===!1,title:j.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":Q&&Q!==`executor:${j.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void ve(j.id),children:Q===`executor:${j.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"})}),(Z==null?void 0:Z.key)===`executor:${j.id}`?e.jsx("div",{className:"detail_warn",children:Z.text}):null]},j.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(at,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:V}),e.jsx("div",{className:"entity_card_sub",children:ue?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${X?"ok":ue?"warn":"danger"}`,style:{marginLeft:"auto"},children:X?"available":ue?"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(at,{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 j;return(j=a.on_open_assistant)==null?void 0:j.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(j=>{var O,je,te,ke,Ce,We;if(j.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(at,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:j.name||j.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:j.entity_id||j.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:j.error})]},j.entity_id||j.slug||j.name);const R=String(((O=j.state)==null?void 0:O.state)||"unknown").toLowerCase(),ee=R==="awake"?"ok":R==="asleep"?"info":R==="paused"?"warn":"muted",he=String(j.liveness||((je=j.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(at,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:j.name||j.slug}),e.jsx("div",{className:"entity_card_sub mono",children:j.entity_id})]}),he?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${R}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${ee}`,style:{marginLeft:"auto"},children:R})]}),e.jsxs("div",{className:"agent_facts",children:[j.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(j.created_at).toLocaleDateString()]}):null,(te=j.state)!=null&&te.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",j.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(ke=j.files)!=null&&ke.spark?"✓":"—"," · memory ",(Ce=j.files)!=null&&Ce.memory?"✓":"—"," · book ",(We=j.files)!=null&&We.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!he&&(R==="asleep"||R==="paused")?e.jsx("button",{className:"btn",disabled:!!Q,title:Q&&Q!==`entity:${j.slug||j.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void L(j,"awake"),children:Q===`entity:${j.slug||j.name}`?"Waking…":"Wake"}):null,!he&&R==="awake"?e.jsx("button",{className:"btn",disabled:!!Q,title:Q&&Q!==`entity:${j.slug||j.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void L(j,"asleep"),children:Q===`entity:${j.slug||j.name}`?"Sending…":"Sleep"}):null,he?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(me=>me===(j.name||j.slug)?null:j.name||j.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:ce===(j.name||j.slug)?"Hide skills":"Skills"})]}),(Z==null?void 0:Z.key)===`entity:${j.slug||j.name}`?e.jsx("div",{className:"detail_warn",children:Z.text}):null]},j.entity_id||j.slug)})}):null,ce?e.jsx(Rg,{gateway:s,entity_name:ce,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:[W.length," agent",W.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:W.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:W.map(j=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:j.agent}),e.jsx("td",{children:j.runs}),e.jsx("td",{className:"col_aux",children:j.active||""}),e.jsx("td",{className:"col_aux",children:j.promoted||""}),e.jsx("td",{className:"col_aux",children:j.completed||""}),e.jsx("td",{className:"col_aux",children:j.awaiting_qa||""}),e.jsx("td",{className:j.failed?"page_error":"",children:j.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:j.timed_runs?Os(j.total_run_ms/j.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:j.last_active?new Date(j.last_active).toLocaleString():""})]},j.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Ds(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 pf(a,s){const r=String(s||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function zg(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function Pg(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 Ig=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,Og=6;function Dg(a){const s=[];for(const r of String(a||"").matchAll(Ig)){const l=r[1];if(Ds(l)&&(s.includes(l)||s.push(l),s.length>=Og))break}return s}function ph(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 f=Math.max(0,(s-c)/36e5);return{label:f<1?`claimed ${Math.max(1,Math.round(f*60))}m`:f<48?`claimed ${Math.round(f)}h`:`claimed ${Math.round(f/24)}d`,stale:f>=r}}const Al=["P0","P1","P2","P3"],_h={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},gh=/^>\s*priority:\s*(p[0-3])\b/i,vh=/^>\s*labels:\s*(.+)$/i;function od(a){return String(a||"").split(",").map(s=>s.trim().toLowerCase().replace(/\s+/g,"-")).filter(s=>!!s&&s.length<=40).slice(0,12)}function Eu(a,s){const r=[];let l=!1;for(const c of a){const f=c.trim();if(/^#{1,6}\s/.test(f)){l=s.test(f);continue}l&&r.push(c)}return r}const Fg=["one paragraph describing","criterion 1 (clear, testable)"];function _f(a){const s=a.trim().toLowerCase();return s?Fg.some(r=>s.startsWith(r)):!0}function bi(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=gh.exec(y);b&&!r&&(r=b[1].toUpperCase());const x=vh.exec(y);x&&!l.length&&(l=od(x[1]))}const c=[];for(const _ of Eu(s,/acceptance criteria/i)){const y=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(_);if(!y)continue;const b=y[2].trim();_f(b)||c.push({text:b,checked:y[1].toLowerCase()==="x"})}const f=[];for(const _ of Eu(s,/testing/i))for(const y of _.matchAll(/`([^`]+)`/g)){const b=y[1].trim();!b||b==="..."||b.toLowerCase()==="n/a"||f.push(b)}const d=Eu(s,/^#{1,6}\s*summary\b/i).map(_=>_.trim()).filter(Boolean),p=d.length>0&&!d.every(_f);return{priority:r,labels:l,acceptance:c,test_commands:f,has_summary:p}}function cd(a,s){const r=String(a.task_type||"").trim().toLowerCase(),l=[{id:"type",label:`Work type is set (${Fa.join(" / ")})`,ok:Fa.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}: "${gf(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}: \`${gf(s.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:l.every(c=>c.ok),checks:l}}function gf(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Gu(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 f=(Array.isArray(l.checks)?l.checks:Array.isArray(l.members)?l.members.flatMap(d=>(Array.isArray(d==null?void 0:d.checks)?d.checks:[]).map(p=>({...p,label:d!=null&&d.relpath?`${d.relpath}: ${String((p==null?void 0:p.label)||"")}`:p==null?void 0:p.label}))):[]).map(d=>({id:String((d==null?void 0:d.id)||""),label:String((d==null?void 0:d.label)||""),ok:(d==null?void 0:d.ok)===!0,evidence:d!=null&&d.evidence?String(d.evidence):void 0}));return f.length?{ok:f.every(d=>d.ok),checks:f}:null}function Ku(a,s){const l=[...String(a||"").split(/\r?\n/)];function c(f,d){const p=[];for(let y=0;y<Math.min(l.length,60);y+=1){const b=l[y].trim();if(/^##+\s/.test(b))break;f.test(b)&&p.push(y)}if(p.length){for(let y=p.length-1;y>=1;y-=1)l.splice(p[y],1);d?l[p[0]]=d:l.splice(p[0],1);return}if(!d)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(d);return}}l.splice(_+1,0,d)}return c(gh,s.priority?`> Priority: ${s.priority}`:null),c(vh,s.labels.length?`> Labels: ${s.labels.join(", ")}`:null),l.join(`
60
- `)}const vf=[{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 Qu(a){const s=String(a||"").trim().toUpperCase();return Al.includes(s)?s:null}function Ju(a){return a.priority!==void 0||a.labels!==void 0}const qg="decision-gate";function Bg(a){return Array.isArray(a)&&a.some(s=>String(s||"").trim().toLowerCase()===qg)}function yh(a,s){return Bg(a.labels!==void 0?a.labels:s==null?void 0:s.labels)}function xh(a){return a.priority!==void 0||a.labels!==void 0}function Yu(a,s){return a.priority!==void 0?a.priority:(s==null?void 0:s.priority)??null}function Xu(a,s){return a.labels!==void 0?a.labels:(s==null?void 0:s.labels)??[]}const Ug=new Set(["queued","running"]);function Wg(a){const s=String(a||"").split("/").filter(Boolean);return s.length?s[s.length-1]:""}const Hg=/^batch\((\d+)\)$/i;function yf(a){const s=Hg.exec(String(a||"").trim());return s?Number(s[1]):null}function Vg(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 C=String(b.backlog_filename||"").trim()||Wg(String(b.backlog_relpath||"")),I=yf(C),E=I!==null?"":C;return E&&N&&l.add(E),{key:E&&N?`file:${E}`:`req:${b.request_id}`,column:x,title:I!==null?`Batch execution (${I} items)`:E||`Execution ${b.request_id.slice(0,8)}…`,filename:E||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();Ug.has(x)?r.push(c(b,"in_progress",!0)):x==="awaiting_qa"&&r.push(c(b,"in_review",!0))}const f=[...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)}),d=new Map;let p=0,_=0;for(const b of f){const x=String(b.status||"").trim().toLowerCase();if(x==="failed"){const N=String(b.backlog_filename||"").trim();N&&yf(N)===null&&d.set(N,(d.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:d.get(x)||void 0,priority:Ju(b)?Qu(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:Ju(b)?Qu(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 Gg=200;function Kg(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 f=new Set,d=new Set;for(const x of a){if(!x.filename||!x.package)continue;const N=pf(x.package,x.filename);N&&d.add(N)}const p=a.map(x=>{if(x.column!=="ready"||x.kind!=="planned"||!x.filename||!x.package)return x;const N=pf(x.package,x.filename);if(!N)return x;const C=r.get(N);return!C||!C.owner?x:(f.add(N),{...x,column:"in_progress",work_id:N,claim_owner:C.owner,claim_started_at:C.started_at})}),_=new Map;p.forEach((x,N)=>{x.filename&&_.set(x.filename,N)});for(const[x,N]of c){const C=N.card?_.get(zg(N.card)):void 0;if(d.has(x)||C!==void 0){if(C!==void 0){const P=p[C],U={...P,work_id:P.work_id||x,card_path:P.card_path||N.card},D=r.get(x);D!=null&&D.owner&&(f.add(x),U.claim_owner||(U.claim_owner=D.owner,U.claim_started_at=D.started_at)),p[C]=U}continue}if(N.status==="deprecated")continue;const I=r.get(x),E=N.status==="completed"?"done":N.status==="planned"?I!=null&&I.owner?"in_progress":"ready":"triage";I!=null&&I.owner&&f.add(x),p.push({key:`work:${x}`,column:E,title:N.title||x,work_id:x,package:(b=Ds(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(f.has(x)||!N.owner)continue;const C=Ds(x);p.push({key:`claim:${x}`,column:"in_progress",title:typeof N.task=="string"&&N.task?N.task:x,work_id:C?x:void 0,package:C==null?void 0:C.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,Gg)){if(y.has(x.item))continue;const N=Ds(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 xi(a){const s=String((a==null?void 0:a.message)??a??"");return/backlog folder not available|backlog browsing not configured/i.test(s)}function xf(a){return String((a==null?void 0:a.message)??a??"").trim().replace(/^[a-z_]+ failed: /,"")}function ud(a,s,r){const[l,c]=h.useState({status:null,legacy:!1});return h.useEffect(()=>{if(!s)return;let f=!1;return(async()=>{try{const d=await a.backlog_status();f||c({status:d,legacy:!1})}catch(d){f||c({status:null,legacy:Number(d==null?void 0:d.status)===404})}})(),()=>{f=!0}},[a,s,r]),l}function Qg(){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 dd(a){const{gateway:s,surface:r,status:l,legacy:c,on_changed:f}=a,[d,p]=h.useState(!1),[_,y]=h.useState(""),[b,x]=h.useState(!1),[N,C]=h.useState(""),[I,E]=h.useState((l==null?void 0:l.writable)??null);h.useEffect(()=>{if((l==null?void 0:l.writable)!==void 0){E(!!l.writable);return}if(!c)return;let F=!1;return s.admin_runtime_config().then(Q=>{F||E((Q==null?void 0:Q.writable)===!0)}).catch(()=>{F||E(!1)}),()=>{F=!0}},[s,l==null?void 0:l.writable,c]);async function P(F){if(!b){x(!0),C("");try{await s.admin_runtime_config_update({triage_repo_root:F}),p(!1),f==null||f()}catch(Q){C(xf(Q))}finally{x(!1)}}}const U=String((l==null?void 0:l.reason)||"").trim()||(a.error?xf(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,U||"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 P(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,d?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:F=>{F.preventDefault(),_.trim()&&P(_.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(Qg,{})}):null]})]})}function Jg(a){const{status:s,on_create:r}=a,[l,c]=h.useState(!1),f=String((s==null?void 0:s.path)||"").trim(),d=f?`${f.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",p=f?`${f.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:[f?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:f}),e.jsx("button",{className:"btn",onClick:()=>{dn(f),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:d})," (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 Yg(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function bh(a){const{gateway:s,can_use_gateway:r,target:l,on_close:c,on_mutated:f,on_open_executions:d}=a,p=!!l,[_,y]=h.useState("spec"),[b,x]=h.useState(""),[N,C]=h.useState(""),[I,E]=h.useState(null),[P,U]=h.useState(!1),[D,F]=h.useState(""),[Q,$]=h.useState(!1),[Z,oe]=h.useState(""),[le,pe]=h.useState(!1),[Ae,Me]=h.useState(""),[ve,ce]=h.useState(""),[q,L]=h.useState(!1),[W,X]=h.useState([]),[M,ue]=h.useState(!1),[V,j]=h.useState(null),[R,ee]=h.useState(null),[_e,he]=h.useState(""),[O,je]=h.useState(!1),[te,ke]=h.useState(""),[Ce,We]=h.useState({}),me=h.useMemo(()=>bi(b),[b]);h.useEffect(()=>{!p||!l||(y(l.initial_tab||"spec"),$(!1),F(""),ke(""),he(""),We({}),qe(!1),j(null),ee(null),E(null),Re(l),Pe(l))},[p,l==null?void 0:l.filename,l==null?void 0:l.kind,l==null?void 0:l.request_id]);async function Re(fe){if(!fe.filename){x(""),C("");return}U(!0);try{let be=null,G=null;for(const Xe of Yg(fe))try{const J=await s.backlog_content(Xe,fe.filename);be={kind:Xe,text:String((J==null?void 0:J.content)||"")};break}catch(J){G=J}if(!be)throw G||new Error("Spec not found in any backlog kind");E(be.kind),x(be.text),C(await Vu(be.text));const Se=bi(be.text);Me(Se.priority||""),ce(Se.labels.join(", "))}catch(be){F(String((be==null?void 0:be.message)||be||"Failed to load the spec"))}finally{U(!1)}}async function Pe(fe){ue(!0);try{const[be,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})]),Xe=[...Array.isArray(be==null?void 0:be.requests)?be.requests:[],...Array.isArray(G==null?void 0:G.requests)?G.requests:[]].filter(A=>fe.filename&&String(A.backlog_filename||"").trim()===fe.filename||A.request_id===fe.request_id);Xe.sort((A,Y)=>String(Y.created_at||"").localeCompare(String(A.created_at||""))),X(Xe);const J=Xe.find(A=>String(A.status||"").toLowerCase()==="awaiting_qa")||null;if(j(J),J)try{const A=await s.backlog_exec_request(J.request_id);ee((A==null?void 0:A.payload)??null)}catch{ee(null)}}catch{X([])}finally{ue(!1)}}async function se(){if(!l||le)return;const fe=I||l.kind;if(fe){pe(!0),F("");try{const be=await s.backlog_update({kind:fe,filename:l.filename,content:Z,expected_sha256:N||null}),G=Z.endsWith(`
61
- `)?Z:`${Z}
62
- `;x(G),C(String((be==null?void 0:be.sha256)||"")),$(!1),await f()}catch(be){F(String((be==null?void 0:be.message)||be||"Save failed"))}finally{pe(!1)}}}async function ye(){if(!l||q)return;const fe=I||l.kind;if(fe){L(!0),F("");try{const be=Ku(b,{priority:Ae||null,labels:od(ve)}),G=await s.backlog_update({kind:fe,filename:l.filename,content:be,expected_sha256:N||null});x(be.endsWith(`
63
- `)?be:`${be}
64
- `),C(String((G==null?void 0:G.sha256)||"")),await f()}catch(be){F(String((be==null?void 0:be.message)||be||"Metadata save failed"))}finally{L(!1)}}}const[ge,qe]=h.useState(!1);async function Ye(fe){if(!(!V||O)){if(fe==="feedback"&&!_e.trim()){ke("Feedback is required.");return}je(!0),ke("");try{fe==="feedback"?await s.backlog_exec_feedback({request_id:V.request_id,feedback:_e}):fe==="promote"?await s.backlog_exec_promote({request_id:V.request_id,redeploy:!0}):await s.backlog_exec_deploy_uat({request_id:V.request_id}),he(""),qe(!1),l&&await Pe(l),await f()}catch(be){ke(String((be==null?void 0:be.message)||be||"QA action failed"));try{const G=await s.backlog_exec_request(V.request_id);ee((G==null?void 0:G.payload)??null)}catch{}}finally{je(!1)}}}if(!p||!l)return null;const ie=me.acceptance.filter((fe,be)=>!Ce[`${be}:${fe.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:fe=>{fe.target===fe.currentTarget&&c()},children:e.jsxs("div",{className:"drawer_panel work_drawer",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:()=>dn(`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 ",W.length?`(${W.length})`:""]}),e.jsxs("button",{className:`tab ${_==="review"?"active":""}`,onClick:()=>y("review"),children:["Review",V?" ●":""]})]}),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:Ae,onChange:fe=>Me(fe.target.value),disabled:q,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),Al.map(fe=>e.jsx("option",{value:fe,children:_h[fe]},fe))]}),e.jsx("input",{value:ve,onChange:fe=>ce(fe.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:q}),e.jsx("button",{className:"btn",onClick:()=>void ye(),disabled:q||!r||P,children:q?"Saving…":"Save metadata"}),Q?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>$(!1),disabled:le,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void se(),disabled:le,children:le?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{oe(b),$(!0)},disabled:P,children:"Edit spec"})]}):null,P?e.jsx("div",{className:"mono muted",children:"Loading…"}):Q?e.jsx("textarea",{className:"mono work_spec_editor",value:Z,onChange:fe=>oe(fe.target.value),rows:24}):b?e.jsxs(e.Fragment,{children:[e.jsx(rs,{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:[M?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!M&&!W.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,W.map(fe=>{const be=String(fe.status||"").toLowerCase(),G=Tl(fe);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Cl(be)}`,children:be}),e.jsx("span",{className:"mono muted",children:fa(fe.request_id,18)}),e.jsx("span",{className:"mono muted",children:fe.created_at?new Date(fe.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:G.run_ms!=null?`ran ${Os(G.run_ms)}`:""}),fe.target_agent?e.jsx("span",{className:"chip mono muted",children:fe.target_agent}):null,be==="running"||be==="queued"||be==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>d(fe.request_id),children:be==="awaiting_qa"?"View logs":"Follow live"}):null]},fe.request_id)})]}):null,_==="review"?V?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."}),me.acceptance.length?e.jsx("div",{className:"work_dod_list",children:me.acceptance.map((fe,be)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Ce[`${be}:${fe.text}`],onChange:G=>We(Se=>({...Se,[`${be}:${fe.text}`]:G.target.checked}))}),e.jsx("span",{children:fe.text})]},`dod:${be}:${fe.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const fe=String((R==null?void 0:R.execution_mode)||"uat").toLowerCase(),be=String((R==null?void 0:R.candidate_relpath)||"").trim(),G=R==null?void 0:R.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: ",fe,be?` • candidate: ${be}`:""]}),e.jsx("button",{className:"btn",onClick:()=>d(V.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]})})(),me.acceptance.length&&ie>0?e.jsxs("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[ie," acceptance criteri",ie===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:_e,onChange:fe=>he(fe.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:O}),te?e.jsx("div",{className:"mono board_error",children:te}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ye("deploy_uat"),disabled:O,children:"Restart UAT"}),ge?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void Ye("promote"),disabled:O,children:["Confirm: promote to prod",ie>0?` (${ie} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>qe(!1),disabled:O,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>qe(!0),disabled:O,children:me.acceptance.length&&ie>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void Ye("feedback"),disabled:O,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function Nr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Xg(a){const{gateway:s,can_use_gateway:r,is_compact_layout:l,maint_provider:c,maint_model:f,maint_reasoning:d,advisor_agent:p,focus_kind:_,focus_type:y}=a,[b,x]=h.useState(!1),[N,C]=h.useState([]),[I,E]=h.useState(""),[P,U]=h.useState(!1),[D,F]=h.useState(""),[Q,$]=h.useState(!1),[Z,oe]=h.useState([]),le=h.useRef(null),pe=h.useRef(null),Ae=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[Me,ve]=h.useState(""),[ce,q]=h.useState("");h.useEffect(()=>{(async()=>{try{const R=await ld(Ae);ve(R)}catch{ve("")}})()},[Ae]);const L=h.useMemo(()=>{if(!r)return{};const R=String(Me||"").trim(),ee=Ae;return{tts:async _e=>{if(!R)throw new Error("Voice store not available (missing run_id).");const he=await s.voice_tts(R,{text:_e,request_id:Nr()}),O=he==null?void 0:he.audio_artifact,je=O&&typeof O=="object"&&!Array.isArray(O)?String(O.$artifact||"").trim():"";if(!je)throw new Error("TTS failed: missing audio artifact");return await(await s.download_run_artifact_content(R,je)).arrayBuffer()},transcribe:async(_e,he)=>{if(!R)throw new Error("Voice input unavailable (missing run_id).");const O=String(he||_e.type||"").toLowerCase(),je=O.includes("mp4")?"m4a":O.includes("ogg")?"ogg":O.includes("wav")?"wav":"webm",te=new File([_e],`recording.${je}`,{type:O||"audio/webm"}),ke=await s.attachments_upload(ee,te,{filename:te.name,content_type:te.type}),Ce=await s.audio_transcribe(R,{audio_artifact:ke,request_id:Nr()});return String((Ce==null?void 0:Ce.text)||"").trim()}}},[r,s,Me,Ae]),W=Xf({...L,on_error:q,on_transcript:R=>{const ee=String(R||"").trim();ee&&(E(_e=>{const he=String(_e||"");return he.trim()?`${he.trimEnd()}
65
- ${ee}`:ee}),window.setTimeout(()=>{var _e;return(_e=le.current)==null?void 0:_e.focus()},0))}});h.useEffect(()=>{if(!b)return;const R=ee=>{ee.key==="Escape"&&(j(),x(!1))};return window.addEventListener("keydown",R),setTimeout(()=>{var ee;return(ee=le.current)==null?void 0:ee.focus()},0),()=>window.removeEventListener("keydown",R)},[b]);async function X(){if(P||!r)return;if(W.voice_ptt_busy){q("Wait for transcription to finish.");return}F(""),q("");const R=I.trim();if(!R)return;const ee={id:Nr(),role:"user",content:R,ts:new Date().toISOString()},_e=[...N,ee];C(_e),E(""),U(!0);try{const he=await s.backlog_advisor({messages:_e.map(ke=>({role:ke.role,content:ke.content})),provider:c||null,model:f||null,thinking:d||null,agent:p||null,include_trace:Q,focus_kind:_,focus_type:y}),O=Q&&Array.isArray(he==null?void 0:he.tool_trace)?he.tool_trace:[],je=String((he==null?void 0:he.run_id)||"").trim(),te=String((he==null?void 0:he.reply)||"").trim();if(Q&&O.length){const ke={id:Nr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:je||null,tool_trace:O},null,2)};C(Ce=>[...Ce,ke])}te&&C(ke=>[...ke,{id:Nr(),role:"assistant",content:te,ts:new Date().toISOString()}])}catch(he){F(String((he==null?void 0:he.message)||he||"Backlog advisor failed"))}finally{U(!1)}}async function M(R){var te;const ee=Array.from(R||[]);if(!ee.length)return;const _e=[],he=[],O=6,je=2e4;for(const ke of ee.slice(0,O)){const Ce=String((ke==null?void 0:ke.name)||"").trim()||"attachment";he.push(Ce);try{const We=await ke.text(),me=We.length>je?`${We.slice(0,je)}
66
- …(truncated)…
67
- `:We;_e.push(`[attached file: ${Ce}]
68
-
69
- \`\`\`
70
- ${me}
71
- \`\`\``)}catch{_e.push(`[attached file: ${Ce}] (unreadable in browser)`)}}oe(ke=>[...he,...ke].slice(0,12)),E(ke=>{const Ce=String(ke||"").trim(),We=_e.join(`
72
-
73
- `);return Ce?`${Ce}
74
-
75
- ${We}`:We});try{(te=le.current)==null||te.focus()}catch{}}function ue(R){const ee=String(R.id||R.ts||"").trim(),_e=String(R.content||"").trim();!ee||!_e||(q(""),W.toggle_tts(ee,_e))}function V(R){const ee=String(R.id||R.ts||"").trim(),_e=W.tts_playback;return!ee||!_e.key||_e.key!==ee?"idle":_e.status}function j(){W.stop_voice_ptt_recording(),W.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${b?"open":""}`,onClick:()=>{x(R=>{const ee=!R;return ee||j(),ee})},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:R=>{R.target===R.currentTarget&&(j(),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)"," / ",f||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${Q?"primary":""}`,onClick:()=>$(R=>!R),disabled:P,title:Q?"Hide tool execution":"Show tool execution","aria-label":Q?"Hide tool execution":"Show tool execution",children:[e.jsx(at,{name:"terminal",size:16}),l?null:Q?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>C([]),disabled:P||!N.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{j(),x(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(id,{messages:N,className:"drawer_chat_thread",messageProps:W.tts_supported&&r&&Me.trim()?{onSpeakToggle:ue,getSpeakState:V,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:pe,type:"file",multiple:!0,style:{display:"none"},onChange:R=>{const ee=Array.from(R.currentTarget.files||[]);R.currentTarget.value="",ee.length&&M(ee)}}),e.jsx(ec,{ref:le,value:I,onChange:E,onSubmit:()=>void X(),placeholder:"Message to backlog advisor…",disabled:!r,busy:P||W.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:W.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${W.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!Me.trim()||P||W.voice_ptt_busy||!W.voice_ptt_supported,title:W.voice_ptt_supported?W.voice_ptt_busy?"Transcribing…":W.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:R=>{var ee,_e;if(!(!r||!Me.trim()||P||W.voice_ptt_busy||!W.voice_ptt_supported)){R.preventDefault();try{(_e=(ee=R.currentTarget)==null?void 0:ee.setPointerCapture)==null||_e.call(ee,R.pointerId)}catch{}W.start_voice_ptt_recording()}},onPointerUp:R=>{R.preventDefault(),W.stop_voice_ptt_recording()},onPointerCancel:R=>{R.preventDefault(),W.stop_voice_ptt_recording()},children:[e.jsx(at,{name:W.voice_ptt_recording?"x":"mic",size:16}),l?null:W.voice_ptt_busy?"Transcribing…":W.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var R;return(R=pe.current)==null?void 0:R.click()},disabled:P,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(at,{name:"paperclip",size:16}),l?null:"Attach"]})]})}),Z.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",Z[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,ce?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ce}):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 qa({open:a,title:s,children:r,actions:l,variant:c="default",onClose:f}){if(h.useEffect(()=>{if(!a)return;const p=_=>{_.key==="Escape"&&f()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a,f]),!a)return null;const d=c==="fullscreen";return e.jsx("div",{className:`modal_backdrop${d?" fullscreen":""}`,onMouseDown:p=>{p.target===p.currentTarget&&f()},children:e.jsxs("div",{className:`modal_panel${d?" fullscreen":""}`,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:s}),e.jsx("button",{className:"btn",onClick:f,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),l?e.jsx("div",{className:"modal_footer",children:l}):null]})})}function Zg(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 wh(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(`
76
- `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>dn(l.join(`
77
- `)),children:"Copy setup"})]})]}):null]})}function jh(a){const{value:s,onChange:r,disabled:l,inplace_warning:c,uat_note:f}=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:d=>r(d.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:f})]})}const ev=["minimal","low","medium","high"];function kh(a){const{executors:s,value:r,onChange:l,disabled:c}=a;if(!s||!s.length)return null;const f=s.find(d=>d.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:d=>l(d.target.value),disabled:c,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",f?` (${f.display||f.id})`:""]}),s.map(d=>e.jsxs("option",{value:d.id,disabled:d.available===!1,children:[d.display||d.id,d.available===!1?" (unavailable on the gateway host)":""]},d.id))]})]})}function tv(a){const{exec_cfg:s,model:r,set_model:l,effort:c,set_effort:f,disabled:d}=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:d})]})}),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=>f(p.target.value),disabled:d,children:[e.jsx("option",{value:"",children:"gateway default"}),ev.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 Sh(a){const{open:s,target:r,execute_mode:l,set_execute_mode:c,action_loading:f,action_error:d,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:b,on_close:x}=a,N=a.readiness??null,C=a.show_readiness===!0,[I,E]=Ht.useState(""),[P,U]=Ht.useState(""),[D,F]=Ht.useState(""),Q=(r==null?void 0:r.filename)||"";Ht.useEffect(()=>{E(""),U(""),F("")},[Q]);const $=I.trim()||P||D?{executor:D||void 0,target_model:I.trim()||void 0,target_reasoning_effort:P||void 0}:void 0;return e.jsxs(qa,{open:s,title:"Execute backlog item?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:f,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b($),disabled:f||_||!r||(p==null?void 0:p.can_execute)!==!0,children:f?"Executing…":C&&!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(kh,{executors:a.executors??null,value:D,onChange:F,disabled:f}),e.jsx(tv,{exec_cfg:p,model:I,set_model:E,effort:P,set_effort:U,disabled:f}),C?e.jsx(Zg,{readiness:N,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(jh,{value:l,onChange:c,disabled:f,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(wh,{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,d?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:d}):null]})}function nv(a){const{open:s,batch_selected_items:r,batch_execute_mode:l,set_batch_execute_mode:c,batch_execute_loading:f,batch_execute_error:d,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:b,on_close:x}=a,[N,C]=Ht.useState("");return Ht.useEffect(()=>{s||C("")},[s]),e.jsxs(qa,{open:s,title:"Execute batch (single context)?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:f,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b(N||void 0),disabled:f||_||r.length<2||(p==null?void 0:p.can_execute)!==!0,children:f?"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(kh,{executors:a.executors??null,value:N,onChange:C,disabled:f}),e.jsx(jh,{value:l,onChange:c,disabled:f,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(wh,{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,d?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:d}):null]})}function sv(a){const{open:s,batch_selected_items:r,merge_package:l,set_merge_package:c,merge_task_type:f,set_merge_task_type:d,merge_title:p,set_merge_title:_,merge_summary:y,set_merge_summary:b,merge_loading:x,merge_error:N,on_confirm:C,on_close:I}=a;return e.jsxs(qa,{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:C,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:E=>c(E.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:f,onChange:E=>d(E.target.value),children:Fa.map(E=>e.jsx("option",{value:E,children:E},E))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:p,onChange:E=>_(E.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:E=>b(E.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(E=>e.jsxs("div",{children:["- docs/backlog/planned/",E.filename]},`mergeitem:${E.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 md(a){const s=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,l]=h.useState(s);return h.useEffect(()=>{var d;if(typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia(a),f=()=>l(c.matches);return f(),typeof c.addEventListener=="function"?c.addEventListener("change",f):(d=c.addListener)==null||d.call(c,f),()=>{var p;typeof c.removeEventListener=="function"?c.removeEventListener("change",f):(p=c.removeListener)==null||p.call(c,f)}},[a]),r}function Nh(a,s){const[r,l]=h.useState(null);return h.useEffect(()=>{if(!s){l(null);return}let c=!1;return(async()=>{try{const f=await a.admin_executors(),d=Array.isArray(f)?f:Array.isArray(f==null?void 0:f.executors)?f.executors:[];c||l(d)}catch{c||l(null)}})(),()=>{c=!0}},[s]),r}function fd(a){const{gateway:s,can_use_gateway:r,kind:l,completed_view:c,is_exec_view:f,is_compact_layout:d,set_compact_pane:p,on_status_transfer:_}=a,[y,b]=h.useState(null),[x,N]=h.useState(!1),[C,I]=h.useState(""),[E,P]=h.useState([]),[U,D]=h.useState(!1),[F,Q]=h.useState(""),[$,Z]=h.useState(null),[oe,le]=h.useState(null),[pe,Ae]=h.useState(!1),[Me,ve]=h.useState(""),[ce,q]=h.useState(""),[L,W]=h.useState(!1),[X,M]=h.useState(""),[ue,V]=h.useState("events"),[j,R]=h.useState(""),[ee,_e]=h.useState(!1),[he,O]=h.useState(""),[je,te]=h.useState(!1),[ke,Ce]=h.useState(!0),We=h.useRef(null),me=h.useRef(!0),Re=h.useRef(null),Pe=h.useRef(!1),se=h.useRef(!1),ye=1e6,ge=h.useMemo(()=>ue!=="events"?null:Ng(j),[j,ue]),qe=h.useMemo(()=>Cg(ge),[ge]),Ye=Tl($);function ie(){Z(null),le(null),ve(""),R(""),O(""),te(!1),Re.current=null}async function fe(){if(!r)return null;if(x)return y;I(""),N(!0);try{const Y=await s.backlog_exec_config();return b(Y),Y}catch(Y){const Ne=String((Y==null?void 0:Y.message)||Y||"Failed to load backlog exec config");return I(Ne),b(null),null}finally{N(!1)}}async function be(Y,Ne,ze){if(se.current)return E;se.current=!0,ze!=null&&ze.background||D(!0);const Ke=Y||l;try{const tt=kg(Ke,Ne||c),dt=await s.backlog_exec_requests({status:tt,limit:200}),yt=Array.isArray(dt==null?void 0:dt.requests)?dt.requests:[];Q(""),P(yt);const pt=String(($==null?void 0:$.status)||"").trim().toLowerCase(),Tt=pt==="failed"||pt==="completed"||pt==="promoted";if(Ke==="processing"&&($!=null&&$.request_id)&&!Tt&&!yt.some(qt=>qt.request_id===$.request_id))try{const qt=await s.backlog_exec_request($.request_id),Oe=qt==null?void 0:qt.payload,it=String((Oe==null?void 0:Oe.status)||"").trim().toLowerCase();(it==="failed"||it==="completed"||it==="promoted")&&(_(it),le(Oe),Z(vl(Oe,$.request_id)))}catch{}if($!=null&&$.request_id){const qt=yt.find(Oe=>Oe.request_id===$.request_id)||null;qt&&Z(qt)}return yt}catch(tt){return Q(String((tt==null?void 0:tt.message)||tt||"Failed to load backlog exec requests")),[]}finally{se.current=!1,ze!=null&&ze.background||D(!1)}}async function G(Y){if(r){Z(Y),d&&p("detail"),le(null),ve(""),Ae(!0),M(""),q(""),R(""),O(""),te(!1),Re.current=null;try{const Ne=await s.backlog_exec_request(Y.request_id);le((Ne==null?void 0:Ne.payload)??null)}catch(Ne){ve(String((Ne==null?void 0:Ne.message)||Ne||"Failed to load request"))}finally{Ae(!1)}}}async function Se(Y){if(!r)return;const Ne=String(($==null?void 0:$.request_id)||"").trim();if(!Ne||L)return;const ze=String(ce||"");if(!ze.trim()){M("Feedback is required.");return}M(""),W(!0);try{const Ke=await s.backlog_exec_feedback({request_id:Ne,feedback:ze}),tt=(Ke==null?void 0:Ke.payload)??null;le(tt),tt&&Z(vl(tt,Ne)),q(""),await Y()}catch(Ke){M(String((Ke==null?void 0:Ke.message)||Ke||"Failed to send feedback"))}finally{W(!1)}}async function Xe(Y){if(!r)return;const Ne=String(($==null?void 0:$.request_id)||"").trim();if(Ne&&!L){M(""),W(!0);try{const ze=await s.backlog_exec_promote({request_id:Ne,redeploy:!0}),Ke=(ze==null?void 0:ze.payload)??null;le(Ke),Ke&&Z(vl(Ke,Ne)),q(""),await Y()}catch(ze){M(String((ze==null?void 0:ze.message)||ze||"Failed to promote to prod"));try{const Ke=await s.backlog_exec_request(Ne),tt=(Ke==null?void 0:Ke.payload)??null;le(tt),tt&&Z(vl(tt,Ne))}catch{}}finally{W(!1)}}}async function J(Y){if(!r)return;const Ne=String(($==null?void 0:$.request_id)||"").trim();if(Ne&&!L){M(""),W(!0);try{const ze=await s.backlog_exec_deploy_uat({request_id:Ne}),Ke=(ze==null?void 0:ze.payload)??null;le(Ke),Ke&&Z(vl(Ke,Ne)),await Y()}catch(ze){M(String((ze==null?void 0:ze.message)||ze||"Failed to deploy to UAT"))}finally{W(!1)}}}async function A(Y){if(!r)return;const Ne=String((Y==null?void 0:Y.request_id)||($==null?void 0:$.request_id)||"").trim();if(!Ne)return;const ze=(Y==null?void 0:Y.name)||ue,Ke=typeof(Y==null?void 0:Y.max_bytes)=="number"&&Number.isFinite(Y.max_bytes)?Number(Y.max_bytes):16e4;if(!Pe.current){Pe.current=!0,O(""),_e(!0);try{const tt=`${Ne}::${String(ze)}`,dt=Re.current,yt=dt!==null&&dt.key===tt,pt=await s.backlog_exec_log_tail({request_id:Ne,name:String(ze),max_bytes:Ke,...yt?{after_bytes:dt.offset}:{}}),Tt=typeof(pt==null?void 0:pt.next_offset)=="number"&&Number.isFinite(pt.next_offset),qt=String((pt==null?void 0:pt.content)||"");yt&&Tt&&(pt==null?void 0:pt.reset)!==!0?(qt&&R(Oe=>{let it=Oe+qt;if(it.length>ye){const et=it.length-ye,kt=it.indexOf(`
78
- `,et);it=kt>=0?it.slice(kt+1):it.slice(et),te(!0)}return it}),Re.current={key:tt,offset:Number(pt.next_offset)}):(R(qt),te(!!(pt!=null&&pt.truncated)),Re.current=Tt?{key:tt,offset:Number(pt.next_offset)}:null)}catch(tt){O(String((tt==null?void 0:tt.message)||tt||"Failed to load logs"))}finally{Pe.current=!1,_e(!1)}}}return h.useEffect(()=>{r&&f&&fe()},[f,r]),h.useEffect(()=>{if(!r||!f)return;const Ne=setInterval(()=>{s.is_backing_off()||be(l,void 0,{background:!0})},l==="processing"?2e3:5e3);return()=>clearInterval(Ne)},[l,c,r,f,$==null?void 0:$.request_id]),h.useEffect(()=>{r&&f&&$!=null&&$.request_id&&A({request_id:$.request_id,name:ue})},[$==null?void 0:$.request_id,ue,f,r]),h.useEffect(()=>{me.current=!0},[$==null?void 0:$.request_id,ue]),h.useEffect(()=>{if(!We.current||!me.current)return;const Ne=window.requestAnimationFrame(()=>{const ze=We.current;ze&&(ze.scrollTop=ze.scrollHeight)});return()=>window.cancelAnimationFrame(Ne)},[j,ue,$==null?void 0:$.request_id]),h.useEffect(()=>{if(!r||!f||!($!=null&&$.request_id))return;const Y=String($.status||"").trim().toLowerCase();if(Y==="completed"||Y==="promoted"||Y==="failed"||Y!=="running"&&ke!==!0)return;const ze=setInterval(()=>{s.is_backing_off()||A({request_id:$.request_id,name:ue})},Y==="running"?1500:2500);return()=>clearInterval(ze)},[$==null?void 0:$.request_id,$==null?void 0:$.status,ue,f,r,ke]),{exec_cfg:y,exec_cfg_loading:x,exec_cfg_error:C,exec_requests:E,exec_loading:U,exec_error:F,exec_selected:$,set_exec_selected:Z,exec_detail:oe,set_exec_detail:le,exec_detail_loading:pe,exec_detail_error:Me,set_exec_detail_error:ve,exec_qa_feedback:ce,set_exec_qa_feedback:q,exec_qa_loading:L,exec_qa_error:X,exec_log_name:ue,set_exec_log_name:V,exec_log_text:j,exec_log_loading:ee,exec_log_error:he,exec_log_truncated:je,exec_log_auto:ke,set_exec_log_auto:Ce,exec_log_scroll_el_ref:We,exec_log_follow_ref:me,parsed_exec_events:ge,event_stats:qe,time_stats:Ye,clear_exec_selection:ie,load_exec_config:fe,refresh_exec_list:be,load_exec_request:G,exec_send_feedback:Se,exec_promote_to_prod:Xe,exec_deploy_uat_now:J,load_exec_log_tail:A}}const bf=[{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 av(a){var Qt;const s=a.gateway,r=a.gateway_connected,l=String(a.maintenance_ai_provider||"").trim(),c=String(a.maintenance_ai_model||"").trim(),f=String(a.maintenance_ai_reasoning||"").trim(),d=String(a.backlog_advisor_agent||"").trim()||"basic-agent",p=a.default_execution_mode==="inplace"?"inplace":"uat",_=md("(max-width: 900px)"),[y,b]=h.useState("planned"),[x,N]=h.useState([]),[C,I]=h.useState(!1),[E,P]=h.useState(""),[U,D]=h.useState(""),[F,Q]=h.useState("all"),[$,Z]=h.useState(""),[oe,le]=h.useState(new Set),pe=h.useRef(0),[Ae,Me]=h.useState(null),[ve,ce]=h.useState([]),[q,L]=h.useState(null),[W,X]=h.useState(p),[M,ue]=h.useState(!1),V=Nh(s,r),[j,R]=h.useState(""),[ee,_e]=h.useState(!1),[he,O]=h.useState(p),[je,te]=h.useState(!1),[ke,Ce]=h.useState(""),[We,me]=h.useState(!1),[Re,Pe]=h.useState(!1),[se,ye]=h.useState("framework"),[ge,qe]=h.useState("task"),[Ye,ie]=h.useState(""),[fe,be]=h.useState(""),[G,Se]=h.useState(!1),[Xe,J]=h.useState(""),A=fd({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 Y(){if(!r)return;const we=++pe.current;I(!0),P("");try{const Ee=await s.backlog_list(y);if(we!==pe.current)return;N(Array.isArray(Ee==null?void 0:Ee.items)?Ee.items:[])}catch(Ee){if(we!==pe.current)return;N([]),P(String((Ee==null?void 0:Ee.message)||Ee||"Failed to load backlog"))}finally{we===pe.current&&I(!1)}if(y==="planned")try{const Ee=await s.backlog_exec_active_items();if(we!==pe.current)return;const Ie=new Set;for(const mt of Array.isArray(Ee==null?void 0:Ee.items)?Ee.items:[]){const _t=String((mt==null?void 0:mt.filename)||"").trim();_t&&Ie.add(_t)}le(Ie)}catch{we===pe.current&&le(new Set)}else le(new Set)}h.useEffect(()=>{ce([]),Z(""),Y()},[y,r]),h.useEffect(()=>{ce(we=>{const Ee=new Set(x.map(mt=>String(mt.filename||"").trim())),Ie=we.filter(mt=>Ee.has(mt));return Ie.length===we.length?we:Ie})},[x]);const Ne=h.useMemo(()=>{const we=U.trim().toLowerCase(),Ee=F.trim().toLowerCase();return x.filter(Ie=>{if(Ee&&Ee!=="all"&&El(Ie.task_type)!==Ee)return!1;if(!we)return!0;const mt=Array.isArray(Ie.labels)?Ie.labels.join(" "):"";return`${Ie.item_id||""} ${Ie.package||""} ${Ie.title||""} ${Ie.task_type||""} ${Ie.summary||""} ${Ie.filename||""} ${mt} ${Ie.priority||""}`.toLowerCase().includes(we)})},[x,U,F]),ze=h.useMemo(()=>x.filter(we=>ve.includes(String(we.filename||"").trim())),[x,ve]),Ke=xi(E),[tt,dt]=h.useState(0),yt=ud(s,r&&Ke,tt);function pt(we){Me({filename:String(we.filename||""),kind:y,title:we.title||we.filename,initial_tab:"spec"})}async function Tt(we,Ee){Z("");try{await s.backlog_move({from_kind:y,to_kind:Ee,filename:String(we.filename||"")}),await Y()}catch(Ie){Z(String((Ie==null?void 0:Ie.message)||Ie||"Move failed"))}}async function qt(we){const Ee=String(we.filename||"").trim();if(!Ee)return;let Ie=null;try{const mt=await s.backlog_content("planned",Ee);Ie=cd({task_type:we.task_type},bi(String((mt==null?void 0:mt.content)||"")))}catch{Ie=null}R(""),X(p),L({filename:Ee,title:we.title||Ee,readiness:Ie}),A.load_exec_config()}async function Oe(we){if(!(!q||M)){ue(!0),R("");try{const Ee=A.exec_cfg||await A.load_exec_config();if(!Ee||Ee.can_execute!==!0){R((Ee==null?void 0:Ee.runner_error)||"Backlog exec is not available on this gateway.");return}const Ie=!!(q.readiness&&!q.readiness.ok);await s.backlog_execute({kind:"planned",filename:q.filename,execution_mode:W,executor:we==null?void 0:we.executor,target_model:we==null?void 0:we.target_model,target_reasoning_effort:we==null?void 0:we.target_reasoning_effort,dor:"check",override:Ie}),L(null),await Y()}catch(Ee){const Ie=Gu(Ee);Ie?(L(mt=>mt&&{...mt,readiness:Ie,server_refused:!0}),R("")):R(String((Ee==null?void 0:Ee.message)||Ee||"Execute failed"))}finally{ue(!1)}}}async function it(we){if(!(je||ze.length<2)){Ce(""),te(!0);try{const Ee=A.exec_cfg||await A.load_exec_config();if(!Ee||Ee.can_execute!==!0){Ce((Ee==null?void 0:Ee.runner_error)||"Backlog exec is not available on this gateway.");return}await s.backlog_execute_batch({items:ze.map(Ie=>({kind:"planned",filename:String(Ie.filename||"")})),execution_mode:he,executor:we,dor:"check",override:We}),_e(!1),ce([]),me(!1),await Y()}catch(Ee){const Ie=Gu(Ee);if(Ie){const mt=Ie.checks.filter(_t=>!_t.ok);me(!0),Ce(`Definition of Ready refused by the gateway:
79
- ${mt.map(_t=>`○ ${_t.label}${_t.evidence?` — ${_t.evidence}`:""}`).join(`
80
- `)}
81
- Execute batch again to override (recorded as dor_overridden).`)}else Ce(String((Ee==null?void 0:Ee.message)||Ee||"Execute batch failed"))}finally{te(!1)}}}async function et(){if(G||ze.length<2)return;const we=Ye.trim();if(!we){J("Title is required.");return}J(""),Se(!0);try{await s.backlog_merge({kind:"planned",items:ze.map(Ee=>({kind:"planned",filename:String(Ee.filename||"")})),package:se.trim()||"framework",task_type:ge,title:we,summary:fe.trim()||void 0}),Pe(!1),ce([]),await Y()}catch(Ee){J(String((Ee==null?void 0:Ee.message)||Ee||"Merge failed"))}finally{Se(!1)}}function kt(we){const Ee=String(we||"").trim();ce(Ie=>Ie.includes(Ee)?Ie.filter(mt=>mt!==Ee):[...Ie,Ee])}function ht(we){if(y==="planned"){const Ee=oe.has(String(we.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void qt(we),disabled:!r||Ee,title:Ee?"A live execution request already exists for this item":void 0,children:Ee?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void Tt(we,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(we,"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 Tt(we,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void Tt(we,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(we,"trash"),disabled:!r,children:"Trash"})]}):y==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(we,"trash"),disabled:!r,children:"Trash"}):y==="deprecated"||y==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void Tt(we,"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:bf.map(we=>e.jsx("button",{"aria-pressed":y===we.id,className:`seg_btn ${y===we.id?"active":""}`,onClick:()=>b(we.id),children:we.label},we.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 ${C?"is_loading":""}`,onClick:()=>void Y(),disabled:!r||C,title:"Refresh","aria-label":"Refresh",children:[e.jsx(at,{name:"refresh",size:16}),C?"Refreshing":"Refresh"]})]}),Ke?e.jsx(dd,{gateway:s,surface:"the backlog archive",status:yt.status,legacy:yt.legacy,error:E,on_changed:()=>{dt(we=>we+1),Y()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:U,onChange:we=>D(we.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:F,onChange:we=>Q(we.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(we=>e.jsx("option",{value:we,children:we},we))]}),e.jsx("div",{className:"page_toolbar_spacer"}),y==="planned"&&ve.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[ve.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:ve.length<2,onClick:()=>{Ce(""),O(p),me(!1),_e(!0),A.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:ve.length<2,onClick:()=>{const we=ze.map(Ee=>String(Ee.package||"").trim()).filter(Boolean);ye(we.length&&we.every(Ee=>Ee===we[0])?we[0]:"framework"),qe("task"),ie(`Master backlog (${ze.length} items)`),be(""),J(""),Pe(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[Ne.length,"/",x.length]})]}),E&&!Ke?e.jsx("div",{className:"page_error mono",children:E}):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:(Qt=bf.find(we=>we.id===y))==null?void 0:Qt.label}),e.jsxs("span",{className:"pane_count",children:[Ne.length," item",Ne.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:Ne.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:Ne.map(we=>{const Ee=String(we.filename||"").trim(),Ie=El(we.task_type),mt=Ju(we)?Qu(we.priority):null,_t=Array.isArray(we.labels)?we.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>pt(we),children:[y==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:gt=>gt.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:ve.includes(Ee),onChange:()=>kt(Ee),"aria-label":`Select ${Ee}`})}):null,e.jsx("td",{className:"mono muted col_id",children:we.item_id||""}),e.jsx("td",{className:"col_type",children:Ie?e.jsx("span",{className:`chip mono ${mh(Ie)}`,title:fh(Ie),children:Ie}):null}),e.jsx("td",{className:"mono muted col_package",title:we.package||"",children:we.package||""}),e.jsx("td",{className:"backlog_table_title",title:Ee,children:we.title||Ee}),e.jsx("td",{className:"col_priority",children:mt?e.jsx("span",{className:`chip mono board_prio_${mt.toLowerCase()}`,children:mt}):null}),e.jsxs("td",{className:"col_labels",title:_t.join(", "),children:[_t.slice(0,2).map(gt=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:gt},gt)),_t.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",_t.length-2]}):null]}),y!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:gt=>gt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:ht(we)})}):null]},`${y}:${Ee}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:C?"Loading…":"No items."})})]})]}),e.jsx(Sh,{open:!!q,target:q?{kind:"planned",filename:q.filename,title:q.title}:null,execute_mode:W,set_execute_mode:X,action_loading:M,action_error:j,exec_cfg:A.exec_cfg,exec_cfg_loading:A.exec_cfg_loading,exec_cfg_error:A.exec_cfg_error,executors:V,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 we=q;L(null),Me({filename:we.filename,kind:"planned",title:we.title,initial_tab:"spec"})}:void 0,on_confirm:we=>void Oe(we),on_close:()=>L(null)}),e.jsx(nv,{open:ee,batch_selected_items:ze,batch_execute_mode:he,set_batch_execute_mode:O,batch_execute_loading:je,batch_execute_error:ke,executors:V,exec_cfg:A.exec_cfg,exec_cfg_loading:A.exec_cfg_loading,exec_cfg_error:A.exec_cfg_error,on_confirm:we=>void it(we),on_close:()=>{_e(!1),Ce(""),me(!1)}}),e.jsx(sv,{open:Re,batch_selected_items:ze,merge_package:se,set_merge_package:ye,merge_task_type:ge,set_merge_task_type:qe,merge_title:Ye,set_merge_title:ie,merge_summary:fe,set_merge_summary:be,merge_loading:G,merge_error:Xe,on_confirm:()=>void et(),on_close:()=>{Pe(!1),J("")}}),e.jsx(bh,{gateway:s,can_use_gateway:r,target:Ae,on_close:()=>Me(null),on_mutated:async()=>{await Y()},on_open_executions:we=>{var Ee;return(Ee=a.on_open_executions)==null?void 0:Ee.call(a,we)}}),e.jsx(Xg,{gateway:s,can_use_gateway:r,is_compact_layout:_,maint_provider:l,maint_model:c,maint_reasoning:f,advisor_agent:d,focus_kind:y,focus_type:F,voice_session_id:a.voice_session_id})]})}function rv(a){const{open:s,gateway:r,can_use_gateway:l,maint_provider:c,maint_model:f,maint_reasoning:d,on_close:p,on_created:_}=a,[y,b]=h.useState(""),[x,N]=h.useState(!1),[C,I]=h.useState(""),[E,P]=h.useState("proposed"),[U,D]=h.useState("feature"),[F,Q]=h.useState("framework"),[$,Z]=h.useState(""),[oe,le]=h.useState(""),[pe,Ae]=h.useState(""),[Me,ve]=h.useState(""),[ce,q]=h.useState(""),[L,W]=h.useState(""),[X,M]=h.useState(!1),[ue,V]=h.useState(""),[j,R]=h.useState(""),[ee,_e]=h.useState(""),[he,O]=h.useState(""),[je,te]=h.useState(""),[ke,Ce]=h.useState(""),[We,me]=h.useState(""),[Re,Pe]=h.useState(""),[se,ye]=h.useState(""),[ge,qe]=h.useState(""),[Ye,ie]=h.useState([]),[fe,be]=h.useState(!1),[G,Se]=h.useState(""),[Xe,J]=h.useState([]),[A,Y]=h.useState(""),[Ne,ze]=h.useState(!1);function Ke(){P("proposed"),D("feature"),Q("framework"),Z(""),le(""),Ae(""),ve(""),q(""),W(""),M(!1),V(""),R(""),_e(""),O(""),te(""),Ce(""),me(""),Pe(""),ye(""),qe(""),ie([]),be(!1),Se(""),J([]),Y(""),ze(!1)}function tt(){p(),Ke()}async function dt(){const Oe=String(y||"").trim();if(Oe)return Oe;if(x)return"";I(""),N(!0);try{const it=await r.backlog_template(),et=String((it==null?void 0:it.content)||"");return b(et),et}catch(it){return I(String((it==null?void 0:it.message)||it||"Failed to load backlog template")),""}finally{N(!1)}}async function yt(Oe){if(!l)return;const it=(Oe==null?void 0:Oe.force)===!0;if(!it&&ce.trim())return;const et=await dt();if(!et.trim())return;const kt=String(F||"").trim().toLowerCase()||"{Package}",ht=Hu(),Qt=$g(et,{package_name:kt,title:$,task_type:U,summary:oe,created_at:ht});q(we=>it||!String(we||"").trim()?Qt:we)}h.useEffect(()=>{s&&l&&yt()},[s,l]);function pt(Oe){if(ce.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const it=String(F||"").trim().toLowerCase()||"{Package}",et=Hu(),kt=Eg({package_name:it,title:$,task_type:U,summary:oe,diagram:ue,context:j,included:Pa(ee),excluded:Pa(he),plan:Pa(je),dependencies:Pa(ke),acceptance:Pa(We),tests_a:Pa(Re),tests_b:Pa(se),tests_c:Pa(ge),created_at:et,attachments:[]});q(kt)}async function Tt(){var it;if(X)return;W(""),M(!0),Se("");let Oe="";try{const et=String(F||"").trim().toLowerCase(),kt=od(Me),ht=!!(pe||kt.length);let Qt=ce||"";ht&&Qt.trim()&&(Qt=Ku(Qt,{priority:pe||null,labels:kt}));const we=await r.backlog_create({kind:E,package:et,title:$,task_type:U,summary:oe||null,content:Qt||null}),Ee=String((we==null?void 0:we.kind)||"").trim(),Ie=String((we==null?void 0:we.filename)||"").trim();if(ht&&!Qt.trim()&&Ee&&Ie)try{const _t=await r.backlog_content(Ee,Ie),gt=String((_t==null?void 0:_t.content)||""),Xt=await Vu(gt),mn=Ku(gt,{priority:pe||null,labels:kt});await r.backlog_update({kind:Ee,filename:Ie,content:mn,expected_sha256:Xt||null})}catch(_t){Oe=[Oe,`metadata lines not written: ${String((_t==null?void 0:_t.message)||_t)}`].filter(Boolean).join("; ")}const mt=[...Ye||[]];if(Ee&&Ie&&mt.length){be(!0);const _t=[];try{for(const gt of mt){const Xt=await r.backlog_upload_attachment({kind:Ee,filename:Ie,file:gt,overwrite:!1}),mn=String(((it=Xt==null?void 0:Xt.stored)==null?void 0:it.relpath)||"").trim();mn&&_t.push(mn)}}catch(gt){Oe=[Oe,String((gt==null?void 0:gt.message)||gt||"Attachment upload failed")].filter(Boolean).join("; "),Se(Oe)}finally{if(_t.length)try{const gt=await r.backlog_content(Ee,Ie),Xt=String((gt==null?void 0:gt.content)||""),mn=await Vu(Xt),Bt=Tg(Xt,_t);await r.backlog_update({kind:Ee,filename:Ie,content:Bt,expected_sha256:mn||null})}catch(gt){Oe=[Oe,`uploaded files not linked: ${String((gt==null?void 0:gt.message)||gt)}`].filter(Boolean).join("; ")}be(!1)}}p(),Ke();try{await _(Ee,Ie,Oe)}catch{}}catch(et){W(String((et==null?void 0:et.message)||et||"Create failed"))}finally{M(!1)}}async function qt(){if(Ne)return;W("");const Oe=A.trim();if(!Oe)return;if(!$.trim()){W("Title is required before using AI assist.");return}const it=String(F||"").trim().toLowerCase();if(!it){W("Package is required before using AI assist.");return}const et={id:Nr(),role:"user",content:Oe,ts:new Date().toISOString()},kt=[...Xe,et];J(kt),Y(""),ze(!0);try{const ht=await r.backlog_assist({kind:E,package:it,title:$,summary:oe||null,draft_markdown:ce||null,messages:kt.map(Ee=>({role:Ee.role,content:Ee.content})),provider:c||null,model:f||null,thinking:d||null}),Qt=String((ht==null?void 0:ht.reply)||"").trim(),we=String((ht==null?void 0:ht.draft_markdown)||"").trim();Qt&&J(Ee=>[...Ee,{id:Nr(),role:"assistant",content:Qt,ts:new Date().toISOString()}]),we&&q(we)}catch(ht){W(String((ht==null?void 0:ht.message)||ht||"AI assist failed"))}finally{ze(!1)}}return e.jsxs(qa,{open:s,title:"New backlog task",onClose:tt,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:tt,disabled:X||Ne,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Tt(),disabled:X||!$.trim()||!F.trim(),children:X?"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:E,onChange:Oe=>P(Oe.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:U,onChange:Oe=>D(Oe.target.value),children:Fa.map(Oe=>e.jsx("option",{value:Oe,children:Oe},Oe))})]})}),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:Oe=>Q(Oe.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:$,onChange:Oe=>Z(Oe.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:pe,onChange:Oe=>Ae(Oe.target.value),children:[e.jsx("option",{value:"",children:"unset"}),Al.map(Oe=>e.jsx("option",{value:Oe,children:_h[Oe]},Oe))]})]})}),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:Me,onChange:Oe=>ve(Oe.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:oe,onChange:Oe=>le(Oe.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:ue,onChange:Oe=>V(Oe.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:j,onChange:Oe=>R(Oe.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:ee,onChange:Oe=>_e(Oe.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:he,onChange:Oe=>O(Oe.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:Oe=>te(Oe.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:ke,onChange:Oe=>Ce(Oe.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:We,onChange:Oe=>me(Oe.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:Re,onChange:Oe=>Pe(Oe.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:se,onChange:Oe=>ye(Oe.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:ge,onChange:Oe=>qe(Oe.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:()=>pt(),disabled:X||Ne,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:Oe=>{const it=Array.from(Oe.target.files||[]);it.length&&(ie(et=>[...et,...it]),Oe.currentTarget.value="")}})}),Ye.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Ye.map((Oe,it)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Oe.name," (",Math.round(Oe.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>ie(et=>et.filter((kt,ht)=>ht!==it)),disabled:X||fe,children:"Remove"})]},`${Oe.name}_${Oe.size}_${it}`))}):null,fe?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,C?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:C}):null,e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{ce.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||yt({force:!0})},disabled:X||Ne||x||!l,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:ce,onChange:Oe=>q(Oe.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(id,{messages:Xe,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(ec,{value:A,onChange:Y,onSubmit:()=>void qt(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!l||!$.trim(),busy:Ne,rows:3,sendButtonClassName:"btn primary"})}),L?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:L}):null]})}class Ch extends Ht.Component{constructor(){super(...arguments);kr(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,f;try{(f=(c=this.props).onError)==null||f.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 hd{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"}:{}}}),f=await c.text();let d=null;try{d=JSON.parse(f)}catch{}if(!c.ok){const p=d&&typeof d=="object"&&(d.detail||d.error)||f,_=new Error(`${s} failed: ${p}`);throw _.status=c.status,_}return d}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)}),f=await c.text();let d=null;try{d=JSON.parse(f)}catch{}if(!c.ok){const p=d&&typeof d=="object"&&(d.detail||d.error)||f,_=new Error(`upload failed: ${p}`);throw _.status=c.status,_}if(!d||typeof d!="object"||!d.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return d}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 f={value:l,note:c};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(f)})}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,f=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:l,value:c,note:f})})}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(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/hub/ws`}}const iv=["commons"],lv=3e4,ov=5*6e4,wf={live:new Map,done:[],work:new Map},jf=new Set(["proposed","planned","completed","deprecated"]);function cv(a,s){const r=s&&typeof s=="object"?String(s.item||""):"";if(r&&Ds(r))return r;const l=a.startsWith("claim:")?a.slice(6):"";return l&&Ds(l)?l:null}function uv(a){const[s,r]=h.useState(wf),l=h.useRef(new hd),c=h.useRef(new Map),f=h.useRef(0),d=h.useRef(!1);return h.useEffect(()=>{let p=!0;const _=async()=>{if(!(d.current||Date.now()<f.current)){d.current=!0;try{const b=new Map,x=[],N=new Map;for(const C of iv){let I=!1;try{const P=await l.current.work_rows(C);for(const U of P){const D=String(U.id||U.item||""),F=String(U.status||"").toLowerCase();!Ds(D)||!jf.has(F)||N.set(D,{item:D,title:typeof U.title=="string"?U.title:void 0,status:F,owner:typeof U.owner=="string"?U.owner:void 0,receipt:typeof U.receipt=="string"?U.receipt:void 0,card:typeof U.card=="string"?U.card:void 0,updated_at:U.updated_at})}I=!0}catch{}const E=await l.current.store_keys(C);for(const P of E){const U=String(P.key||"");if(U.startsWith("work:")){if(I)continue;const le=U.slice(5);if(!Ds(le))continue;const pe=Number(P.version||0),Ae=`${C}\0${U}`,Me=c.current.get(Ae);let ve;if(Me&&Me.version===pe)ve=Me.value;else{const q=await l.current.store_get(C,U);ve=q==null?void 0:q.value,c.current.set(Ae,{version:pe,value:ve})}const ce=ve&&typeof ve=="object"?String(ve.status||"").toLowerCase():"";if(!jf.has(ce))continue;N.set(le,{item:le,title:typeof ve.title=="string"?ve.title:void 0,status:ce,owner:typeof ve.owner=="string"?ve.owner:void 0,receipt:typeof ve.receipt=="string"?ve.receipt:void 0,card:typeof ve.card=="string"?ve.card:void 0,updated_at:P.updated_at});continue}if(!U.startsWith("claim:"))continue;const D=Number(P.version||0),F=`${C}\0${U}`,Q=c.current.get(F);let $;if(Q&&Q.version===D)$=Q.value;else{const le=await l.current.store_get(C,U);$=le==null?void 0:le.value,c.current.set(F,{version:D,value:$})}if(!$||typeof $!="object"||typeof $.owner!="string"||!$.owner)continue;const Z=cv(U,$)||U.slice(6);if(!Z)continue;!!$.done||String($.status||"").toLowerCase()==="done"?x.push({item:Z,owner:$.owner,receipt:typeof $.receipt=="string"?$.receipt:void 0,updated_at:P.updated_at}):b.has(Z)||b.set(Z,$)}}x.sort((C,I)=>(I.updated_at||0)-(C.updated_at||0)),p&&r(C=>C.live.size===b.size&&[...b.keys()].every(E=>JSON.stringify(C.live.get(E))===JSON.stringify(b.get(E)))&&JSON.stringify(C.done)===JSON.stringify(x)&&C.work.size===N.size&&[...N.keys()].every(E=>JSON.stringify(C.work.get(E))===JSON.stringify(N.get(E)))?C:{live:b,done:x,work:N})}catch{f.current=Date.now()+ov,p&&r(b=>b.live.size||b.done.length||b.work.size?wf:b)}finally{d.current=!1}}};_();const y=setInterval(()=>void _(),lv);return()=>{p=!1,clearInterval(y)}},[a]),s}const dv=40,mv=4;function fv(a){const{gateway:s,can_use_gateway:r,data_nonce:l}=a,[c,f]=h.useState([]),[d,p]=h.useState(!1),[_,y]=h.useState(""),[b,x]=h.useState(""),[N,C]=h.useState(null),[I,E]=h.useState(null),[P,U]=h.useState({}),D=h.useRef({}),F=h.useRef(!1),Q=h.useCallback(async le=>{if(r&&!F.current){F.current=!0,le!=null&&le.background||p(!0);try{const[pe,Ae,Me,ve,ce]=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=[],L=[],W=(je,te)=>je.status==="fulfilled"?je.value:(q.push(te),L.push(je.reason),null),X=W(pe,"proposed list"),M=W(Ae,"planned list"),ue=W(Me,"live requests"),V=W(ve,"recent history"),j=W(ce,"busy set");if(C(L.find(je=>xi(je))??null),!X&&!M&&!ue&&!V){y("Failed to load the board (all sources failed)");return}y("");const R=Array.isArray(ue==null?void 0:ue.requests)?ue.requests:[];let ee=Array.isArray(j==null?void 0:j.items)?j.items:[];j||(ee=R.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 _e=Array.isArray(X==null?void 0:X.items)?X.items:[],he=Array.isArray(M==null?void 0:M.items)?M.items:[];E(X&&M?_e.length+he.length:null);const O=Vg({proposed:_e,planned:he,active_requests:R,terminal_requests:Array.isArray(V==null?void 0:V.requests)?V.requests:[],active_items:ee});f(O),x(q.length?`#FALLBACK partial board — failed: ${q.join(", ")}`:""),$(O,_e,he)}finally{F.current=!1,le!=null&&le.background||p(!1)}}},[s,r]);async function $(le,pe,Ae){const Me=new Map;for(const L of pe)Me.set(String(L.filename||"").trim(),"proposed");for(const L of Ae)Me.set(String(L.filename||"").trim(),"planned");const ve=le.filter(L=>L.filename&&!D.current[L.filename]&&Me.has(L.filename)).filter(L=>!xh(L)||L.column==="ready").slice(0,dv).map(L=>({filename:L.filename,kind:Me.get(L.filename)}));if(!ve.length)return;const ce=[...ve],q=Array.from({length:Math.min(mv,ce.length)},async()=>{for(;;){const L=ce.shift();if(!L)return;try{const W=await s.backlog_content(L.kind,L.filename),X=bi(String((W==null?void 0:W.content)||""));D.current={...D.current,[L.filename]:X}}catch{}}});await Promise.all(q),U(D.current)}const Z=h.useCallback(async(le,pe)=>{try{const Ae=await s.backlog_content(le,pe),Me=bi(String((Ae==null?void 0:Ae.content)||""));D.current={...D.current,[pe]:Me},U(D.current)}catch{}},[s]);return h.useEffect(()=>{Q()},[Q,l]),h.useEffect(()=>{if(!r)return;const le=setInterval(()=>{s.is_backing_off()||Q({background:!0})},1e4);return()=>clearInterval(le)},[r,Q,s]),{cards:c,loading:d,error:_,degraded:b,unconfigured:N!==null,unavailable:N,item_count:I,metadata:P,refresh:Q,refresh_item_metadata:Z}}function kf(a,s){return a.length<=s?a:`${a.slice(0,s-1).trimEnd()}…`}const hv=new hd;function pv(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 _v(a){const{card:s}=a,r=s.work_id||"",l=!!(r&&Ds(r)),[c,f]=h.useState({loading:l,error:"",claims:[],decisions:[],messages:[]});h.useEffect(()=>{let _=!0;if(l)return f(y=>({...y,loading:!0,error:""})),hv.work(r).then(y=>{_&&f({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=>{_&&f({loading:!1,error:String((y==null?void 0:y.message)||y||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{_=!1}},[r,l]);const d=c.messages[0],p=s.claim_started_at!==void 0&&s.claim_owner?ph({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," · ",pv(_.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:kf(String(_.title),140)}):null,_.body?e.jsx("div",{className:"board_activity_msg_body muted",children:kf(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(d?{channel:String(d.channel||"commons"),message_id:String(d.id||""),seq:Number(d.seq)}:{channel:"commons"}),title:d?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function gv(a){var be;const{gateway:s,gateway_connected:r,data_nonce:l,on_mutated:c,on_open_executions:f}=a,d=a.default_execution_mode==="inplace"?"inplace":"uat",p=md("(max-width: 900px)"),_=Nh(s,r),y=fv({gateway:s,can_use_gateway:r,data_nonce:l}),[b,x]=h.useState(0),N=ud(s,r,l+b),C=y.unconfigured||((be=N.status)==null?void 0:be.available)===!1,I=!C&&y.item_count===0&&!y.error,E=uv(!0),P=h.useMemo(()=>Kg(y.cards,E),[y.cards,E]),U=fd({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]=h.useState("");h.useEffect(()=>{var Se;if(!a.query_preset)return;const G=Ds(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[Q,$]=h.useState("all"),[Z,oe]=h.useState("all"),[le,pe]=h.useState(""),[Ae,Me]=h.useState(!1),[ve,ce]=h.useState(null),[q,L]=h.useState(null),[W,X]=h.useState(null),[M,ue]=h.useState("uat"),[V,j]=h.useState(!1),[R,ee]=h.useState(""),[_e,he]=h.useState(""),[O,je]=h.useState(null),te=h.useRef(null),ke=P.some(G=>G.column==="in_progress"),[,Ce]=h.useState(0);h.useEffect(()=>{if(!ke)return;const G=setInterval(()=>Ce(Se=>(Se+1)%3600),1e3);return()=>clearInterval(G)},[ke]);const We=h.useMemo(()=>{const G=new Set;for(const Se of P)Se.package&&G.add(Se.package);return[...G].sort()},[P]),me=h.useMemo(()=>P.filter(G=>G.filename&&G.kind).length,[P]),Re=h.useMemo(()=>P.filter(G=>G.filename&&G.kind&&(xh(G)||y.metadata[G.filename])).length,[P,y.metadata]),Pe=h.useMemo(()=>{const G=new Map;for(const Se of P)if(Se.filename)for(const Xe of Xu(Se,y.metadata[Se.filename]))G.set(Xe,(G.get(Xe)||0)+1);return[...G.entries()].sort((Se,Xe)=>Xe[1]-Se[1]).slice(0,12)},[P,y.metadata]),se=h.useMemo(()=>{const G=D.trim().toLowerCase();return P.filter(Se=>{if(Q!=="all"&&(Se.package||"")!==Q||Z!=="all"&&String(Se.task_type||"").toLowerCase()!==Z)return!1;const Xe=Se.filename?y.metadata[Se.filename]:void 0,J=Xu(Se,Xe);return le&&!J.includes(le)||Ae&&!J.some(Y=>{const Ne=Y.toLowerCase();return Ne==="decision-gate"||Ne.startsWith("wave-")||Ne.startsWith("seat-")})?!1:G?`${Se.item_id||""} ${Se.title} ${Se.filename||""} ${Se.package||""} ${Se.summary||""} ${Se.exec_status||""} ${J.join(" ")} ${Yu(Se,Xe)||""}`.toLowerCase().includes(G):!0})},[P,y.metadata,D,Q,Z,le,Ae]),ye=h.useMemo(()=>{var Xe;const G=new Map;for(const J of vf)G.set(J.id,[]);for(const J of se)(Xe=G.get(J.column))==null||Xe.push(J);const Se=J=>{const A=J.filename?Yu(J,y.metadata[J.filename]):null;return A?Al.indexOf(A):Al.length};for(const[J,A]of G)(J==="triage"||J==="ready")&&A.sort((Y,Ne)=>Se(Y)-Se(Ne)||(Ne.item_id||0)-(Y.item_id||0));return G},[se,y.metadata]);async function ge(G,Se){if(!(!G.filename||!G.kind||G.kind==="completed")&&G.kind!==Se){he("");try{await s.backlog_move({from_kind:G.kind,to_kind:Se,filename:G.filename}),await y.refresh(),c()}catch(Xe){he(String((Xe==null?void 0:Xe.message)||Xe||"Move failed"))}}}async function qe(G){if(!G.filename)return;let Se=y.metadata[G.filename];if(!Se)try{const J=await s.backlog_content("planned",G.filename);Se=bi(String((J==null?void 0:J.content)||""))}catch{Se=void 0}const Xe=Se?cd({task_type:G.task_type},Se):null;ee(""),ue(d),X({filename:G.filename,title:G.title,readiness:Xe}),U.load_exec_config()}async function Ye(G){if(!(!W||V)){j(!0),ee("");try{const Se=U.exec_cfg||await U.load_exec_config();if(!Se||Se.can_execute!==!0){ee((Se==null?void 0:Se.runner_error)||"Backlog exec is not available on this gateway.");return}const Xe=!!(W.readiness&&!W.readiness.ok);await s.backlog_execute({kind:"planned",filename:W.filename,execution_mode:M,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:Xe}),X(null),await y.refresh(),c()}catch(Se){const Xe=Gu(Se);Xe?(X(J=>J&&{...J,readiness:Xe,server_refused:!0}),ee("")):ee(String((Se==null?void 0:Se.message)||Se||"Execute failed"))}finally{j(!1)}}}function ie(G){if(!G.filename&&!G.request_id){const Se=Pg(G.card_path);if(Se&&r){s.backlog_content(Se.kind,Se.filename).then(()=>{ce({filename:Se.filename,kind:Se.kind,title:G.title,work_id:G.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>L(G));return}L(G);return}ce({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 fe={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:Q,onChange:G=>$(G.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),We.map(G=>e.jsx("option",{value:G,children:G},G))]}),e.jsxs("select",{value:Z,onChange:G=>oe(G.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(G=>e.jsx("option",{value:G,children:G},G))]}),e.jsx("button",{className:`chip mono board_facet ${Ae?"active":"muted"}`,onClick:()=>Me(G=>!G),"aria-pressed":Ae,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&&!C?e.jsx("span",{className:"mono board_warn",title:y.degraded,children:"partial board"}):null,y.error&&!C?e.jsx("span",{className:"mono board_error",children:y.error}):null,_e?e.jsx("span",{className:"mono board_error",children:_e}):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"})]}),C?e.jsx(dd,{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(Jg,{status:N.status,on_create:a.on_new_task}):null,!C&&(Pe.length||me)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),Pe.map(([G,Se])=>e.jsxs("button",{className:`chip mono board_facet ${le===G?"active":"info"}`,onClick:()=>pe(Xe=>Xe===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)),le?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>pe(""),children:"clear ✕"}):null,Re<me?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 ",Re,"/",me]}):null]}):null,e.jsx("div",{className:"board_columns",style:C?{display:"none"}:void 0,children:vf.map(G=>{const Se=ye.get(G.id)||[],Xe=fe[G.id];return e.jsxs("div",{className:`board_column board_column_${G.id} ${O===G.id?"drag_over":""}`,onDragOver:J=>{!Xe||!te.current||(J.preventDefault(),je(G.id))},onDragLeave:()=>je(J=>J===G.id?null:J),onDrop:J=>{J.preventDefault(),je(null);const A=te.current;te.current=null,A&&Xe&&ge(A,Xe)},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(J=>{const A=yh(J,J.filename?y.metadata[J.filename]:void 0);return e.jsx(vv,{card:J,metadata:J.filename?y.metadata[J.filename]:void 0,draggable:!A&&!!(J.kind&&J.filename&&(J.column==="triage"||J.column==="ready")),on_drag_start:()=>{te.current=J},on_drag_end:()=>{te.current=null,je(null)},on_open:()=>ie(J),on_promote:!A&&G.id==="triage"?()=>void ge(J,"planned"):void 0,on_demote:!A&&G.id==="ready"?()=>void ge(J,"proposed"):void 0,on_execute:!A&&G.id==="ready"?()=>void qe(J):void 0,on_follow:J.exec_status==="running"||J.exec_status==="queued"?()=>f(J.request_id):void 0},J.key)}),Se.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},G.id)})}),e.jsx(Sh,{open:!!W,target:W?{kind:"planned",filename:W.filename,title:W.title}:null,execute_mode:M,set_execute_mode:ue,action_loading:V,action_error:R,exec_cfg:U.exec_cfg,exec_cfg_loading:U.exec_cfg_loading,exec_cfg_error:U.exec_cfg_error,executors:_,readiness:(W==null?void 0:W.readiness)??null,server_refused:(W==null?void 0:W.server_refused)===!0,show_readiness:!0,on_open_spec:W?()=>{const G=W;X(null),ce({filename:G.filename,kind:"planned",title:G.title,initial_tab:"spec"})}:void 0,on_confirm:G=>void Ye(G),on_close:()=>X(null)}),e.jsx(bh,{gateway:s,can_use_gateway:r,target:ve,on_close:()=>ce(null),on_mutated:async()=>{ve!=null&&ve.filename&&(ve.kind==="proposed"||ve.kind==="planned")&&await y.refresh_item_metadata(ve.kind,ve.filename),await y.refresh(),c()},on_open_executions:f}),q?e.jsx(_v,{card:q,on_close:()=>L(null),on_open_team:a.on_open_team}):null]})}function vv(a){const{card:s,metadata:r,draggable:l,on_drag_start:c,on_drag_end:f,on_open:d,on_promote:p,on_demote:_,on_execute:y,on_follow:b}=a,x=Yu(s,r),N=yh(s,r),C=!N&&r?cd({task_type:s.task_type},r):null,I=El(s.task_type),E=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:d,role:"button",tabIndex:0,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),d())},draggable:l,onDragStart:l?c:void 0,onDragEnd:l?f:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[C?e.jsx("span",{className:`board_ready_dot ${C.ok?"ok":"warn"}`,title:C.ok?"Definition of Ready: satisfied":`Not ready: ${C.checks.filter(P=>!P.ok).map(P=>P.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 ${mh(I)}`,title:fh(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,Xu(s,r).filter(P=>!N||P.toLowerCase()!=="decision-gate").slice(0,3).map(P=>e.jsx("span",{className:"chip mono info",children:P},P)),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,E!==null?e.jsx("span",{className:"chip mono info",children:Os(E)}):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 P=ph({owner:s.claim_owner,started_at:s.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${P!=null&&P.stale?"warn":"info"}`,title:`Live hub claim${s.work_id?` (claim:${s.work_id})`:""}${P!=null&&P.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",s.claim_owner,P?` · ${P.label.replace("claimed ","")}`:""]})})():null]}),p||_||y||b?e.jsxs("div",{className:"board_card_actions",onClick:P=>P.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 Tu(a,s){const r=String(a||"").replace(/\r/g,"").trim();if(!r)return"";const c=(r.split(`
82
- `,1)[0]||"").trim();return c.length<=s?c:`${c.slice(0,Math.max(0,s-1))}…`}function yv(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 $h(a){const s=String(a||"").trim();if(!s)return"";const r=s.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?yv(String(r[1]||"").trim()):s}function xv(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 f=String(c.status||"").trim().toLowerCase();if(f==="failed")return"error";const d=c.exit_code,p=typeof d=="number"?d:Number.isFinite(Number(d))?Number(d):null;if(p!=null)return p===0?"ok":"error";if(f==="completed")return"ok"}return"info"}function bv(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():"",f=l?String(l.text||"").trim():"",d=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"&&d)return $h(d)||d;if(c==="todo_list"&&p.length>0){const b=p.length,x=p.filter(U=>(U&&U.completed)===!0).length,N=p.find(U=>(U&&U.completed)!==!0),C=String((N==null?void 0:N.text)||"").trim(),I=b>1?` (+${b-1})`:"",E=b>0?` (${x}/${b})`:"",P=C?`todo: ${C}${I}`:`todo list (${b})`;return Tu(`${P}${E}`,96)}return f?Tu(f,96)||f:_?Tu(_,96)||_:c||String(a||"").trim()||"event"}function Sf(a){const s=new Date(a),r=l=>String(l).padStart(2,"0");return`${r(s.getHours())}:${r(s.getMinutes())}`}function wv(a){var l,c,f;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,(f=s.item)==null?void 0:f.timestamp];for(const d of r)if(d!=null){if(typeof d=="number"&&Number.isFinite(d)){const p=d>1e11?d:d*1e3;return Sf(p)}if(typeof d=="string"){const p=d.trim();if(!p)continue;const _=Date.parse(p.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(_))return Sf(_)}}return null}function jv(a){var P;const{exec_selected:s,exec_detail:r,is_compact_layout:l,exec_log_name:c,set_exec_log_name:f,exec_log_text:d,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:C,parsed_exec_events:I,load_exec_log_tail:E}=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:U=>f(U.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(U=>!U),disabled:!(s!=null&&s.request_id),children:b?"Auto on":"Auto off"}),e.jsxs("button",{className:`btn btn_icon ${p?"is_loading":""}`,onClick:()=>E(),disabled:p||!(s!=null&&s.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(at,{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:U=>{C.current=hf(U.currentTarget,12)},children:I.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):I.events.map(U=>{var ue;const D=U.payload,F=D&&typeof D.item=="object"?D.item:null,Q=F?String(F.type||"").trim():"",$=F?String(F.id||"").trim():"",Z=D?String(D.thread_id||"").trim():"",oe=xv(U.type,D),le=oe==="error"?"danger":oe==="ok"?"ok":"info",pe=wv(D),Ae=bv(U.type,D),Me=String((D==null?void 0:D.message)||((ue=D==null?void 0:D.error)==null?void 0:ue.message)||"").trim(),ve=F?String(F.text||"").trim():"",ce=F?String(F.command||"").trim():"",q=F?String(F.status||"").trim():"",L=F&&F.exit_code!=null?String(F.exit_code):"",W=F?String(F.aggregated_output||"").trim():"",X=F&&Array.isArray(F.items)?F.items:[],M=ce?$h(ce)||ce:"";return e.jsxs("details",{className:`exec_event ${oe}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[pe?e.jsx("span",{className:"exec_event_when mono muted",children:pe}):null,pe?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:Ae,children:Ae}),e.jsx("span",{className:`chip mono ${le}`,children:Q||U.type}),L?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",L]}):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:U.type}),$?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:$}):null,Z?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",fa(Z,18)]}):null]}),Me?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Me}):null,X&&X.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:X.map((V,j)=>e.jsxs("div",{children:[(V&&V.completed)===!0?"✓":"○"," ",String((V==null?void 0:V.text)||"").trim()]},`${U.idx}-todo-${j}`))}):null,ce?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",q?`(${q})`:""," ",L?`exit=${L}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:M})]}):null,W?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",W.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:W})]}):null,ve?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(rs,{className:"md_doc",text:ve})}):null]})]},`${U.idx}-${$}-${U.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:U=>{C.current=hf(U.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var D;if(String(d||"").trim())return d;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 Q=String(s.status||"").trim().toLowerCase();return Q==="queued"||Q==="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)"})()})}),(P=r==null?void 0:r.result)!=null&&P.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 kv(a){const{pipeline:s,is_compact_layout:r,on_back_to_list:l,on_send_feedback:c,on_promote:f,on_deploy_uat:d}=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:C,exec_qa_error:I,event_stats:E,time_stats:P,exec_log_name:U}=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 ${Cl(D)}`,children:D||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:fa(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:()=>dn(p.request_id),disabled:y,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(at,{name:"copy",size:16}),r?null:"Copy request id"]}),p.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(p.backlog_relpath||""),disabled:y,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(at,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var Q;const F=(Array.isArray((Q=_==null?void 0:_.backlog_queue)==null?void 0:Q.items)?_.backlog_queue.items:[]).map($=>String(($==null?void 0:$.relpath)||"").trim()).filter(Boolean);return F.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(F.join(`
83
- `)),disabled:y,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(at,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),p.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(p.run_dir_relpath||""),disabled:y,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(at,{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(Sv,{exec_selected:p,exec_detail:_,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:C,exec_qa_error:I,on_send_feedback:c,on_promote:f,on_deploy_uat:d}),e.jsx(Nv,{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,P.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Os(P.age_ms)})]}):null,P.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:Os(P.queue_delay_ms)})]}):null,P.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:Os(P.run_ms)})]}):null,P.total_ms!=null&&P.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Os(P.total_ms)})]}):null,E?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"commands"}),e.jsxs("span",{className:"fact_value",children:[E.command_count.toLocaleString(),E.command_fail_count?` (${E.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:E!=null&&E.has_tokens?e.jsxs(e.Fragment,{children:["in ",E.input_tokens.toLocaleString(),E.cached_input_tokens?` (cached ${E.cached_input_tokens.toLocaleString()})`:"",", out ",E.output_tokens.toLocaleString(),", total ",E.total_tokens.toLocaleString()]}):e.jsx("span",{className:"muted",children:U==="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(Ev,{exec_detail:_}),e.jsx(Cv,{exec_detail:_,exec_qa_loading:C,status:String(p.status||"")}),e.jsx($v,{exec_detail:_}),e.jsx(Tv,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_divider"}),e.jsx(jv,{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 Sv(a){const{exec_selected:s,exec_detail:r,exec_qa_feedback:l,set_exec_qa_feedback:c,exec_qa_loading:f,exec_qa_error:d,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(),C=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),I=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),E=String((r==null?void 0:r.uat_current_relpath)||"").trim(),P=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),U=!!(r!=null&&r.uat_lock_acquired),D=!!(r!=null&&r.uat_pending),F=(r==null?void 0:r.uat_deploy)??null,Q=String((r==null?void 0:r.uat_deploy_error)||"").trim(),$=r==null?void 0:r.attempt,Z=(r==null?void 0:r.promotion_report)??null,oe=!!(Z!=null&&Z.blocked),le=String((Z==null?void 0:Z.reason)||"").trim(),pe=Array.isArray(Z==null?void 0:Z.conflicts)?(Z==null?void 0:Z.conflicts).slice(0,8):[],Ae=typeof(Z==null?void 0:Z.conflicts_total)=="number"?Number(Z.conflicts_total):pe.length;let Me="",ve="";const ce=[];try{const q=F==null?void 0:F.processes;if(q&&typeof q=="object"&&!Array.isArray(q)){typeof q.status=="string"&&(Me=String(q.status||"").trim()),typeof q.reason=="string"&&(ve=String(q.reason||"").trim());for(const[L,W]of Object.entries(q)){if(!W||typeof W!="object"||Array.isArray(W))continue;const X=W.probe;!X||typeof X!="object"||X.ok===!1&&ce.push(String(L))}}}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"&&P?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[fa(P,18),U?" (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,C?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:C})]}):null,E?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:E})]}):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&&P&&!U?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",fa(P,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):x==="uat"&&U?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."}),ce.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",ce.slice(0,4).join(", "),ce.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,x==="uat"&&Me==="skipped"&&ve==="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,Q?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",Q]}):null,oe&&le==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",Ae," conflict",Ae===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",pe.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:pe.map((q,L)=>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:${L}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[C?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(C),disabled:f,children:[e.jsx(at,{name:"copy",size:16}),"Copy patch path"]}):null,I?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(I),disabled:f,children:[e.jsx(at,{name:"copy",size:16}),"Copy manifest path"]}):null,N?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(N),disabled:f,children:[e.jsx(at,{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:f})}),d?e.jsx("div",{className:"detail_warn",children:d}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[x==="uat"?e.jsx("button",{className:"btn",onClick:y,disabled:f,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:_,disabled:f,children:x==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:p,disabled:f,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function Nv(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(),f=(r==null?void 0:r.promotion)??null,d=(r==null?void 0:r.promotion_report)??null,p=typeof(f==null?void 0:f.copied)=="number"?Number(f==null?void 0:f.copied):null,_=typeof(f==null?void 0:f.deleted)=="number"?Number(f==null?void 0:f.deleted):null,y=String((f==null?void 0:f.manifest_sha256)||"").trim(),b=String((f==null?void 0:f.mode)||"").trim(),x=(d==null?void 0:d.redeploy)??null,N=String((x==null?void 0:x.status)||"").trim(),C=String((x==null?void 0:x.reason)||"").trim(),I=String((d==null?void 0:d.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,C?` (${C})`:""]})]}):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 Cv(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,f=String((l==null?void 0:l.mode)||"").trim(),d=(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:[f?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:f})]}):null,d?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[d," 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:()=>dn(_),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(at,{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 $v(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(f=>String((f==null?void 0:f.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(f=>e.jsx("div",{children:f},`bq:${f}`))})]}):null}function Ev(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:{},f=Array.isArray(s.verdicts)?s.verdicts:[];if(!r.length&&!l.length&&!f.length)return null;const d=new Set(l.map(x=>String(x))),p=f.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=d.has(String(x)),C=c[String(x)];return e.jsxs("span",{className:`chip mono ${N?"ok":"warn"}`,title:N?C?`active · ${String(C).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[x,N?"":" (held)"]},`skill:${x}`)})}),p.map((x,N)=>{const C=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:[C,": ",I]},`verdict:${N}:${C}`)})]})}function Tv(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(rs,{className:"md_doc",text:s})})]}):null}const Av=10;function Rv(a){const{gateway:s,gateway_connected:r}=a,l=md("(max-width: 900px)"),[c,f]=h.useState("list"),[d,p]=h.useState(null);async function _(){try{const L=await s.admin_executors(),W=Array.isArray(L)?L:Array.isArray(L==null?void 0:L.executors)?L.executors:[];p(W)}catch{p(null)}}h.useEffect(()=>{if(!r){p(null);return}_()},[s,r]);const y=fd({gateway:s,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:l,set_compact_pane:f,on_status_transfer:()=>{I()}}),[b,x]=h.useState([]),[N,C]=h.useState("");async function I(){if(r)try{const L=await s.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),W=Array.isArray(L==null?void 0:L.requests)?L.requests:[];W.sort((X,M)=>{const ue=String(X.finished_at||X.started_at||X.created_at||"");return String(M.finished_at||M.started_at||M.created_at||"").localeCompare(ue)}),x(W.slice(0,Av)),C("")}catch(L){C(String((L==null?void 0:L.message)||L||"Failed to load recent executions"))}}h.useEffect(()=>{if(!r)return;(async()=>{var M;const W=await y.refresh_exec_list("processing");await I();const X=String(a.focus_request_id||"").trim();if(X){const ue=W.find(V=>V.request_id===X);if(ue)await y.load_exec_request(ue);else try{const V=await s.backlog_exec_request(X);V!=null&&V.payload&&await y.load_exec_request({request_id:X,status:String(V.payload.status||"unknown")})}catch{}(M=a.on_focus_consumed)==null||M.call(a)}})();const L=setInterval(()=>{s.is_backing_off()||I()},15e3);return()=>clearInterval(L)},[r,a.focus_request_id]);const E=y.exec_requests.some(L=>String(L.status||"").toLowerCase()==="running"),[,P]=h.useState(0);h.useEffect(()=>{if(!E)return;const L=setInterval(()=>P(W=>(W+1)%3600),1e3);return()=>clearInterval(L)},[E]);const U=y.exec_requests,D=h.useMemo(()=>{let L=0,W=0,X=0;for(const M of U){const ue=String(M.status||"").trim().toLowerCase();ue==="queued"?L+=1:ue==="running"?W+=1:ue==="awaiting_qa"&&(X+=1)}return{queued:L,running:W,awaiting:X}},[U]),F=y.exec_cfg,Q=!!(F!=null&&F.runner_alive),$=String((F==null?void 0:F.executor)||"").trim(),Z=!$||$==="none",oe=Z?"execution agent":$,le=!!(F!=null&&F.can_execute),pe=xi(y.exec_error)||xi(N),[Ae,Me]=h.useState(0),ve=ud(s,r&&pe,Ae),ce=!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 ${le?"ok":"warn"}`,title:F.codex_model?`${oe}: ${F.codex_model}${F.codex_reasoning_effort?` (reasoning ${F.codex_reasoning_effort})`:""}`:void 0,children:[Z?"no execution agent":`${oe} worker ${Q?"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)."}),!pe&&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(at,{name:"refresh",size:16})})]}),r&&F&&!le&&!pe?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(at,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[Z?d!=null&&d.length?"No default executor selected":"No execution agent on this gateway":Q?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:Z?"setup required":Q?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!Z)return F.runner_error?`The worker reports: ${F.runner_error} — new executions queue until it comes back.`:Q?"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(!(d!=null&&d.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const L=d.map(M=>M.display||M.id),W=L.slice(0,4).join(", ")+(L.length>4?` +${L.length-4} more`:"");return d.some(M=>M.available!==!1)?`The gateway's registry serves ${d.length} executor${d.length===1?"":"s"} (${W}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${d.length} executor${d.length===1?"":"s"} (${W}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(d!=null&&d.length)||!d.some(L=>L.available!==!1))&&(Z||!Q)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
84
- abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
85
- # 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,pe?e.jsx(dd,{gateway:s,surface:"the execution pipeline",status:ve.status,legacy:ve.legacy,error:xi(y.exec_error)?y.exec_error:N,on_changed:()=>{Me(L=>L+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 ${le?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:le?"on":Z?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[oe,Z?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[ce?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:U.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:U.length?U.map(L=>{var R;const W=String(L.status||"").trim().toLowerCase(),X=Tl(L),M=((R=y.exec_selected)==null?void 0:R.request_id)===L.request_id,ue=W==="running"&&L.started_at?Math.max(0,Date.now()-Date.parse(L.started_at)):null,V=String(L.backlog_filename||L.backlog_relpath||"").trim(),j=L.target_agent||(L.target_model?`${String(L.executor_type||"agent").trim()||"agent"}:${L.target_model}`:"");return e.jsxs("button",{className:`run_card ${M?"selected":""} ${W==="running"?"is_running":""}`,onClick:()=>void y.load_exec_request(L),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:V,children:V||`request ${fa(L.request_id,12)}`}),e.jsx("span",{className:`chip mono ${Cl(W)}`,children:W||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:ue!==null?`running ${Os(ue)}`:X.queue_delay_ms!=null?`queued ${Os(X.queue_delay_ms)}`:" "}),j?e.jsx("span",{className:"chip mono muted",children:j}):null,e.jsx("span",{className:"run_card_id mono",children:fa(L.request_id,14)})]})]},L.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&&!pe?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(L=>{var V;const W=String(L.status||"").trim().toLowerCase(),X=Tl(L),M=((V=y.exec_selected)==null?void 0:V.request_id)===L.request_id,ue=fa(L.backlog_filename||L.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${M?"selected":""}`,onClick:()=>void y.load_exec_request(L),title:String(L.backlog_filename||L.backlog_relpath||L.request_id),children:[e.jsx("span",{className:`chip mono ${Cl(W)}`,children:W||"?"}),e.jsx("span",{className:"recent_row_name",children:ue}),e.jsx("span",{className:"recent_row_time mono",children:X.run_ms!=null?Os(X.run_ms):""})]},`recent:${L.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 ${Cl(String(y.exec_selected.status||"").toLowerCase())}`,children:String(y.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:fa(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(kv,{pipeline:y,is_compact_layout:l,on_back_to_list:()=>f("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 Au(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Lv(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 Nf(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),f=s(l);if(c!==f)return c-f;const d=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 d<p?-1:d>p?1:0})}function Mv(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 zv({gateway:a,gateway_connected:s}){const[r,l]=h.useState("prod"),[c,f]=h.useState(null),[d,p]=h.useState([]),[_,y]=h.useState(!1),[b,x]=h.useState(""),[N,C]=h.useState(!1),[I,E]=h.useState(null),[P,U]=h.useState([]),[D,F]=h.useState(!1),[Q,$]=h.useState(""),[Z,oe]=h.useState({}),[le,pe]=h.useState(!1),[Ae,Me]=h.useState(null),[ve,ce]=h.useState(""),[q,L]=h.useState(""),[W,X]=h.useState(!1),M=h.useRef(null),ue=h.useMemo(()=>Nf(d.filter(se=>!String((se==null?void 0:se.id)||"").trim().endsWith("_uat"))),[d]),V=h.useMemo(()=>Nf(d.filter(se=>String((se==null?void 0:se.id)||"").trim().endsWith("_uat"))),[d]),j=r==="uat"?V:ue,R=h.useCallback(async()=>{if(s){y(!0),x("");try{const se=await a.list_processes();f(!!(se!=null&&se.enabled));const ye=Array.isArray(se==null?void 0:se.processes)?se.processes:[];p(ye)}catch(se){x(String((se==null?void 0:se.message)||se||"Failed to list processes"))}finally{y(!1)}}},[a,s]),ee=h.useCallback(async()=>{if(s){F(!0),$("");try{const se=await a.list_process_env_vars();E(!!(se!=null&&se.enabled));const ye=Array.isArray(se==null?void 0:se.vars)?se.vars:[];U(ye);const ge=String((se==null?void 0:se.error)||"").trim();ge&&$(ge)}catch(se){$(String((se==null?void 0:se.message)||se||"Failed to list env vars"))}finally{F(!1)}}},[a,s]),_e=h.useCallback(async()=>{if(!s)return;const se=Ae;if(se){X(!0);try{const ye=await a.process_log_tail(String(se.id||""),{max_bytes:16e4}),ge=String((ye==null?void 0:ye.content)||""),qe=typeof(ye==null?void 0:ye.bytes)=="number"?Number(ye.bytes):0,Ye=!!(ye!=null&&ye.truncated),ie=String((ye==null?void 0:ye.log_relpath)||"");ce(ge),L(`${qe.toLocaleString()} bytes${Ye?" (tail)":""}${ie?` • ${ie}`:""}`)}catch(ye){ce(""),L(String((ye==null?void 0:ye.message)||ye||"Failed to read logs"))}finally{X(!1)}}},[a,s,Ae]),he=h.useCallback(async se=>{Me(se),pe(!0)},[]),O=h.useCallback(()=>{pe(!1),Me(null),ce(""),L("")},[]);h.useEffect(()=>{s&&R()},[s,R]),h.useEffect(()=>{if(!s||r==="env"||!N)return;const se=window.setInterval(()=>{a.is_backing_off()||R()},2e3);return()=>window.clearInterval(se)},[s,r,N,R,a]),h.useEffect(()=>{s&&r==="env"&&ee()},[s,r,ee]),h.useEffect(()=>{if(s&&le)return _e(),M.current&&window.clearInterval(M.current),M.current=window.setInterval(()=>{a.is_backing_off()||_e()},1500),()=>{M.current&&window.clearInterval(M.current),M.current=null}},[s,le,_e]);const je=h.useRef(!1),[te,ke]=h.useState(!1);async function Ce(se,ye){if(!je.current){je.current=!0,ke(!0),x("");try{ye==="start"?await a.start_process(se.id):ye==="stop"?await a.stop_process(se.id):ye==="restart"?await a.restart_process(se.id):ye==="redeploy"&&await a.redeploy_process(se.id),await R()}catch(ge){x(String((ge==null?void 0:ge.message)||ge||`Failed to ${ye}`))}finally{je.current=!1,ke(!1)}}}async function We(se){const ye=String(se||"").trim();if(ye){$("");try{const ge=String((Z==null?void 0:Z[ye])??""),qe=await a.update_process_env_vars({set:{[ye]:ge}});E(!!(qe!=null&&qe.enabled)),U(Array.isArray(qe==null?void 0:qe.vars)?qe.vars:[]),oe(ie=>({...ie||{},[ye]:""}));const Ye=String((qe==null?void 0:qe.error)||"").trim();Ye&&$(Ye)}catch(ge){$(String((ge==null?void 0:ge.message)||ge||"Failed to set env var"))}}}async function me(se){const ye=String(se||"").trim();if(ye){$("");try{const ge=await a.update_process_env_vars({unset:[ye]});E(!!(ge!=null&&ge.enabled)),U(Array.isArray(ge==null?void 0:ge.vars)?ge.vars:[]),oe(Ye=>({...Ye||{},[ye]:""}));const qe=String((ge==null?void 0:ge.error)||"").trim();qe&&$(qe)}catch(ge){$(String((ge==null?void 0:ge.message)||ge||"Failed to unset env var"))}}}const Re=c===null?"…":c?"enabled":"disabled",Pe=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 ",Re]}):null,s&&r==="env"?e.jsxs("span",{className:`chip mono ${I===!1?"warn":"muted"}`,children:["env ",Pe]}):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:se=>C(!!se.target.checked)}),"auto"]}),e.jsxs("button",{className:`btn btn_icon ${_?"is_loading":""}`,onClick:()=>void R(),disabled:!s||_,children:[e.jsx(at,{name:"refresh",size:16}),_?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${D?"is_loading":""}`,onClick:()=>void ee(),disabled:!s||D,children:[e.jsx(at,{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"&&Q?e.jsx("div",{className:"page_error mono",children:Q}):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:j.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[j.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."]}),j.map(se=>{const ye=String(se.id||"").trim(),ge=String(se.label||ye).trim()||ye,qe=Lv(String(se.status||"")),ie=String(se.status||"").trim().toLowerCase()==="running",fe=Array.isArray(se==null?void 0:se.actions)?se.actions.map(yt=>String(yt||"").trim()):[],be=fe.includes("start"),G=fe.includes("stop"),Se=fe.includes("restart"),Xe=fe.includes("redeploy"),J=fe.includes("logs"),A=typeof(se==null?void 0:se.pid)=="number"?Number(se.pid):null,Y=String((se==null?void 0:se.url)||"").trim(),Ne=String((se==null?void 0:se.description)||"").trim(),ze=String((se==null?void 0:se.last_error)||"").trim(),Ke=typeof(se==null?void 0:se.exit_code)=="number"?Number(se.exit_code):null,tt=[];A&&tt.push(`pid ${A}`),Ke!==null&&tt.push(`exit ${Ke}`);const dt=tt.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:ge}),e.jsx("span",{className:`chip mono ${qe.cls}`,children:qe.label}),e.jsx("span",{className:"chip mono muted",children:ye}),dt?e.jsx("span",{className:"entity_card_sub mono",children:dt}):null]}),Ne?e.jsx("div",{className:"entity_card_sub mono",children:Au(Ne,220)}):null,Y?e.jsx("div",{className:"entity_card_sub mono",children:ie?e.jsx("a",{href:Y,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:Y}):e.jsx("span",{className:"mono",children:Y})}):null,ze?e.jsx("div",{className:"page_error mono",children:Au(ze,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[be?e.jsx("button",{className:"btn primary",onClick:()=>void Ce(se,"start"),disabled:_||te,children:"Start"}):null,G?e.jsx("button",{className:"btn danger",onClick:()=>void Ce(se,"stop"),disabled:_||te,children:"Stop"}):null,Se?e.jsx("button",{className:"btn",onClick:()=>void Ce(se,"restart"),disabled:_||te,children:"Restart"}):null,Xe?e.jsx("button",{className:"btn",onClick:()=>void Ce(se,"redeploy"),disabled:_||te,children:"Redeploy"}):null,J?e.jsx("button",{className:"btn",onClick:()=>void he(se),disabled:_,children:"Logs"}):null]})]},ye)})]})]}):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:P.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:[P.map(se=>{const ye=String((se==null?void 0:se.key)||"").trim();if(!ye)return null;const ge=String((se==null?void 0:se.label)||ye).trim()||ye,qe=String((se==null?void 0:se.description)||"").trim(),Ye=String((se==null?void 0:se.source)||"").trim(),ie=!!(se!=null&&se.secret),fe=String((se==null?void 0:se.updated_at)||"").trim(),be=Mv(Ye),G=String((Z==null?void 0:Z[ye])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:ge}),e.jsx("span",{className:`chip mono ${be.cls}`,children:be.label}),e.jsx("span",{className:"chip mono muted",children:ye})]}),qe?e.jsx("div",{className:"entity_card_sub mono",children:Au(qe,280)}):null,fe?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",fe]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:G,onChange:Se=>oe(Xe=>({...Xe||{},[ye]:String(Se.target.value||"")})),placeholder:ie?"••••••••":"value",type:ie?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void We(ye),disabled:D,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void me(ye),disabled:D,children:"Unset"})]})]},`env:${ye}`)}),P.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,le&&Ae?e.jsxs(qa,{open:le,title:`${String(Ae.label||Ae.id||"logs").trim()||"Logs"}`,onClose:O,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 ${W?"is_loading":""}`,onClick:()=>void _e(),disabled:W,children:[e.jsx(at,{name:"refresh",size:16}),W?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{try{navigator.clipboard.writeText(ve||"")}catch{}},disabled:!ve,children:[e.jsx(at,{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:ve||"(no logs yet)"})]}):null]})})}function Cf(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function yl(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Ru(a){const s=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return s.length<=1?s[0]||"":s}function Pv(a){const s=a.gateway,[r,l]=h.useState([]),[c,f]=h.useState(""),[d,p]=h.useState(""),[_,y]=h.useState(""),[b,x]=h.useState("7d"),[N,C]=h.useState("unread"),[I,E]=h.useState(25),[P,U]=h.useState(!1),[D,F]=h.useState(!1),[Q,$]=h.useState(!1),[Z,oe]=h.useState(!1),[le,pe]=h.useState(""),[Ae,Me]=h.useState(""),[ve,ce]=h.useState(""),[q,L]=h.useState([]),[W,X]=h.useState(""),[M,ue]=h.useState(null),[V,j]=h.useState(!1),[R,ee]=h.useState(""),[_e,he]=h.useState(""),[O,je]=h.useState(""),[te,ke]=h.useState(""),[Ce,We]=h.useState(""),me=a.enabled,Re=h.useMemo(()=>(Array.isArray(r)?r:[]).map(Y=>({account:String((Y==null?void 0:Y.account)||"").trim(),can_read:(Y==null?void 0:Y.can_read)!==!1,can_send:(Y==null?void 0:Y.can_send)!==!1,label:""})).filter(Y=>!!Y.account),[r]),Pe=h.useMemo(()=>{const A=String(d||"").trim();return A&&Re.find(Y=>Y.account===A)||null},[Re,d]),se=!!(Pe!=null&&Pe.can_read),ye=!!(Pe!=null&&Pe.can_send),ge=h.useMemo(()=>Re.map(A=>{const Y=A.can_read?A.can_send?"":" (read-only)":" (send-only)";return{...A,label:`${A.account}${Y}`}}),[Re]);async function qe(){if(me){pe(""),U(!0);try{const A=await s.email_list_accounts();l(Array.isArray(A==null?void 0:A.accounts)?A.accounts:[]),f(String((A==null?void 0:A.default_account)||"").trim())}catch(A){pe(String((A==null?void 0:A.message)||A||"Failed to list email accounts")),l([]),f("")}finally{U(!1)}}}h.useEffect(()=>{qe()},[me]),h.useEffect(()=>{if(!me)return;const A=String(d||"").trim();if(A&&Re.some(Ne=>Ne.account===A))return;const Y=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(Y&&Re.some(Ne=>Ne.account===Y)){p(Y);return}if(c&&Re.some(Ne=>Ne.account===c)){p(c);return}Re.length&&p(Re[0].account)},[me,d,c,Re]),h.useEffect(()=>{const A=String(d||"").trim();A&&localStorage.setItem("abstractcontinuum_email_account",A)},[d]);async function Ye(){if(!me)return;const A=String(d||"").trim();if(A){if(!se){pe("Selected account is not allowed to read email."),L([]),X(""),ue(null);return}pe(""),F(!0);try{const Y=await s.email_list_messages({account:A,mailbox:String(_||"").trim()||void 0,since:String(b||"").trim()||void 0,status:N,limit:I}),Ne=Array.isArray(Y==null?void 0:Y.messages)?Y.messages:[];L(Ne);const ze=String(W||"").trim();ze&&!Ne.some(Ke=>String((Ke==null?void 0:Ke.uid)||"").trim()===ze)&&(X(""),ue(null))}catch(Y){pe(String((Y==null?void 0:Y.message)||Y||"Failed to list emails")),L([]),X(""),ue(null)}finally{F(!1)}}}h.useEffect(()=>{me&&String(d||"").trim()&&Ye()},[me,d]);async function ie(A){if(!me)return;const Y=String(d||"").trim(),Ne=String(A||"").trim();if(!(!Y||!Ne)&&se){X(Ne),ue(null),Me(""),$(!0);try{const ze=await s.email_read_message(Ne,{account:Y,mailbox:String(_||"").trim()||void 0,max_body_chars:2e4});ue(ze)}catch(ze){Me(String((ze==null?void 0:ze.message)||ze||"Failed to read email"))}finally{$(!1)}}}function fe(A){ce(""),ee(String((A==null?void 0:A.to)||"").trim()),he(""),je(""),ke(String((A==null?void 0:A.subject)||"").trim()),We(String((A==null?void 0:A.body)||"")),j(!0)}function be(){if(!M)return;const A=String((M==null?void 0:M.from)||"").trim(),Y=String((M==null?void 0:M.subject)||"").trim(),Ne=Y.toLowerCase().startsWith("re:")?Y:`Re: ${Y||"(no subject)"}`,ze=String((M==null?void 0:M.body_text)||"").trim(),Ke=`
86
-
87
- ---
88
- On ${Cf((M==null?void 0:M.date)||"")}, ${A} wrote:
89
-
90
- ${ze}`;fe({to:A,subject:Ne,body:Ke})}async function G(){if(!me||Z)return;const A=String(d||"").trim();if(A){if(!ye){ce("Selected account is not allowed to send email.");return}ce(""),oe(!0);try{const Y=Ru(R);if(!Y)throw new Error("to is required");const Ne=String(te||"").trim();if(!Ne)throw new Error("subject is required");const ze=String(Ce||"").trim();if(!ze)throw new Error("body is required");await s.email_send({account:A,to:Y,subject:Ne,body_text:ze,cc:Ru(_e),bcc:Ru(O)}),j(!1),ee(""),he(""),je(""),ke(""),We(""),await Ye()}catch(Y){ce(String((Y==null?void 0:Y.message)||Y||"Failed to send email"))}finally{oe(!1)}}}const Se=h.useMemo(()=>{const A=String(W||"").trim();return A&&q.find(Y=>String((Y==null?void 0:Y.uid)||"").trim()===A)||null},[q,W]),Xe=String((M==null?void 0:M.body_text)||"").trim()||String((M==null?void 0:M.body_html)||"").trim(),J=String((M==null?void 0:M.body_text)||"").trim()?"Body (text)":String((M==null?void 0:M.body_html)||"").trim()?"Body (html, raw)":"Body";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Email"}),e.jsx("span",{className:"pane_count",children:q.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:d,onChange:A=>p(String(A.target.value||"")),disabled:!me||P,children:ge.length?ge.map(A=>e.jsx("option",{value:A.account,children:A.label},A.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void qe(),disabled:!me||P,children:P?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ye(),disabled:!me||D||!String(d||"").trim()||!se,children:D?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>fe(),disabled:!me||!String(d||"").trim()||!ye,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:b,onChange:A=>x(String(A.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:N,onChange:A=>C(String(A.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(I),onChange:A=>E(Number(A.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:_,onChange:A=>y(String(A.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void Ye(),disabled:!me||D||!String(d||"").trim()||!se,children:"Apply"})})]}),le?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:le}):null,e.jsx("div",{className:"inbox_list",children:q.length?q.map((A,Y)=>{const Ne=String((A==null?void 0:A.uid)||"").trim(),ze=!!Ne&&Ne===String(W||"").trim(),Ke=String((A==null?void 0:A.subject)||"").trim()||"(no subject)",tt=String((A==null?void 0:A.from)||"").trim(),dt=String((A==null?void 0:A.date)||"").trim(),yt=!!(A!=null&&A.seen);return e.jsxs("button",{className:`inbox_item ${ze?"active":""}`,onClick:()=>void ie(Ne),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${yt?"approved":"pending"}`,children:yt?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:yl(Ke,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:yl(tt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[yl(dt,36)||"(date?)"," • uid ",yl(Ne,10)]})]},Ne||`idx:${Y}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane",children:e.jsx("div",{className:"pane_body",children:W?Q?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):Ae?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ae}):M?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((M==null?void 0:M.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((M==null?void 0:M.account)||"").trim()||d}),e.jsx("span",{className:"pill muted",children:String((M==null?void 0:M.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",yl(String((M==null?void 0:M.uid)||W),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>dn(String((M==null?void 0:M.message_id)||"")),disabled:!String((M==null?void 0:M.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>dn(String(W||"")),disabled:!String(W||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>be(),disabled:!ye||!String((M==null?void 0:M.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((M==null?void 0:M.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((M==null?void 0:M.to)||"").trim()||"(to?)"})]}),String((M==null?void 0:M.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((M==null?void 0:M.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:Cf(String((M==null?void 0:M.date)||(Se==null?void 0:Se.date)||"").trim())||String((M==null?void 0:M.date)||(Se==null?void 0:Se.date)||"").trim()||"(date?)"})]}),Array.isArray(M==null?void 0:M.attachments)&&M.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:M.attachments.map((A,Y)=>e.jsxs("div",{children:[String((A==null?void 0:A.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((A==null?void 0:A.content_type)||"").trim()?`(${String((A==null?void 0:A.content_type)||"").trim()})`:""})]},`${(A==null?void 0:A.filename)||""}:${Y}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:J}),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:Xe||"(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(qa,{open:V,title:`Compose (${String(d||"").trim()||"account"})`,onClose:()=>{Z||j(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[ve?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:ve}):null,e.jsx("button",{className:"btn",onClick:()=>j(!1),disabled:Z,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void G(),disabled:Z,children:Z?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:R,onChange:A=>ee(String(A.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:_e,onChange:A=>he(String(A.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:O,onChange:A=>je(String(A.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:te,onChange:A=>ke(String(A.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Ce,onChange:A=>We(String(A.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 $f(a){const s=String(a||"").trim();if(!s)return"";const r=s.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Uo(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function gi(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Iv(a){const s=a.gateway,r=!!a.enable_triage,[l,c]=h.useState(r?"messages":"email"),[f,d]=h.useState([]),[p,_]=h.useState([]),[y,b]=h.useState([]),[x,N]=h.useState(!1),[C,I]=h.useState(""),[E,P]=h.useState(null),[U,D]=h.useState(""),[F,Q]=h.useState(!1),[$,Z]=h.useState(""),[oe,le]=h.useState("pending"),[pe,Ae]=h.useState(null),[Me,ve]=h.useState(""),[ce,q]=h.useState(null),[L,W]=h.useState(""),[X,M]=h.useState(!1),[ue,V]=h.useState(!1),[j,R]=h.useState(""),[ee,_e]=h.useState(""),he=!!ee,[O,je]=h.useState(""),[te,ke]=h.useState(""),[Ce,We]=h.useState(""),[me,Re]=h.useState(!1),Pe=a.gateway_connected;h.useEffect(()=>{!r&&l!=="email"&&c("email")},[r,l]);const se=h.useMemo(()=>l==="bugs"?f:l==="features"?p:[],[l,f,p]);h.useEffect(()=>{l==="email"&&(I(""),N(!1))},[l]);async function ye(){const J=await s.list_bug_reports();d(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function ge(){const J=await s.list_feature_requests();_(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function qe(){const J=await s.list_triage_decisions({status:oe||void 0,limit:500}),A=Array.isArray(J==null?void 0:J.decisions)?J.decisions:[];b(A),pe&&!A.some(Y=>Y.decision_id===pe.decision_id)&&(Ae(null),ve(""),q(null),W(""))}async function Ye(){if(Pe&&r&&l!=="email"){I(""),N(!0);try{l==="bugs"?await ye():l==="features"?await ge():await qe()}catch(J){I(String((J==null?void 0:J.message)||J||"Refresh failed"))}finally{N(!1)}}}h.useEffect(()=>{Ye()},[l,Pe,oe,r]);async function ie(J){P(J),D(""),Z(""),Q(!0);try{if(J.report_type==="bug"){const A=await s.get_bug_report_content(J.filename);D(String((A==null?void 0:A.content)||""))}else{const A=await s.get_feature_request_content(J.filename);D(String((A==null?void 0:A.content)||""))}}catch(A){Z(String((A==null?void 0:A.message)||A||"Failed to load report"))}finally{Q(!1)}}async function fe(J){Ae(J),ve(""),q(null),W("");const A=$f(J.report_relpath);if(A)try{if(J.report_type==="bug"){const Y=await s.get_bug_report_content(A);ve(String((Y==null?void 0:Y.content)||""))}else if(J.report_type==="feature"){const Y=await s.get_feature_request_content(A);ve(String((Y==null?void 0:Y.content)||""))}}catch(Y){W(String((Y==null?void 0:Y.message)||Y||"Failed to load report"))}}async function be(J){W(""),q(null);const A=String(J.draft_relpath||"").trim();if(!A)return;const Y=$f(A);if(Y)try{const Ne=await s.backlog_content("proposed",Y);q(Ne)}catch(Ne){W(String((Ne==null?void 0:Ne.message)||Ne||"Failed to load draft (is repo root configured on gateway?)"))}}async function G(J,A){if(pe&&!X){W(""),M(!0);try{const Y=await s.apply_triage_decision(pe.decision_id,{action:J,defer_days:A??null});await qe();const Ne=String(oe||"").trim().toLowerCase(),ze=String((Y==null?void 0:Y.status)||"").trim().toLowerCase();if(!(!Ne||Ne===ze))Ae(null),ve(""),q(null);else if(Ae(Y),String(Y.draft_relpath||"").trim())try{await be(Y)}catch{}}catch(Y){W(String((Y==null?void 0:Y.message)||Y||"Decision action failed"))}finally{M(!1)}}}async function Se(){if(!ue){I(""),V(!0);try{const J=await s.triage_run({write_drafts:!1,enable_llm:!1});R(`Scanned ${(J==null?void 0:J.reports)??0} report(s); updated ${(J==null?void 0:J.updated_decisions)??0} decision(s).`),await qe()}catch(J){I(String((J==null?void 0:J.message)||J||"Triage failed"))}finally{V(!1)}}}h.useEffect(()=>{he&&(We(""),ke(""),Re(!1),je(String(a.default_session_id||"").trim()))},[he,a.default_session_id]);async function Xe(){var J,A;if(ee&&!me){We(""),Re(!0);try{const Y=String(O||"").trim();if(!Y)throw new Error("session_id is required");const Ne=String(te||"").trim();if(!Ne)throw new Error("description is required");const ze={session_id:Y,description:Ne,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(((J=globalThis==null?void 0:globalThis.navigator)==null?void 0:J.userAgent)||""),url:String(((A=globalThis==null?void 0:globalThis.location)==null?void 0:A.href)||"")};if(ee==="bug"){const Ke=await s.bug_report_create(ze),tt=String((Ke==null?void 0:Ke.filename)||"").trim();_e(""),c("bugs");const dt=await s.list_bug_reports(),yt=Array.isArray(dt==null?void 0:dt.items)?dt.items:[];d(yt);const pt=yt.find(Tt=>Tt.filename===tt)||null;pt&&await ie(pt)}else{const Ke=await s.feature_report_create(ze),tt=String((Ke==null?void 0:Ke.filename)||"").trim();_e(""),c("features");const dt=await s.list_feature_requests(),yt=Array.isArray(dt==null?void 0:dt.items)?dt.items:[];_(yt);const pt=yt.find(Tt=>Tt.filename===tt)||null;pt&&await ie(pt)}}catch(Y){We(String((Y==null?void 0:Y.message)||Y||"Failed to create report"))}finally{Re(!1)}}}return 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":l==="messages",className:`seg_btn ${l==="messages"?"active":""}`,onClick:()=>c("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":l==="email",className:`seg_btn ${l==="email"?"active":""}`,onClick:()=>c("email"),children:"Email"}),e.jsx("button",{"aria-pressed":l==="bugs",className:`seg_btn ${l==="bugs"?"active":""}`,onClick:()=>c("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":l==="features",className:`seg_btn ${l==="features"?"active":""}`,onClick:()=>c("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":l==="email",className:`seg_btn ${l==="email"?"active":""}`,onClick:()=>c("email"),children:"Email"})}),r&&l!=="email"&&j?e.jsx("span",{className:"page_hint mono",children:j}):null,r&&l!=="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:[l==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:oe,onChange:J=>le(String(J.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 Ye(),disabled:!Pe||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void Se(),disabled:!Pe||ue,children:ue?"Running…":"Run triage"})]}):l==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void Ye(),disabled:!Pe||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>_e("bug"),disabled:!Pe,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>_e("feature"),disabled:!Pe,children:"File feature"})]}):null]}),l==="email"?e.jsx(Pv,{gateway:s,enabled:Pe}):e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:l==="messages"?"Triage decisions":l==="bugs"?"Bug reports":"Feature requests"}),e.jsx("span",{className:"pane_count",children:l==="messages"?y.length:se.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:l==="messages"?e.jsx(e.Fragment,{children:y.length?y.map(J=>{const A=(pe==null?void 0:pe.decision_id)===J.decision_id,Y=Array.isArray(J.missing_fields)?J.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${A?"active":""}`,onClick:()=>void fe(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(J.status||"").toLowerCase()}`,children:String(J.status||"pending")}),e.jsx("span",{className:"mono",children:J.report_type}),e.jsx("span",{className:"mono muted",children:gi(J.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Y?`${Y} missing`:"complete"," • ",Uo(J.updated_at||J.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:gi(J.report_relpath||"",46)})]},J.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:se.length?se.map(J=>{const A=(E==null?void 0:E.filename)===J.filename&&(E==null?void 0:E.report_type)===J.report_type,Y=String(J.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${A?"active":""}`,onClick:()=>void ie(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[Y?e.jsx("span",{className:`pill ${Y}`,children:Y}):null,e.jsx("span",{className:"mono",children:gi(J.title||J.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Uo(J.created_at)||"(time?)"," • ",J.session_id?gi(J.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:J.filename})]},J.relpath)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})})]}),e.jsx("div",{className:"pane",children:e.jsx("div",{className:"pane_body",children:l==="messages"?pe?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:pe.report_type}),e.jsx("span",{className:"chip mono muted",children:pe.status}),e.jsx("span",{className:"chip mono muted",children:gi(pe.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{dn(pe.report_relpath||"")},children:"Copy report path"}),pe.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void be(pe),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void G("approve"),disabled:X,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void G("defer",1),disabled:X,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void G("defer",7),disabled:X,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void G("reject"),disabled:X,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[pe.updated_at?`updated ${Uo(pe.updated_at)}`:null,pe.created_at?`${pe.updated_at?" • ":""}created ${Uo(pe.created_at)}`:null,pe.defer_until?` • defer until ${pe.defer_until}`:null]}),L?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:L}):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"}),pe.missing_fields&&pe.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:pe.missing_fields.map(J=>e.jsx("li",{children:J},J))}):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"}),pe.duplicates&&pe.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:pe.duplicates.slice(0,20).map((J,A)=>{const Y=String((J==null?void 0:J.title)||(J==null?void 0:J.ref)||(J==null?void 0:J.kind)||"duplicate").trim(),Ne=typeof(J==null?void 0:J.score)=="number"&&Number.isFinite(J.score)?` (score ${J.score.toFixed(2)})`:"";return e.jsxs("li",{children:[Y,Ne]},`${Y}_${A}`)})}):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"}),pe.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:pe.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)."})]})]}),ce?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(rs,{className:"md_doc",text:String(ce.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),Me?e.jsx(rs,{className:"md_doc",text:Me}):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."}):E?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:E.report_type==="bug"?"Bug report":"Feature request"}),E.triage_status?e.jsx("span",{className:`pill ${E.triage_status}`,children:E.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:E.filename}),E.session_id?e.jsx("span",{className:"chip mono muted",children:gi(E.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{dn(E.relpath||"")},children:"Copy path"})})]}),$?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:$}):null,F?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):U?e.jsx(rs,{className:"md_doc",text:U}):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(qa,{open:he,title:ee==="bug"?"File bug report":"File feature request",onClose:()=>_e(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>_e(""),disabled:me,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Xe(),disabled:me,children:me?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:O,onChange:J=>je(J.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:ee==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:te,onChange:J=>ke(J.target.value),placeholder:ee==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Ce?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ce}):null]})]})}const Ov="/api/continuum/settings";async function Eh(a){const s=await fetch(Ov,{...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:"",f=new Error(c||`settings unavailable (HTTP ${s.status})`);throw f.status=s.status,f}return l}function Dv(){return Eh()}function Fv(a,s){return Eh({method:"PUT",body:JSON.stringify({[a]:s})})}const Th="abstractcontinuum_voice_override_v1",Lu={enabled:!1};function Zu(){try{const a=localStorage.getItem(Th);if(!a)return{...Lu};const s=JSON.parse(a);return!s||typeof s!="object"?{...Lu}:{enabled:!!s.enabled,provider:Is(s.provider),model:Is(s.model),profile:Is(s.profile),voice:Is(s.voice),quality_preset:Is(s.quality_preset)}}catch{return{...Lu}}}const ed="abstractcontinuum:voice_override_changed";function qv(a){try{localStorage.setItem(Th,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(ed))}catch{}}function Ah(a){if(!a)return{};const s={},r=Is(a.quality_preset);if(r&&(s.quality_preset=r),!a.enabled)return s;for(const l of["provider","model","profile","voice"]){const c=Is(a[l]);c&&(s[l]=c)}return s}function Is(a){return String(a??"").trim()||void 0}function Rh(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={},f=Is(l.provider),d=Is(l.model),p=l.options,_=p&&typeof p=="object"?Is(p.voice):void 0;return f&&(c.provider=f),d&&(c.model=d),_&&(c.voice=_),c}function Bv(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 xl={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function Uv(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 f=String(r.provider||"").trim(),d=String(r.id||r.voice||r.name||"").trim();if(!d)continue;const p=f||"*";(s[p]||(s[p]=[])).push(d)}for(const r of Object.keys(s))s[r]=[...new Set(s[r])];return s}function td(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 Mu(a){const s={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,l]of Object.entries(a)){const c=td(l);c.length&&(s[String(r)]=c)}return s}function Wv(a){const{gateway:s,gateway_connected:r}=a,[l,c]=h.useState(()=>Zu()),[f,d]=h.useState(xl),[p,_]=h.useState(!1),[y,b]=h.useState(""),x=h.useRef(null),N=h.useCallback(F=>{c(Q=>{const $={...Q,...F};return qv($),$})},[]);h.useEffect(()=>{if(!r){d(xl);return}if(typeof(s==null?void 0:s.voice_voices)!="function"){d(xl);return}let F=!0;d($=>({...$,loading:!0,error:""}));let Q;try{Q=s.voice_voices()}catch($){d({...xl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")});return}return Q.then($=>{if(!F)return;const Z=[...new Set([...td($==null?void 0:$.providers),...td($==null?void 0:$.tts_providers)])];d({loading:!1,error:"",providers:Z,models_by_provider:Mu($==null?void 0:$.tts_models_by_provider),profiles_by_provider:Mu($==null?void 0:$.tts_profiles_by_provider),voices_by_provider:Mu($==null?void 0:$.tts_voices_by_provider),cloned_by_provider:Uv($==null?void 0:$.items)})}).catch($=>{F&&d({...xl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")})}),()=>{F=!1}},[s,r]);const C=l.provider||"",I=C&&f.models_by_provider[C]?f.models_by_provider[C]:[],E=C&&f.voices_by_provider[C]?f.voices_by_provider[C]:[],P=C&&f.profiles_by_provider[C]?f.profiles_by_provider[C]:[],U=[...C&&f.cloned_by_provider[C]?f.cloned_by_provider[C]:[],...f.cloned_by_provider["*"]||[]];async function D(){if(!(p||!r)){_(!0),b("");try{const F=await ld("abstractcontinuum_team_voice");let Q={};if(typeof s.capability_defaults=="function")try{Q=Rh(await s.capability_defaults())}catch{Q={}}const $=await s.voice_tts(F,{text:"This is the voice AbstractContinuum will use to read your messages.",...Q,...Ah(l),timeout_s:30}),Z=$==null?void 0:$.audio_artifact,oe=Z&&typeof Z=="object"?String(Z.$artifact||"").trim():"";if(!oe)throw new Error("no audio returned");const le=await s.download_run_artifact_content(F,oe),pe=URL.createObjectURL(le);if(x.current)try{x.current.pause()}catch{}const Ae=x.current;if(Ae){try{Ae.pause()}catch{}const ve=Ae.src;ve.startsWith("blob:")&&URL.revokeObjectURL(ve)}const Me=new Audio(pe);x.current=Me,Me.onended=()=>{URL.revokeObjectURL(pe),b("")};try{await Me.play(),b("Playing…")}catch(ve){b(String((ve==null?void 0:ve.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((ve==null?void 0:ve.message)||ve).slice(0,80)}`),URL.revokeObjectURL(pe)}}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"]}),f.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",f.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,f.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,l.enabled&&!C&&(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(Wo,{value:C,options:f.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(Wo,{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(Wo,{value:l.profile||"",options:P,placeholder:"default",onChange:F=>N({profile:F})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(Wo,{value:l.voice||"",options:[...U,...E],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 Wo(a){const s=Ht.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 Hv=["minimal","low","medium","high","xhigh"];function Vv(a){const{gateway:s,connected:r,model:l,value:c,onChange:f}=a,[d,p]=h.useState({state:"unknown",levels:[]}),[_,y]=h.useState(!1);if(h.useEffect(()=>{y(!1);const N=String(l||"").trim();if(!N||!r){p({state:"unknown",levels:[]});return}let C=!1;return p({state:"loading",levels:[]}),s.discovery_model_capabilities(N).then(I=>{if(C)return;const E=I!=null&&I.capabilities&&typeof I.capabilities=="object"?I.capabilities:{},P=E.thinking_support,U=Array.isArray(E.reasoning_levels)?E.reasoning_levels.map(D=>String(D)):[];p(P===!0?{state:"supported",levels:U}:P===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{C||p({state:"unknown",levels:[]})}),()=>{C=!0}},[l,r]),!String(l||"").trim())return null;const b=d.state==="unsupported"||d.state==="unknown"&&!_||d.state==="loading",x=d.state==="supported"&&d.levels.length?d.levels:d.state==="unknown"&&_?[...Hv]:[];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=>f(String(N.target.value||"")),disabled:b,title:d.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":d.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":d.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:d.state==="unsupported"?"none — this model doesn't reason":d.state==="loading"?"checking…":d.state==="unknown"&&!_?"unknown — no served facts":"gateway default"}),x.map(N=>e.jsx("option",{value:N,children:N},N))]}),d.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,d.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||f("")}}),"set anyway (I know this model reasons)"]}):null]})}function Gv(a){const[s,r]=h.useState(!1),[l,c]=h.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:f=>c(f.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 Kv(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,f]=r[s]||[s,"muted",""];return e.jsx("span",{className:`chip mono ${c}`,title:f,"data-testid":"hub_seat_source",children:l})}function Qv(){var I;const[a,s]=h.useState(null),[r,l]=h.useState(""),[c,f]=h.useState(""),[d,p]=h.useState(!1),[_,y]=h.useState("");h.useEffect(()=>{let E=!1;return Dv().then(P=>{var U;E||(s(P),f(String(((U=P.settings.hub_seat)==null?void 0:U.value)??"")))}).catch(P=>{E||l(String((P==null?void 0:P.message)||P))}),()=>{E=!0}},[]);async function b(E){var P;p(!0),y("");try{const U=await Fv("hub_seat",E);s(U),f(String(((P=U.settings.hub_seat)==null?void 0:P.value)??""))}catch(U){y(String((U==null?void 0:U.message)||U||"Save refused"))}finally{p(!1)}}const x=a==null?void 0:a.settings.hub_seat,N=String((x==null?void 0:x.value)??""),C=!!((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}),Kv(x==null?void 0:x.source),e.jsx("div",{className:"admin_row_action",children:C?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono","aria-label":"Hub seat",value:c,onChange:E=>f(E.target.value),placeholder:"your seat",disabled:d}),e.jsx("button",{className:"btn primary",disabled:d||!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:d,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 Jv(a){var ve,ce;const{gateway:s,gateway_connected:r,settings:l,set_settings:c}=a,f=(ce=(ve=a.connection)==null?void 0:ve.gateway)==null?void 0:ce.principal,[d,p]=h.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[_,y]=h.useState(null),[b,x]=h.useState(null),[N,C]=h.useState(!1),[I,E]=h.useState(null),[P,U]=h.useState([]),[D,F]=h.useState(""),[Q,$]=h.useState(!1),[Z,oe]=h.useState(0);async function le(q){if(!Q){$(!0),F("");try{const L=await s.admin_runtime_config_update(q);y(L),oe(W=>W+1)}catch(L){F(String((L==null?void 0:L.message)||L||"Config update refused"))}finally{$(!1)}}}h.useEffect(()=>{if(!r)return;let q=!1;return(async()=>{var W;const L={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const X=await s.backlog_exec_config(),M=!!(X!=null&&X.runner_enabled),ue=!!(X!=null&&X.runner_alive),V=(X==null?void 0:X.can_execute)===!0;L.exec_pipeline=V?"on":M||ue?"degraded":"off",L.exec_detail=V?"":M?ue?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",L.executor=String((X==null?void 0:X.executor)||"").trim()}catch{L.exec_pipeline=null}try{const X=await s.admin_runtime_config();if(X&&typeof X=="object"){q||(y(X),L.process_manager=_i(X.process_manager),L.backlog_root=((W=X.triage_repo_root)==null?void 0:W.available)!==void 0?!!X.triage_repo_root.available:_i(X.triage_repo_root),p(L));return}}catch{}try{const X=await s.list_processes();L.process_manager=!!(X!=null&&X.enabled)}catch{L.process_manager=null}try{await s.backlog_template(),L.backlog_root=!0}catch(X){L.backlog_root=xi(X)?!1:null}q||p(L)})(),(async()=>{try{const L=await s.admin_data_homes();q||(E(Array.isArray(L==null?void 0:L.homes)?L.homes:[]),U(Array.isArray(L==null?void 0:L.warnings)?L.warnings:[]))}catch{q||E(null)}})(),(async()=>{try{const L=await s.list_bundles(),W=Array.isArray(L==null?void 0:L.items)?L.items:Array.isArray(L==null?void 0:L.bundles)?L.bundles:Array.isArray(L)?L:[],X=[];for(const V of W){const j=String((V==null?void 0:V.bundle_id)||(V==null?void 0:V.id)||"").trim();if(!j)continue;const R=Array.isArray(V==null?void 0:V.entrypoints)?V.entrypoints:[];for(const ee of R){if((ee==null?void 0:ee.deprecated)===!0||!(Array.isArray(ee==null?void 0:ee.interfaces)?ee.interfaces:[]).some(O=>String(O||"").trim().length>0))continue;const he=String((ee==null?void 0:ee.name)||"").trim();X.push({id:j,name:he?`${j} · ${he}`:j,description:String((ee==null?void 0:ee.description)||"").trim()||void 0})}}const M=new Set,ue=X.filter(V=>M.has(V.id)?!1:(M.add(V.id),!0));ue.sort((V,j)=>V.name.localeCompare(j.name)),q||x(ue)}catch{q||x(null)}})(),()=>{q=!0}},[s,r,Z]);function pe(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 Ae(q,L="on",W="off"){return q===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${q?"ok":"warn"}`,children:q?L:W})}function Me(q){const L=String(q||"").trim();if(!L)return null;const W={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."]},[X,M,ue]=W[L]||[L,"muted",""];return e.jsx("span",{className:`chip mono ${M}`,title:ue,"data-testid":"source_chip",children:X})}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(L=>({...L,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(Op,{disabled:!r,value:{provider:l.maintenance_ai_provider,model:l.maintenance_ai_model},onChange:q=>c(L=>({...L,maintenance_ai_provider:q.provider,maintenance_ai_model:q.model,maintenance_ai_reasoning:q.model===L.maintenance_ai_model?L.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const q=await s.discovery_providers();return(Array.isArray(q==null?void 0:q.items)?q.items:[]).map(L=>({name:L.name,display_name:L.display_name}))},fetchModels:async q=>{const L=await s.discovery_provider_models(q);return Array.isArray(L==null?void 0:L.models)?L.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(Vv,{gateway:s,connected:r,model:l.maintenance_ai_model,value:l.maintenance_ai_reasoning,onChange:q=>c(L=>({...L,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(L=>({...L,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(),L=q===""||b.some(W=>W.id===q);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:L&&!N?q:"__custom__",onChange:W=>{const X=W.target.value;X==="__custom__"?C(!0):(C(!1),c(M=>({...M,backlog_advisor_agent:X})))},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(W=>e.jsx("option",{value:W.id,title:W.description||void 0,children:W.name||W.id},W.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!L||N?e.jsx("input",{className:"mono",style:{marginTop:6},value:l.backlog_advisor_agent,onChange:W=>c(X=>({...X,backlog_advisor_agent:String(W.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(Wv,{gateway:s,gateway_connected:r}),e.jsx(Qv,{}),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:[f!=null&&f.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:f.user_id}),f.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):f.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 W,X,M,ue,V,j,R,ee,_e;const q=(_==null?void 0:_.writable)===!0,L=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"}),Ae(d.backlog_root,"available","not available"),Me((W=_==null?void 0:_.triage_repo_root)==null?void 0:W.source),e.jsxs("div",{className:"admin_row_action",children:[q&&((X=_==null?void 0:_.triage_repo_root)!=null&&X.default_path)&&gl(_==null?void 0:_.triage_repo_root)!==_.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:Q,onClick:()=>{var he;return void le({triage_repo_root:((he=_==null?void 0:_.triage_repo_root)==null?void 0:he.default_path)||null})},title:_.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,q?e.jsx(Gv,{current:gl(_==null?void 0:_.triage_repo_root),busy:Q,on_apply:he=>void le({triage_repo_root:he})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((M=_==null?void 0:_.triage_repo_root)==null?void 0:M.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",gl(_==null?void 0:_.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:gl(_==null?void 0:_.triage_repo_root)})]}):null,((ue=_==null?void 0:_.triage_repo_root)==null?void 0:ue.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"}),d.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${d.exec_pipeline==="on"?"ok":"warn"}`,children:d.exec_pipeline}),Me((V=_==null?void 0:_.backlog_exec_runner)==null?void 0:V.source),e.jsx("div",{className:"admin_row_action",children:q?e.jsx("button",{className:"btn",disabled:Q,onClick:()=>void le({backlog_exec_runner:_i(_==null?void 0:_.backlog_exec_runner)!==!0}),children:_i(_==null?void 0:_.backlog_exec_runner)===!0?"Disable":"Enable"}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:[((j=_==null?void 0:_.backlog_exec_runner)==null?void 0:j.help)||"Runs the backlog items queued for execution on the gateway's computer.",d.exec_detail?e.jsxs(e.Fragment,{children:[" — ",d.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"}),d.executor&&d.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:d.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),Me((R=_==null?void 0:_.executor)==null?void 0:R.source),e.jsx("div",{className:"admin_row_action",children:q&&L.length?e.jsx("select",{value:gl(_==null?void 0:_.executor),disabled:Q,onChange:he=>void le({executor:String(he.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:L.map(he=>e.jsxs("option",{value:he.id,disabled:he.available===!1,children:[he.display||he.id,he.available===!1?" (unavailable)":""]},he.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"}),Ae(d.process_manager,"enabled","disabled"),Me((ee=_==null?void 0:_.process_manager)==null?void 0:ee.source),e.jsx("div",{className:"admin_row_action",children:q?e.jsx("button",{className:"btn",disabled:Q,onClick:()=>void le({process_manager:_i(_==null?void 0:_.process_manager)!==!0}),children:_i(_==null?void 0:_.process_manager)===!0?"Disable":"Enable"}):null})]}),e.jsx("div",{className:"admin_row_detail",children:((_e=_==null?void 0:_.process_manager)==null?void 0:_e.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,L)=>(L.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"}):pe(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))})]})}),P.map((q,L)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:q},`dhw:${L}`)),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 Yv=/^(```+|~~~+)\s*mermaid\s*$/i;function Xv(a){const s=String(a||"").split(`
91
- `),r=[];let l=[],c=0;for(;c<s.length;){const f=s[c].match(Yv);if(!f){l.push(s[c]),c+=1;continue}const d=f[1];let p=-1;for(let _=c+1;_<s.length;_++){const y=s[_].trimEnd();if(y.startsWith(d[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(y)&&y[0]===d[0]){p=_;break}}if(p===-1){l.push(s[c]),c+=1;continue}l.length&&(r.push({kind:"md",text:l.join(`
92
- `)}),l=[]),r.push({kind:"mermaid",text:s.slice(c+1,p).join(`
93
- `)}),c=p+1}return l.length&&r.push({kind:"md",text:l.join(`
94
- `)}),r}const Zv="modulepreload",ey=function(a){return"/"+a},Ef={},ty=function(s,r,l){let c=Promise.resolve();if(r&&r.length>0){let d=function(y){return Promise.all(y.map(b=>Promise.resolve(b).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),_=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));c=d(r.map(y=>{if(y=ey(y),y in Ef)return;Ef[y]=!0;const b=y.endsWith(".css"),x=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${x}`))return;const N=document.createElement("link");if(N.rel=b?"stylesheet":Zv,b||(N.as="script"),N.crossOrigin="",N.href=y,_&&N.setAttribute("nonce",_),document.head.appendChild(N),b)return new Promise((C,I)=>{N.addEventListener("load",C),N.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${y}`)))})}))}function f(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return c.then(d=>{for(const p of d||[])p.status==="rejected"&&f(p.reason);return s().catch(f)})};let zu=null;function ny(){return zu||(zu=ty(()=>import("./mermaid.core-_-YW0o95.js").then(a=>a.bp),[]).then(a=>{const s=a.default||a;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),s})),zu}let sy=0;function ay(a){const s=h.useRef(null),[r,l]=h.useState("");return h.useEffect(()=>{let c=!0;return l(""),ny().then(async f=>{const d=`af_mermaid_${sy+=1}`,{svg:p}=await f.render(d,a.text);c&&s.current&&(s.current.innerHTML=p)}).catch(f=>{c&&l(String((f==null?void 0:f.message)||f||"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 ry=400;function iy(a){const s=new Map;for(const c of a)s.set(c.id,c);const r=c=>{let f=c,d=!1;const p=new Set([f.id]);for(let _=0;_<ry;_++){const y=String(f.reply_to||"");if(!y)break;const b=s.get(y);if(!b){d=f.id===c.id||d;break}if(p.has(b.id))break;p.add(b.id),f=b}return{root:f,orphan:d&&f.id===c.id}},l=new Map;for(const c of[...a].sort((f,d)=>(f.seq||0)-(d.seq||0))){const{root:f,orphan:d}=r(c);let p=l.get(f.id);p||(p={root:f,replies:[],orphan:f.id===c.id?d:!1,last_seq:f.seq||0},l.set(f.id,p)),c.id!==f.id&&(p.replies.push(c),p.last_seq=Math.max(p.last_seq,c.seq||0))}return[...l.values()].sort((c,f)=>c.last_seq-f.last_seq||(c.root.seq||0)-(f.root.seq||0))}const Tf=[{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 Lh(a,s,r){var c,f,d,p,_;if(a.retracted===!0)return s==="all"?!0:s==="unread"?!!((c=r.unread_seqs)!=null&&c.has(a.seq)||(f=r.unread_snapshot_seqs)!=null&&f.has(a.seq)):!1;const l=String(a.status||"").toLowerCase();switch(s){case"all":return!0;case"unread":return!!((d=r.unread_seqs)!=null&&d.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 Af(a,s,r){return s==="all"?a:a.filter(l=>[l.root,...l.replies].some(c=>Lh(c,s,r)))}function ly(a,s,r){return Lh(a,s,r)}function oy(a){const s={},r={};for(const l of a){const c=String(l.channel||"");if(!c)continue;const f=Number(l.seq);if(Number.isFinite(f)){const d=s[c]||(s[c]=new Set);if(d.has(f))continue;d.add(f)}r[c]=(r[c]||0)+1}return r}function cy(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 uy(a,s){const r={};for(const l of a){const c=String(l.channel||""),f=Number(l.seq);if(!c||!Number.isFinite(f))continue;const d=String(l.status||"").toLowerCase(),p=Array.isArray(l.to)&&s?l.to.includes(s):!1;(d==="open"||d==="blocked"||(d==="reply"||d==="fyi")&&p)&&(r[c]||(r[c]=new Set)).add(f)}return r}function dy(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);if(!l||!Number.isFinite(c))continue;const f=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||f==="interrupt")&&(s[l]||(s[l]=new Set)).add(c)}return s}function my(a,s){const r=s?s.replace(/\/+$/,"")+"/":"",l=new Map,c=[];for(const f of a){const d=String(f.path||"");if(!d.startsWith(r))continue;const p=d.slice(r.length);if(!p)continue;const _=p.indexOf("/");if(_===-1)c.push(f);else{const y=p.slice(0,_);l.set(y,(l.get(y)||0)+1)}}return{dirs:[...l.entries()].map(([f,d])=>({name:f,path:r+f,count:d})).sort((f,d)=>f.name.localeCompare(d.name)),leaves:c.sort((f,d)=>f.path.localeCompare(d.path))}}function Rf(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 fy(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function hy(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 f=s.get(c);(f===void 0||f!==String(l.sender||""))&&r.add(c)}return r}const py=/(?:^|[\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,_y=4;function gy(a){const s=[];for(const r of String(a||"").matchAll(py)){const l=r[1],c=r.index===void 0?-1:r.index,f=c>=0?String(a).slice(Math.max(0,c-12),c+1):"";if(!(f.includes("://")||f.includes("/api/"))&&(s.includes(l)||s.push(l),s.length>=_y))break}return s}function vy(a,s,r){var c,f;const l=a.split("/").pop()||a;if(s!=null&&s.has(a))return{kind:"fs",path:a,rewritten:!1};for(let d=0;d<r.length;d++)if(String(((c=r[d])==null?void 0:c.filename)||"")===a)return{kind:"attachment",attachment_index:d};if(s){const d=[];for(const p of s)(p===l||p.endsWith(`/${l}`))&&d.push(p);if(d.length===1)return{kind:"fs",path:d[0],rewritten:d[0]!==a}}for(let d=0;d<r.length;d++){const p=String(((f=r[d])==null?void 0:f.filename)||"");if(p&&(p===l||p.split("/").pop()===l))return{kind:"attachment",attachment_index:d}}return null}const Lf=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function Pu(a){const s=[];for(const l of a.matchAll(Lf)){const c=l[1].toLowerCase();s.includes(c)||s.push(c)}return{title:a.replace(Lf," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:s}}function Iu(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 Ou(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 Mf=400,zf=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Pf=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function yy(a){if(!a||a.length<Mf)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 f of c){if(/\n/.test(f)||f.length<Mf){r.push(f);continue}const d=f.split(/(`[^`\n]*`)/);let p=0;for(const _ of d)_.startsWith("`")||(p+=(_.match(zf)||[]).length+(_.match(Pf)||[]).length);if(p<2){r.push(f);continue}r.push(d.map(_=>_.startsWith("`")?_:_.replace(zf,`$1
95
-
96
- $2 `).replace(Pf,`$1
97
-
98
- `)).join(""))}}return r.join("")}const xy=/https?:\/\/[^\s<>()[\]{}"'`]+/g,by=/\.(png|jpe?g|gif|webp)$/i;function wy(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 jy(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]*?(?:```|$))/),f=[];for(let d=0;d<c.length;d++){const p=c[d];if(p.startsWith("```")){f.push(p);continue}const _=p.split(/(`[^`\n]*`)/);for(let y=0;y<_.length;y++){const b=_[y];if(b.startsWith("`")){f.push(b);continue}f.push(b.replace(xy,(x,N)=>{const C=b.slice(Math.max(0,N-2),N);if(C.endsWith("](")||C.endsWith("("))return x;const I=x.replace(/[.,;:!?]+$/,""),E=x.slice(I.length);let P="";try{P=new URL(I).pathname}catch{return x}const U=wy(I,r),D=by.test(P),F=U.startsWith("/")||l!==""&&U.startsWith(l+"/");return D&&F?`![image](${U})${E}`:`[${I}](${U})${E}`}))}}return f.join("")}const ky=/^\/api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function Sy(a){const s=a.trim();return s.startsWith("/api/")?/\s/.test(s)||s.includes("..")?!0:!ky.test(s):!1}function Nl(a){if(!a||!a.includes("/api/"))return a;const s=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(s,(r,l,c,f)=>Sy(String(f))?"`"+(String(c||"").trim()||String(f)).replace(/`/g,"")+" (blocked link)`":r)}function pd(a){let s=0;for(let r=0;r<a.length;r++)s=s*31+a.charCodeAt(r)>>>0;return s%360}const Ny=24e3,Cy=160;function If(a,s){var y,b,x,N;const r=Ny,l=Math.max(500,Math.floor(r/2)),c=[...a].sort((C,I)=>(C.seq||0)-(I.seq||0)),f=[];for(const C of c){const I=Array.isArray(C.to)&&C.to.length?` to=[${C.to.join(",")}]`:"",E=(b=(y=C.data)==null?void 0:y.asks)!=null&&b.length?` asks=${C.data.asks.map(F=>`${F.id}:"${F.text}"`).join("; ")}`:"",P=(N=(x=C.data)==null?void 0:x.answers)!=null&&N.length?` answers=[${C.data.answers.join(",")}]`:"",U=C.reply_to?` reply_to=${C.reply_to}`:"";let D=`#${C.seq} [${C.sender}] (${C.status})${I}${U}${E}${P}
99
- ${C.title?`title: ${C.title}
100
- `:""}${String(C.body||"").trim()}`;D.length>l&&(D=D.slice(0,l)+`
101
- [#TRUNCATION: message #${C.seq} clamped to fit the context budget]`),f.push(D)}let d=0,p=f.reduce((C,I)=>C+I.length+2,0);for(;f.length>1&&p>r-Cy;){const C=f.shift();p-=C.length+2,d++}return(d>0?`#TRUNCATION: the ${d} oldest message(s) were dropped to fit the context budget.
102
-
103
- `:"")+f.join(`
104
-
105
- `)}function $y(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 Ey(a,s){const r=Array.from(String(a??"")),l=(s??[]).filter(d=>Array.isArray(d)&&d.length>=2&&Number.isFinite(d[0])&&Number.isFinite(d[1])&&d[0]>=0&&d[1]>0).sort((d,p)=>d[0]-p[0]),c=[];let f=0;for(const[d,p]of l){if(d>=r.length)break;const _=Math.max(d,f),y=Math.min(d+p,r.length);y<=_||(_>f&&c.push({text:r.slice(f,_).join(""),hit:!1}),c.push({text:r.slice(_,y).join(""),hit:!0}),f=y)}return f<r.length&&c.push({text:r.slice(f).join(""),hit:!1}),!c.length&&r.length&&c.push({text:r.join(""),hit:!1}),c}const Ho=[{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"}],Ty=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Sr(a,s){const r=a.toLowerCase().split(".").pop()||"",l=String(s||"").toLowerCase();if(r==="md"||r==="markdown"||l==="text/markdown")return"md";if(Ty.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 Ay({url:a,name:s}){const[r,l]=Ht.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 Ry({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(qa,{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:Xv(a.text||"").map((l,c)=>l.kind==="mermaid"?e.jsx(ay,{text:l.text},c):e.jsx(rs,{className:"md_doc",text:Nl(l.text)},c))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(Ay,{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 Ly=Ht.memo(rs),My=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Of(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 Mh{constructor(s){this.value=s}}function Df(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 f=c[1]+(c[2]||""),p=parseInt(c[3],10)+1;let _;if(p<=-4||p>16){const y=f.length>1?`${f[0]}.${f.slice(1)}`:f[0],b=p-1,x=(b<0?"-":"+")+String(Math.abs(b)).padStart(2,"0");_=`${y}e${x}`}else p<=0?_="0."+"0".repeat(-p)+f:p>=f.length?_=f+"0".repeat(p-f.length)+".0":_=f.slice(0,p)+"."+f.slice(p);return(s?"-":"")+_}function nd(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof Mh){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Df(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):Df(a)}if(typeof a=="string")return Of(a);if(Array.isArray(a))return"["+a.map(nd).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Of(r)+":"+nd(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 Py(a,s,r){const l={};for(const c of My)c!=="channel"&&(l[c]=s[c]??null);return l.channel=r,typeof l.created_at=="number"&&(l.created_at=new Mh(l.created_at)),await zy(a+`
106
- `+nd(l))}async function Iy(a){const s=a.channel;let r="",l=0,c=0,f=null,d="";for(const _ of a.turns){if(_.hash===null||_.hash===void 0){l>0&&f===null&&(f=_.seq),c+=1,r="";continue}const y=await Py(r,_,s);y!==_.hash&&f===null&&(f=_.seq),r=_.hash,d=y,l+=1}const p=f===null&&String(a.head||"")!==d;return{ok:f===null&&!p,broken_at:f,head_mismatch:p,computed_head:d,hashed:l,legacy:c}}const Oy=5e3,Dy=6,ma=200,Fy=50,Vo=380,Ff=240,qf=2,qy=12,bl=8,Bf=16*1024*1024,By=new Set(["image/png","image/jpeg","image/gif","image/webp"]),$l=256*1024;function Uy(){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 Uf(){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 Go(a){return a.length<=$l?a:a.slice(0,$l)+`
107
-
108
- ---
109
- #TRUNCATION: preview clamped at ${Dn($l)} of ${Dn(a.length)} — download the file for the full content.`}function Du(a,s){try{return JSON.stringify(a)===JSON.stringify(s)}catch{return!1}}function Fu(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],f=s[l];if(!f||c.size!==f.size)return!1;for(const d of c)if(!f.has(d))return!1}return!0}function Dn(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 zh="abstractcontinuum_team_drafts_v1";function Wy(){try{const a=window.localStorage.getItem(zh),s=a?JSON.parse(a):{};return s&&typeof s=="object"?s:{}}catch{return{}}}function wl(a){try{window.localStorage.setItem(zh,JSON.stringify(a))}catch{}}const Ko="agora/0.4";function jl(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 kl(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function Wf(a){return{color:`hsl(${pd(a)}, 60%, 55%)`}}function Ia(a){const s=pd(a),r=s>=40&&s<=190?36:45;return{background:`hsl(${s}, 55%, ${r}%)`,color:"#fff"}}const yi=[{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."}],Hy=[{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."}],Hf={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(yi.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function Sl(a){const s=yi.find(r=>r.id===a);return s?s.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function Vy(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function Gy(a){var aa,hr,ai,ra,_s,$t;const s=a.gateway,r=!!a.gateway_connected,l=h.useMemo(()=>new hd,[]),c=h.useMemo(()=>{if(a.advisor)return a.advisor;if(!r||!s)return;const u=a.advisor_agent;return async(v,S)=>{const w=[...S.map(ne=>({role:ne.role,content:ne.content})),{role:"user",content:v}],T=await s.backlog_advisor({messages:w,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]),f=!!c,[d,p]=h.useState(""),[_,y]=h.useState(()=>Zu()),[b,x]=h.useState(""),N=h.useRef(_);N.current=_;const C=h.useRef({});h.useEffect(()=>{if(!r||!s){p("");return}let u=!0;return(async()=>{try{const v=await ld("abstractcontinuum_team_voice");u&&p(v)}catch{u&&p("")}})(),typeof s.capability_defaults=="function"&&Promise.resolve().then(()=>s.capability_defaults()).then(v=>{u&&(C.current=Rh(v))}).catch(()=>{u&&(C.current={})}),()=>{u=!1}},[s,r]),h.useEffect(()=>{const u=()=>y(Zu());return window.addEventListener(ed,u),window.addEventListener("storage",u),()=>{window.removeEventListener(ed,u),window.removeEventListener("storage",u)}},[]);const I=h.useMemo(()=>{const u=String(d||"").trim();if(!(!r||!s||!u))return v=>{const S=s.voice_stream_transport(u,{text:v,...C.current,...Ah(N.current)});return A_({path:S.path,body:S.body,headers:S.headers})}},[s,r,d]),E=Xf({tts_stream:I,on_error:x});h.useEffect(()=>{if(!b)return;ge(b);const u=setTimeout(()=>x(""),6e3);return()=>clearTimeout(u)},[b]);const[P,U]=h.useState(null),D=h.useRef(null);h.useEffect(()=>{D.current=P},[P]);const[F,Q]=h.useState(""),[$,Z]=h.useState(null),[oe,le]=h.useState([]),[pe,Ae]=h.useState({}),[Me,ve]=h.useState({}),[ce,q]=h.useState({}),[L,W]=h.useState({}),[X,M]=h.useState(null),[ue,V]=h.useState(""),j=h.useRef(0),R=h.useRef(!1),ee=h.useRef(!1);async function _e(){if(!R.current&&!(Date.now()-j.current<3e4)){j.current=Date.now();try{const u=await l.desk();M(v=>v==="loading"?v:u),u.rows.length&&!ee.current&&Zt(v=>v!==""?v:(ee.current=!0,"desk"))}catch(u){((u==null?void 0:u.status)===403||(u==null?void 0:u.status)===404)&&(R.current=!0)}}}async function he(){M("loading"),V("");try{const u=await l.desk();M(u),j.current=Date.now(),R.current=!1}catch(u){M(null),V((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[O,je]=h.useState(""),[te,ke]=h.useState([]),[Ce,We]=h.useState("all"),me=h.useRef(null),[Re,Pe]=h.useState(null),se=h.useRef(""),[ye,ge]=h.useState(""),[qe,Ye]=h.useState(!1),[ie,fe]=h.useState({}),[be,G]=h.useState({}),[Se,Xe]=h.useState({}),J=h.useRef(new Set),A=h.useRef(0),[Y,Ne]=h.useState(""),[ze,Ke]=h.useState(""),[tt,dt]=h.useState([]),[yt,pt]=h.useState(!1),Tt=h.useRef(null),[qt,Oe]=h.useState(!1),it=h.useRef(null);h.useEffect(()=>{const u=it.current;u&&(u.style.height="auto",u.style.height=`${Math.min(u.scrollHeight+2,160)}px`)},[Y,O]);const[et,kt]=h.useState("fyi"),[ht,Qt]=h.useState(""),[we,Ee]=h.useState(""),[Ie,mt]=h.useState(null),[_t,gt]=h.useState({}),[Xt,mn]=h.useState(""),Bt=h.useRef(Wy()),Ba=h.useRef(""),[Qn,qn]=h.useState(!1),[ha,Tr]=h.useState(!1),[wi,ot]=h.useState(""),[Vt,Jn]=h.useState(null),[Rt,Ua]=h.useState(null),[Rl,ji]=h.useState({});function Ar(u,v){v.length&&ji(S=>{const w={...S},T=new Set(w[u]||[]);for(const ne of v)T.add(ne);return w[u]=T,w})}function ki(u,v){const S=new Set(v.map(w=>String(w.agent_id||"")).filter(Boolean));S.size&&ji(w=>{const T=w[u];if(!T||![...T].some(xe=>S.has(xe)))return w;const ne=new Set([...T].filter(xe=>!S.has(xe))),B={...w};return ne.size?B[u]=ne:delete B[u],B})}const Wa=h.useRef(0),[Ll,Rr]=h.useState(""),[Lt,Ml]=h.useState(null),[Ha,Fs]=h.useState(""),[is,Lr]=h.useState(!1),[pa,Va]=h.useState(""),[fn,zl]=h.useState([]);function Sn(){l.delegations().then(u=>{Ml(u),Fs("")}).catch(u=>{Ml([]);const v=String((u==null?void 0:u.message)||u);Fs((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 tc(){if(!(!pa||!fn.length||is)){Lr(!0),Fs("");try{await l.set_delegation(pa,fn),Va(""),zl([]),Sn()}catch(u){Fs(String((u==null?void 0:u.message)||u||"delegation failed"))}finally{Lr(!1)}}}async function nc(u){if(!is){Lr(!0),Fs("");try{await l.revoke_delegation(u),Sn()}catch(v){Fs(String((v==null?void 0:v.message)||v||"resign failed"))}finally{Lr(!1)}}}const[Bn,Yn]=h.useState(null),[qs,Xn]=h.useState(null),[Ot,sn]=h.useState(""),[Mr,ws]=h.useState(null),[Bs,zr]=h.useState([]),[Pt,js]=h.useState(""),[Pr,ct]=h.useState(""),[Ir,Si]=h.useState(""),[Ga,Ni]=h.useState(!1),[Ci,Ka]=h.useState(""),[ks,Us]=h.useState({open:!1,name:"",is_private:!1}),[Gt,hn]=h.useState(!1),[Ss,ls]=h.useState({}),[St,Zt]=h.useState(""),[Un,Or]=h.useState(null),[Ws,Pl]=h.useState(""),[Wn,Qa]=h.useState("channel"),[Ja,Il]=h.useState(""),[Hs,os]=h.useState(null),[Vs,Ya]=h.useState(""),[$i,Ol]=h.useState(""),[Gs,Zn]=h.useState(""),[_a,Dr]=h.useState(null),[es,Xa]=h.useState(""),[cs,ga]=h.useState(""),[Fr,Ut]=h.useState(null),[qr,pn]=h.useState([]),[Ks,Za]=h.useState(""),[Qs,Ei]=h.useState(!1),[Br,er]=h.useState(""),va=h.useRef(null),tr=h.useRef(0),Ur=h.useRef(!1),Dl=h.useRef(0),[Ti,Ai]=h.useState(!1),Wr=h.useRef(""),En=h.useRef([]),Ns=h.useRef([]),Cs=h.useRef(null),Ri=h.useRef(!1),Li=h.useRef(null);Wr.current=O,En.current=oe,Ns.current=te,h.useEffect(()=>{for(const u of te){const v=ba.current[u.id];v!==void 0&&u.ratings&&Number(u.ratings.mine||0)===v&&delete ba.current[u.id]}},[te]);const Hr=h.useRef(!1);async function sc(u){var v;try{const S=await l.inbox(),w=oy(S),T=cy(S);ve(Ue=>Fu(Ue,T)?Ue:T);const ne=uy(S,((v=D.current)==null?void 0:v.seat)||"");q(Ue=>Fu(Ue,ne)?Ue:ne);const B=dy(S);W(Ue=>Fu(Ue,B)?Ue:B),_e();const xe=u.slice(0,qy),De=await Promise.allSettled(xe.map(Ue=>l.digest(Ue.name))),Be={};for(const Ue of u)Be[Ue.name]={unread:w[Ue.name]||0,open_questions:0};De.forEach((Ue,Mt)=>{var Rn;const Et=xe[Mt].name;if(Ue.status==="fulfilled"){const xt=(Rn=Ue.value)==null?void 0:Rn.counts;Be[Et]={...Be[Et],open_questions:Number((xt==null?void 0:xt.open_questions)||0)}}}),Ae(Ue=>Du(Ue,Be)?Ue:Be)}catch{}}async function ya(u){if(Ri.current){Li.current=u;return}Ri.current=!0;let v=u;try{for(;v;)Li.current=null,await sc(v),v=Li.current}finally{Ri.current=!1}}async function nr(){const v=[...await l.channels()];return v.sort((S,w)=>(w.last_at||0)-(S.last_at||0)),le(S=>Du(S,v)?S:v),En.current=v,v}async function us(){try{const[u,v]=await Promise.all([l.meta(),l.channels()]);U({seat:u.seat,seat_key_present:u.seat_key_present}),Q(String(u.hub_url||"")),l.healthz().then(T=>Z(T)).catch(()=>Z(null)),l.presence().then(T=>{const ne=[...new Set(T.map(B=>String(B.agent_id||"")).filter(B=>B&&B!==u.seat))].sort();zr(ne)}).catch(()=>zr([]));const S=[...v];S.sort((T,ne)=>(ne.last_at||0)-(T.last_at||0)),le(S);const w=S.filter(T=>!T.name.startsWith("dm:"));!O&&w.length&&je(w[0].name),ge(""),ya(S)}catch(u){ge(String((u==null?void 0:u.message)||u||"Hub unreachable"))}}async function ds(u,v){var w,T,ne;if(!u)return;const S=A.current;v!=null&&v.background||Ye(!0);try{const B=Ns.current.length&&Ns.current[Ns.current.length-1].seq||0,xe=((w=En.current.find(rt=>rt.name===u))==null?void 0:w.last_seq)||0;let De=xe,Be=null;if(!(v!=null&&v.background))if(xe>0)Be=nr().catch(()=>null);else try{const rt=await nr();if(S!==A.current)return;De=((T=rt.find(bn=>bn.name===u))==null?void 0:T.last_seq)||0}catch{}const Ue=Math.max(0,De-ma),Mt=v!=null&&v.background&&B>0?Math.max(0,B-Fy):Ue,Et=await l.messages(u,{since:Mt,limit:ma});if(S!==A.current)return;const Rn=new Set(Ns.current.map(rt=>rt.id)),xt=Et.some(rt=>!Rn.has(rt.id));if(v!=null&&v.background&&!xt&&B>0){const rt=Date.now();if(rt-Dl.current>1e4){Dl.current=rt;try{const bn=await nr();if(S!==A.current)return;const bt=((ne=bn.find(He=>He.name===u))==null?void 0:ne.last_seq)||0;if(bt>0&&bt<B){const He=Math.max(0,bt-ma),Ct=await l.messages(u,{since:He,limit:ma});if(S!==A.current)return;Ct.sort((ln,en)=>(ln.seq||0)-(en.seq||0)),ke(Ct),ge("");return}}catch{}}}Et.sort((rt,bn)=>(rt.seq||0)-(bn.seq||0)),ke(rt=>{if(v!=null&&v.background&&rt.length){if(!Et.length)return rt;const bn=new Set(rt.map(jt=>jt.id)),bt=Et.filter(jt=>!bn.has(jt.id)),He=new Map(Et.map(jt=>[jt.id,jt]));let Ct=0;const ln=rt.map(jt=>{const ft=He.get(jt.id);if(!ft)return jt;const zt=JSON.stringify(ft.ratings??null)!==JSON.stringify(jt.ratings??null)||(ft.has_resolved_reply??null)!==(jt.has_resolved_reply??null)||JSON.stringify(ft.pending_asks??null)!==JSON.stringify(jt.pending_asks??null)||!!ft.retracted!=!!jt.retracted;return zt&&Ct++,zt?ft:jt});if(!bt.length&&!Ct)return rt;const en=[...Ct?ln:rt,...bt];return en.length>ma*2?en.slice(en.length-ma*2):en}return Et}),ge(""),!(v!=null&&v.background)&&Be&&(async()=>{var rt;try{const bn=await Be;if(S!==A.current||!bn)return;const bt=((rt=bn.find(He=>He.name===u))==null?void 0:rt.last_seq)||0;if(bt>0&&bt!==xe){const He=Math.max(0,bt-ma),Ct=await l.messages(u,{since:He,limit:ma});if(S!==A.current)return;Ct.sort((ln,en)=>(ln.seq||0)-(en.seq||0)),ke(ln=>Du(ln,Ct)?ln:Ct)}}catch{}})()}catch(B){if(S!==A.current)return;ge(String((B==null?void 0:B.message)||B||"Failed to load messages"))}finally{!(v!=null&&v.background)&&S===A.current&&Ye(!1)}}h.useEffect(()=>{us()},[]),h.useEffect(()=>{let u=null,v=!1,S=0,w=0;const T=()=>{if(!v){try{u=new WebSocket(l.ws_url())}catch{Ai(!1),S+=1,setTimeout(T,Math.min(15e3,1e3*Math.max(1,S)));return}u.onopen=()=>{Ai(!0),w=Date.now(),(!En.current.length||!D.current)&&us()},u.onmessage=ne=>{var B;try{const xe=JSON.parse(String(ne.data||"{}"));if((xe==null?void 0:xe.type)!=="envelope")return;const De=String(((B=xe.envelope)==null?void 0:B.channel)||"");De&&De===Wr.current&&ds(De,{background:!0}),De&&!En.current.some(Be=>Be.name===De)&&nr(),Cs.current&&clearTimeout(Cs.current),Cs.current=setTimeout(()=>void ya(En.current),800)}catch{}},u.onclose=()=>{Ai(!1),v||(w&&Date.now()-w>=15e3?S=0:S+=1,w=0,setTimeout(T,Math.min(15e3,1e3*Math.max(1,S))))},u.onerror=()=>{try{u==null||u.close()}catch{}}}};return T(),()=>{v=!0,Cs.current&&clearTimeout(Cs.current);try{u==null||u.close()}catch{}}},[]),h.useEffect(()=>{A.current+=1,fe({}),G({}),Xe({}),J.current=new Set,Jn(null),Ua(null);try{E.stop_tts()}catch{}Wa.current=0,ba.current={},lr("recency"),ta(null),ti(""),Dr(null),Xa(""),ga(""),Ut(null),Yn(null),Xn(null),ws(null),sn(""),ct(""),ls({}),pn([]),er(""),Ei(!1),Za(""),ke([]),We(me.current||"all"),me.current=null,mt(null),gt({}),mn(""),dt([]),Ba.current&&Ba.current!==O&&(Y||ze?Bt.current[Ba.current]={text:Y,title:ze,kind:et}:delete Bt.current[Ba.current],wl(Bt.current));const u=Bt.current[O];if(Ne((u==null?void 0:u.text)||""),Ke((u==null?void 0:u.title)||""),kt((u==null?void 0:u.kind)||"fyi"),Ba.current=O,Hr.current=!0,ds(O),!O)return;St==="files"&&Di(),St==="members"&&Mi();const v=setInterval(()=>{tr.current+=1,Ur.current||(Ur.current=!0,ds(O,{background:!0}).finally(()=>{Ur.current=!1})),tr.current%Dy===0&&(nr().then(S=>ya(S)).catch(()=>ya(En.current)),l.healthz().then(Z).catch(()=>{}),l.meta().then(S=>U(S)).catch(()=>{}))},Oy);return()=>clearInterval(v)},[O]);const Fl=h.useRef({text:"",title:"",kind:"fyi",selected:""});Fl.current={text:Y,title:ze,kind:et,selected:O},h.useEffect(()=>{if(!O)return;const u=setTimeout(()=>{Y||ze?Bt.current[O]={text:Y,title:ze,kind:et}:delete Bt.current[O],wl(Bt.current)},300);return()=>clearTimeout(u)},[Y,ze,et,O]),h.useEffect(()=>{const u=()=>{const v=Fl.current;v.selected&&(v.text||v.title?Bt.current[v.selected]={text:v.text,title:v.title,kind:v.kind}:delete Bt.current[v.selected],wl(Bt.current))};return window.addEventListener("pagehide",u),window.addEventListener("beforeunload",u),()=>{window.removeEventListener("pagehide",u),window.removeEventListener("beforeunload",u),u()}},[]),h.useEffect(()=>{const u=va.current;if(!u||!te.length)return;if(Hr.current){Hr.current=!1,u.scrollTop=u.scrollHeight;return}u.scrollHeight-u.scrollTop-u.clientHeight<240&&(u.scrollTop=u.scrollHeight)},[te]),h.useEffect(()=>{if(Ce!=="unread"||!O){Pe(null);return}const u=Me[O];Pe(new Set(u||[])),se.current=""},[Ce,O]),h.useEffect(()=>{if(Ce!=="unread"||!O||!Re||!Re.size)return;const u=Math.min(...Re),v=te.length&&te[0].seq||0;if(!u||!v||v<=u)return;const S=`${O}:${u}`;if(se.current===S)return;se.current=S;const w=A.current;l.messages(O,{since:Math.max(0,u-1),limit:ma}).then(T=>{w!==A.current||!T.length||ke(ne=>{const B=new Set(ne.map(De=>De.id)),xe=T.filter(De=>!B.has(De.id));return xe.length?[...ne,...xe].sort((De,Be)=>(De.seq||0)-(Be.seq||0)):ne})}).catch(()=>{w===A.current&&(ot("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ot(""),6e3))})},[Ce,O,Re,te]);function ql(u){J.current.has(u.id)||(J.current.add(u.id),l.read_message(u.channel,u.id).catch(()=>{}),l.ack(u.channel,u.seq).catch(()=>{}),ve(v=>{const S=v[u.channel];if(!S||!S.has(u.seq))return v;const w=new Set(S);return w.delete(u.seq),{...v,[u.channel]:w}}),Cs.current&&clearTimeout(Cs.current),Cs.current=setTimeout(()=>void ya(En.current),500),u.critical&&(ot(`Read recorded for critical #${u.seq}.`),setTimeout(()=>ot(""),2500)))}function Bl(u){const v=!ie[u.id];fe(S=>({...S,[u.id]:v})),v&&ql(u)}function Ul(u){const v=window.getSelection();if(v&&!v.isCollapsed)return;const S=String(u.body||""),w=u.status==="reply"?Ff:Vo;S.length>w?Bl(u):ql(u)}async function ac(){if(!O||Vt==="running")return;const u=A.current;Jn("running");try{const v=await l.ledger(O),S=await Iy(v);if(u!==A.current)return;Jn(S)}catch(v){if(u!==A.current)return;Jn({error:String((v==null?void 0:v.message)||v||"verification failed")})}}function Mi(){{const u=A.current;Ua("loading"),Yn(null),Rr(""),Xn(null),l.channel_info(O).then(v=>{u===A.current&&Ua(v)}).catch(v=>{u===A.current&&Ua({error:String((v==null?void 0:v.message)||v||"info failed")})}),l.members(O).then(v=>{u===A.current&&(Yn(v),Rr(""),ki(O,v))}).catch(v=>{u===A.current&&(Yn([]),Rr(String((v==null?void 0:v.message)||v||"members unavailable")))}),l.list_blocks().then(v=>{u===A.current&&Xn(v)}).catch(()=>{u===A.current&&Xn([])}),l.retired_agents().then(v=>{u===A.current&&ws(v)}).catch(()=>{u===A.current&&ws([])})}}function xa(u){const v=St===u?"":u;if(Zt(v),v==="files"&&Di(),v==="members"){let S=0;for(const w of Ns.current)String(w.sender||"")==="hub"&&(w.seq||0)>S&&(S=w.seq||0);Wa.current=S,Mi(),Sn()}v==="leaderboard"&&zi(Wn),v==="desk"&&he()}function zi(u){const v=A.current;Or(null),Pl(""),Il(""),os(null),Zn(""),(u==="hub"?l.reputation_hub():l.reputation(O)).then(w=>{v===A.current&&Or(w)}).catch(w=>{if(v!==A.current)return;const T=Number((w==null?void 0:w.status)||0);Pl(T===404||T===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((w==null?void 0:w.message)||w||"failed to load leaderboard"))})}function Wl(u){const v=Ja===u?"":u;if(Il(v),os(null),Zn(""),!v||Wn==="hub")return;const S=A.current;l.reputation_votes(O,v).then(w=>{S===A.current&&os(w)}).catch(w=>{S===A.current&&(os(null),Zn(`votes list failed: ${String((w==null?void 0:w.message)||w||"fetch failed")}`))})}const[Pi,Hl]=h.useState(""),[$s,Js]=h.useState("");h.useEffect(()=>{if(!$s)return;const u=setTimeout(()=>Js(""),6e3);return()=>clearTimeout(u)},[$s]);async function rc(u){if($s!==u.id){Js(u.id);return}Js("");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 ${(P==null?void 0:P.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 w=S[u.channel];if(!(w!=null&&w.has(u.seq)))return S;const T=new Set(w);return T.delete(u.seq),{...S,[u.channel]:T}})}catch(v){ge(String((v==null?void 0:v.message)||v||"decline failed"))}}const ba=h.useRef({});function Vr(u){const v=u.ratings;return v?$y(v,ba.current[u.id]):null}async function Ii(u,v){var T,ne;const S=(P==null?void 0:P.seat)||"";if(!u||!S||Pi)return;const w=Ns.current.find(B=>B.id===u)||((T=no.current)==null?void 0:T.find(B=>B.id===u));if(w){Hl(`${u}:${v}`),Zn("");try{const B=((ne=Vr(w))==null?void 0:ne.mine)??0;B===v?await l.unrate_message(O,u):await l.rate_message(O,u,v),ba.current[u]=B===v?0:v}catch(B){Zn(String((B==null?void 0:B.message)||B||"rating failed"))}finally{Hl("")}}}async function Oi(u,v,S){if(!$i){Ol(`${u}:${v}:${S}`),Zn("");try{await l.rate(O,u,v,S,Vs.trim()),Ya("");const w=A.current,[T,ne]=await Promise.all([l.reputation(O),l.reputation_votes(O,u)]);w===A.current&&(Or(T),os(ne))}catch(w){Zn(String((w==null?void 0:w.message)||w||"vote failed"))}finally{Ol("")}}}function Di(){const u=A.current;Dr(null),Xa(""),ga(""),l.fs_list(O).then(v=>{u===A.current&&Dr(v)}).catch(v=>{u===A.current&&Xa(String((v==null?void 0:v.message)||v||"failed to list files"))})}async function wa(u){const v=A.current,S=Sr(u.path,"text/markdown"),w=`${u.updated_by||"?"} · ${kl(u.updated_at)} · v${u.version}`;Ut({name:u.path,mode:S==="image"?"text":S,meta:w,loading:!0});try{const T=await l.fs_read(O,u.path);if(v!==A.current)return;const ne=Sr(u.path,T.mime);Ut({name:u.path,mode:ne==="image"?"text":ne,text:Go(T.content),content_type:T.mime,meta:w,loading:!1})}catch(T){if(v!==A.current)return;Ut({name:u.path,mode:"text",meta:w,error:String((T==null?void 0:T.message)||T||"failed to read file")})}}const Ys=h.useRef(null);function sr(){const u=Ys.current,v=Ns.current;if(!u||!v.length)return;if(u.message_id?v.some(w=>w.id===u.message_id):!1){Ys.current=null,requestAnimationFrame(()=>{const w=document.getElementById(`hubmsg-${u.message_id}`);w==null||w.scrollIntoView({block:"center"}),w==null||w.classList.add("hit"),setTimeout(()=>w==null?void 0:w.classList.remove("hit"),2500)});return}if(u.seq&&Number.isFinite(u.seq)){const w=A.current,T=u.seq;Ys.current={...u,seq:void 0},l.messages(O,{since:Math.max(0,T-3),limit:10}).then(ne=>{w!==A.current||!ne.length||ke(B=>{const xe=new Set(B.map(Be=>Be.id)),De=ne.filter(Be=>!xe.has(Be.id));return De.length?[...B,...De].sort((Be,Ue)=>(Be.seq||0)-(Ue.seq||0)):B})}).catch(()=>{})}}h.useEffect(()=>{var w;if(!a.focus)return;const{channel:u,message_id:v,seq:S}=a.focus;(w=a.on_focus_consumed)==null||w.call(a),u&&(Ys.current={message_id:v,seq:S},u===O?sr():je(u))},[a.focus]),h.useEffect(()=>{sr()},[te]),h.useEffect(()=>{if(St!=="members"||!O)return;let u=0,v="";for(const w of te){if(w.channel&&w.channel!==O||String(w.sender||"")!=="hub")continue;const T=`${String(w.title||"")} ${String(w.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(T)&&(w.seq||0)>u&&(u=w.seq||0,v=T)}if(!u||u<=Wa.current)return;const S=A.current;l.members(O).then(w=>{S===A.current&&(Wa.current=u,Yn(w),Rr(""),ki(O,w))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(v)&&l.list_blocks(O).then(w=>{S===A.current&&Xn(w)}).catch(()=>{})},[te,St,O]);const[ic,ar]=h.useState(null),Gr=h.useRef(0);h.useEffect(()=>{if(ar(null),Gr.current=0,!O)return;const u=A.current;l.fs_list(O).then(v=>{u===A.current&&ar(new Set(v.map(S=>String(S.path||"")).filter(Boolean)))}).catch(()=>{u===A.current&&ar(null)})},[O]),h.useEffect(()=>{const u=te.reduce((S,w)=>{if(w.channel&&w.channel!==O)return S;const T=String(w.title||"");return(T.startsWith("fs:put")||T.startsWith("fs:delete"))&&(w.seq||0)>S?w.seq||0:S},0);if(!u||u<=Gr.current)return;const v=A.current;l.fs_list(O).then(S=>{v===A.current&&(Gr.current=u,ar(new Set(S.map(w=>String(w.path||"")).filter(Boolean))))}).catch(()=>{})},[te,O]);async function rr(u){const v=A.current,S=Sr(u,"text/markdown");Ut({name:u,mode:S==="image"?"text":S,loading:!0});try{const w=await l.fs_read(O,u);if(v!==A.current)return;const T=Sr(u,w.mime),ne=w.updated_by?`${w.updated_by} · ${kl(w.updated_at)} · v${w.version??"?"}`:void 0;Ut({name:u,mode:T==="image"?"text":T,text:Go(w.content),content_type:w.mime,meta:ne,loading:!1})}catch(w){if(v!==A.current)return;Ut({name:u,mode:"text",error:String((w==null?void 0:w.message)||w||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function Es(u,v){const S=A.current,w=l.attachment_url(u,v.id),T=Sr(v.filename,v.content_type);if(T==="image"){Ut({name:v.filename,mode:"image",url:w,content_type:v.content_type,size:v.size});return}if(T==="md"||T==="text"){if(v.size>$l){Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size,error:`too large to preview inline (${Dn(v.size)} > ${Dn($l)}) — download to view`});return}Ut({name:v.filename,mode:T,url:w,content_type:v.content_type,size:v.size,loading:!0});try{const ne=await fetch(w);if(!ne.ok)throw new Error(`fetch failed (${ne.status})`);const B=await ne.text();if(S!==A.current)return;Ut({name:v.filename,mode:T,url:w,content_type:v.content_type,size:v.size,text:Go(B)})}catch(ne){if(S!==A.current)return;Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size,error:String((ne==null?void 0:ne.message)||ne||"failed to load")})}return}Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size})}async function Kr(u,v,S="channel"){if(!Pt){js(`${S}:${v}:${u}`),ct("");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(O,u):await l.block(O,u,v==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ot(`${S==="hub"?"hub ":""}${v} → ${u} applied.`),setTimeout(()=>ot(""),3e3);const w=A.current,T=await l.members(O).catch(()=>null);T&&w===A.current&&Yn(T);const ne=await l.list_blocks().catch(()=>null);ne&&w===A.current&&Xn(ne)}catch(w){ct(String((w==null?void 0:w.message)||w||"moderation refused"))}finally{js("")}}}async function Qr(u){if(!Pt){js(`retire:${u}`),ct("");try{await l.retire_agent(u,"decommissioned via Continuum Team page"),sn(""),ot(`${u} retired (decommissioned — not banned).`),setTimeout(()=>ot(""),3500);const v=A.current,S=await l.members(O).catch(()=>null);S&&v===A.current&&Yn(S);const w=await l.retired_agents().catch(()=>null);w&&v===A.current&&ws(w)}catch(v){const S=v==null?void 0:v.status,w=String((v==null?void 0:v.message)||v||"");S===404||/not found|hub_route_not_allowed/i.test(w)?(ot("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ot(""),6e3)):ct(w||"retire refused")}finally{js("")}}}async function lc(u){if(!Pt){js(`unretire:${u}`),ct("");try{await l.unretire_agent(u),sn(""),ot(`${u} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ot(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ws(v)}catch(v){ct(String((v==null?void 0:v.message)||v||"un-retire refused"))}finally{js("")}}}async function Vl(u){if(!Pt){js(`delete:${u}`),ct("");try{await l.delete_agent(u),sn(""),ot(`${u} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ot(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ws(v)}catch(v){const S=String((v==null?void 0:v.message)||v);ct((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{js("")}}}async function Jr(u){if(!Gt){hn(!0),ct("");try{let v={state:u},S;try{const w=await l.channel_meta(O);w&&typeof w.value=="object"&&w.value&&(v={...w.value,state:u}),typeof(w==null?void 0:w.version)=="number"&&(S=w.version)}catch{}await l.put_channel_meta(O,v,S),ot(u==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ot(""),3500),Mi(),us()}catch(v){ct(String((v==null?void 0:v.message)||v||"channel state change refused"))}finally{hn(!1)}}}const[Fi,qi]=h.useState("");async function Gl(u){if(!Gt){hn(!0),ge("");try{await l.leave(u),qi(""),O===u&&je(""),await us(),ot("Direct message removed from your list."),setTimeout(()=>ot(""),3e3)}catch(v){ge(String((v==null?void 0:v.message)||v||"leave refused"))}finally{hn(!1)}}}const[Kl,Bi]=h.useState("");async function oc(u){if(!Gt){hn(!0),ge("");try{await l.archive(u),Bi(""),O===u&&je(""),await us(),ot(`Channel #${u} archived (history preserved).`),setTimeout(()=>ot(""),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)?(Bi(""),ot("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ot(""),6e3)):ge(S||"archive refused")}finally{hn(!1)}}}async function Ql(){const u=ks.name.trim();if(!(!u||Gt)){hn(!0),ge("");try{await l.create_channel(u,ks.is_private),Us({open:!1,name:"",is_private:!1}),await us(),je(u),ot(`Channel #${u} created.`),setTimeout(()=>ot(""),3e3)}catch(v){ge(String((v==null?void 0:v.message)||v||"channel create refused"))}finally{hn(!1)}}}async function Jl(u,v){if(!c)throw new Error("AI advisor is not available");return c(u,v)}async function cc(u){if(!f)return;const v=u.root.id,S=A.current,w=u.replies.length+1;ls(T=>{var ne;return{...T,[v]:{busy:!0,text:((ne=T[v])==null?void 0:ne.text)||"",error:"",count:w}}});try{const ne=`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.
110
-
111
- THREAD TRANSCRIPT:
112
- ${If([u.root,...u.replies])}`,B=await Jl(ne,[]);if(S!==A.current)return;ls(xe=>({...xe,[v]:{busy:!1,text:B,error:"",count:w}}))}catch(T){if(S!==A.current)return;ls(ne=>({...ne,[v]:{busy:!1,text:"",error:String((T==null?void 0:T.message)||T||"summary failed"),count:w}}))}}async function Tn(u){const v=u.trim();if(!v||Qs||!f)return;const S=A.current;Zt("assistant"),Ei(!0),er(""),pn(w=>[...w,{role:"user",content:v}]);try{const w=If(te),T=`You are the operator's analyst for the agora hub channel #${O}. 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.
113
-
114
- CHANNEL TRANSCRIPT (window):
115
- ${w}
116
-
117
- QUESTION: ${v}`,ne=await Jl(T,qr);if(S!==A.current)return;pn(B=>[...B,{role:"assistant",content:ne}])}catch(w){if(S!==A.current)return;er(String((w==null?void 0:w.message)||w||"assistant failed"))}finally{S===A.current&&Ei(!1)}}const[Ts,Ui]=h.useState(""),[ir,Wi]=h.useState("");async function Yl(u){if(!Qn){qn(!0),ge("");try{await l.retract_message(O,u.id),Wi(""),ot(`#${u.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ot(""),4e3),await ds(O,{background:!0})}catch(v){const S=String((v==null?void 0:v.message)||v||"retract failed");ge(/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{qn(!1)}}}async function Hi(u){if(!Qn){qn(!0),ge("");try{const v=Rf(O,Nt);await l.post_message(O,{body:"Resolved.",status:"resolved",to:v?[v]:void 0,reply_to:u.id}),Ui(""),ot(`Marked #${u.seq} resolved.`),setTimeout(()=>ot(""),3e3),await ds(O,{background:!0})}catch(v){ge(String((v==null?void 0:v.message)||v||"Resolve failed"))}finally{qn(!1)}}}async function Xl(u){if(!u||!u.length||yt)return;const v=Array.from(u);if(tt.length+v.length>bl){ge(`At most ${bl} attachments per message.`);return}const S=v.find(B=>B.size>Bf);if(S){ge(`"${S.name}" is ${Dn(S.size)} — the limit is ${Dn(Bf)}.`);return}const w=A.current,T=O;pt(!0),ge("");let ne=0;try{for(const B of v){const xe=await l.upload_attachment(T,B);if(w!==A.current||O!==T)return;dt(De=>[...De,xe]),ne+=1}}catch(B){const xe=B==null?void 0:B.status,De=String((B==null?void 0:B.message)||B||"");if(xe===404||/not found|hub_route_not_allowed/i.test(De))ot("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ot(""),6e3);else{const Be=v.length>1?` (${ne} of ${v.length} attached before this)`:"";ge(`${De||"attachment upload failed"}${Be}`)}}finally{pt(!1),Tt.current&&(Tt.current.value="")}}function uc(u){var S;mt(u);const v=((S=u.data)==null?void 0:S.asks)||[];gt(v.length===1?{[v[0].id]:!0}:{}),mn(""),kt("fyi")}function Xs(){mt(null),gt({}),mn("")}async function Vi(u){const{title:v,members:S}=Pu(u);if(!S.length){ge("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const w=v||`focused work with ${S.join(", ")}`;await Zs({title:w,members:S})}async function ja(u,v,S){const w=[],T=[];for(const ne of S)try{const B=await fetch(l.attachment_url(u,ne.id));if(!B.ok)throw new Error(`fetch ${B.status}`);const xe=await B.blob(),De=new File([xe],ne.filename||"attachment",{type:ne.content_type||xe.type||"application/octet-stream"}),Be=await l.upload_attachment(v,De);w.push({id:Be.id,filename:Be.filename||ne.filename})}catch(B){T.push(`${ne.filename||ne.id.slice(0,8)} (${String((B==null?void 0:B.message)||B)})`)}return{migrated:w,att_failed:T}}async function Yr(u,v,S){try{const w=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='${w}'), read the recent messages, and work the topic THERE.`}),null}catch(w){return String((w==null?void 0:w.message)||w)}}async function Zl(u){var v,S;if(!(!O||!u)){Ni(!0),Ka("");try{const w=Rt&&typeof Rt=="object"&&"meta"in Rt?String(((v=Rt.meta)==null?void 0:v.purpose)||""):"",T=!!((S=En.current.find(B=>B.name===O))!=null&&S.private);let ne=null;if(T)ne=await Yr(O,u,w||void 0);else try{await l.send_dm(u,{title:`join ${O}${w?`: ${w}`:""}`.slice(0,120),body:`You are invited to '${O}' (public)${w?` — ${w}`:""}. Join with join_channel(channel='${O}'), read the recent messages, and work the topic THERE.`})}catch(B){ne=String((B==null?void 0:B.message)||B)}ne?Ka(ne.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${ne}`):(Ka(`Invited @${u} — join pointer DM'd.`),Si(""),Ar(O,[u]))}finally{Ni(!1),setTimeout(()=>Ka(""),8e3)}}}async function Xr(u,v){var S;try{const w=Pu(v).members;if(!w.length)return;const T=await l.members(u),ne=new Set(T.map(Ue=>String(Ue.agent_id||""))),B=w.filter(Ue=>!ne.has(Ue)&&Bs.includes(Ue)&&Ue!==Nt);if(!B.length)return;const xe=!!((S=En.current.find(Ue=>Ue.name===u))!=null&&S.private),De=[],Be=[];for(const Ue of B)if(xe){const Mt=await Yr(u,Ue);Mt?Be.push(`${Ue} (${Mt})`):De.push(Ue)}else try{await l.send_dm(Ue,{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.`}),De.push(Ue)}catch(Mt){Be.push(`${Ue} (${String((Mt==null?void 0:Mt.message)||Mt)})`)}De.length&&(Ar(u,De),ot(`Posted — @${De.join(", @")} ${xe?"invited":"nudged"} (mentioned, not yet member${De.length===1?"":"s"}).`)),Be.length&&ge(Be.some(Ue=>Ue.includes("outside the Team page allowlist"))?"Posted; inviting mentioned non-members needs the updated console server (one stack restart).":`Posted; invite failed for ${Be.join("; ")}.`)}catch{}}async function Zs(u){var ne,B;const{title:v,members:S}=u,w=[...tt],T=O;qn(!0),ge("");try{const xe=new Set(En.current.map(xt=>xt.name)),De=Ou(v,xe);let Be=[],Ue=[],Mt=!1;try{const xt=await l.create_group({name:De,members:S,purpose:v,opening_post:((ne=u.opening_body)==null?void 0:ne.trim())||v,private:!0});Mt=!0,Be=Array.isArray(xt==null?void 0:xt.invited)?xt.invited.map(String):S,Ue=Array.isArray(xt==null?void 0:xt.failed)?xt.failed.map(rt=>typeof rt=="string"?rt:`${(rt==null?void 0:rt.agent)||(rt==null?void 0:rt.member)||(rt==null?void 0:rt.peer)||"?"} (${String((rt==null?void 0:rt.error)||(rt==null?void 0:rt.detail)||"failed")})`):[]}catch(xt){const rt=String((xt==null?void 0:xt.message)||xt||"");if(!((xt==null?void 0:xt.status)===404||rt.includes("outside the Team page allowlist")||rt.includes("Not Found")))throw xt;try{await l.create_invite("__group-preflight__",S[0])}catch(bt){if(String((bt==null?void 0:bt.message)||bt).includes("outside the Team page allowlist")){ge("/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(De,!0),await l.put_channel_meta(De,{purpose:v},0);for(const bt of S)try{const He=await l.create_invite(De,bt);await l.send_dm(bt,{title:`invite to ${De}: ${v}`.slice(0,120),body:`You are invited to '${De}' — focused room: ${v}. Join with join_channel(channel='${De}', invite_token='${He}'), read the opening post, and work the topic THERE (not in commons).`}),Be.push(bt)}catch(He){Ue.push(`${bt} (${String((He==null?void 0:He.message)||He)})`)}}const{migrated:Et,att_failed:Rn}=await ja(T,De,w);Mt?Et.length&&await l.post_message(De,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Et}):await l.post_message(De,{body:((B=u.opening_body)==null?void 0:B.trim())||v,title:v.slice(0,120),status:"open",attachments:Et.length?Et:void 0}),Ar(De,Be),ot(`Room '${De}' created — private, ${Be.length} invited${Be.length?`: ${Be.join(", ")}`:""}.`+(Et.length?` ${Et.length} attachment(s) carried over.`:"")+(Ue.length?` Invite FAILED for ${Ue.join("; ")}.`:"")),Ue.length&&ge(`Some invites failed — ${Ue.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),Rn.length&&ge(`Attachment carry-over failed for ${Rn.join("; ")} — the room and post were created; re-attach in the new room.`),Ne(""),Ke(""),Ee(""),kt("fyi"),dt([]),delete Bt.current[O],wl(Bt.current),await us(),je(De),setTimeout(()=>ot(""),6e3)}catch(xe){ge(`group creation failed: ${String((xe==null?void 0:xe.message)||xe)}`)}finally{qn(!1)}}async function Zr(){var ne;const u=Y.trim(),v=tt.length>0,S=!Ie&&!O.startsWith("dm:")&&et==="group";if(!u&&!v&&!S||Qn||!O)return;if(S){const B=Iu(we);if(!B.length){ge("Group needs at least one member — write their names like: @entity @assistant");return}const xe=ze.trim()||(u?u.split(`
118
- `)[0].slice(0,80):`focused work with ${B.join(", ")}`);await Zs({title:xe,members:B,opening_body:u});return}if(/^\/assistant(?=\s|$)/i.test(u)){if(!f){ge("AI advisor is not configured — connect a gateway or inject an advisor.");return}const B=u.replace(/^\/assistant/i,"").trim();Ne(""),B?Tn(B):Zt("assistant");return}if(/^\/group(?=\s|$)/i.test(u)){await Vi(u.replace(/^\/group/i,"").trim());return}if(/^\//.test(u)){ge(`Unknown command "${u.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const w=Object.entries(_t).filter(([,B])=>B).map(([B])=>B),T=O.startsWith("dm:");if(Ie&&(((ne=Ie.data)==null?void 0:ne.asks)||[]).length&&!w.length&&Xt!=="void_reply"){mn("void_reply");return}if(!Ie&&!T&&et==="ask"&&!ze.trim()&&Xt!=="untitled_open"){mn("untitled_open");return}if(!Ie&&!T&&et==="dm"&&!ht.trim()){ge("Pick a recipient for the direct message.");return}qn(!0),ge("");try{if(!Ie&&!T&&et==="dm"){const B=ht.trim(),xe=[...tt],De=O;await l.send_dm(B,{body:u||(xe.length?`(${xe.length} attachment${xe.length===1?"":"s"})`:u),title:ze.trim()||void 0});const Be=`dm:${[Nt,B].sort().join("--")}`;if(xe.length){const{migrated:Ue,att_failed:Mt}=await ja(De,Be,xe);Ue.length&&await l.post_message(Be,{body:"",to:[B],attachments:Ue}),ot(`DM sent to ${B}${Ue.length?` with ${Ue.length} attachment(s)`:""}.`),Mt.length&&ge(`Attachment carry-over failed for ${Mt.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ot(`DM sent to ${B}.`);await us(),je(Be)}else{const B=tt.map(Be=>({id:Be.id,filename:Be.filename})),xe=T?Rf(O,Nt):"";T&&!xe&&ge(`#FALLBACK this dm's pair does not include seat '${Nt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const De={body:u,title:ze.trim()||void 0,status:fy({is_reply:!!Ie,in_dm:T,kind:et}),to:xe?[xe]:void 0,reply_to:Ie==null?void 0:Ie.id,answers:Ie&&w.length?w:void 0,attachments:B.length?B:void 0};try{await l.post_message(O,De)}catch(Be){if(xe&&/address non-members/i.test(String((Be==null?void 0:Be.message)||Be)))await l.post_message(O,{...De,to:void 0}),ge(`#FALLBACK '${xe}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw Be}ot(T?"Sent.":"Posted."),await ds(O,{background:!0}),!T&&u&&Xr(O,u)}Ne(""),Ke(""),dt([]),mt(null),gt({}),kt("fyi"),Qt(""),mn(""),delete Bt.current[O],wl(Bt.current),setTimeout(()=>ot(""),3e3)}catch(B){ge(String((B==null?void 0:B.message)||B||"Post failed"))}finally{qn(!1)}}async function eo(u){if(!(!O||!u||ha||qe)){Tr(!0);try{await l.ack(O,u),ot(`Marked read to #${u}.`),setTimeout(()=>ot(""),3e3),ya(En.current)}catch(v){ge(String((v==null?void 0:v.message)||v||"Ack failed"))}finally{Tr(!1)}}}const _n=!!(P!=null&&P.seat_key_present)&&!($!=null&&$.paused),Nt=(P==null?void 0:P.seat)||"",Jt=O.startsWith("dm:"),ei=(()=>{if(!Jt)return"";const u=O.slice(3);return Nt&&u.startsWith(`${Nt}--`)?u.slice(Nt.length+2):Nt&&u.endsWith(`--${Nt}`)?u.slice(0,u.length-Nt.length-2):u||O})(),to=h.useMemo(()=>hy(te),[te]),ms=h.useMemo(()=>({seat:Nt,unread_seqs:Me[O],unread_snapshot_seqs:Ce==="unread"&&Re||void 0,escalated_seqs:L[O]}),[Nt,Me,O,Ce,Re,L]),fs=h.useMemo(()=>{if(Ie)return null;const u=new Set(oe.map(S=>S.name)),v=Y.trimStart();if(/^\/group(\s|$)/i.test(v)){const{title:S,members:w}=Pu(v.replace(/^\/group/i,"").trim()),T=S||(w.length?`focused work with ${w.join(", ")}`:"");return{name:T?Ou(T,u):"group",members:w,source:"slash"}}if(et==="group"&&!O.startsWith("dm:")){const S=Iu(we),w=ze.trim()||(S.length?`focused work with ${S.join(", ")}`:"");return{name:w?Ou(w,u):"group",members:S,source:"kind"}}return null},[Y,Ie,oe,et,we,ze,O]),an=h.useMemo(()=>iy(te),[te]),As=h.useMemo(()=>Af(an,Ce,ms),[an,Ce,ms]),[ea,lr]=h.useState("recency"),[or,ta]=h.useState(null),no=h.useRef(null);h.useEffect(()=>{no.current=or},[or]);const[Gi,ti]=h.useState("");function At(){const u=A.current;ta(null),ti(""),l.messages(O,{sort:"votes",limit:50}).then(v=>{u===A.current&&ta(v)}).catch(v=>{if(u!==A.current)return;const S=String((v==null?void 0:v.message)||v);ti((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 Ki(u){Ys.current={message_id:u.id,seq:u.seq},lr("recency"),requestAnimationFrame(()=>sr())}const[cr,ka]=h.useState(""),[na,Qi]=h.useState("all"),[rn,Sa]=h.useState(""),[gn,ur]=h.useState(null),[Ji,hs]=h.useState(null),Hn=h.useRef(0);function sa(u,v,S){if(!u&&!S)return;const w=++Hn.current;hs(null),ur({q:u,report:null,error:"",busy:!0}),l.search({q:u,channel:v==="channel"&&O?[O]:void 0,rated:S||void 0,sort:!u&&S?"votes":void 0}).then(T=>{w===Hn.current&&ur({q:u,report:T,error:"",busy:!1})}).catch(T=>{if(w!==Hn.current)return;const ne=String((T==null?void 0:T.message)||T);ur({q:u,report:null,busy:!1,error:(T==null?void 0:T.status)===404||/allowlist/i.test(ne)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":ne})})}function ni(u){sa(u.trim(),na,rn)}function dr(){Hn.current+=1,ur(null),hs(null),Sa("")}function Yi(u,v){const S=(gn==null?void 0:gn.q)||"";if(!S&&!rn)return;const w=++Hn.current;hs({label:u,kind:v,hits:[],total:0,cursor:null,busy:!0,error:""}),l.search({q:S,kind:v,sort:"recent",limit:50,rated:rn||void 0,channel:na==="channel"&&O?[O]:void 0}).then(T=>{if(w!==Hn.current)return;const ne=si(T,v);hs({label:u,kind:v,hits:ne.hits,total:ne.total,cursor:T.next_cursor??null,busy:!1,error:""})}).catch(T=>{w===Hn.current&&hs({label:u,kind:v,hits:[],total:0,cursor:null,busy:!1,error:String((T==null?void 0:T.message)||T)})})}function Xi(){const u=Ji,v=(gn==null?void 0:gn.q)||"";if(!u||!u.cursor||u.busy||!v&&!rn)return;const S=Hn.current;hs({...u,busy:!0}),l.search({q:v,kind:u.kind,sort:"recent",limit:50,cursor:u.cursor,rated:rn||void 0,channel:na==="channel"&&O?[O]:void 0}).then(w=>{if(S!==Hn.current)return;const T=si(w,u.kind);hs(ne=>ne&&ne.kind===u.kind?{...ne,hits:[...ne.hits,...T.hits],cursor:w.next_cursor??null,busy:!1}:ne)}).catch(w=>{S===Hn.current&&hs(T=>T&&T.kind===u.kind?{...T,busy:!1,error:String((w==null?void 0:w.message)||w)}:T)})}function si(u,v){const S=Ho.find(T=>T.kind===v),w=S?u[S.id]:void 0;return w?{hits:w.hits||[],total:w.total||0}:{hits:[],total:0}}function dc(u){const v=String(u.channel||"");v&&(Ys.current={message_id:u.kind==="message"?u.ref:void 0,seq:u.seq??void 0},dr(),lr("recency"),v===O?sr():je(v))}async function so(u){const v=String(u.channel||""),S=String(u.ref||"");if(!v||!S)return;const w=Sr(S,"text/markdown");Ut({name:S,mode:w==="image"?"text":w,meta:`#${v}`,loading:!0});try{const T=await l.fs_read(v,S),ne=Sr(S,T.mime);Ut({name:S,mode:ne==="image"?"text":ne,text:Go(T.content),content_type:T.mime,meta:`#${v} · ${T.updated_by||"?"} · v${T.version??"?"}`,loading:!1})}catch(T){Ut({name:S,mode:"text",meta:`#${v}`,error:String((T==null?void 0:T.message)||T||"failed to read file")})}}function ao(u){const v=u.kind==="message"&&!!u.channel,S=u.kind==="file"&&!!u.channel,w=v||S,T=Ey(String(u.snippet||""),u.highlights),ne=u.ratings,B=String(u.channel||""),xe=B?B.startsWith("dm:")?B:`#${B}`:"";return e.jsxs("div",{className:`team_search_hit${w?" clickable":""}`,onClick:w?()=>S?void so(u):dc(u):void 0,role:w?"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,xe?e.jsx("span",{className:"team_search_chan mono",children:xe}):null,u.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${pd(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,ne&&(ne.up||ne.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",ne.up," ▽",ne.down]}):null,u.created_at?e.jsx("span",{className:"muted team_search_time",children:kl(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((De,Be)=>De.hit?e.jsx("mark",{children:De.text},Be):e.jsx(Ht.Fragment,{children:De.text},Be))}):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 mc=h.useMemo(()=>{let u=0;for(const v of As)for(const S of[v.root,...v.replies])u=Math.max(u,S.seq||0);return u},[As]),Zi=h.useMemo(()=>{const u={};for(const v of["asks","vigilance","fyi","resolved","to_me"])u[v]=Af(an,v,ms).length;return u.unread=te.filter(v=>{var S,w;return((S=ms.unread_seqs)==null?void 0:S.has(v.seq))||((w=ms.unread_snapshot_seqs)==null?void 0:w.has(v.seq))}).length,u},[an,te,ms]);function Rs(){var u,v;return Rt==="loading"?e.jsx("span",{className:"muted team_note",children:"Loading channel info…"}):Rt&&typeof Rt=="object"&&"error"in Rt?e.jsx("span",{className:"page_error mono",children:Rt.error}):Rt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_info_row",children:[Rt.state?e.jsx(On,{tone:Rt.state==="open"?"success":"warning",size:"sm",children:Rt.state}):null,(u=Rt.channel)!=null&&u.private?e.jsx(On,{tone:"muted",size:"sm",children:"private"}):e.jsx(On,{tone:"muted",size:"sm",children:"public"}),Rt.response_sla_minutes?e.jsxs(On,{tone:"muted",size:"sm",title:"Expected response SLA",children:["SLA ",Math.round(Number(Rt.response_sla_minutes)/60),"h"]}):null,e.jsxs("span",{className:"muted team_note",children:[(Bn??Rt.members??[]).length," members"]})]}),(v=Rt.meta)!=null&&v.purpose?e.jsx("div",{className:"team_info_purpose",children:Rt.meta.purpose}):null,Rt.charter?e.jsxs("div",{className:"team_info_charter",children:[e.jsx("div",{className:"muted team_note",style:{marginBottom:4},children:"Charter"}),e.jsx(rs,{className:"md_doc",text:Nl(String(Rt.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})`:""]}),!Jt&&Bn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Ir,onChange:S=>Si(S.target.value),disabled:!!Ga,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Bs.filter(S=>!(Bn||[]).some(w=>String(w.agent_id||"")===S)).filter(S=>!(Rl[O]||new Set).has(S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),e.jsx("button",{className:"btn",disabled:!Ir||!!Ga,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void Zl(Ir),children:Ga?"Inviting…":"Invite"})]}):null,Ci?e.jsx("div",{className:"muted team_note",children:Ci}):null,(()=>{const S=[...Rl[O]||[]].filter(w=>!(Bn||[]).some(T=>String(T.agent_id||"")===w));return!S.length||Bn===null?null:S.map(w=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Ia(w),"aria-hidden":"true",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:w}),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:${w}`))})(),Ll?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Ll.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 w=String(S.agent_id||"");return w?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(w),"aria-hidden":"true",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(S.about||""),children:w}),w!==Nt&&!Jt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Pt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void Kr(w,"kick"),children:Pt===`channel:kick:${w}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Ot===`channel:ban:${w}`?"team_danger":""}`,disabled:!!Pt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Ot===`channel:ban:${w}`?(sn(""),Kr(w,"ban")):sn(`channel:ban:${w}`)},children:Pt===`channel:ban:${w}`?"banning…":Ot===`channel:ban:${w}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Ot===`hub:ban:${w}`?"team_danger":""}`,disabled:!!Pt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Ot===`hub:ban:${w}`?(sn(""),Kr(w,"ban","hub")):sn(`hub:ban:${w}`)},children:Pt===`hub:ban:${w}`?"hub-banning…":Ot===`hub:ban:${w}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Ot===`retire:${w}`?"team_danger":""}`,disabled:!!Pt,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:()=>{Ot===`retire:${w}`?(sn(""),Qr(w)):sn(`retire:${w}`)},children:Pt===`retire:${w}`?"retiring…":Ot===`retire:${w}`?"confirm retire":"retire"})]}):w===Nt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},w):null})]}),!Jt&&qs&&qs.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",qs.length,")"]}),qs.map(S=>{const w=String(S.agent_id||S.agent||"");if(!w)return null;const T=String(S.scope||""),ne=T==="hub",B=ne?"hub":"channel",xe=S.expires_at?` · until ${new Date(Number(S.expires_at)*1e3).toLocaleString()}`:" · indefinite",De=ne?"hub-wide":`#${T}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(w),"aria-hidden":"true",children:(w[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[w,e.jsxs("span",{className:"muted team_note",children:[De,xe]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Pt,title:ne?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void Kr(w,"unblock",B),children:Pt===`${B}:unblock:${w}`?"unblocking…":"unblock"})})]},`blocked:${T}:${w}`)})]}):null,!Jt&&Mr&&Mr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Mr.length,")"]}),Mr.map(S=>{const w=String(S.id||"");if(!w)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:Ia(w),"aria-hidden":"true",children:(w[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[w,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 ${Ot===`unretire:${w}`?"team_danger":""}`,disabled:!!Pt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Ot===`unretire:${w}`?(sn(""),lc(w)):sn(`unretire:${w}`)},children:Pt===`unretire:${w}`?"un-retiring…":Ot===`unretire:${w}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Ot===`delete:${w}`?"team_danger":""}`,disabled:!!Pt,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:()=>{Ot===`delete:${w}`?(sn(""),Vl(w)):sn(`delete:${w}`)},children:Pt===`delete:${w}`?"deleting…":Ot===`delete:${w}`?"confirm delete":"delete"})]})]},`retired:${w}`)})]}):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:"ⓘ"})]}),Lt===null?e.jsx("span",{className:"muted team_note",children:Ha||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Lt.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Lt.map(S=>{const w=String(S.agent_id||""),T=Array.isArray(S.powers)?S.powers.map(String):[],ne=Number(S.expires_at||S.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(w),"aria-hidden":"true",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:w}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(S.note||""),children:[T.join(" + ")||"(no powers?)",ne?` · until ${new Date(ne*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Ot===`resign:${w}`?"team_danger":""}`,disabled:is,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Ot===`resign:${w}`?(sn(""),nc(w)):sn(`resign:${w}`)},children:is?"resigning…":Ot===`resign:${w}`?"confirm resign":"resign"})]},w)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pa,onChange:S=>Va(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??Rt.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!==Nt&&!Lt.some(w=>String(w.agent_id)===S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),pa?e.jsxs("div",{className:"team_delegation_powers_pick",children:[Hy.map(S=>e.jsxs("label",{className:"team_delegation_power",title:S.help,children:[e.jsx("input",{type:"checkbox",checked:fn.includes(S.id),onChange:w=>zl(T=>w.target.checked?[...T,S.id]:T.filter(ne=>ne!==S.id))}),S.id]},S.id)),e.jsx("button",{className:"btn",disabled:is||!fn.length,title:fn.length?`Grant ${pa} the powers: ${fn.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void tc(),children:is?"Assigning…":"Assign"})]}):null]}),Ha?e.jsx("div",{className:"page_error mono",children:Ha}):null]})]}),Jt?null:e.jsx("div",{className:"team_chan_admin",children:fr?String(Rt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:Gt,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void Jr("closed"),children:Gt?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:Gt,title:"Reopen this channel for member posts",onClick:()=>void Jr("open"),children:Gt?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",Ls||"unknown",")."]})}),Pr?e.jsx("div",{className:"page_error mono",children:Pr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function ro(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((w,T)=>{const ne=`${w.id}:${T}`,B=l.attachment_url(u.channel,w.id);return By.has(String(w.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${w.filename} · ${Dn(w.size)} — click to preview`,onClick:()=>void Es(u.channel,w),children:[e.jsx("img",{className:"team_attach_img",src:B,alt:w.filename,loading:"lazy",onError:De=>{var Mt;const Be=De.currentTarget;Be.style.display="none";const Ue=(Mt=Be.parentElement)==null?void 0:Mt.querySelector(".team_attach_fallback");Ue&&(Ue.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(at,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:w.filename}),e.jsx("span",{className:"muted",children:Dn(w.size)})]})]},ne):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${w.content_type} · ${Dn(w.size)} — click to preview`,onClick:()=>void Es(u.channel,w),children:[e.jsx(at,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:w.filename}),e.jsx("span",{className:"muted",children:Dn(w.size)})]},ne)})}):null}function Na(u,v){var xe;const S=[],w=String(u.status||"").toLowerCase();(w==="open"||w==="blocked")&&(u.has_resolved_reply===!0||(u.id?to.has(u.id):!1))?S.push(e.jsx(On,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):w==="open"||w==="blocked"?S.push(e.jsx(On,{tone:w==="blocked"?"error":"warning",size:"sm",children:w},"st")):w==="resolved"&&v&&S.push(e.jsx(On,{tone:"success",size:"sm",children:"resolved"},"st")),u.critical&&S.push(e.jsx(On,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const ne=((xe=u.data)==null?void 0:xe.answers)||[];w==="reply"&&ne.length&&S.push(e.jsxs(On,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${ne.join(", ")} of its parent.`,children:["✓ answers ",ne.join(",")]},"dis"));const B=u.to||[];for(const De of B.slice(0,2))S.push(e.jsxs(On,{tone:"muted",size:"sm",children:["@",De]},`to:${De}`));return B.length>2&&S.push(e.jsxs(On,{tone:"muted",size:"sm",title:B.map(De=>`@${De}`).join(" "),children:["+",B.length-2]},"to+")),S}function An(u,v){return e.jsx(Ch,{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:Wf(u.sender),children:u.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",u.seq," · ",jl(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+`
119
- `:"")+String(u.body||"(no text)")})]})}),children:mr(u,v)},u.id)}function mr(u,v){var xt,rt,bn,bt;const S=!!ie[u.id],w=String(u.body||""),T=v.is_root?Vo:Ff,ne=w.length>T,B=ne&&!S,xe=((xt=u.data)==null?void 0:xt.asks)||[],De=!!((rt=ms.unread_seqs)!=null&&rt.has(u.seq)),Be=Ce!=="all"&&ly(u,Ce,ms),Ue=String(u.title||"").trim(),Mt=((bn=w.trim().split(`
120
- `)[0])==null?void 0:bn.trim())||"",Et=Ue&&(Ue===w.trim()||Ue===Mt),Rn=(Ie==null?void 0:Ie.id)===u.id;return e.jsxs("div",{className:`team_row ${u.sender===Nt?"own":""} ${Be?"hit":""} ${Rn?"replying":""} ${De?"unread":""} ${u.retracted?"retracted":""}`,id:`hubmsg-${u.id}`,onClick:()=>Ul(u),title:ne?void 0:u.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Ia(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:[(bt=ce[u.channel])!=null&&bt.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 ${$s===u.id?"armed":""}`,title:$s===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:He=>{He.stopPropagation(),rc(u)},children:$s===u.id?"sure? declines on the record":"decline"})]}):De?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:Wf(u.sender),children:u.sender}),Na(u,v.is_root),(()=>{const He=Vr(u);return!He||!He.up&&!He.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${He.mine>0?"pos":He.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:[He.up?`▲${He.up}`:"",He.up&&He.down?" ":"",He.down?`▼${He.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:kl(u.created_at),children:["#",u.seq," · ",jl(u.created_at)]})]}),Ue&&!Et?e.jsx("div",{className:"team_row_title",children:Ue}):null,e.jsx("div",{className:`team_row_body ${B?v.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(Ly,{className:"md_doc",text:Nl(jy(yy(w),{hub_base:F}))})}),ro(u),(()=>{var jt;const He=gy(`${String(u.title||"")}
121
- ${w}`),Ct=((jt=u.data)==null?void 0:jt.attachments)||u.attachments||[],ln=He.map(ft=>({mention:ft,res:vy(ft,ic,Ct)})).filter(ft=>ft.res!==null).filter(ft=>{var zt;return!(ft.res.kind==="attachment"&&String(((zt=Ct[ft.res.attachment_index])==null?void 0:zt.filename)||"")===ft.mention)}),en=a.on_open_board?Dg(`${String(u.title||"")}
122
- ${w}`):[];return!ln.length&&!en.length?null:e.jsxs("div",{className:"team_fs_chips",children:[ln.map(({mention:ft,res:zt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:zt.kind==="fs"?zt.rewritten?`Opens ${zt.path} (the mention's path moved — matched by name in #${O}'s files)`:`Open ${zt.path} from #${O}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:Ln=>{Ln.stopPropagation(),zt.kind==="fs"?rr(zt.path):Es(u.channel,Ct[zt.attachment_index])},children:[e.jsx(Uf,{}),e.jsx("span",{className:"team_attach_name",children:ft}),zt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):zt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},ft)),en.map(ft=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${ft} — open the Board filtered to it`,onClick:zt=>{var Ln;zt.stopPropagation(),(Ln=a.on_open_board)==null||Ln.call(a,ft)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:ft})]},`w:${ft}`))]})})(),xe.length?e.jsx("div",{className:"team_row_asks",children:xe.map(He=>e.jsxs("span",{className:"team_ask",title:He.text,children:["ask ",He.id,": ",He.text.length>90?He.text.slice(0,90)+"…":He.text]},He.id))}):null,ne?e.jsx("button",{className:"team_row_expand",onClick:He=>{He.stopPropagation(),Bl(u)},children:S?"collapse":"show more"}):null]}),_n?e.jsxs("div",{className:"team_row_rail",children:[u.id&&u.sender!==Nt&&u.sender!=="hub"&&!u.retracted?(()=>{const He=Vr(u);return He?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${He.mine>0?"up_on":""}`,title:He.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!Pi,onClick:Ct=>{Ct.stopPropagation(),Ii(u.id,1)},children:[e.jsx(at,{name:He.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),He.up?e.jsx("span",{className:"team_thumb_count",children:He.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${He.mine<0?"down_on":""}`,title:He.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!Pi,onClick:Ct=>{Ct.stopPropagation(),Ii(u.id,-1)},children:[e.jsx(at,{name:He.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),He.down?e.jsx("span",{className:"team_thumb_count",children:He.down}):null]})]}):null})():null,E.tts_supported&&u.id?(()=>{const He=E.tts_playback.key===u.id&&E.tts_playback.status==="playing",Ct=E.tts_playback.key===u.id&&E.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${He||Ct?"team_speak_on":""}`,title:He?"Pause":Ct?"Synthesizing…":_.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":He?"Pause reading":"Read this message aloud",onClick:ln=>{ln.stopPropagation();const en=Bv(u.body||u.title||"");en?E.toggle_tts(u.id,en):ge("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(at,{name:He?"pause":Ct?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:xe.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:He=>{He.stopPropagation(),uc(u)},children:"↩ Reply"}),u.sender===Nt&&!u.retracted?e.jsx("button",{className:`btn btn_icon ${ir===u.id?"team_danger":""}`,title:ir===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:He=>{He.stopPropagation(),ir===u.id?Yl(u):Wi(u.id)},children:ir===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 ${Ts===u.id?"team_danger":""}`,title:Ts===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:He=>{He.stopPropagation(),Ts===u.id?Hi(u):Ui(u.id)},children:Ts===u.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},u.id)}function ps(u){const v=u.replies.length,S=!!Se[u.root.id],w=!!be[u.root.id],T=S?[]:w||Ce!=="all"||v<=qf+1?u.replies:u.replies.slice(v-qf),ne=S?v:v-T.length,B=Ss[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,An(u.root,{is_root:!0}),ne>0||v>0||String(u.root.body||"").length>Vo?e.jsxs("div",{className:"team_trail_bar",children:[v>0?e.jsx("button",{className:"team_replies_more",onClick:()=>Xe(xe=>({...xe,[u.root.id]:!xe[u.root.id]})),children:S?`show ${v} repl${v===1?"y":"ies"}`:"fold thread"}):null,!S&&ne>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>G(xe=>({...xe,[u.root.id]:!0})),children:["↓ ",ne," earlier repl",ne===1?"y":"ies"]}):null,!S&&f&&(v>0||String(u.root.body||"").length>Vo)?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 cc(u),children:B!=null&&B.busy?"✦ summarizing…":`✦ Summarize (${v+1})`}):null]}):null,!S&&v>0?e.jsx("div",{className:"team_replies",children:T.map(xe=>An(xe,{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.count," message",B.count===1?"":"s"]}),e.jsx("button",{className:"team_row_expand",onClick:()=>ls(xe=>({...xe,[u.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(rs,{className:"md_doc",text:Nl(B.text)})]}):null,B!=null&&B.error?e.jsx("div",{className:"page_error mono",children:B.error}):null]},u.root.id)}const el=te.length?te[te.length-1].seq:0,fc=Math.max(el,((aa=oe.find(u=>u.name===O))==null?void 0:aa.last_seq)||0),io=((hr=oe.find(u=>u.name===O))==null?void 0:hr.member_count)||0,Ls=((ai=(Bn||[]).find(u=>String(u.role||"")==="owner"))==null?void 0:ai.agent_id)||"",fr=!!Nt&&Ls===Nt;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(),_n&&!yt&&Oe(!0))},onDragLeave:u=>{u.currentTarget.contains(u.relatedTarget)||Oe(!1)},onDrop:u=>{var v,S;(S=(v=u.dataTransfer)==null?void 0:v.files)!=null&&S.length&&(u.preventDefault(),Oe(!1),!(!_n||yt)&&Xl(u.dataTransfer.files))},children:[qt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Jt?ei:`#${O}`]})}):null,$!=null&&$.protocol&&$.protocol!==Ko||$!=null&&$.paused||ye||Gs||wi||P&&!P.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[P&&!P.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!==Ko?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${$.protocol}; this page was written against ${Ko}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",$.protocol," ≠ ",Ko]}):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,ye?e.jsx("span",{className:"page_error mono",children:ye}):null,Gs?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",Gs]}):null,wi?e.jsx("span",{className:"chip mono ok",children:wi}):null]}):null,e.jsxs("div",{className:`team_layout ${St?"with_drawer":""} ${St==="leaderboard"?"drawer_wide":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:oe.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:()=>Us(u=>({...u,open:!u.open})),children:e.jsx(at,{name:"plus",size:14})})})]}),ks.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:ks.name,onChange:u=>Us(v=>({...v,name:u.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:u=>{u.key==="Enter"&&Ql()}}),e.jsxs("label",{title:"Private channels need invites; public ones are joinable by any registered agent.",children:[e.jsx("input",{type:"checkbox",checked:ks.is_private,onChange:u=>Us(v=>({...v,is_private:u.target.checked}))}),"private"]}),e.jsx("button",{className:"btn primary",disabled:!ks.name.trim()||Gt,onClick:()=>void Ql(),children:Gt?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[oe.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:ye?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),oe.filter(u=>!u.name.startsWith("dm:")).map(u=>{const v=pe[u.name],S=Kl===u.name;return e.jsxs("div",{className:`team_channel team_dm_row ${O===u.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>je(u.name),onKeyDown:w=>{(w.key==="Enter"||w.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:w=>{w.stopPropagation(),u.name!==O&&(me.current="unread"),je(u.name),We("unread")},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.stopPropagation(),u.name!==O&&(me.current="unread"),je(u.name),We("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:w=>{w.stopPropagation(),u.name!==O&&(me.current="asks"),je(u.name),We("asks")},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.stopPropagation(),u.name!==O&&(me.current="asks"),je(u.name),We("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:Gt,onClick:w=>{w.stopPropagation(),S?oc(u.name):Bi(u.name)},children:e.jsx(at,{name:S?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:S?"archive? click ✕":`${u.member_count} seats · ${jl(u.last_at)}`})]},u.name)}),(()=>{const u=oe.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=pe[v.name],w=v.name.replace(/^dm:/,"").split("--").filter(ne=>ne!==Nt).join("")||v.name,T=Fi===v.name;return e.jsxs("div",{className:`team_channel team_dm_row ${O===v.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>je(v.name),onKeyDown:ne=>{(ne.key==="Enter"||ne.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:["@",w]}),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:Gt,onClick:ne=>{ne.stopPropagation(),T?Gl(v.name):qi(v.name)},children:e.jsx(at,{name:T?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:T?"remove? click ✕":jl(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("span",{className:"pane_title team_pane_title",children:O?Jt?`@${ei} — direct`:`#${O}`:"Select a channel"}),O&&io?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{St!=="members"&&xa("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[io," members"]}):null,qe?e.jsx("span",{className:"muted team_note",children:"loading…"}):null,e.jsxs("span",{className:"pane_header_actions",children:[E.tts_playback.status!=="idle"?e.jsx("button",{className:"btn team_speak_stop",title:"Stop reading aloud",onClick:()=>E.stop_tts(),children:"◼ Stop reading"}):null,(()=>{const u=Ce==="all"?fc:mc;return e.jsx("button",{className:"btn",onClick:()=>void eo(u),disabled:!O||!te.length||!u||ha||qe,title:Ce==="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:ha?"Marking…":`Mark read → #${u||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{us(),ds(O)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(at,{name:"refresh",size:14})}),Vt&&Vt!=="running"&&typeof Vt=="object"&&"ok"in Vt?Vt.ok?e.jsxs(On,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Vt.hashed} hashed turns (${Vt.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Vt.hashed,")"]}):e.jsxs(On,{tone:"error",size:"sm",title:Vt.broken_at!==null?`Recomputed chain diverges at seq ${Vt.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",Vt.broken_at!==null?` at #${Vt.broken_at}`:" (head mismatch)"]}):null,Vt&&typeof Vt=="object"&&"error"in Vt?e.jsx(On,{tone:"warning",size:"sm",title:Vt.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void ac(),disabled:!O||Vt==="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:Vt==="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:Tf.map(u=>{const v=Ce===u.id,S=Zi[u.id];return e.jsxs("button",{className:`seg_btn ${v?"active":""}`,"aria-pressed":v,title:u.title,onClick:()=>We(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=cr.trim();if(!v&&!rn){Sa("down"),sa("",na,"down");return}ni(v)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:cr,onChange:u=>ka(u.target.value),onKeyDown:u=>{u.key==="Escape"&&(gn&&dr(),ka(""))},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"}),gn?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:dr,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:()=>lr("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:()=>{lr("votes"),At()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Ti?"on":""}`,title:Ti?"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:Ti?"● live":"◌ polling"})," · ",As.length!==an.length?`${As.length} of ${an.length} threads`:an.length?`${an.length} threads`:"",P!=null&&P.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",P.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:va,children:gn?(()=>{const u=gn;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(Ji){const T=Ji;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:()=>hs(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(ne=>ao(ne)),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:Xi,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=Ho.filter(T=>{var ne;return!((((ne=v[T.id])==null?void 0:ne.total)??0)>0)}),w=S.length<Ho.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${rn?` (${rn==="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 ${rn===T?"active":""}`,"aria-pressed":rn===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 ne=rn===T?"":T;Sa(ne),sa(u.q,na,ne)},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:na==="channel",onChange:T=>{const ne=T.target.checked?"channel":"all";Qi(ne),sa(u.q,ne,rn)}}),"this channel only"]})]}),Ho.map(T=>{const ne=v[T.id],B=(ne==null?void 0:ne.shown)??0,xe=(ne==null?void 0:ne.total)??0,De=(ne==null?void 0:ne.hits)??[];return!ne||!xe&&!De.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<xe?`showing ${B} of ${xe}`:`${xe}`}),B<xe&&T.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>Yi(T.label,T.kind),title:`All ${xe} ${T.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),De.map(Be=>ao(Be))]},T.id)}),w?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"?Gi?e.jsx("div",{className:"muted team_note",children:Gi}):or===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):or.length?or.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:()=>Ki(u),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),An(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 As){const w=S.replies.length?S.replies[S.replies.length-1]:S.root,T=Vy(w.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(ps(S))}return u})(),!As.length&&O&&!qe?e.jsx("div",{className:"muted team_note",children:an.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((ra=Tf.find(u=>u.id===Ce))==null?void 0:ra.label)||Ce})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>We("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:u=>{u.key==="Escape"&&Ie&&Xs()},children:[Ie?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-${Ie.id}`))==null||u.scrollIntoView({block:"center"})},children:["↩ #",Ie.seq," (",Ie.sender,") —"," ",(String(Ie.title||"").trim()||String(Ie.body||"").trim()).slice(0,80)||"(no text)"]}),(((_s=Ie.data)==null?void 0:_s.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:((($t=Ie.data)==null?void 0:$t.asks)||[]).map(u=>e.jsxs("label",{title:u.text,children:[e.jsx("input",{type:"checkbox",checked:!!_t[u.id],onChange:v=>gt(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:Xs,children:"cancel (Esc)"})]}):null,Xt==="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 ",Ie?"Reply":"Post"," again to send as-is."]}):null,Xt==="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,fs?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:fs.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:["#",fs.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",fs.members.map(u=>`@${u}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:fs.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!Ie&&!Jt&&(et==="ask"||et==="group")?e.jsx("input",{className:"team_ask_title",value:ze,onChange:u=>Ke(u.target.value),placeholder:et==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!_n}):null,!Ie&&!Jt&&et==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:we,onChange:u=>Ee(u.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!_n,list:"team_roster_options"}):null,!Ie&&!Jt&&et==="group"&&Bs.length?e.jsx("datalist",{id:"team_roster_options",children:Bs.map(u=>e.jsx("option",{value:`@${u}`},u))}):null,tt.length?e.jsx("div",{className:"team_attach_pending",children:tt.map(u=>e.jsxs("span",{className:"team_attach_chip",title:`${u.content_type} · ${Dn(u.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void Es(O,u),"aria-label":`Preview ${u.filename}`,children:[e.jsx(at,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:u.filename}),e.jsx("span",{className:"muted",children:Dn(u.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${u.filename}`,title:"Remove this attachment",onClick:()=>dt(v=>v.filter(S=>S.id!==u.id)),children:e.jsx(at,{name:"x",size:10})})]},u.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!Ie&&!Jt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:et,onChange:u=>{const v=u.target.value,S=v==="ask"?"ask":v==="dm"?"dm":v==="group"?"group":"fyi";kt(S),S!=="ask"&&S!=="group"&&Ke(""),S!=="group"&&Ee("")},disabled:!_n,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,!Ie&&!Jt&&et==="dm"?Bs.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:ht,onChange:u=>Qt(u.target.value),disabled:!_n,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Bs.map(u=>e.jsx("option",{value:u,children:u},u))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:ht,onChange:u=>Qt(u.target.value),placeholder:"to: agent id",disabled:!_n,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:it,className:"team_compose_text",rows:2,value:Y,onChange:u=>Ne(u.target.value),placeholder:_n?Ie?`Reply to #${Ie.seq} in #${O}…`:Jt?`Message ${ei}…`:et==="dm"?`Direct message${ht.trim()?` to ${ht.trim()}`:""}…`:f?`Message #${O||"…"} as ${(P==null?void 0:P.seat)||"operator"} — or /assistant <question>`:`Message #${O||"…"} as ${(P==null?void 0:P.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:!_n,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),!Qn&&(Y.trim()||tt.length)&&Zr())}}),e.jsx("input",{ref:Tt,type:"file",multiple:!0,style:{display:"none"},onChange:u=>void Xl(u.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!_n||yt||tt.length>=bl,title:tt.length>=bl?`Attachment limit (${bl}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var u;return(u=Tt.current)==null?void 0:u.click()},children:e.jsx(at,{name:"paperclip",size:14})}),e.jsx("button",{className:"btn primary team_send",disabled:!_n||Qn||!Y.trim()&&!tt.length&&!(et==="group"&&!Ie&&!Jt&&Iu(we).length>0),onClick:()=>void Zr(),children:Qn?"Sending…":fs!=null&&fs.members.length||!Ie&&!Jt&&et==="group"?"Create room":Ie?"Reply":Jt||et==="dm"?"Send DM":et==="ask"?"Ask":"Send"})]})]})]}),St==="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:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Zt(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[qr.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",O," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",te.length," messages) and cites seqs. It never posts to the room."]}),qr.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(rs,{className:"md_doc",text:Nl(u.content)})]},v)),Qs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,Br?e.jsx("div",{className:"page_error mono",children:Br}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(ec,{value:Ks,onChange:Za,onSubmit:()=>{const u=Ks;Za(""),Tn(u)},placeholder:f?`Ask about #${O}…`:"AI advisor is not configured for this shell.",disabled:!f,busy:Qs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,St==="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:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Zt(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:Rs()})]}):null,St==="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:["#",O]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Zt(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${cs===""?"active":""}`,onClick:()=>ga(""),title:"Channel root",children:["#",O||"…"]}),cs?cs.split("/").map((u,v,S)=>{const w=S.slice(0,v+1).join("/");return e.jsxs(Ht.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${v===S.length-1?"active":""}`,onClick:()=>ga(w),children:u})]},w)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:_a===null&&!es?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):es?e.jsx("div",{className:"page_error mono",children:es}):_a&&_a.length?(()=>{const{dirs:u,leaves:v}=my(_a,cs);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:()=>ga(S.path),title:`${S.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Uy,{})}),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 wa(S),title:`${S.updated_by||"?"} · ${kl(S.updated_at)} · v${S.version} · ${Dn(S.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Uf,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:S.path.slice(cs?cs.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:[Dn(S.size)," · ",jl(S.updated_at)]})]},S.path))]})})():e.jsx("div",{className:"muted team_note",children:"No files in this channel's virtual filesystem yet."})})]}):null,St==="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":`#${O}`}),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:()=>{Qa("channel"),zi("channel")},disabled:!O,title:`This channel's board (#${O||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${Wn==="hub"?"active":""}`,onClick:()=>{Qa("hub"),zi("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Zt(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:Un===null&&!Ws?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Ws?e.jsx("div",{className:"muted team_note",children:Ws}):!Un||Un.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(Un==null?void 0:Un.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 w;const u=Array.isArray(Un.categories)||Un.leaderboard.some(T=>T.breakdown!=null||typeof T.score=="number"),v=u?(w=Un.categories)!=null&&w.length?Un.categories:["general",...yi.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:Hf[T]||`${Sl(T)} — reputation category.`,children:Sl(T)},T))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),yi.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"})]})]}),Un.leaderboard.map((T,ne)=>e.jsxs(Ht.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${Ja===T.target?"open":""}`,style:S,onClick:()=>Wl(T.target),role:"button",tabIndex:0,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),Wl(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 ${ne<3?`top${ne+1}`:""}`,"aria-hidden":"true",children:ne<3?"●":ne+1}),e.jsx("span",{className:"team_avatar",style:Ia(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),xe=T.votes;return e.jsxs("span",{className:`team_lb_total ${B>0?"pos":B<0?"neg":""}`,title:(()=>{const De=Object.entries(T.breakdown||{}).filter(([,Be])=>Be&&Number(Be.score||0)!==0).map(([Be,Ue])=>`${Sl(Be)} ${Number(Ue.score)>0?"+":""}${Number(Ue.score)}`).join(" · ");return`${T.target}: score ${B>0?"+":""}${B} = ${De||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${xe?` — total: ${xe.up} up, ${xe.down} down`:""}`})(),children:[B>0?`+${B}`:B,xe&&(xe.up||xe.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[xe.up,"↑"]}),e.jsxs("span",{className:xe.down>0?"rv_down_hot":"rv_down",children:[xe.down,"↓"]})]}):null]})})(),v.map(B=>{var Ue;const xe=(Ue=T.breakdown)==null?void 0:Ue[B],De=Number((xe==null?void 0:xe.score)||0),Be=!!(xe&&(xe.up||xe.down||xe.raters));return e.jsx("span",{className:`team_lb_axis ${De>0?"pos":De<0?"neg":""}`,title:Be?`${Sl(B)}: ${De>0?"+":""}${De} (▲${xe.up} ▼${xe.down} voices · ${xe.raters} engaged colleague${xe.raters===1?"":"s"}) — ${Hf[B]||"reputation category"}`:`${Sl(B)}: no standing input`,children:Be?De>0?`+${De}`:De:"·"},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}),yi.map(B=>{var Be;const xe=(Be=T.axes)==null?void 0:Be[B.id],De=(xe==null?void 0:xe.score)||0;return e.jsx("span",{className:`team_lb_axis ${De>0?"pos":De<0?"neg":""}`,title:xe?`${B.label}: ${xe.up} up, ${xe.down} down`:`${B.label}: no votes`,children:xe?De>0?`+${De}`:De:"·"},B.id)}),(()=>{const B=T.messages,xe=B?B.up-B.down:0;return e.jsx("span",{className:`team_lb_axis ${xe>0?"pos":xe<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}`:""}`:"·"})})()]})]}),Ja===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 ${Nt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",Nt||"operator",":"]}),yi.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:!!$i||T.target===Nt,onClick:xe=>{xe.stopPropagation(),Oi(T.target,B.id,1)},title:`+1 ${B.label} for ${T.target}`,children:e.jsx(at,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!$i||T.target===Nt,onClick:xe=>{xe.stopPropagation(),Oi(T.target,B.id,-1)},title:`-1 ${B.label} for ${T.target}`,children:e.jsx(at,{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:Vs,maxLength:280,onChange:B=>Ya(B.target.value),onClick:B=>B.stopPropagation()}),Gs?e.jsx("div",{className:"team_lb_error",children:Gs}):null,Hs===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Hs.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."}):Hs.map(B=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Ia(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(at,{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,Ja===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,St==="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 he(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Zt(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[X==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,X===null&&ue?e.jsx("div",{className:"muted team_note",children:ue}):null,X!==null&&X!=="loading"?e.jsxs(e.Fragment,{children:[X.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),X.rows.map((u,v)=>{const S=Number(u.age_minutes),w=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:w})]}),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:()=>{Ys.current={message_id:u.id?String(u.id):void 0,seq:Number(u.seq)||void 0},String(u.channel)===O?sr():je(String(u.channel)),Zt("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(u.id||u.key||v))}),X.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:"}),X.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:[f?e.jsx("button",{className:`team_drawer_tab ${St==="assistant"?"active":""}`,onClick:()=>xa("assistant"),disabled:!O,"aria-pressed":St==="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 ${St==="members"?"active":""}`,onClick:()=>xa("members"),disabled:!O,"aria-pressed":St==="members","aria-label":"Open channel members drawer",title:"Channel members — roster, moderation, and channel lifecycle",children:"Members"}),e.jsx("button",{className:`team_drawer_tab ${St==="files"?"active":""}`,onClick:()=>xa("files"),disabled:!O,"aria-pressed":St==="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 ${St==="leaderboard"?"active":""}`,onClick:()=>xa("leaderboard"),disabled:!O,"aria-pressed":St==="leaderboard","aria-label":"Open reputation leaderboard drawer",title:"Reputation leaderboard — trust, wisdom, thorough, helper; per-channel and hub-wide",children:"Leaderboard"}),(()=>{const u=X!==null&&X!=="loading"?X:null,v=u?u.rows.length:0,S=u?u.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${St==="desk"?"active":""}`,onClick:()=>xa("desk"),"aria-pressed":St==="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(Ry,{view:Fr,onClose:()=>Ut(null)})]})}const Vf=[{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"}],sd="abstractcontinuum_settings_v1";function Ky(){try{const a=window.localStorage.getItem(sd)||"{}",s=JSON.parse(a);if(s&&(s.auth_token||s.gateway_url)){delete s.auth_token,delete s.gateway_url;try{window.localStorage.setItem(sd,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 Qy(){var je;const[a,s]=h.useState("board"),[r,l]=h.useState(null),[c,f]=h.useState(null),[d,p]=h.useState(()=>Ky()),[_,y]=h.useState(!1),[b,x]=h.useState(!1),[N,C]=h.useState(0),[I,E]=h.useState(!1),[P,U]=h.useState(!1),[D,F]=E_("continuum"),[Q,$]=h.useState(0),[Z,oe]=h.useState(null),[le,pe]=h.useState("");h.useEffect(()=>{if(!Z)return;const te=setTimeout(()=>oe(null),8e3);return()=>clearTimeout(te)},[Z]);const[Ae,Me]=h.useState(!1);h.useEffect(()=>{var Re;const te=((Re=document.querySelector('script[type="module"][src*="/assets/"]'))==null?void 0:Re.getAttribute("src"))||"";if(!te)return;let ke=!1;async function Ce(){try{const Pe=await fetch("/",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Pe.ok)return;const ye=(await Pe.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),ge=(ye==null?void 0:ye[1])||"";!ke&&ge&&te&&ge!==te&&Me(!0)}catch{}}const We=()=>void Ce();window.addEventListener("focus",We);const me=setInterval(()=>void Ce(),300*1e3);return Ce(),()=>{ke=!0,window.removeEventListener("focus",We),clearInterval(me)}},[]);function ve(te){pe(String(te||"")),s("executions")}h.useEffect(()=>{const te=ke=>{var Ce;Array.from(((Ce=ke.dataTransfer)==null?void 0:Ce.types)||[]).includes("Files")&&ke.preventDefault()};return window.addEventListener("dragover",te),window.addEventListener("drop",te),()=>{window.removeEventListener("dragover",te),window.removeEventListener("drop",te)}},[]);const[ce,q]=h.useState(!1);h.useEffect(()=>{a==="team"&&q(!0)},[a]);function L(te){var me;const ke=te.target,Ce=(me=ke==null?void 0:ke.closest)==null?void 0:me.call(ke,"a[href]");if(!Ce||Ce.target==="_blank"||Ce.hasAttribute("download"))return;const We=Ce.getAttribute("href")||"";We.startsWith("/")&&(te.preventDefault(),window.open(We,"_blank","noopener"))}h.useEffect(()=>{try{window.localStorage.setItem(sd,JSON.stringify(d))}catch{}},[d]);const W=h.useMemo(()=>new vg({base_url:""}),[]),X=o_({appName:"AbstractContinuum",onStatusChange:()=>C(te=>te+1)}),M=X.status,ue=h.useMemo(()=>v_("abstractcontinuum",hg),[]),[V,j]=h.useState(mf),R=h.useRef(0);function ee(){const te=++R.current;j(mf),xg(W).then(ke=>{te===R.current&&j(ke)})}const _e=h.useRef(0);h.useEffect(()=>{let te=!1,ke;return(async()=>{try{await W.list_processes(),te||(_e.current=0,y(!0))}catch{if(te)return;_e.current+=1,_e.current>=2?y(!1):ke=window.setTimeout(()=>{te||C(Ce=>Ce+1)},2e3)}})(),()=>{te=!0,ke!==void 0&&window.clearTimeout(ke)}},[W,a,N]);const he=h.useRef(_);h.useEffect(()=>{he.current&&!_&&(M!=null&&M.has_session)&&X.refresh(),he.current=_},[_,M==null?void 0:M.has_session]);async function O(te,ke){const Ce=[...ke.history.map(me=>({role:me.role,content:me.content})),{role:"user",content:te}],We=await W.backlog_advisor({messages:Ce,agent:d.backlog_advisor_agent||null});return String((We==null?void 0:We.reply)||"").trim()||"(the advisor returned an empty reply)"}return e.jsxs("div",{className:"shell",onClickCapture:L,children:[e.jsxs("aside",{className:"shell_sidebar",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",children:Vf.map(te=>e.jsxs("button",{className:`shell_nav_item ${a===te.id?"active":""}`,onClick:()=>s(te.id),title:te.label,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(at,{name:te.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:te.label})]},te.id))})]}),e.jsxs("div",{className:"shell_main",children:[e.jsxs("header",{className:"shell_header",children:[e.jsx("div",{className:"shell_header_title",children:((je=Vf.find(te=>te.id===a))==null?void 0:je.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(N_,{assistant:{open:I,onToggle:()=>E(te=>!te)},appearance:{onOpen:()=>U(!0)},about:{identity:ue,extraRows:V,onOpen:ee},extraActions:e.jsx("button",{className:"btn primary",onClick:()=>x(!0),disabled:!_,children:"+ New task"}),connection:{phase:X.phase,signingOut:X.signingOut,onConnect:X.openModal,onDisconnect:()=>void X.signOut()}})})]}),!_&&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:X.openModal,children:"Connect"})]}):null,X.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",X.signOutError," — the session may still be live."]})}):null,Z?e.jsxs("div",{className:`shell_banner ${Z.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:Z.text}),e.jsx("button",{className:"btn",onClick:()=>oe(null),children:"Dismiss"})]}):null,Ae?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(gv,{gateway:W,gateway_connected:_,data_nonce:Q,on_mutated:()=>$(te=>te+1),on_open_executions:ve,default_execution_mode:d.default_execution_mode,query_preset:r,on_query_preset_consumed:()=>l(null),on_open_team:te=>{f(te),s("team")},on_new_task:()=>x(!0)}):null,a==="executions"?e.jsx(Rv,{gateway:W,gateway_connected:_,focus_request_id:le,on_focus_consumed:()=>pe(""),on_open_settings:()=>s("settings")}):null,a==="backlog"?e.jsx(av,{gateway:W,gateway_connected:_,maintenance_ai_provider:d.maintenance_ai_provider,maintenance_ai_model:d.maintenance_ai_model,maintenance_ai_reasoning:d.maintenance_ai_reasoning,backlog_advisor_agent:d.backlog_advisor_agent,default_execution_mode:d.default_execution_mode,on_open_executions:ve}):null,a==="agents"?e.jsx(Mg,{gateway:W,gateway_connected:_,backlog_advisor_agent:d.backlog_advisor_agent,on_open_assistant:()=>E(!0),on_open_team:()=>s("team"),on_open_executions:()=>ve()}):null,ce?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(Ch,{fallback:te=>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(te.message||te)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(Gy,{gateway:W,gateway_connected:_,advisor:_?async(te,ke)=>{const Ce=[...ke.map(me=>({role:me.role,content:me.content})),{role:"user",content:te}],We=await W.backlog_advisor({messages:Ce,agent:d.backlog_advisor_agent||null});return String((We==null?void 0:We.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:d.backlog_advisor_agent,on_open_board:te=>{l(te||null),s("board")},focus:c,on_focus_consumed:()=>f(null)})})}):null,a==="inbox"?e.jsx(Iv,{gateway:W,gateway_connected:_,enable_triage:!0}):null,a==="services"?e.jsx(zv,{gateway:W,gateway_connected:_}):null,a==="settings"?e.jsx(Jv,{gateway:W,gateway_connected:_,settings:d,set_settings:p,connection:M}):null]})]}),e.jsx(i_,{...X.modalProps}),e.jsx(f_,{open:I,onClose:()=>E(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(mg,{ask:O,assistantName:"Continuum advisor",blockedNotice:_?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(T_,{open:P,onClose:()=>U(!1),value:D,onChange:F}),e.jsx(rv,{open:b,gateway:W,can_use_gateway:_,maint_provider:d.maintenance_ai_provider,maint_model:d.maintenance_ai_model,maint_reasoning:d.maintenance_ai_reasoning,on_close:()=>x(!1),on_created:async(te,ke,Ce)=>{$(me=>me+1);const We=String(te||"");s(We==="recurrent"?"backlog":"board"),oe(Ce?{text:`Task created (${ke}), but attachments failed: ${Ce}`,tone:"warn"}:{text:`Task created: ${ke} (${We||"?"})${We==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}const Ph=document.getElementById("root");if(!Ph)throw new Error("root element missing");Cp.createRoot(Ph).render(e.jsx(Ht.StrictMode,{children:e.jsx(Qy,{})}));export{ty as _,yp as g};
123
- //# sourceMappingURL=index-CFGJJTR4.js.map