@abstractframework/continuum 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -17
- package/bin/cli.js +157 -32
- package/bin/hub_proxy.js +37 -17
- package/bin/settings.js +511 -0
- package/dist/assets/{abnfDiagram-VRR7QNED-DHZzhKO_.js → abnfDiagram-VRR7QNED-DkP5u0Ku.js} +2 -2
- package/dist/assets/{arc-9iPl5OLd.js → arc-vxPq5BjA.js} +2 -2
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-BVRc0NRl.js → architectureDiagram-ZJ3FMSHR-ku0NT7zM.js} +2 -2
- package/dist/assets/{blockDiagram-677ZJIJ3-BTIe50OR.js → blockDiagram-677ZJIJ3-DXQQcNdo.js} +2 -2
- package/dist/assets/{c4Diagram-LMCZKHZV-D5P-4VLr.js → c4Diagram-LMCZKHZV-DuZ33cED.js} +2 -2
- package/dist/assets/channel-tvH0KUyT.js +2 -0
- package/dist/assets/{chunk-2Q5K7J3B-WcmxYPWP.js → chunk-2Q5K7J3B-BGWsS7uu.js} +2 -2
- package/dist/assets/{chunk-32BRIVSS-BPArWk_S.js → chunk-32BRIVSS-BgokockY.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DplW9bbf.js → chunk-5VM5RSS4-OLY5jTMg.js} +2 -2
- package/dist/assets/{chunk-EX3LRPZG-B8O0P99j.js → chunk-EX3LRPZG-BWHQVZSz.js} +2 -2
- package/dist/assets/{chunk-JWPE2WC7-DZoiE5m4.js → chunk-JWPE2WC7-CuM7Hcrw.js} +2 -2
- package/dist/assets/{chunk-MOJQB5TN-FqMZZAe1.js → chunk-MOJQB5TN-DI56DwNK.js} +2 -2
- package/dist/assets/{chunk-RYQCIY6F-D4I_kub_.js → chunk-RYQCIY6F-phvbPmeC.js} +2 -2
- package/dist/assets/{chunk-V7JOEXUC-CwJZa6s3.js → chunk-V7JOEXUC-Cv7eW1t4.js} +2 -2
- package/dist/assets/{chunk-VR4S4FIN-CdF7hCRc.js → chunk-VR4S4FIN-D8k2SzA3.js} +2 -2
- package/dist/assets/{chunk-XXDRQBXY-C2vm2DXm.js → chunk-XXDRQBXY-DZy8Plz8.js} +2 -2
- package/dist/assets/classDiagram-OUVF2IWQ-C0x6Ou39.js +2 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-C0x6Ou39.js +2 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-BEoqSVoj.js → cose-bilkent-JH36ORCC-CiwWaVUb.js} +2 -2
- package/dist/assets/{cynefin-VYW2F7L2-DzsDaKjB.js → cynefin-VYW2F7L2-Cz79Fwdx.js} +2 -2
- package/dist/assets/{cynefinDiagram-TSTJHNR4-qVt2ETEm.js → cynefinDiagram-TSTJHNR4-DYlkii-x.js} +2 -2
- package/dist/assets/{dagre-VKFMJZFB-BszpuHqM.js → dagre-VKFMJZFB-Cumo7o1R.js} +2 -2
- package/dist/assets/{diagram-FQU43EPY-DkSwN897.js → diagram-FQU43EPY-Dorm69_e.js} +2 -2
- package/dist/assets/{diagram-G47NLZAW-DmmkniMR.js → diagram-G47NLZAW-Bhtzc4JU.js} +2 -2
- package/dist/assets/{diagram-NH7WQ7WH-PkbaZ3fb.js → diagram-NH7WQ7WH-DJF-iHCK.js} +2 -2
- package/dist/assets/{diagram-OA4YK3LP-D5O-VGkx.js → diagram-OA4YK3LP-8mQ4915-.js} +2 -2
- package/dist/assets/{diagram-WEI45ONY-CtS1f8zZ.js → diagram-WEI45ONY-C4Bv6dbm.js} +2 -2
- package/dist/assets/{ebnfDiagram-CCIWWBDH-2ydDo0Sq.js → ebnfDiagram-CCIWWBDH-DzagnQVX.js} +2 -2
- package/dist/assets/{erDiagram-Q63AITRT-Dc-2Dmcc.js → erDiagram-Q63AITRT-BbkYElA6.js} +2 -2
- package/dist/assets/{flowDiagram-23GEKE2U-DKKOHSrp.js → flowDiagram-23GEKE2U-OcR4vkjk.js} +2 -2
- package/dist/assets/{ganttDiagram-NO4QXBWP-B9Zi-Zd_.js → ganttDiagram-NO4QXBWP-DyAPiIdB.js} +2 -2
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-lXzgHn-s.js → gitGraphDiagram-IHSO6WYX-pymEefZi.js} +2 -2
- package/dist/assets/index-D0YdqMpf.css +1 -0
- package/dist/assets/index-DTn9k-3t.js +123 -0
- package/dist/assets/{infoDiagram-FWYZ7A6U-BHV_H3bL.js → infoDiagram-FWYZ7A6U-Dh41Som-.js} +2 -2
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-BX74rKth.js → ishikawaDiagram-FXEZZL3T-Xc9vuvPV.js} +2 -2
- package/dist/assets/{journeyDiagram-5HDEW3XC-BByysGFJ.js → journeyDiagram-5HDEW3XC-bJ0gK8bC.js} +2 -2
- package/dist/assets/{kanban-definition-HUTT4EX6-DatfLmCp.js → kanban-definition-HUTT4EX6-Cu1Zn3KW.js} +2 -2
- package/dist/assets/{linear-BgTPNh4i.js → linear-DrGsraGo.js} +2 -2
- package/dist/assets/{mermaid.core-CrABX5SH.js → mermaid.core-CkQqPHPZ.js} +5 -5
- package/dist/assets/{mindmap-definition-LN4V7U3C-Bz1XgdXA.js → mindmap-definition-LN4V7U3C-ZCEP6XWH.js} +2 -2
- package/dist/assets/{pegDiagram-2B236MQR-D5B8Egll.js → pegDiagram-2B236MQR-DjDrn07n.js} +2 -2
- package/dist/assets/{pieDiagram-ENE6RG2P-BaDg4f41.js → pieDiagram-ENE6RG2P-oD3ciEy7.js} +2 -2
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-jr1V5VXJ.js → quadrantDiagram-ABIIQ3AL-CYbDYNM7.js} +2 -2
- package/dist/assets/{railroadDiagram-RFXS5EU6-F13Ho8ra.js → railroadDiagram-RFXS5EU6-DMcO7O0d.js} +2 -2
- package/dist/assets/{requirementDiagram-TGXJPOKE-DXb_w8Ww.js → requirementDiagram-TGXJPOKE-DeeSIVn-.js} +2 -2
- package/dist/assets/{sankeyDiagram-HTMAVEWB-BN42kL5b.js → sankeyDiagram-HTMAVEWB-C43xzNvP.js} +2 -2
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-DI7-dEyi.js → sequenceDiagram-DBY2YBRQ-d3lj6z8y.js} +2 -2
- package/dist/assets/{sizeCapture-X5ZJPWSS-Dv-15ctr.js → sizeCapture-X5ZJPWSS-D4UyeLsX.js} +2 -2
- package/dist/assets/{stateDiagram-2N3HPSRC-De5ObM42.js → stateDiagram-2N3HPSRC-Cq4YMMP1.js} +2 -2
- package/dist/assets/stateDiagram-v2-6OUMAXLB-DMVYrQgX.js +2 -0
- package/dist/assets/{swimlanes-5IMT3BWC-DzZwgXNi.js → swimlanes-5IMT3BWC-CRbkVLoI.js} +3 -3
- package/dist/assets/swimlanesDiagram-G3AALYLV-Bzg2g7oq.js +9 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-BO8KkL_w.js → timeline-definition-FHXFAJF6-BN8oLdvs.js} +2 -2
- package/dist/assets/{vennDiagram-L72KCM5P-D6LUv_CX.js → vennDiagram-L72KCM5P-BqAHS4HE.js} +2 -2
- package/dist/assets/{wardleyDiagram-EHGQE667-DWJp0Lmi.js → wardleyDiagram-EHGQE667-D2aA14yL.js} +2 -2
- package/dist/assets/{xychartDiagram-FW5EYKEG-B5IA4jNf.js → xychartDiagram-FW5EYKEG-BkrnnKWS.js} +2 -2
- package/dist/index.html +2 -2
- package/package.json +2 -2
- package/dist/assets/channel-CEGeSBNz.js +0 -2
- package/dist/assets/classDiagram-OUVF2IWQ-D11Ru5dS.js +0 -2
- package/dist/assets/classDiagram-v2-EOCWNBFH-D11Ru5dS.js +0 -2
- package/dist/assets/index-CCcufdYK.css +0 -1
- package/dist/assets/index-DmnZnFTc.js +0 -124
- package/dist/assets/stateDiagram-v2-6OUMAXLB-D9AwhP3S.js +0 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-DyzT80_E.js +0 -9
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var up=Object.defineProperty;var dp=(a,s,r)=>s in a?up(a,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[s]=r;var kr=(a,s,r)=>dp(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 m of c)if(m.type==="childList")for(const f of m.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&l(f)}).observe(document,{childList:!0,subtree:!0});function r(c){const m={};return c.integrity&&(m.integrity=c.integrity),c.referrerPolicy&&(m.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?m.credentials="include":c.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function l(c){if(c.ep)return;c.ep=!0;const m=r(c);fetch(c.href,m)}})();function mp(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var fu={exports:{}},hl={},hu={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 qm;function fp(){if(qm)return ut;qm=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"),m=Symbol.for("react.provider"),f=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(){}},O=Object.assign,E={};function D(j,R,U){this.props=j,this.context=R,this.refs=E,this.updater=U||C}D.prototype.isReactComponent={},D.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")},D.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function P(){}P.prototype=D.prototype;function G(j,R,U){this.props=j,this.context=R,this.refs=E,this.updater=U||C}var F=G.prototype=new P;F.constructor=G,O(F,D.prototype),F.isPureReactComponent=!0;var J=Array.isArray,$=Object.prototype.hasOwnProperty,ee={current:null},oe={key:!0,ref:!0,__self:!0,__source:!0};function ce(j,R,U){var le,ae={},M=null,ye=null;if(R!=null)for(le in R.ref!==void 0&&(ye=R.ref),R.key!==void 0&&(M=""+R.key),R)$.call(R,le)&&!oe.hasOwnProperty(le)&&(ae[le]=R[le]);var xe=arguments.length-2;if(xe===1)ae.children=U;else if(1<xe){for(var Oe=Array(xe),Fe=0;Fe<xe;Fe++)Oe[Fe]=arguments[Fe+2];ae.children=Oe}if(j&&j.defaultProps)for(le in xe=j.defaultProps,xe)ae[le]===void 0&&(ae[le]=xe[le]);return{$$typeof:a,type:j,key:M,ref:ye,props:ae,_owner:ee.current}}function pe(j,R){return{$$typeof:a,type:j.type,key:R,ref:j.ref,props:j.props,_owner:j._owner}}function Ee(j){return typeof j=="object"&&j!==null&&j.$$typeof===a}function Ae(j){var R={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(U){return R[U]})}var _e=/\/+/g;function ue(j,R){return typeof j=="object"&&j!==null&&j.key!=null?Ae(""+j.key):R.toString(36)}function q(j,R,U,le,ae){var M=typeof j;(M==="undefined"||M==="boolean")&&(j=null);var ye=!1;if(j===null)ye=!0;else switch(M){case"string":case"number":ye=!0;break;case"object":switch(j.$$typeof){case a:case s:ye=!0}}if(ye)return ye=j,ae=ae(ye),j=le===""?"."+ue(ye,0):le,J(ae)?(U="",j!=null&&(U=j.replace(_e,"$&/")+"/"),q(ae,R,U,"",function(Fe){return Fe})):ae!=null&&(Ee(ae)&&(ae=pe(ae,U+(!ae.key||ye&&ye.key===ae.key?"":(""+ae.key).replace(_e,"$&/")+"/")+j)),R.push(ae)),1;if(ye=0,le=le===""?".":le+":",J(j))for(var xe=0;xe<j.length;xe++){M=j[xe];var Oe=le+ue(M,xe);ye+=q(M,R,U,Oe,ae)}else if(Oe=N(j),typeof Oe=="function")for(j=Oe.call(j),xe=0;!(M=j.next()).done;)M=M.value,Oe=le+ue(M,xe++),ye+=q(M,R,U,Oe,ae);else if(M==="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 ye}function L(j,R,U){if(j==null)return j;var le=[],ae=0;return q(j,le,"","",function(M){return R.call(U,M,ae++)}),le}function W(j){if(j._status===-1){var R=j._result;R=R(),R.then(function(U){(j._status===0||j._status===-1)&&(j._status=1,j._result=U)},function(U){(j._status===0||j._status===-1)&&(j._status=2,j._result=U)}),j._status===-1&&(j._status=0,j._result=R)}if(j._status===1)return j._result.default;throw j._result}var Z={current:null},z={transition:null},de={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:z,ReactCurrentOwner:ee};function V(){throw Error("act(...) is not supported in production builds of React.")}return ut.Children={map:L,forEach:function(j,R,U){L(j,function(){R.apply(this,arguments)},U)},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(!Ee(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},ut.Component=D,ut.Fragment=r,ut.Profiler=c,ut.PureComponent=G,ut.StrictMode=l,ut.Suspense=_,ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=de,ut.act=V,ut.cloneElement=function(j,R,U){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var le=O({},j.props),ae=j.key,M=j.ref,ye=j._owner;if(R!=null){if(R.ref!==void 0&&(M=R.ref,ye=ee.current),R.key!==void 0&&(ae=""+R.key),j.type&&j.type.defaultProps)var xe=j.type.defaultProps;for(Oe in R)$.call(R,Oe)&&!oe.hasOwnProperty(Oe)&&(le[Oe]=R[Oe]===void 0&&xe!==void 0?xe[Oe]:R[Oe])}var Oe=arguments.length-2;if(Oe===1)le.children=U;else if(1<Oe){xe=Array(Oe);for(var Fe=0;Fe<Oe;Fe++)xe[Fe]=arguments[Fe+2];le.children=xe}return{$$typeof:a,type:j.type,key:ae,ref:M,props:le,_owner:ye}},ut.createContext=function(j){return j={$$typeof:f,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},j.Provider={$$typeof:m,_context:j},j.Consumer=j},ut.createElement=ce,ut.createFactory=function(j){var R=ce.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=Ee,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=z.transition;z.transition={};try{j()}finally{z.transition=R}},ut.unstable_act=V,ut.useCallback=function(j,R){return Z.current.useCallback(j,R)},ut.useContext=function(j){return Z.current.useContext(j)},ut.useDebugValue=function(){},ut.useDeferredValue=function(j){return Z.current.useDeferredValue(j)},ut.useEffect=function(j,R){return Z.current.useEffect(j,R)},ut.useId=function(){return Z.current.useId()},ut.useImperativeHandle=function(j,R,U){return Z.current.useImperativeHandle(j,R,U)},ut.useInsertionEffect=function(j,R){return Z.current.useInsertionEffect(j,R)},ut.useLayoutEffect=function(j,R){return Z.current.useLayoutEffect(j,R)},ut.useMemo=function(j,R){return Z.current.useMemo(j,R)},ut.useReducer=function(j,R,U){return Z.current.useReducer(j,R,U)},ut.useRef=function(j){return Z.current.useRef(j)},ut.useState=function(j){return Z.current.useState(j)},ut.useSyncExternalStore=function(j,R,U){return Z.current.useSyncExternalStore(j,R,U)},ut.useTransition=function(){return Z.current.useTransition()},ut.version="18.3.1",ut}var Bm;function td(){return Bm||(Bm=1,hu.exports=fp()),hu.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 Um;function hp(){if(Um)return hl;Um=1;var a=td(),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,m={key:!0,ref:!0,__self:!0,__source:!0};function f(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)&&!m.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 hl.Fragment=r,hl.jsx=f,hl.jsxs=f,hl}var Wm;function pp(){return Wm||(Wm=1,fu.exports=hp()),fu.exports}var e=pp(),h=td();const Kt=mp(h);var Fo={},pu={exports:{}},In={},_u={exports:{}},gu={};/**
|
|
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 Hm;function _p(){return Hm||(Hm=1,(function(a){function s(z,de){var V=z.length;z.push(de);e:for(;0<V;){var j=V-1>>>1,R=z[j];if(0<c(R,de))z[j]=de,z[V]=R,V=j;else break e}}function r(z){return z.length===0?null:z[0]}function l(z){if(z.length===0)return null;var de=z[0],V=z.pop();if(V!==de){z[0]=V;e:for(var j=0,R=z.length,U=R>>>1;j<U;){var le=2*(j+1)-1,ae=z[le],M=le+1,ye=z[M];if(0>c(ae,V))M<R&&0>c(ye,ae)?(z[j]=ye,z[M]=V,j=M):(z[j]=ae,z[le]=V,j=le);else if(M<R&&0>c(ye,V))z[j]=ye,z[M]=V,j=M;else break e}}return de}function c(z,de){var V=z.sortIndex-de.sortIndex;return V!==0?V:z.id-de.id}if(typeof performance=="object"&&typeof performance.now=="function"){var m=performance;a.unstable_now=function(){return m.now()}}else{var f=Date,p=f.now();a.unstable_now=function(){return f.now()-p}}var _=[],y=[],b=1,x=null,N=3,C=!1,O=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,G=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(z){for(var de=r(y);de!==null;){if(de.callback===null)l(y);else if(de.startTime<=z)l(y),de.sortIndex=de.expirationTime,s(_,de);else break;de=r(y)}}function J(z){if(E=!1,F(z),!O)if(r(_)!==null)O=!0,W($);else{var de=r(y);de!==null&&Z(J,de.startTime-z)}}function $(z,de){O=!1,E&&(E=!1,P(ce),ce=-1),C=!0;var V=N;try{for(F(de),x=r(_);x!==null&&(!(x.expirationTime>de)||z&&!Ae());){var j=x.callback;if(typeof j=="function"){x.callback=null,N=x.priorityLevel;var R=j(x.expirationTime<=de);de=a.unstable_now(),typeof R=="function"?x.callback=R:x===r(_)&&l(_),F(de)}else l(_);x=r(_)}if(x!==null)var U=!0;else{var le=r(y);le!==null&&Z(J,le.startTime-de),U=!1}return U}finally{x=null,N=V,C=!1}}var ee=!1,oe=null,ce=-1,pe=5,Ee=-1;function Ae(){return!(a.unstable_now()-Ee<pe)}function _e(){if(oe!==null){var z=a.unstable_now();Ee=z;var de=!0;try{de=oe(!0,z)}finally{de?ue():(ee=!1,oe=null)}}else ee=!1}var ue;if(typeof G=="function")ue=function(){G(_e)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,L=q.port2;q.port1.onmessage=_e,ue=function(){L.postMessage(null)}}else ue=function(){D(_e,0)};function W(z){oe=z,ee||(ee=!0,ue())}function Z(z,de){ce=D(function(){z(a.unstable_now())},de)}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(z){z.callback=null},a.unstable_continueExecution=function(){O||C||(O=!0,W($))},a.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):pe=0<z?Math.floor(1e3/z):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_getFirstCallbackNode=function(){return r(_)},a.unstable_next=function(z){switch(N){case 1:case 2:case 3:var de=3;break;default:de=N}var V=N;N=de;try{return z()}finally{N=V}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(z,de){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var V=N;N=z;try{return de()}finally{N=V}},a.unstable_scheduleCallback=function(z,de,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,z){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,z={id:b++,callback:de,priorityLevel:z,startTime:V,expirationTime:R,sortIndex:-1},V>j?(z.sortIndex=V,s(y,z),r(_)===null&&z===r(y)&&(E?(P(ce),ce=-1):E=!0,Z(J,V-j))):(z.sortIndex=R,s(_,z),O||C||(O=!0,W($))),z},a.unstable_shouldYield=Ae,a.unstable_wrapCallback=function(z){var de=N;return function(){var V=N;N=de;try{return z.apply(this,arguments)}finally{N=V}}}})(gu)),gu}var Vm;function gp(){return Vm||(Vm=1,_u.exports=_p()),_u.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 Gm;function vp(){if(Gm)return In;Gm=1;var a=td(),s=gp();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 m(t,n){f(t,n),f(t+"Capture",n)}function f(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 O(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,d,g,k){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=o,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=g,this.removeEmptyString=k}var D={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){D[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];D[n]=new E(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){D[t]=new E(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){D[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){D[t]=new E(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){D[t]=new E(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){D[t]=new E(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){D[t]=new E(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){D[t]=new E(t,5,!1,t.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function G(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(P,G);D[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(P,G);D[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(P,G);D[n]=new E(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){D[t]=new E(t,1,!1,t.toLowerCase(),null,!1,!1)}),D.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){D[t]=new E(t,1,!1,t.toLowerCase(),null,!0,!0)});function F(t,n,i,o){var d=D.hasOwnProperty(n)?D[n]:null;(d!==null?d.type!==0:o||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(O(n,i,d,o)&&(i=null),o||d===null?N(n)&&(i===null?t.removeAttribute(n):t.setAttribute(n,""+i)):d.mustUseProperty?t[d.propertyName]=i===null?d.type===3?!1:"":i:(n=d.attributeName,o=d.attributeNamespace,i===null?t.removeAttribute(n):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,o?t.setAttributeNS(o,n,i):t.setAttribute(n,i))))}var J=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),ee=Symbol.for("react.portal"),oe=Symbol.for("react.fragment"),ce=Symbol.for("react.strict_mode"),pe=Symbol.for("react.profiler"),Ee=Symbol.for("react.provider"),Ae=Symbol.for("react.context"),_e=Symbol.for("react.forward_ref"),ue=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),z=Symbol.iterator;function de(t){return t===null||typeof t!="object"?null:(t=z&&t[z]||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 U=!1;function le(t,n){if(!t||U)return"";U=!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(me){var o=me}Reflect.construct(t,[],n)}else{try{n.call()}catch(me){o=me}t.call(n.prototype)}else{try{throw Error()}catch(me){o=me}t()}}catch(me){if(me&&o&&typeof me.stack=="string"){for(var d=me.stack.split(`
|
|
35
|
+
`),g=o.stack.split(`
|
|
36
|
+
`),k=d.length-1,I=g.length-1;1<=k&&0<=I&&d[k]!==g[I];)I--;for(;1<=k&&0<=I;k--,I--)if(d[k]!==g[I]){if(k!==1||I!==1)do if(k--,I--,0>I||d[k]!==g[I]){var H=`
|
|
37
|
+
`+d[k].replace(" at new "," at ");return t.displayName&&H.includes("<anonymous>")&&(H=H.replace("<anonymous>",t.displayName)),H}while(1<=k&&0<=I);break}}}finally{U=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?R(t):""}function ae(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=le(t.type,!1),t;case 11:return t=le(t.type.render,!1),t;case 1:return t=le(t.type,!0),t;default:return""}}function M(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 ee:return"Portal";case pe:return"Profiler";case ce:return"StrictMode";case ue:return"Suspense";case q:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Ae:return(t.displayName||"Context")+".Consumer";case Ee:return(t._context.displayName||"Context")+".Provider";case _e: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:M(t.type)||"Memo";case W:n=t._payload,t=t._init;try{return M(t(n))}catch{}}return null}function ye(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 M(n);case 8:return n===ce?"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 xe(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Oe(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Fe(t){var n=Oe(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 d=i.get,g=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return d.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 Ze(t){t._valueTracker||(t._valueTracker=Fe(t))}function he(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),o="";return t&&(o=Oe(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=xe(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 be(t,n){n=n.checked,n!=null&&F(t,"checked",n,!1)}function ge(t,n){be(t,n);var i=xe(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")?Je(t,n.type,i):n.hasOwnProperty("defaultValue")&&Je(t,n.type,xe(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 Je(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 d=0;d<i.length;d++)n["$"+i[d]]=!0;for(i=0;i<t.length;i++)d=n.hasOwnProperty("$"+t[i].value),t[i].selected!==d&&(t[i].selected=d),d&&o&&(t[i].defaultSelected=!0)}else{for(i=""+xe(i),n=null,d=0;d<t.length;d++){if(t[d].value===i){t[d].selected=!0,o&&(t[d].defaultSelected=!0);return}n!==null||t[d].disabled||(n=t[d])}n!==null&&(n.selected=!0)}}function we(t,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return V({},n,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function K(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:xe(i)}}function ke(t,n){var i=xe(n.value),o=xe(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 Ye(t){var n=t.textContent;n===t._wrapperState.initialValue&&n!==""&&n!==null&&(t.value=n)}function Y(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"?Y(n):t==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var X,Se=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,o,d){MSApp.execUnsafeLocalFunction(function(){return t(n,i,o,d)})}:t})(function(t,n){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=n;else{for(X=X||document.createElement("div"),X.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=X.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function Le(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var Ge={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(Ge).forEach(function(t){tt.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),Ge[n]=Ge[t]})});function dt(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||Ge.hasOwnProperty(t)&&Ge[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,d=dt(i,n[i],o);i==="float"&&(i="cssFloat"),o?t.setProperty(i,d):t[i]=d}}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 ze=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 je(t){kt?ht?ht.push(t):ht=[t]:kt=t}function Ce(){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 Me(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 Me(t,n,i)}finally{_t=!1,(kt!==null||ht!==null)&&(mt(),Ce())}}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,d,g,k,I,H){var me=Array.prototype.slice.call(arguments,3);try{n.apply(i,me)}catch($e){this.onError($e)}}var Qn=!1,qn=null,ha=!1,Er=null,bi={onError:function(t){Qn=!0,qn=t}};function ot(t,n,i,o,d,g,k,I,H){Qn=!1,qn=null,Ba.apply(bi,arguments)}function Ht(t,n,i,o,d,g,k,I,H){if(ot.apply(this,arguments),Qn){if(Qn){var me=qn;Qn=!1,qn=null}else throw Error(r(198));ha||(ha=!0,Er=me)}}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 Al(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 d=i.return;if(d===null)break;var g=d.alternate;if(g===null){if(o=d.return,o!==null){i=o;continue}break}if(d.child===g.child){for(g=d.child;g;){if(g===i)return Ua(d),t;if(g===o)return Ua(d),n;g=g.sibling}throw Error(r(188))}if(i.return!==o.return)i=d,o=g;else{for(var k=!1,I=d.child;I;){if(I===i){k=!0,i=d,o=g;break}if(I===o){k=!0,o=d,i=g;break}I=I.sibling}if(!k){for(I=g.child;I;){if(I===i){k=!0,i=g,o=d;break}if(I===o){k=!0,o=g,i=d;break}I=I.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 wi(t){return t=Al(t),t!==null?Tr(t):null}function Tr(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var n=Tr(t);if(n!==null)return n;t=t.sibling}return null}var ji=s.unstable_scheduleCallback,Wa=s.unstable_cancelCallback,Rl=s.unstable_shouldYield,Ar=s.unstable_requestPaint,Lt=s.unstable_now,Ll=s.unstable_getCurrentPriorityLevel,Ha=s.unstable_ImmediatePriority,Fs=s.unstable_UserBlockingPriority,is=s.unstable_NormalPriority,Rr=s.unstable_LowPriority,pa=s.unstable_IdlePriority,Va=null,fn=null;function Ml(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,Zo=Math.log,ec=Math.LN2;function Bn(t){return t>>>=0,t===0?32:31-(Zo(t)/ec|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 Dt(t,n){var i=t.pendingLanes;if(i===0)return 0;var o=0,d=t.suspendedLanes,g=t.pingedLanes,k=i&268435455;if(k!==0){var I=k&~d;I!==0?o=Xn(I):(g&=k,g!==0&&(o=Xn(g)))}else k=i&~d,k!==0?o=Xn(k):g!==0&&(o=Xn(g));if(o===0)return 0;if(n!==0&&n!==o&&(n&d)===0&&(d=o&-o,g=n&-n,d>=g||d===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),d=1<<i,o|=t[i],n&=~d;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 Lr(t,n){for(var i=t.suspendedLanes,o=t.pingedLanes,d=t.expirationTimes,g=t.pendingLanes;0<g;){var k=31-Sn(g),I=1<<k,H=d[k];H===-1?((I&i)===0||(I&o)!==0)&&(d[k]=sn(I,n)):H<=n&&(t.expiredLanes|=I),g&=~I}}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 Mr(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 d=31-Sn(i),g=1<<d;n[d]=0,o[d]=-1,t[d]=-1,i&=~g}}function zr(t,n){var i=t.entangledLanes|=n;for(t=t.entanglements;i;){var o=31-Sn(i),d=1<<o;d&n|t[o]&n&&(t[o]|=n),i&=~d}}var ct=0;function Pr(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var ki,Ga,Si,Ni,Ka,ks=!1,Us=[],Vt=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 Ir(t,n){switch(t){case"focusin":case"focusout":Vt=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,d,g){return t===null||t.nativeEvent!==g?(t={blockedOn:n,domEventName:i,eventSystemFlags:o,nativeEvent:g,targetContainers:[d]},n!==null&&(n=fr(n),n!==null&&Ga(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),t)}function zl(t,n,i,o,d){switch(n){case"focusin":return Vt=Ws(Vt,t,n,i,o,d),!0;case"dragenter":return hn=Ws(hn,t,n,i,o,d),!0;case"mouseover":return Ss=Ws(Ss,t,n,i,o,d),!0;case"pointerover":var g=d.pointerId;return ls.set(g,Ws(ls.get(g)||null,t,n,i,o,d)),!0;case"gotpointercapture":return g=d.pointerId,St.set(g,Ws(St.get(g)||null,t,n,i,o,d)),!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(){Si(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);ze=o,i.target.dispatchEvent(o),ze=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 Pl(){ks=!1,Vt!==null&&Qa(Vt)&&(Vt=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,Pl)))}function os(t){function n(d){return Hs(d,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(Vt!==null&&Hs(Vt,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=J.ReactCurrentBatchConfig,Ya=!0;function Ci(t,n,i,o){var d=ct,g=Vs.transition;Vs.transition=null;try{ct=1,Gs(t,n,i,o)}finally{ct=d,Vs.transition=g}}function Il(t,n,i,o){var d=ct,g=Vs.transition;Vs.transition=null;try{ct=4,Gs(t,n,i,o)}finally{ct=d,Vs.transition=g}}function Gs(t,n,i,o){if(Ya){var d=_a(t,n,i,o);if(d===null)Ki(t,n,o,Zn,i),Ir(t,o);else if(zl(d,t,n,i,o))o.stopPropagation();else if(Ir(t,o),n&4&&-1<Un.indexOf(t)){for(;d!==null;){var g=fr(d);if(g!==null&&ki(g),g=_a(t,n,i,o),g===null&&Ki(t,n,o,Zn,i),g===d)break;d=g}d!==null&&o.stopPropagation()}else Ki(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(Ll()){case Ha:return 1;case Fs:return 4;case is:case Rr: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,d="value"in es?es.value:es.textContent,g=d.length;for(t=0;t<i&&n[t]===d[t];t++);var k=i-t;for(o=1;o<=k&&n[i-o]===d[g-o];o++);return cs=d.slice(t,1<o?1-o:void 0)}function Or(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 Fr(){return!1}function pn(t){function n(i,o,d,g,k){this._reactName=i,this._targetInst=d,this.type=o,this.nativeEvent=g,this.target=k,this.currentTarget=null;for(var I in t)t.hasOwnProperty(I)&&(i=t[I],this[I]=i?i(g):g[I]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Ut:Fr,this.isPropagationStopped=Fr,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}),$i=pn(Qs),qr,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"?(qr=t.screenX-va.screenX,er=t.screenY-va.screenY):er=qr=0,va=t),qr)},movementY:function(t){return"movementY"in t?t.movementY:er}}),Br=pn(tr),Dl=V({},tr,{dataTransfer:0}),Ei=pn(Dl),Ti=V({},Qs,{relatedTarget:0}),Ur=pn(Ti),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}}),Ai=pn(Cs),Ri=V({},Ks,{data:0}),Wr=pn(Ri),tc={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 Ol=V({},Qs,{key:function(t){if(t.key){var n=tc[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=Or(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"?Or(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Or(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Fl=pn(Ol),ql=V({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bl=pn(ql),nc=V({},Qs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ds}),Li=pn(nc),xa=V({},Ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),Mi=pn(xa),Ul=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}),zi=pn(Ul),Wl=[9,13,27,32],$s=p&&"CompositionEvent"in window,Js=null;p&&"documentMode"in document&&(Js=document.documentMode);var sc=p&&"TextEvent"in window&&!Js,ba=p&&(!$s||Js&&8<Js&&11>=Js),Hr=" ",Pi=!1;function Ii(t,n){switch(t){case"keyup":return Wl.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:(Pi=!0,Hr);case"textInput":return t=n.data,t===Hr&&Pi?null:t;default:return null}}function sr(t,n){if(wa)return t==="compositionend"||!$s&&Ii(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 ac={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"?!!ac[t.type]:n==="textarea"}function Vr(t,n,i,o){je(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 Gr(t){ei(t,0)}function Kr(t){var n=aa(t);if(he(n))return t}function rc(t,n){if(t==="change")return n}var Hl=!1;if(p){var Qr;if(p){var Oi="oninput"in document;if(!Oi){var Fi=document.createElement("div");Fi.setAttribute("oninput","return;"),Oi=typeof Fi.oninput=="function"}Qr=Oi}else Qr=!1;Hl=Qr&&(!document.documentMode||9<document.documentMode)}function Vl(){rr&&(rr.detachEvent("onpropertychange",Gl),Es=rr=null)}function Gl(t){if(t.propertyName==="value"&&Kr(Es)){var n=[];Vr(n,Es,t,it(t)),gt(Gr,n)}}function qi(t,n,i){t==="focusin"?(Vl(),rr=n,Es=i,rr.attachEvent("onpropertychange",Gl)):t==="focusout"&&Vl()}function ic(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Kr(Es)}function Kl(t,n){if(t==="click")return Kr(n)}function Ql(t,n){if(t==="input"||t==="change")return Kr(n)}function lc(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var Tn=typeof Object.is=="function"?Object.is:lc;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 d=i[o];if(!_.call(n,d)||!Tn(t[d],n[d]))return!1}return!0}function Bi(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function ir(t,n){var i=Bi(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=Bi(i)}}function Ui(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Ui(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Jl(){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 Wi(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 Yl(t){var n=Jl(),i=t.focusedElem,o=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&Ui(i.ownerDocument.documentElement,i)){if(o!==null&&Wi(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 d=i.textContent.length,g=Math.min(o.start,d);o=o.end===void 0?g:Math.min(o.end,d),!t.extend&&g>o&&(d=o,o=g,g=d),d=ir(i,g);var k=ir(i,o);d&&k&&(t.rangeCount!==1||t.anchorNode!==d.node||t.anchorOffset!==d.offset||t.focusNode!==k.node||t.focusOffset!==k.offset)&&(n=n.createRange(),n.setStart(d.node,d.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 oc=p&&"documentMode"in document&&11>=document.documentMode,Xs=null,Hi=null,ja=null,Jr=!1;function Xl(t,n,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Jr||Xs==null||Xs!==Re(o)||(o=Xs,"selectionStart"in o&&Wi(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(Hi,"onSelect"),0<o.length&&(n=new Za("onSelect","select",null,n,i),t.push({event:n,listeners:o}),n.target=Xs)))}function Yr(t,n){var i={};return i[t.toLowerCase()]=n.toLowerCase(),i["Webkit"+t]="webkit"+n,i["Moz"+t]="moz"+n,i}var Zs={animationend:Yr("Animation","AnimationEnd"),animationiteration:Yr("Animation","AnimationIteration"),animationstart:Yr("Animation","AnimationStart"),transitionend:Yr("Transition","TransitionEnd")},Xr={},Zl={};p&&(Zl=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(Xr[t])return Xr[t];if(!Zs[t])return t;var n=Zs[t],i;for(i in n)if(n.hasOwnProperty(i)&&i in Zl)return Xr[t]=n[i];return t}var Nt=_n("animationend"),Jt=_n("animationiteration"),Zr=_n("animationstart"),eo=_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),m(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(Zr,"onAnimationStart"),an("dblclick","onDoubleClick"),an("focusin","onFocus"),an("focusout","onBlur"),an(eo,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),m("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),m("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),m("onBeforeInput",["compositionend","keypress","textInput","paste"]),m("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),m("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),m("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(" "),to=new Set("cancel close invalid load scroll toggle".split(" ").concat(ta));function Vi(t,n,i){var o=t.type||"unknown-event";t.currentTarget=i,Ht(o,n,void 0,t),t.currentTarget=null}function ei(t,n){n=(n&4)!==0;for(var i=0;i<t.length;i++){var o=t[i],d=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var k=o.length-1;0<=k;k--){var I=o[k],H=I.instance,me=I.currentTarget;if(I=I.listener,H!==g&&d.isPropagationStopped())break e;Vi(d,I,me),g=H}else for(k=0;k<o.length;k++){if(I=o[k],H=I.instance,me=I.currentTarget,I=I.listener,H!==g&&d.isPropagationStopped())break e;Vi(d,I,me),g=H}}}if(ha)throw t=Er,ha=!1,Er=null,t}function At(t,n){var i=n[Zi];i===void 0&&(i=n[Zi]=new Set);var o=t+"__bubble";i.has(o)||(na(n,t,2,!1),i.add(o))}function Gi(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"&&(to.has(i)||Gi(i,!1,t),Gi(i,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[cr]||(n[cr]=!0,Gi("selectionchange",!1,n))}}function na(t,n,i,o){switch(Dr(n)){case 1:var d=Ci;break;case 4:d=Il;break;default:d=Gs}i=d.bind(null,n,i,t),d=void 0,!mn||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),o?d!==void 0?t.addEventListener(n,i,{capture:!0,passive:d}):t.addEventListener(n,i,!0):d!==void 0?t.addEventListener(n,i,{passive:d}):t.addEventListener(n,i,!1)}function Ki(t,n,i,o,d){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 I=o.stateNode.containerInfo;if(I===d||I.nodeType===8&&I.parentNode===d)break;if(k===4)for(k=o.return;k!==null;){var H=k.tag;if((H===3||H===4)&&(H=k.stateNode.containerInfo,H===d||H.nodeType===8&&H.parentNode===d))return;k=k.return}for(;I!==null;){if(k=Ls(I),k===null)return;if(H=k.tag,H===5||H===6){o=g=k;continue e}I=I.parentNode}}o=o.return}gt(function(){var me=g,$e=it(i),Te=[];e:{var Ne=ms.get(t);if(Ne!==void 0){var He=Za,Ke=t;switch(t){case"keypress":if(Or(i)===0)break e;case"keydown":case"keyup":He=Fl;break;case"focusin":Ke="focus",He=Ur;break;case"focusout":Ke="blur",He=Ur;break;case"beforeblur":case"afterblur":He=Ur;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":He=Br;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=Ei;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=Li;break;case Nt:case Jt:case Zr:He=Ns;break;case eo:He=Mi;break;case"scroll":He=$i;break;case"wheel":He=zi;break;case"copy":case"cut":case"paste":He=Ai;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Bl}var Qe=(n&4)!==0,Gt=!Qe&&t==="scroll",ne=Qe?Ne!==null?Ne+"Capture":null:Ne;Qe=[];for(var Q=me,re;Q!==null;){re=Q;var De=re.stateNode;if(re.tag===5&&De!==null&&(re=De,ne!==null&&(De=Xt(Q,ne),De!=null&&Qe.push(rn(Q,De,re)))),Gt)break;Q=Q.return}0<Qe.length&&(Ne=new He(Ne,Ke,null,i,$e),Te.push({event:Ne,listeners:Qe}))}}if((n&7)===0){e:{if(Ne=t==="mouseover"||t==="pointerover",He=t==="mouseout"||t==="pointerout",Ne&&i!==ze&&(Ke=i.relatedTarget||i.fromElement)&&(Ls(Ke)||Ke[ps]))break e;if((He||Ne)&&(Ne=$e.window===$e?$e:(Ne=$e.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,He?(Ke=i.relatedTarget||i.toElement,He=me,Ke=Ke?Ls(Ke):null,Ke!==null&&(Gt=Jn(Ke),Ke!==Gt||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(He=null,Ke=me),He!==Ke)){if(Qe=Br,De="onMouseLeave",ne="onMouseEnter",Q="mouse",(t==="pointerout"||t==="pointerover")&&(Qe=Bl,De="onPointerLeave",ne="onPointerEnter",Q="pointer"),Gt=He==null?Ne:aa(He),re=Ke==null?Ne:aa(Ke),Ne=new Qe(De,Q+"leave",He,i,$e),Ne.target=Gt,Ne.relatedTarget=re,De=null,Ls($e)===me&&(Qe=new Qe(ne,Q+"enter",Ke,i,$e),Qe.target=re,Qe.relatedTarget=Gt,De=Qe),Gt=De,He&&Ke)t:{for(Qe=He,ne=Ke,Q=0,re=Qe;re;re=gn(re))Q++;for(re=0,De=ne;De;De=gn(De))re++;for(;0<Q-re;)Qe=gn(Qe),Q--;for(;0<re-Q;)ne=gn(ne),re--;for(;Q--;){if(Qe===ne||ne!==null&&Qe===ne.alternate)break t;Qe=gn(Qe),ne=gn(ne)}Qe=null}else Qe=null;He!==null&&ur(Te,Ne,He,Qe,!1),Ke!==null&&Gt!==null&&ur(Te,Gt,Ke,Qe,!0)}}e:{if(Ne=me?aa(me):window,He=Ne.nodeName&&Ne.nodeName.toLowerCase(),He==="select"||He==="input"&&Ne.type==="file")var Xe=rc;else if(ar(Ne))if(Hl)Xe=Ql;else{Xe=ic;var nt=qi}else(He=Ne.nodeName)&&He.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Xe=Kl);if(Xe&&(Xe=Xe(t,me))){Vr(Te,Xe,i,$e);break e}nt&&nt(t,Ne,me),t==="focusout"&&(nt=Ne._wrapperState)&&nt.controlled&&Ne.type==="number"&&Je(Ne,"number",Ne.value)}switch(nt=me?aa(me):window,t){case"focusin":(ar(nt)||nt.contentEditable==="true")&&(Xs=nt,Hi=me,ja=null);break;case"focusout":ja=Hi=Xs=null;break;case"mousedown":Jr=!0;break;case"contextmenu":case"mouseup":case"dragend":Jr=!1,Xl(Te,i,$e);break;case"selectionchange":if(oc)break;case"keydown":case"keyup":Xl(Te,i,$e)}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?Ii(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=$e,Xa="value"in es?es.value:es.textContent,wa=!0)),nt=Sa(me,lt),0<nt.length&&(lt=new Wr(lt,t,null,i,$e),Te.push({event:lt,listeners:nt}),st?lt.data=st:(st=Di(i),st!==null&&(lt.data=st)))),(st=sc?Ys(t,i):sr(t,i))&&(me=Sa(me,"onBeforeInput"),0<me.length&&($e=new Wr("onBeforeInput","beforeinput",null,i,$e),Te.push({event:$e,listeners:me}),$e.data=st))}ei(Te,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 d=t,g=d.stateNode;d.tag===5&&g!==null&&(d=g,g=Xt(t,i),g!=null&&o.unshift(rn(t,g,d)),g=Xt(t,n),g!=null&&o.push(rn(t,g,d))),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,d){for(var g=n._reactName,k=[];i!==null&&i!==o;){var I=i,H=I.alternate,me=I.stateNode;if(H!==null&&H===o)break;I.tag===5&&me!==null&&(I=me,d?(H=Xt(i,g),H!=null&&k.unshift(rn(i,H,I))):d||(H=Xt(i,g),H!=null&&k.push(rn(i,H,I)))),i=i.return}k.length!==0&&t.push({event:n,listeners:k})}var Qi=/\r\n?/g,hs=/\u0000|\uFFFD/g;function Hn(t){return(typeof t=="string"?t:""+t).replace(Qi,`
|
|
38
|
+
`).replace(hs,"")}function sa(t,n,i){if(n=Hn(n),Hn(t)!==n&&i)throw Error(r(425))}function ti(){}var dr=null,Ji=null;function Yi(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 ni=typeof setTimeout=="function"?setTimeout:void 0,cc=typeof clearTimeout=="function"?clearTimeout:void 0,no=typeof Promise=="function"?Promise:void 0,so=typeof queueMicrotask=="function"?queueMicrotask:typeof no<"u"?function(t){return no.resolve(null).then(t).catch(uc)}:ni;function uc(t){setTimeout(function(){throw t})}function Xi(t,n){var i=n,o=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(o===0){t.removeChild(d),os(n);return}o--}else i!=="$"&&i!=="$?"&&i!=="$!"||o++;i=d}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 ao(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,Zi="__reactEvents$"+Na,dc="__reactListeners$"+Na,ro="__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=ao(t);t!==null;){if(i=t[An])return i;t=ao(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 si=[],ra=-1;function _s(t){return{current:t}}function $t(t){0>ra||(t.current=si[ra],si[ra]=null,ra--)}function u(t,n){ra++,si[ra]=t.current,t.current=n}var v={},S=_s(v),w=_s(!1),T=v;function te(t,n){var i=t.type.contextTypes;if(!i)return v;var o=t.stateNode;if(o&&o.__reactInternalMemoizedUnmaskedChildContext===n)return o.__reactInternalMemoizedMaskedChildContext;var d={},g;for(g in i)d[g]=n[g];return o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=d),d}function B(t){return t=t.childContextTypes,t!=null}function ve(){$t(w),$t(S)}function Ie(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 d in o)if(!(d in n))throw Error(r(108,ye(t)||"Unknown",d));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(d){throw Et!==null&&(Et=Et.slice(t+1)),ji(Ha,bt),d}finally{ct=n,xt=!1}}return null}var We=[],Ct=0,ln=null,en=0,jt=[],ft=0,zt=null,Ln=1,ia="";function pr(t,n){We[Ct++]=en,We[Ct++]=ln,ln=t,en=n}function fd(t,n,i){jt[ft++]=Ln,jt[ft++]=ia,jt[ft++]=zt,zt=t;var o=Ln;t=ia;var d=32-Sn(o)-1;o&=~(1<<d),i+=1;var g=32-Sn(n)+d;if(30<g){var k=d-d%5;g=(o&(1<<k)-1).toString(32),o>>=k,d-=k,Ln=1<<32-Sn(n)+d|i<<d|o,ia=g+t}else Ln=1<<g|i<<d|o,ia=t}function mc(t){t.return!==null&&(pr(t,1),fd(t,1,0))}function fc(t){for(;t===ln;)ln=We[--Ct],We[Ct]=null,en=We[--Ct],We[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 hd(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 pd(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 hc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function pc(t){if(It){var n=Gn;if(n){var i=n;if(!pd(t,n)){if(hc(t))throw Error(r(418));n=Rs(i.nextSibling);var o=Vn;n&&pd(t,n)?hd(o,i):(t.flags=t.flags&-4097|2,It=!1,Vn=t)}}else{if(hc(t))throw Error(r(418));t.flags=t.flags&-4097|2,It=!1,Vn=t}}}function _d(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Vn=t}function io(t){if(t!==Vn)return!1;if(!It)return _d(t),It=!0,!1;var n;if((n=t.tag!==3)&&!(n=t.tag!==5)&&(n=t.type,n=n!=="head"&&n!=="body"&&!Yi(t.type,t.memoizedProps)),n&&(n=Gn)){if(hc(t))throw gd(),Error(r(418));for(;n;)hd(t,n),n=Rs(n.nextSibling)}if(_d(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 gd(){for(var t=Gn;t;)t=Rs(t.nextSibling)}function ai(){Gn=Vn=null,It=!1}function _c(t){gs===null?gs=[t]:gs.push(t)}var Th=J.ReactCurrentBatchConfig;function el(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 d=o,g=""+t;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===g?n.ref:(n=function(k){var I=d.refs;k===null?delete I[g]:I[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 lo(t,n){throw t=Object.prototype.toString.call(n),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t))}function vd(t){var n=t._init;return n(t._payload)}function yd(t){function n(ne,Q){if(t){var re=ne.deletions;re===null?(ne.deletions=[Q],ne.flags|=16):re.push(Q)}}function i(ne,Q){if(!t)return null;for(;Q!==null;)n(ne,Q),Q=Q.sibling;return null}function o(ne,Q){for(ne=new Map;Q!==null;)Q.key!==null?ne.set(Q.key,Q):ne.set(Q.index,Q),Q=Q.sibling;return ne}function d(ne,Q){return ne=Ma(ne,Q),ne.index=0,ne.sibling=null,ne}function g(ne,Q,re){return ne.index=re,t?(re=ne.alternate,re!==null?(re=re.index,re<Q?(ne.flags|=2,Q):re):(ne.flags|=2,Q)):(ne.flags|=1048576,Q)}function k(ne){return t&&ne.alternate===null&&(ne.flags|=2),ne}function I(ne,Q,re,De){return Q===null||Q.tag!==6?(Q=lu(re,ne.mode,De),Q.return=ne,Q):(Q=d(Q,re),Q.return=ne,Q)}function H(ne,Q,re,De){var Xe=re.type;return Xe===oe?$e(ne,Q,re.props.children,De,re.key):Q!==null&&(Q.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===W&&vd(Xe)===Q.type)?(De=d(Q,re.props),De.ref=el(ne,Q,re),De.return=ne,De):(De=Ro(re.type,re.key,re.props,null,ne.mode,De),De.ref=el(ne,Q,re),De.return=ne,De)}function me(ne,Q,re,De){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==re.containerInfo||Q.stateNode.implementation!==re.implementation?(Q=ou(re,ne.mode,De),Q.return=ne,Q):(Q=d(Q,re.children||[]),Q.return=ne,Q)}function $e(ne,Q,re,De,Xe){return Q===null||Q.tag!==7?(Q=jr(re,ne.mode,De,Xe),Q.return=ne,Q):(Q=d(Q,re),Q.return=ne,Q)}function Te(ne,Q,re){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=lu(""+Q,ne.mode,re),Q.return=ne,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case $:return re=Ro(Q.type,Q.key,Q.props,null,ne.mode,re),re.ref=el(ne,null,Q),re.return=ne,re;case ee:return Q=ou(Q,ne.mode,re),Q.return=ne,Q;case W:var De=Q._init;return Te(ne,De(Q._payload),re)}if(ie(Q)||de(Q))return Q=jr(Q,ne.mode,re,null),Q.return=ne,Q;lo(ne,Q)}return null}function Ne(ne,Q,re,De){var Xe=Q!==null?Q.key:null;if(typeof re=="string"&&re!==""||typeof re=="number")return Xe!==null?null:I(ne,Q,""+re,De);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case $:return re.key===Xe?H(ne,Q,re,De):null;case ee:return re.key===Xe?me(ne,Q,re,De):null;case W:return Xe=re._init,Ne(ne,Q,Xe(re._payload),De)}if(ie(re)||de(re))return Xe!==null?null:$e(ne,Q,re,De,null);lo(ne,re)}return null}function He(ne,Q,re,De,Xe){if(typeof De=="string"&&De!==""||typeof De=="number")return ne=ne.get(re)||null,I(Q,ne,""+De,Xe);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case $:return ne=ne.get(De.key===null?re:De.key)||null,H(Q,ne,De,Xe);case ee:return ne=ne.get(De.key===null?re:De.key)||null,me(Q,ne,De,Xe);case W:var nt=De._init;return He(ne,Q,re,nt(De._payload),Xe)}if(ie(De)||de(De))return ne=ne.get(re)||null,$e(Q,ne,De,Xe,null);lo(Q,De)}return null}function Ke(ne,Q,re,De){for(var Xe=null,nt=null,st=Q,lt=Q=0,un=null;st!==null&<<re.length;lt++){st.index>lt?(un=st,st=null):un=st.sibling;var wt=Ne(ne,st,re[lt],De);if(wt===null){st===null&&(st=un);break}t&&st&&wt.alternate===null&&n(ne,st),Q=g(wt,Q,lt),nt===null?Xe=wt:nt.sibling=wt,nt=wt,st=un}if(lt===re.length)return i(ne,st),It&&pr(ne,lt),Xe;if(st===null){for(;lt<re.length;lt++)st=Te(ne,re[lt],De),st!==null&&(Q=g(st,Q,lt),nt===null?Xe=st:nt.sibling=st,nt=st);return It&&pr(ne,lt),Xe}for(st=o(ne,st);lt<re.length;lt++)un=He(st,ne,lt,re[lt],De),un!==null&&(t&&un.alternate!==null&&st.delete(un.key===null?lt:un.key),Q=g(un,Q,lt),nt===null?Xe=un:nt.sibling=un,nt=un);return t&&st.forEach(function(za){return n(ne,za)}),It&&pr(ne,lt),Xe}function Qe(ne,Q,re,De){var Xe=de(re);if(typeof Xe!="function")throw Error(r(150));if(re=Xe.call(re),re==null)throw Error(r(151));for(var nt=Xe=null,st=Q,lt=Q=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=Ne(ne,st,wt.value,De);if(za===null){st===null&&(st=un);break}t&&st&&za.alternate===null&&n(ne,st),Q=g(za,Q,lt),nt===null?Xe=za:nt.sibling=za,nt=za,st=un}if(wt.done)return i(ne,st),It&&pr(ne,lt),Xe;if(st===null){for(;!wt.done;lt++,wt=re.next())wt=Te(ne,wt.value,De),wt!==null&&(Q=g(wt,Q,lt),nt===null?Xe=wt:nt.sibling=wt,nt=wt);return It&&pr(ne,lt),Xe}for(st=o(ne,st);!wt.done;lt++,wt=re.next())wt=He(st,ne,lt,wt.value,De),wt!==null&&(t&&wt.alternate!==null&&st.delete(wt.key===null?lt:wt.key),Q=g(wt,Q,lt),nt===null?Xe=wt:nt.sibling=wt,nt=wt);return t&&st.forEach(function(cp){return n(ne,cp)}),It&&pr(ne,lt),Xe}function Gt(ne,Q,re,De){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 Xe=re.key,nt=Q;nt!==null;){if(nt.key===Xe){if(Xe=re.type,Xe===oe){if(nt.tag===7){i(ne,nt.sibling),Q=d(nt,re.props.children),Q.return=ne,ne=Q;break e}}else if(nt.elementType===Xe||typeof Xe=="object"&&Xe!==null&&Xe.$$typeof===W&&vd(Xe)===nt.type){i(ne,nt.sibling),Q=d(nt,re.props),Q.ref=el(ne,nt,re),Q.return=ne,ne=Q;break e}i(ne,nt);break}else n(ne,nt);nt=nt.sibling}re.type===oe?(Q=jr(re.props.children,ne.mode,De,re.key),Q.return=ne,ne=Q):(De=Ro(re.type,re.key,re.props,null,ne.mode,De),De.ref=el(ne,Q,re),De.return=ne,ne=De)}return k(ne);case ee:e:{for(nt=re.key;Q!==null;){if(Q.key===nt)if(Q.tag===4&&Q.stateNode.containerInfo===re.containerInfo&&Q.stateNode.implementation===re.implementation){i(ne,Q.sibling),Q=d(Q,re.children||[]),Q.return=ne,ne=Q;break e}else{i(ne,Q);break}else n(ne,Q);Q=Q.sibling}Q=ou(re,ne.mode,De),Q.return=ne,ne=Q}return k(ne);case W:return nt=re._init,Gt(ne,Q,nt(re._payload),De)}if(ie(re))return Ke(ne,Q,re,De);if(de(re))return Qe(ne,Q,re,De);lo(ne,re)}return typeof re=="string"&&re!==""||typeof re=="number"?(re=""+re,Q!==null&&Q.tag===6?(i(ne,Q.sibling),Q=d(Q,re),Q.return=ne,ne=Q):(i(ne,Q),Q=lu(re,ne.mode,De),Q.return=ne,ne=Q),k(ne)):i(ne,Q)}return Gt}var ri=yd(!0),xd=yd(!1),oo=_s(null),co=null,ii=null,gc=null;function vc(){gc=ii=co=null}function yc(t){var n=oo.current;$t(oo),t._currentValue=n}function xc(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 li(t,n){co=t,gc=ii=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(gc!==t)if(t={context:t,memoizedValue:n,next:null},ii===null){if(co===null)throw Error(r(308));ii=t,co.dependencies={lanes:0,firstContext:t}}else ii=ii.next=t;return n}var _r=null;function bc(t){_r===null?_r=[t]:_r.push(t)}function bd(t,n,i,o){var d=n.interleaved;return d===null?(i.next=i,bc(n)):(i.next=d.next,d.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 wc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wd(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 d=o.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),o.pending=n,la(t,i)}return d=o.interleaved,d===null?(n.next=n,bc(o)):(n.next=d.next,d.next=n),o.interleaved=n,la(t,i)}function uo(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,zr(t,i)}}function jd(t,n){var i=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var d=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?d=g=k:g=g.next=k,i=i.next}while(i!==null);g===null?d=g=n:g=g.next=n}else d=g=n;i={baseState:o.baseState,firstBaseUpdate:d,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 mo(t,n,i,o){var d=t.updateQueue;Ca=!1;var g=d.firstBaseUpdate,k=d.lastBaseUpdate,I=d.shared.pending;if(I!==null){d.shared.pending=null;var H=I,me=H.next;H.next=null,k===null?g=me:k.next=me,k=H;var $e=t.alternate;$e!==null&&($e=$e.updateQueue,I=$e.lastBaseUpdate,I!==k&&(I===null?$e.firstBaseUpdate=me:I.next=me,$e.lastBaseUpdate=H))}if(g!==null){var Te=d.baseState;k=0,$e=me=H=null,I=g;do{var Ne=I.lane,He=I.eventTime;if((o&Ne)===Ne){$e!==null&&($e=$e.next={eventTime:He,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var Ke=t,Qe=I;switch(Ne=n,He=i,Qe.tag){case 1:if(Ke=Qe.payload,typeof Ke=="function"){Te=Ke.call(He,Te,Ne);break e}Te=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Qe.payload,Ne=typeof Ke=="function"?Ke.call(He,Te,Ne):Ke,Ne==null)break e;Te=V({},Te,Ne);break e;case 2:Ca=!0}}I.callback!==null&&I.lane!==0&&(t.flags|=64,Ne=d.effects,Ne===null?d.effects=[I]:Ne.push(I))}else He={eventTime:He,lane:Ne,tag:I.tag,payload:I.payload,callback:I.callback,next:null},$e===null?(me=$e=He,H=Te):$e=$e.next=He,k|=Ne;if(I=I.next,I===null){if(I=d.shared.pending,I===null)break;Ne=I,I=Ne.next,Ne.next=null,d.lastBaseUpdate=Ne,d.shared.pending=null}}while(!0);if($e===null&&(H=Te),d.baseState=H,d.firstBaseUpdate=me,d.lastBaseUpdate=$e,n=d.shared.interleaved,n!==null){d=n;do k|=d.lane,d=d.next;while(d!==n)}else g===null&&(d.shared.lanes=0);yr|=k,t.lanes=k,t.memoizedState=Te}}function kd(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;n<t.length;n++){var o=t[n],d=o.callback;if(d!==null){if(o.callback=null,o=i,typeof d!="function")throw Error(r(191,d));d.call(o)}}}var tl={},Ms=_s(tl),nl=_s(tl),sl=_s(tl);function gr(t){if(t===tl)throw Error(r(174));return t}function jc(t,n){switch(u(sl,n),u(nl,t),u(Ms,tl),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 oi(){$t(Ms),$t(nl),$t(sl)}function Sd(t){gr(sl.current);var n=gr(Ms.current),i=A(n,t.type);n!==i&&(u(nl,t),u(Ms,i))}function kc(t){nl.current===t&&($t(Ms),$t(nl))}var Ot=_s(0);function fo(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 Sc=[];function Nc(){for(var t=0;t<Sc.length;t++)Sc[t]._workInProgressVersionPrimary=null;Sc.length=0}var ho=J.ReactCurrentDispatcher,Cc=J.ReactCurrentBatchConfig,vr=0,Ft=null,tn=null,on=null,po=!1,al=!1,rl=0,Ah=0;function wn(){throw Error(r(321))}function $c(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 Ec(t,n,i,o,d,g){if(vr=g,Ft=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,ho.current=t===null||t.memoizedState===null?zh:Ph,t=i(o,d),al){g=0;do{if(al=!1,rl=0,25<=g)throw Error(r(301));g+=1,on=tn=null,n.updateQueue=null,ho.current=Ih,t=i(o,d)}while(al)}if(ho.current=vo,n=tn!==null&&tn.next!==null,vr=0,on=tn=Ft=null,po=!1,n)throw Error(r(300));return t}function Tc(){var t=rl!==0;return rl=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 il(t,n){return typeof n=="function"?n(t):n}function Ac(t){var n=ns(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=tn,d=o.baseQueue,g=i.pending;if(g!==null){if(d!==null){var k=d.next;d.next=g.next,g.next=k}o.baseQueue=d=g,i.pending=null}if(d!==null){g=d.next,o=o.baseState;var I=k=null,H=null,me=g;do{var $e=me.lane;if((vr&$e)===$e)H!==null&&(H=H.next={lane:0,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),o=me.hasEagerState?me.eagerState:t(o,me.action);else{var Te={lane:$e,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null};H===null?(I=H=Te,k=o):H=H.next=Te,Ft.lanes|=$e,yr|=$e}me=me.next}while(me!==null&&me!==g);H===null?k=o:H.next=I,Tn(o,n.memoizedState)||(Mn=!0),n.memoizedState=o,n.baseState=k,n.baseQueue=H,i.lastRenderedState=o}if(t=i.interleaved,t!==null){d=t;do g=d.lane,Ft.lanes|=g,yr|=g,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Rc(t){var n=ns(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=i.dispatch,d=i.pending,g=n.memoizedState;if(d!==null){i.pending=null;var k=d=d.next;do g=t(g,k.action),k=k.next;while(k!==d);Tn(g,n.memoizedState)||(Mn=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),i.lastRenderedState=g}return[g,o]}function Nd(){}function Cd(t,n){var i=Ft,o=ns(),d=n(),g=!Tn(o.memoizedState,d);if(g&&(o.memoizedState=d,Mn=!0),o=o.queue,Lc(Td.bind(null,i,o,t),[t]),o.getSnapshot!==n||g||on!==null&&on.memoizedState.tag&1){if(i.flags|=2048,ll(9,Ed.bind(null,i,o,d,n),void 0,null),cn===null)throw Error(r(349));(vr&30)!==0||$d(i,n,d)}return d}function $d(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 Ed(t,n,i,o){n.value=i,n.getSnapshot=o,Ad(n)&&Rd(t)}function Td(t,n,i){return i(function(){Ad(n)&&Rd(t)})}function Ad(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!Tn(t,i)}catch{return!0}}function Rd(t){var n=la(t,1);n!==null&&bs(n,t,1,-1)}function Ld(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:il,lastRenderedState:t},n.queue=t,t=t.dispatch=Mh.bind(null,Ft,t),[n.memoizedState,t]}function ll(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 Md(){return ns().memoizedState}function _o(t,n,i,o){var d=zs();Ft.flags|=t,d.memoizedState=ll(1|n,i,void 0,o===void 0?null:o)}function go(t,n,i,o){var d=ns();o=o===void 0?null:o;var g=void 0;if(tn!==null){var k=tn.memoizedState;if(g=k.destroy,o!==null&&$c(o,k.deps)){d.memoizedState=ll(n,i,g,o);return}}Ft.flags|=t,d.memoizedState=ll(1|n,i,g,o)}function zd(t,n){return _o(8390656,8,t,n)}function Lc(t,n){return go(2048,8,t,n)}function Pd(t,n){return go(4,2,t,n)}function Id(t,n){return go(4,4,t,n)}function Dd(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 Od(t,n,i){return i=i!=null?i.concat([t]):null,go(4,4,Dd.bind(null,n,t),i)}function Mc(){}function Fd(t,n){var i=ns();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&$c(n,o[1])?o[0]:(i.memoizedState=[t,n],t)}function qd(t,n){var i=ns();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&$c(n,o[1])?o[0]:(t=t(),i.memoizedState=[t,n],t)}function Bd(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 Rh(t,n){var i=ct;ct=i!==0&&4>i?i:4,t(!0);var o=Cc.transition;Cc.transition={};try{t(!1),n()}finally{ct=i,Cc.transition=o}}function Ud(){return ns().memoizedState}function Lh(t,n,i){var o=Ra(t);if(i={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null},Wd(t))Hd(n,i);else if(i=bd(t,n,i,o),i!==null){var d=Cn();bs(i,t,o,d),Vd(i,n,o)}}function Mh(t,n,i){var o=Ra(t),d={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null};if(Wd(t))Hd(n,d);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var k=n.lastRenderedState,I=g(k,i);if(d.hasEagerState=!0,d.eagerState=I,Tn(I,k)){var H=n.interleaved;H===null?(d.next=d,bc(n)):(d.next=H.next,H.next=d),n.interleaved=d;return}}catch{}finally{}i=bd(t,n,d,o),i!==null&&(d=Cn(),bs(i,t,o,d),Vd(i,n,o))}}function Wd(t){var n=t.alternate;return t===Ft||n!==null&&n===Ft}function Hd(t,n){al=po=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function Vd(t,n,i){if((i&4194240)!==0){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,zr(t,i)}}var vo={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},zh={readContext:ts,useCallback:function(t,n){return zs().memoizedState=[t,n===void 0?null:n],t},useContext:ts,useEffect:zd,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,_o(4194308,4,Dd.bind(null,n,t),i)},useLayoutEffect:function(t,n){return _o(4194308,4,t,n)},useInsertionEffect:function(t,n){return _o(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=Lh.bind(null,Ft,t),[o.memoizedState,t]},useRef:function(t){var n=zs();return t={current:t},n.memoizedState=t},useState:Ld,useDebugValue:Mc,useDeferredValue:function(t){return zs().memoizedState=t},useTransition:function(){var t=Ld(!1),n=t[0];return t=Rh.bind(null,t[1]),zs().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var o=Ft,d=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||$d(o,n,i)}d.memoizedState=i;var g={value:i,getSnapshot:n};return d.queue=g,zd(Td.bind(null,o,g,t),[t]),o.flags|=2048,ll(9,Ed.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=rl++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=Ah++,n=":"+n+"r"+i.toString(32)+":";return t.memoizedState=n},unstable_isNewReconciler:!1},Ph={readContext:ts,useCallback:Fd,useContext:ts,useEffect:Lc,useImperativeHandle:Od,useInsertionEffect:Pd,useLayoutEffect:Id,useMemo:qd,useReducer:Ac,useRef:Md,useState:function(){return Ac(il)},useDebugValue:Mc,useDeferredValue:function(t){var n=ns();return Bd(n,tn.memoizedState,t)},useTransition:function(){var t=Ac(il)[0],n=ns().memoizedState;return[t,n]},useMutableSource:Nd,useSyncExternalStore:Cd,useId:Ud,unstable_isNewReconciler:!1},Ih={readContext:ts,useCallback:Fd,useContext:ts,useEffect:Lc,useImperativeHandle:Od,useInsertionEffect:Pd,useLayoutEffect:Id,useMemo:qd,useReducer:Rc,useRef:Md,useState:function(){return Rc(il)},useDebugValue:Mc,useDeferredValue:function(t){var n=ns();return tn===null?n.memoizedState=t:Bd(n,tn.memoizedState,t)},useTransition:function(){var t=Rc(il)[0],n=ns().memoizedState;return[t,n]},useMutableSource:Nd,useSyncExternalStore:Cd,useId:Ud,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 zc(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 yo={isMounted:function(t){return(t=t._reactInternals)?Jn(t)===t:!1},enqueueSetState:function(t,n,i){t=t._reactInternals;var o=Cn(),d=Ra(t),g=oa(o,d);g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,d),n!==null&&(bs(n,t,d,o),uo(n,t,d))},enqueueReplaceState:function(t,n,i){t=t._reactInternals;var o=Cn(),d=Ra(t),g=oa(o,d);g.tag=1,g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,d),n!==null&&(bs(n,t,d,o),uo(n,t,d))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var i=Cn(),o=Ra(t),d=oa(i,o);d.tag=2,n!=null&&(d.callback=n),n=$a(t,d,o),n!==null&&(bs(n,t,o,i),uo(n,t,o))}};function Gd(t,n,i,o,d,g,k){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,g,k):n.prototype&&n.prototype.isPureReactComponent?!Ts(i,o)||!Ts(d,g):!0}function Kd(t,n,i){var o=!1,d=v,g=n.contextType;return typeof g=="object"&&g!==null?g=ts(g):(d=B(n)?T:S.current,o=n.contextTypes,g=(o=o!=null)?te(t,d):v),n=new n(i,g),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=yo,t.stateNode=n,n._reactInternals=t,o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=g),n}function Qd(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&&yo.enqueueReplaceState(n,n.state,null)}function Pc(t,n,i,o){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},wc(t);var g=n.contextType;typeof g=="object"&&g!==null?d.context=ts(g):(g=B(n)?T:S.current,d.context=te(t,g)),d.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(zc(t,n,g,i),d.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(n=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),n!==d.state&&yo.enqueueReplaceState(d,d.state,null),mo(t,i,d,o),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ci(t,n){try{var i="",o=n;do i+=ae(o),o=o.return;while(o);var d=i}catch(g){d=`
|
|
39
|
+
Error generating stack: `+g.message+`
|
|
40
|
+
`+g.stack}return{value:t,source:n,stack:d,digest:null}}function Ic(t,n,i){return{value:t,source:null,stack:i??null,digest:n??null}}function Dc(t,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Dh=typeof WeakMap=="function"?WeakMap:Map;function Jd(t,n,i){i=oa(-1,i),i.tag=3,i.payload={element:null};var o=n.value;return i.callback=function(){No||(No=!0,Zc=o),Dc(t,n)},i}function Yd(t,n,i){i=oa(-1,i),i.tag=3;var o=t.type.getDerivedStateFromError;if(typeof o=="function"){var d=n.value;i.payload=function(){return o(d)},i.callback=function(){Dc(t,n)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){Dc(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 Xd(t,n,i){var o=t.pingCache;if(o===null){o=t.pingCache=new Dh;var d=new Set;o.set(n,d)}else d=o.get(n),d===void 0&&(d=new Set,o.set(n,d));d.has(i)||(d.add(i),t=Xh.bind(null,t,n,i),n.then(t,t))}function Zd(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 em(t,n,i,o,d){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=d,t)}var Oh=J.ReactCurrentOwner,Mn=!1;function Nn(t,n,i,o){n.child=t===null?xd(n,null,i,o):ri(n,t.child,i,o)}function tm(t,n,i,o,d){i=i.render;var g=n.ref;return li(n,d),o=Ec(t,n,i,o,g,d),i=Tc(),t!==null&&!Mn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~d,ca(t,n,d)):(It&&i&&mc(n),n.flags|=1,Nn(t,n,o,d),n.child)}function nm(t,n,i,o,d){if(t===null){var g=i.type;return typeof g=="function"&&!iu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,sm(t,n,g,o,d)):(t=Ro(i.type,null,o,n,n.mode,d),t.ref=n.ref,t.return=n,n.child=t)}if(g=t.child,(t.lanes&d)===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,d)}return n.flags|=1,t=Ma(g,o),t.ref=n.ref,t.return=n,n.child=t}function sm(t,n,i,o,d){if(t!==null){var g=t.memoizedProps;if(Ts(g,o)&&t.ref===n.ref)if(Mn=!1,n.pendingProps=o=g,(t.lanes&d)!==0)(t.flags&131072)!==0&&(Mn=!0);else return n.lanes=t.lanes,ca(t,n,d)}return Oc(t,n,i,o,d)}function am(t,n,i){var o=n.pendingProps,d=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(di,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(di,Kn),Kn|=t,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},o=g!==null?g.baseLanes:i,u(di,Kn),Kn|=o}else g!==null?(o=g.baseLanes|i,n.memoizedState=null):o=i,u(di,Kn),Kn|=o;return Nn(t,n,d,i),n.child}function rm(t,n){var i=n.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Oc(t,n,i,o,d){var g=B(i)?T:S.current;return g=te(n,g),li(n,d),i=Ec(t,n,i,o,g,d),o=Tc(),t!==null&&!Mn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~d,ca(t,n,d)):(It&&o&&mc(n),n.flags|=1,Nn(t,n,i,d),n.child)}function im(t,n,i,o,d){if(B(i)){var g=!0;Ue(n)}else g=!1;if(li(n,d),n.stateNode===null)bo(t,n),Kd(n,i,o),Pc(n,i,o,d),o=!0;else if(t===null){var k=n.stateNode,I=n.memoizedProps;k.props=I;var H=k.context,me=i.contextType;typeof me=="object"&&me!==null?me=ts(me):(me=B(i)?T:S.current,me=te(n,me));var $e=i.getDerivedStateFromProps,Te=typeof $e=="function"||typeof k.getSnapshotBeforeUpdate=="function";Te||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(I!==o||H!==me)&&Qd(n,k,o,me),Ca=!1;var Ne=n.memoizedState;k.state=Ne,mo(n,o,k,d),H=n.memoizedState,I!==o||Ne!==H||w.current||Ca?(typeof $e=="function"&&(zc(n,i,$e,o),H=n.memoizedState),(I=Ca||Gd(n,i,I,o,Ne,H,me))?(Te||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=me,o=I):(typeof k.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{k=n.stateNode,wd(t,n),I=n.memoizedProps,me=n.type===n.elementType?I:vs(n.type,I),k.props=me,Te=n.pendingProps,Ne=k.context,H=i.contextType,typeof H=="object"&&H!==null?H=ts(H):(H=B(i)?T:S.current,H=te(n,H));var He=i.getDerivedStateFromProps;($e=typeof He=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(I!==Te||Ne!==H)&&Qd(n,k,o,H),Ca=!1,Ne=n.memoizedState,k.state=Ne,mo(n,o,k,d);var Ke=n.memoizedState;I!==Te||Ne!==Ke||w.current||Ca?(typeof He=="function"&&(zc(n,i,He,o),Ke=n.memoizedState),(me=Ca||Gd(n,i,me,o,Ne,Ke,H)||!1)?($e||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(o,Ke,H),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(o,Ke,H)),typeof k.componentDidUpdate=="function"&&(n.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof k.componentDidUpdate!="function"||I===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||I===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=Ke),k.props=o,k.state=Ke,k.context=H,o=me):(typeof k.componentDidUpdate!="function"||I===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||I===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),o=!1)}return Fc(t,n,i,o,g,d)}function Fc(t,n,i,o,d,g){rm(t,n);var k=(n.flags&128)!==0;if(!o&&!k)return d&&Mt(n,i,!1),ca(t,n,g);o=n.stateNode,Oh.current=n;var I=k&&typeof i.getDerivedStateFromError!="function"?null:o.render();return n.flags|=1,t!==null&&k?(n.child=ri(n,t.child,null,g),n.child=ri(n,null,I,g)):Nn(t,n,I,g),n.memoizedState=o.state,d&&Mt(n,i,!0),n.child}function lm(t){var n=t.stateNode;n.pendingContext?Ie(t,n.pendingContext,n.pendingContext!==n.context):n.context&&Ie(t,n.context,!1),jc(t,n.containerInfo)}function om(t,n,i,o,d){return ai(),_c(d),n.flags|=256,Nn(t,n,i,o),n.child}var qc={dehydrated:null,treeContext:null,retryLane:0};function Bc(t){return{baseLanes:t,cachePool:null,transitions:null}}function cm(t,n,i){var o=n.pendingProps,d=Ot.current,g=!1,k=(n.flags&128)!==0,I;if((I=k)||(I=t!==null&&t.memoizedState===null?!1:(d&2)!==0),I?(g=!0,n.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),u(Ot,d&1),t===null)return pc(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=Lo(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=Bc(i),n.memoizedState=qc,t):Uc(n,k));if(d=t.memoizedState,d!==null&&(I=d.dehydrated,I!==null))return Fh(t,n,k,o,I,d,i);if(g){g=o.fallback,k=n.mode,d=t.child,I=d.sibling;var H={mode:"hidden",children:o.children};return(k&1)===0&&n.child!==d?(o=n.child,o.childLanes=0,o.pendingProps=H,n.deletions=null):(o=Ma(d,H),o.subtreeFlags=d.subtreeFlags&14680064),I!==null?g=Ma(I,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?Bc(i):{baseLanes:k.baseLanes|i,cachePool:null,transitions:k.transitions},g.memoizedState=k,g.childLanes=t.childLanes&~i,n.memoizedState=qc,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 Uc(t,n){return n=Lo({mode:"visible",children:n},t.mode,0,null),n.return=t,t.child=n}function xo(t,n,i,o){return o!==null&&_c(o),ri(n,t.child,null,i),t=Uc(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function Fh(t,n,i,o,d,g,k){if(i)return n.flags&256?(n.flags&=-257,o=Ic(Error(r(422))),xo(t,n,k,o)):n.memoizedState!==null?(n.child=t.child,n.flags|=128,null):(g=o.fallback,d=n.mode,o=Lo({mode:"visible",children:o.children},d,0,null),g=jr(g,d,k,null),g.flags|=2,o.return=n,g.return=n,o.sibling=g,n.child=o,(n.mode&1)!==0&&ri(n,t.child,null,k),n.child.memoizedState=Bc(k),n.memoizedState=qc,g);if((n.mode&1)===0)return xo(t,n,k,null);if(d.data==="$!"){if(o=d.nextSibling&&d.nextSibling.dataset,o)var I=o.dgst;return o=I,g=Error(r(419)),o=Ic(g,o,void 0),xo(t,n,k,o)}if(I=(k&t.childLanes)!==0,Mn||I){if(o=cn,o!==null){switch(k&-k){case 4:d=2;break;case 16:d=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:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(o.suspendedLanes|k))!==0?0:d,d!==0&&d!==g.retryLane&&(g.retryLane=d,la(t,d),bs(o,t,d,-1))}return ru(),o=Ic(Error(r(421))),xo(t,n,k,o)}return d.data==="$?"?(n.flags|=128,n.child=t.child,n=Zh.bind(null,t),d._reactRetry=n,null):(t=g.treeContext,Gn=Rs(d.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=Uc(n,o.children),n.flags|=4096,n)}function um(t,n,i){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),xc(t.return,n,i)}function Wc(t,n,i,o,d){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:d}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=o,g.tail=i,g.tailMode=d)}function dm(t,n,i){var o=n.pendingProps,d=o.revealOrder,g=o.tail;if(Nn(t,n,o.children,i),o=Ot.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&&um(t,i,n);else if(t.tag===19)um(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(Ot,o),(n.mode&1)===0)n.memoizedState=null;else switch(d){case"forwards":for(i=n.child,d=null;i!==null;)t=i.alternate,t!==null&&fo(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=n.child,n.child=null):(d=i.sibling,i.sibling=null),Wc(n,!1,d,i,g);break;case"backwards":for(i=null,d=n.child,n.child=null;d!==null;){if(t=d.alternate,t!==null&&fo(t)===null){n.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}Wc(n,!0,i,null,g);break;case"together":Wc(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function bo(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 qh(t,n,i){switch(n.tag){case 3:lm(n),ai();break;case 5:Sd(n);break;case 1:B(n.type)&&Ue(n);break;case 4:jc(n,n.stateNode.containerInfo);break;case 10:var o=n.type._context,d=n.memoizedProps.value;u(oo,o._currentValue),o._currentValue=d;break;case 13:if(o=n.memoizedState,o!==null)return o.dehydrated!==null?(u(Ot,Ot.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?cm(t,n,i):(u(Ot,Ot.current&1),t=ca(t,n,i),t!==null?t.sibling:null);u(Ot,Ot.current&1);break;case 19:if(o=(i&n.childLanes)!==0,(t.flags&128)!==0){if(o)return dm(t,n,i);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),u(Ot,Ot.current),o)break;return null;case 22:case 23:return n.lanes=0,am(t,n,i)}return ca(t,n,i)}var mm,Hc,fm,hm;mm=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}},Hc=function(){},fm=function(t,n,i,o){var d=t.memoizedProps;if(d!==o){t=n.stateNode,gr(Ms.current);var g=null;switch(i){case"input":d=Pe(t,d),o=Pe(t,o),g=[];break;case"select":d=V({},d,{value:void 0}),o=V({},o,{value:void 0}),g=[];break;case"textarea":d=we(t,d),o=we(t,o),g=[];break;default:typeof d.onClick!="function"&&typeof o.onClick=="function"&&(t.onclick=ti)}Tt(i,o);var k;i=null;for(me in d)if(!o.hasOwnProperty(me)&&d.hasOwnProperty(me)&&d[me]!=null)if(me==="style"){var I=d[me];for(k in I)I.hasOwnProperty(k)&&(i||(i={}),i[k]="")}else me!=="dangerouslySetInnerHTML"&&me!=="children"&&me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&me!=="autoFocus"&&(c.hasOwnProperty(me)?g||(g=[]):(g=g||[]).push(me,null));for(me in o){var H=o[me];if(I=d!=null?d[me]:void 0,o.hasOwnProperty(me)&&H!==I&&(H!=null||I!=null))if(me==="style")if(I){for(k in I)!I.hasOwnProperty(k)||H&&H.hasOwnProperty(k)||(i||(i={}),i[k]="");for(k in H)H.hasOwnProperty(k)&&I[k]!==H[k]&&(i||(i={}),i[k]=H[k])}else i||(g||(g=[]),g.push(me,i)),i=H;else me==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,I=I?I.__html:void 0,H!=null&&I!==H&&(g=g||[]).push(me,H)):me==="children"?typeof H!="string"&&typeof H!="number"||(g=g||[]).push(me,""+H):me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&(c.hasOwnProperty(me)?(H!=null&&me==="onScroll"&&At("scroll",t),g||I===H||(g=[])):(g=g||[]).push(me,H))}i&&(g=g||[]).push("style",i);var me=g;(n.updateQueue=me)&&(n.flags|=4)}},hm=function(t,n,i,o){i!==o&&(n.flags|=4)};function ol(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 d=t.child;d!==null;)i|=d.lanes|d.childLanes,o|=d.subtreeFlags&14680064,o|=d.flags&14680064,d.return=t,d=d.sibling;else for(d=t.child;d!==null;)i|=d.lanes|d.childLanes,o|=d.subtreeFlags,o|=d.flags,d.return=t,d=d.sibling;return t.subtreeFlags|=o,t.childLanes=i,n}function Bh(t,n,i){var o=n.pendingProps;switch(fc(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)&&ve(),jn(n),null;case 3:return o=n.stateNode,oi(),$t(w),$t(S),Nc(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(t===null||t.child===null)&&(io(n)?n.flags|=4:t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,gs!==null&&(nu(gs),gs=null))),Hc(t,n),jn(n),null;case 5:kc(n);var d=gr(sl.current);if(i=n.type,t!==null&&n.stateNode!=null)fm(t,n,i,o,d),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),io(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(d=0;d<ta.length;d++)At(ta[d],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":K(o,g),At("invalid",o)}Tt(i,g),d=null;for(var k in g)if(g.hasOwnProperty(k)){var I=g[k];k==="children"?typeof I=="string"?o.textContent!==I&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,I,t),d=["children",I]):typeof I=="number"&&o.textContent!==""+I&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,I,t),d=["children",""+I]):c.hasOwnProperty(k)&&I!=null&&k==="onScroll"&&At("scroll",o)}switch(i){case"input":Ze(o),qe(o,g,!0);break;case"textarea":Ze(o),Ye(o);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(o.onclick=ti)}o=d,n.updateQueue=o,o!==null&&(n.flags|=4)}else{k=d.nodeType===9?d:d.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=Y(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,mm(t,n,!1,!1),n.stateNode=t;e:{switch(k=qt(i,o),i){case"dialog":At("cancel",t),At("close",t),d=o;break;case"iframe":case"object":case"embed":At("load",t),d=o;break;case"video":case"audio":for(d=0;d<ta.length;d++)At(ta[d],t);d=o;break;case"source":At("error",t),d=o;break;case"img":case"image":case"link":At("error",t),At("load",t),d=o;break;case"details":At("toggle",t),d=o;break;case"input":se(t,o),d=Pe(t,o),At("invalid",t);break;case"option":d=o;break;case"select":t._wrapperState={wasMultiple:!!o.multiple},d=V({},o,{value:void 0}),At("invalid",t);break;case"textarea":K(t,o),d=we(t,o),At("invalid",t);break;default:d=o}Tt(i,d),I=d;for(g in I)if(I.hasOwnProperty(g)){var H=I[g];g==="style"?yt(t,H):g==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,H!=null&&Se(t,H)):g==="children"?typeof H=="string"?(i!=="textarea"||H!=="")&&Le(t,H):typeof H=="number"&&Le(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":Ze(t),qe(t,o,!1);break;case"textarea":Ze(t),Ye(t);break;case"option":o.value!=null&&t.setAttribute("value",""+xe(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 d.onClick=="function"&&(t.onclick=ti)}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)hm(t,n,t.memoizedProps,o);else{if(typeof o!="string"&&n.stateNode===null)throw Error(r(166));if(i=gr(sl.current),gr(Ms.current),io(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(Ot),o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(It&&Gn!==null&&(n.mode&1)!==0&&(n.flags&128)===0)gd(),ai(),n.flags|=98560,g=!1;else if(g=io(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 ai(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;jn(n),g=!1}else gs!==null&&(nu(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||(Ot.current&1)!==0?nn===0&&(nn=3):ru())),n.updateQueue!==null&&(n.flags|=4),jn(n),null);case 4:return oi(),Hc(t,n),t===null&&ka(n.stateNode.containerInfo),jn(n),null;case 10:return yc(n.type._context),jn(n),null;case 17:return B(n.type)&&ve(),jn(n),null;case 19:if($t(Ot),g=n.memoizedState,g===null)return jn(n),null;if(o=(n.flags&128)!==0,k=g.rendering,k===null)if(o)ol(g,!1);else{if(nn!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(k=fo(t),k!==null){for(n.flags|=128,ol(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(Ot,Ot.current&1|2),n.child}t=t.sibling}g.tail!==null&&Lt()>mi&&(n.flags|=128,o=!0,ol(g,!1),n.lanes=4194304)}else{if(!o)if(t=fo(k),t!==null){if(n.flags|=128,o=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ol(g,!0),g.tail===null&&g.tailMode==="hidden"&&!k.alternate&&!It)return jn(n),null}else 2*Lt()-g.renderingStartTime>mi&&i!==1073741824&&(n.flags|=128,o=!0,ol(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=Ot.current,u(Ot,o?i&1|2:i&1),n):(jn(n),null);case 22:case 23:return au(),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 Uh(t,n){switch(fc(n),n.tag){case 1:return B(n.type)&&ve(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return oi(),$t(w),$t(S),Nc(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return kc(n),null;case 13:if($t(Ot),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(r(340));ai()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return $t(Ot),null;case 4:return oi(),null;case 10:return yc(n.type._context),null;case 22:case 23:return au(),null;case 24:return null;default:return null}}var wo=!1,kn=!1,Wh=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function ui(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 Vc(t,n,i){try{i()}catch(o){Wt(t,n,o)}}var pm=!1;function Hh(t,n){if(dr=Ya,t=Jl(),Wi(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 d=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var k=0,I=-1,H=-1,me=0,$e=0,Te=t,Ne=null;t:for(;;){for(var He;Te!==i||d!==0&&Te.nodeType!==3||(I=k+d),Te!==g||o!==0&&Te.nodeType!==3||(H=k+o),Te.nodeType===3&&(k+=Te.nodeValue.length),(He=Te.firstChild)!==null;)Ne=Te,Te=He;for(;;){if(Te===t)break t;if(Ne===i&&++me===d&&(I=k),Ne===g&&++$e===o&&(H=k),(He=Te.nextSibling)!==null)break;Te=Ne,Ne=Te.parentNode}Te=He}i=I===-1||H===-1?null:{start:I,end:H}}else i=null}i=i||{start:0,end:0}}else i=null;for(Ji={focusedElem:t,selectionRange:i},Ya=!1,Ve=n;Ve!==null;)if(n=Ve,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Ve=t;else for(;Ve!==null;){n=Ve;try{var Ke=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Qe=Ke.memoizedProps,Gt=Ke.memoizedState,ne=n.stateNode,Q=ne.getSnapshotBeforeUpdate(n.elementType===n.type?Qe:vs(n.type,Qe),Gt);ne.__reactInternalSnapshotBeforeUpdate=Q}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(De){Wt(n,n.return,De)}if(t=n.sibling,t!==null){t.return=n.return,Ve=t;break}Ve=n.return}return Ke=pm,pm=!1,Ke}function cl(t,n,i){var o=n.updateQueue;if(o=o!==null?o.lastEffect:null,o!==null){var d=o=o.next;do{if((d.tag&t)===t){var g=d.destroy;d.destroy=void 0,g!==void 0&&Vc(n,i,g)}d=d.next}while(d!==o)}}function jo(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 Gc(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 _m(t){var n=t.alternate;n!==null&&(t.alternate=null,_m(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[Zi],delete n[dc],delete n[ro])),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 gm(t){return t.tag===5||t.tag===3||t.tag===4}function vm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||gm(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 Kc(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=ti));else if(o!==4&&(t=t.child,t!==null))for(Kc(t,n,i),t=t.sibling;t!==null;)Kc(t,n,i),t=t.sibling}function Qc(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(Qc(t,n,i),t=t.sibling;t!==null;)Qc(t,n,i),t=t.sibling}var vn=null,ys=!1;function Ea(t,n,i){for(i=i.child;i!==null;)ym(t,n,i),i=i.sibling}function ym(t,n,i){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(Va,i)}catch{}switch(i.tag){case 5:kn||ui(i,n);case 6:var o=vn,d=ys;vn=null,Ea(t,n,i),vn=o,ys=d,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?Xi(t.parentNode,i):t.nodeType===1&&Xi(t,i),os(t)):Xi(vn,i.stateNode));break;case 4:o=vn,d=ys,vn=i.stateNode.containerInfo,ys=!0,Ea(t,n,i),vn=o,ys=d;break;case 0:case 11:case 14:case 15:if(!kn&&(o=i.updateQueue,o!==null&&(o=o.lastEffect,o!==null))){d=o=o.next;do{var g=d,k=g.destroy;g=g.tag,k!==void 0&&((g&2)!==0||(g&4)!==0)&&Vc(i,n,k),d=d.next}while(d!==o)}Ea(t,n,i);break;case 1:if(!kn&&(ui(i,n),o=i.stateNode,typeof o.componentWillUnmount=="function"))try{o.props=i.memoizedProps,o.state=i.memoizedState,o.componentWillUnmount()}catch(I){Wt(i,n,I)}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 xm(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new Wh),n.forEach(function(o){var d=ep.bind(null,t,o);i.has(o)||(i.add(o),o.then(d,d))})}}function xs(t,n){var i=n.deletions;if(i!==null)for(var o=0;o<i.length;o++){var d=i[o];try{var g=t,k=n,I=k;e:for(;I!==null;){switch(I.tag){case 5:vn=I.stateNode,ys=!1;break e;case 3:vn=I.stateNode.containerInfo,ys=!0;break e;case 4:vn=I.stateNode.containerInfo,ys=!0;break e}I=I.return}if(vn===null)throw Error(r(160));ym(g,k,d),vn=null,ys=!1;var H=d.alternate;H!==null&&(H.return=null),d.return=null}catch(me){Wt(d,n,me)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)bm(n,t),n=n.sibling}function bm(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{cl(3,t,t.return),jo(3,t)}catch(Qe){Wt(t,t.return,Qe)}try{cl(5,t,t.return)}catch(Qe){Wt(t,t.return,Qe)}}break;case 1:xs(n,t),Ps(t),o&512&&i!==null&&ui(i,i.return);break;case 5:if(xs(n,t),Ps(t),o&512&&i!==null&&ui(i,i.return),t.flags&32){var d=t.stateNode;try{Le(d,"")}catch(Qe){Wt(t,t.return,Qe)}}if(o&4&&(d=t.stateNode,d!=null)){var g=t.memoizedProps,k=i!==null?i.memoizedProps:g,I=t.type,H=t.updateQueue;if(t.updateQueue=null,H!==null)try{I==="input"&&g.type==="radio"&&g.name!=null&&be(d,g),qt(I,k);var me=qt(I,g);for(k=0;k<H.length;k+=2){var $e=H[k],Te=H[k+1];$e==="style"?yt(d,Te):$e==="dangerouslySetInnerHTML"?Se(d,Te):$e==="children"?Le(d,Te):F(d,$e,Te,me)}switch(I){case"input":ge(d,g);break;case"textarea":ke(d,g);break;case"select":var Ne=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!g.multiple;var He=g.value;He!=null?fe(d,!!g.multiple,He,!1):Ne!==!!g.multiple&&(g.defaultValue!=null?fe(d,!!g.multiple,g.defaultValue,!0):fe(d,!!g.multiple,g.multiple?[]:"",!1))}d[mr]=g}catch(Qe){Wt(t,t.return,Qe)}}break;case 6:if(xs(n,t),Ps(t),o&4){if(t.stateNode===null)throw Error(r(162));d=t.stateNode,g=t.memoizedProps;try{d.nodeValue=g}catch(Qe){Wt(t,t.return,Qe)}}break;case 3:if(xs(n,t),Ps(t),o&4&&i!==null&&i.memoizedState.isDehydrated)try{os(n.containerInfo)}catch(Qe){Wt(t,t.return,Qe)}break;case 4:xs(n,t),Ps(t);break;case 13:xs(n,t),Ps(t),d=t.child,d.flags&8192&&(g=d.memoizedState!==null,d.stateNode.isHidden=g,!g||d.alternate!==null&&d.alternate.memoizedState!==null||(Xc=Lt())),o&4&&xm(t);break;case 22:if($e=i!==null&&i.memoizedState!==null,t.mode&1?(kn=(me=kn)||$e,xs(n,t),kn=me):xs(n,t),Ps(t),o&8192){if(me=t.memoizedState!==null,(t.stateNode.isHidden=me)&&!$e&&(t.mode&1)!==0)for(Ve=t,$e=t.child;$e!==null;){for(Te=Ve=$e;Ve!==null;){switch(Ne=Ve,He=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:cl(4,Ne,Ne.return);break;case 1:ui(Ne,Ne.return);var Ke=Ne.stateNode;if(typeof Ke.componentWillUnmount=="function"){o=Ne,i=Ne.return;try{n=o,Ke.props=n.memoizedProps,Ke.state=n.memoizedState,Ke.componentWillUnmount()}catch(Qe){Wt(o,i,Qe)}}break;case 5:ui(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){km(Te);continue}}He!==null?(He.return=Ne,Ve=He):km(Te)}$e=$e.sibling}e:for($e=null,Te=t;;){if(Te.tag===5){if($e===null){$e=Te;try{d=Te.stateNode,me?(g=d.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(I=Te.stateNode,H=Te.memoizedProps.style,k=H!=null&&H.hasOwnProperty("display")?H.display:null,I.style.display=dt("display",k))}catch(Qe){Wt(t,t.return,Qe)}}}else if(Te.tag===6){if($e===null)try{Te.stateNode.nodeValue=me?"":Te.memoizedProps}catch(Qe){Wt(t,t.return,Qe)}}else if((Te.tag!==22&&Te.tag!==23||Te.memoizedState===null||Te===t)&&Te.child!==null){Te.child.return=Te,Te=Te.child;continue}if(Te===t)break e;for(;Te.sibling===null;){if(Te.return===null||Te.return===t)break e;$e===Te&&($e=null),Te=Te.return}$e===Te&&($e=null),Te.sibling.return=Te.return,Te=Te.sibling}}break;case 19:xs(n,t),Ps(t),o&4&&xm(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(gm(i)){var o=i;break e}i=i.return}throw Error(r(160))}switch(o.tag){case 5:var d=o.stateNode;o.flags&32&&(Le(d,""),o.flags&=-33);var g=vm(t);Qc(t,g,d);break;case 3:case 4:var k=o.stateNode.containerInfo,I=vm(t);Kc(t,I,k);break;default:throw Error(r(161))}}catch(H){Wt(t,t.return,H)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function Vh(t,n,i){Ve=t,wm(t)}function wm(t,n,i){for(var o=(t.mode&1)!==0;Ve!==null;){var d=Ve,g=d.child;if(d.tag===22&&o){var k=d.memoizedState!==null||wo;if(!k){var I=d.alternate,H=I!==null&&I.memoizedState!==null||kn;I=wo;var me=kn;if(wo=k,(kn=H)&&!me)for(Ve=d;Ve!==null;)k=Ve,H=k.child,k.tag===22&&k.memoizedState!==null?Sm(d):H!==null?(H.return=k,Ve=H):Sm(d);for(;g!==null;)Ve=g,wm(g),g=g.sibling;Ve=d,wo=I,kn=me}jm(t)}else(d.subtreeFlags&8772)!==0&&g!==null?(g.return=d,Ve=g):jm(t)}}function jm(t){for(;Ve!==null;){var n=Ve;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||jo(5,n);break;case 1:var o=n.stateNode;if(n.flags&4&&!kn)if(i===null)o.componentDidMount();else{var d=n.elementType===n.type?i.memoizedProps:vs(n.type,i.memoizedProps);o.componentDidUpdate(d,i.memoizedState,o.__reactInternalSnapshotBeforeUpdate)}var g=n.updateQueue;g!==null&&kd(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}kd(n,k,i)}break;case 5:var I=n.stateNode;if(i===null&&n.flags&4){i=I;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 me=n.alternate;if(me!==null){var $e=me.memoizedState;if($e!==null){var Te=$e.dehydrated;Te!==null&&os(Te)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}kn||n.flags&512&&Gc(n)}catch(Ne){Wt(n,n.return,Ne)}}if(n===t){Ve=null;break}if(i=n.sibling,i!==null){i.return=n.return,Ve=i;break}Ve=n.return}}function km(t){for(;Ve!==null;){var n=Ve;if(n===t){Ve=null;break}var i=n.sibling;if(i!==null){i.return=n.return,Ve=i;break}Ve=n.return}}function Sm(t){for(;Ve!==null;){var n=Ve;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{jo(4,n)}catch(H){Wt(n,i,H)}break;case 1:var o=n.stateNode;if(typeof o.componentDidMount=="function"){var d=n.return;try{o.componentDidMount()}catch(H){Wt(n,d,H)}}var g=n.return;try{Gc(n)}catch(H){Wt(n,g,H)}break;case 5:var k=n.return;try{Gc(n)}catch(H){Wt(n,k,H)}}}catch(H){Wt(n,n.return,H)}if(n===t){Ve=null;break}var I=n.sibling;if(I!==null){I.return=n.return,Ve=I;break}Ve=n.return}}var Gh=Math.ceil,ko=J.ReactCurrentDispatcher,Jc=J.ReactCurrentOwner,ss=J.ReactCurrentBatchConfig,vt=0,cn=null,Yt=null,yn=0,Kn=0,di=_s(0),nn=0,ul=null,yr=0,So=0,Yc=0,dl=null,zn=null,Xc=0,mi=1/0,ua=null,No=!1,Zc=null,Ta=null,Co=!1,Aa=null,$o=0,ml=0,eu=null,Eo=-1,To=0;function Cn(){return(vt&6)!==0?Lt():Eo!==-1?Eo:Eo=Lt()}function Ra(t){return(t.mode&1)===0?1:(vt&2)!==0&&yn!==0?yn&-yn:Th.transition!==null?(To===0&&(To=Bs()),To):(t=ct,t!==0||(t=window.event,t=t===void 0?16:Dr(t.type)),t)}function bs(t,n,i,o){if(50<ml)throw ml=0,eu=null,Error(r(185));Pt(t,i,o),((vt&2)===0||t!==cn)&&(t===cn&&((vt&2)===0&&(So|=i),nn===4&&La(t,yn)),Pn(t,o),i===1&&vt===0&&(n.mode&1)===0&&(mi=Lt()+500,Rn&&bt()))}function Pn(t,n){var i=t.callbackNode;Lr(t,n);var o=Dt(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(Cm.bind(null,t)):rt(Cm.bind(null,t)),so(function(){(vt&6)===0&&bt()}),i=null;else{switch(Pr(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=zm(i,Nm.bind(null,t))}t.callbackPriority=n,t.callbackNode=i}}function Nm(t,n){if(Eo=-1,To=0,(vt&6)!==0)throw Error(r(327));var i=t.callbackNode;if(fi()&&t.callbackNode!==i)return null;var o=Dt(t,t===cn?yn:0);if(o===0)return null;if((o&30)!==0||(o&t.expiredLanes)!==0||n)n=Ao(t,o);else{n=o;var d=vt;vt|=2;var g=Em();(cn!==t||yn!==n)&&(ua=null,mi=Lt()+500,br(t,n));do try{Jh();break}catch(I){$m(t,I)}while(!0);vc(),ko.current=g,vt=d,Yt!==null?n=0:(cn=null,yn=0,n=nn)}if(n!==0){if(n===2&&(d=ws(t),d!==0&&(o=d,n=tu(t,d))),n===1)throw i=ul,br(t,0),La(t,o),Pn(t,Lt()),i;if(n===6)La(t,o);else{if(d=t.current.alternate,(o&30)===0&&!Kh(d)&&(n=Ao(t,o),n===2&&(g=ws(t),g!==0&&(o=g,n=tu(t,g))),n===1))throw i=ul,br(t,0),La(t,o),Pn(t,Lt()),i;switch(t.finishedWork=d,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=Xc+500-Lt(),10<n)){if(Dt(t,0)!==0)break;if(d=t.suspendedLanes,(d&o)!==o){Cn(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=ni(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,d=-1;0<o;){var k=31-Sn(o);g=1<<k,k=n[k],k>d&&(d=k),o&=~g}if(o=d,o=Lt()-o,o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*Gh(o/1960))-o,10<o){t.timeoutHandle=ni(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?Nm.bind(null,t):null}function tu(t,n){var i=dl;return t.current.memoizedState.isDehydrated&&(br(t,n).flags|=256),t=Ao(t,n),t!==2&&(n=zn,zn=i,n!==null&&nu(n)),t}function nu(t){zn===null?zn=t:zn.push.apply(zn,t)}function Kh(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 d=i[o],g=d.getSnapshot;d=d.value;try{if(!Tn(g(),d))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&=~Yc,n&=~So,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 Cm(t){if((vt&6)!==0)throw Error(r(327));fi();var n=Dt(t,0);if((n&1)===0)return Pn(t,Lt()),null;var i=Ao(t,n);if(t.tag!==0&&i===2){var o=ws(t);o!==0&&(n=o,i=tu(t,o))}if(i===1)throw i=ul,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 su(t,n){var i=vt;vt|=1;try{return t(n)}finally{vt=i,vt===0&&(mi=Lt()+500,Rn&&bt())}}function xr(t){Aa!==null&&Aa.tag===0&&(vt&6)===0&&fi();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 au(){Kn=di.current,$t(di)}function br(t,n){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,cc(i)),Yt!==null)for(i=Yt.return;i!==null;){var o=i;switch(fc(o),o.tag){case 1:o=o.type.childContextTypes,o!=null&&ve();break;case 3:oi(),$t(w),$t(S),Nc();break;case 5:kc(o);break;case 4:oi();break;case 13:$t(Ot);break;case 19:$t(Ot);break;case 10:yc(o.type._context);break;case 22:case 23:au()}i=i.return}if(cn=t,Yt=t=Ma(t.current,null),yn=Kn=n,nn=0,ul=null,Yc=So=yr=0,zn=dl=null,_r!==null){for(n=0;n<_r.length;n++)if(i=_r[n],o=i.interleaved,o!==null){i.interleaved=null;var d=o.next,g=i.pending;if(g!==null){var k=g.next;g.next=d,o.next=k}i.pending=o}_r=null}return t}function $m(t,n){do{var i=Yt;try{if(vc(),ho.current=vo,po){for(var o=Ft.memoizedState;o!==null;){var d=o.queue;d!==null&&(d.pending=null),o=o.next}po=!1}if(vr=0,on=tn=Ft=null,al=!1,rl=0,Jc.current=null,i===null||i.return===null){nn=1,ul=n,Yt=null;break}e:{var g=t,k=i.return,I=i,H=n;if(n=yn,I.flags|=32768,H!==null&&typeof H=="object"&&typeof H.then=="function"){var me=H,$e=I,Te=$e.tag;if(($e.mode&1)===0&&(Te===0||Te===11||Te===15)){var Ne=$e.alternate;Ne?($e.updateQueue=Ne.updateQueue,$e.memoizedState=Ne.memoizedState,$e.lanes=Ne.lanes):($e.updateQueue=null,$e.memoizedState=null)}var He=Zd(k);if(He!==null){He.flags&=-257,em(He,k,I,g,n),He.mode&1&&Xd(g,me,n),n=He,H=me;var Ke=n.updateQueue;if(Ke===null){var Qe=new Set;Qe.add(H),n.updateQueue=Qe}else Ke.add(H);break e}else{if((n&1)===0){Xd(g,me,n),ru();break e}H=Error(r(426))}}else if(It&&I.mode&1){var Gt=Zd(k);if(Gt!==null){(Gt.flags&65536)===0&&(Gt.flags|=256),em(Gt,k,I,g,n),_c(ci(H,I));break e}}g=H=ci(H,I),nn!==4&&(nn=2),dl===null?dl=[g]:dl.push(g),g=k;do{switch(g.tag){case 3:g.flags|=65536,n&=-n,g.lanes|=n;var ne=Jd(g,H,n);jd(g,ne);break e;case 1:I=H;var Q=g.type,re=g.stateNode;if((g.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||re!==null&&typeof re.componentDidCatch=="function"&&(Ta===null||!Ta.has(re)))){g.flags|=65536,n&=-n,g.lanes|=n;var De=Yd(g,I,n);jd(g,De);break e}}g=g.return}while(g!==null)}Am(i)}catch(Xe){n=Xe,Yt===i&&i!==null&&(Yt=i=i.return);continue}break}while(!0)}function Em(){var t=ko.current;return ko.current=vo,t===null?vo:t}function ru(){(nn===0||nn===3||nn===2)&&(nn=4),cn===null||(yr&268435455)===0&&(So&268435455)===0||La(cn,yn)}function Ao(t,n){var i=vt;vt|=2;var o=Em();(cn!==t||yn!==n)&&(ua=null,br(t,n));do try{Qh();break}catch(d){$m(t,d)}while(!0);if(vc(),vt=i,ko.current=o,Yt!==null)throw Error(r(261));return cn=null,yn=0,nn}function Qh(){for(;Yt!==null;)Tm(Yt)}function Jh(){for(;Yt!==null&&!Rl();)Tm(Yt)}function Tm(t){var n=Mm(t.alternate,t,Kn);t.memoizedProps=t.pendingProps,n===null?Am(t):Yt=n,Jc.current=null}function Am(t){var n=t;do{var i=n.alternate;if(t=n.return,(n.flags&32768)===0){if(i=Bh(i,n,Kn),i!==null){Yt=i;return}}else{if(i=Uh(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,d=ss.transition;try{ss.transition=null,ct=1,Yh(t,n,i,o)}finally{ss.transition=d,ct=o}return null}function Yh(t,n,i,o){do fi();while(Aa!==null);if((vt&6)!==0)throw Error(r(327));i=t.finishedWork;var d=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||Co||(Co=!0,zm(is,function(){return fi(),null})),g=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||g){g=ss.transition,ss.transition=null;var k=ct;ct=1;var I=vt;vt|=4,Jc.current=null,Hh(t,i),bm(i,t),Yl(Ji),Ya=!!dr,Ji=dr=null,t.current=i,Vh(i),Ar(),vt=I,ct=k,ss.transition=g}else t.current=i;if(Co&&(Co=!1,Aa=t,$o=d),g=t.pendingLanes,g===0&&(Ta=null),Ml(i.stateNode),Pn(t,Lt()),n!==null)for(o=t.onRecoverableError,i=0;i<n.length;i++)d=n[i],o(d.value,{componentStack:d.stack,digest:d.digest});if(No)throw No=!1,t=Zc,Zc=null,t;return($o&1)!==0&&t.tag!==0&&fi(),g=t.pendingLanes,(g&1)!==0?t===eu?ml++:(ml=0,eu=t):ml=0,bt(),null}function fi(){if(Aa!==null){var t=Pr($o),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,$o=0,(vt&6)!==0)throw Error(r(331));var d=vt;for(vt|=4,Ve=t.current;Ve!==null;){var g=Ve,k=g.child;if((Ve.flags&16)!==0){var I=g.deletions;if(I!==null){for(var H=0;H<I.length;H++){var me=I[H];for(Ve=me;Ve!==null;){var $e=Ve;switch($e.tag){case 0:case 11:case 15:cl(8,$e,g)}var Te=$e.child;if(Te!==null)Te.return=$e,Ve=Te;else for(;Ve!==null;){$e=Ve;var Ne=$e.sibling,He=$e.return;if(_m($e),$e===me){Ve=null;break}if(Ne!==null){Ne.return=He,Ve=Ne;break}Ve=He}}}var Ke=g.alternate;if(Ke!==null){var Qe=Ke.child;if(Qe!==null){Ke.child=null;do{var Gt=Qe.sibling;Qe.sibling=null,Qe=Gt}while(Qe!==null)}}Ve=g}}if((g.subtreeFlags&2064)!==0&&k!==null)k.return=g,Ve=k;else e:for(;Ve!==null;){if(g=Ve,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:cl(9,g,g.return)}var ne=g.sibling;if(ne!==null){ne.return=g.return,Ve=ne;break e}Ve=g.return}}var Q=t.current;for(Ve=Q;Ve!==null;){k=Ve;var re=k.child;if((k.subtreeFlags&2064)!==0&&re!==null)re.return=k,Ve=re;else e:for(k=Q;Ve!==null;){if(I=Ve,(I.flags&2048)!==0)try{switch(I.tag){case 0:case 11:case 15:jo(9,I)}}catch(Xe){Wt(I,I.return,Xe)}if(I===k){Ve=null;break e}var De=I.sibling;if(De!==null){De.return=I.return,Ve=De;break e}Ve=I.return}}if(vt=d,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 Rm(t,n,i){n=ci(i,n),n=Jd(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)Rm(t,t,i);else for(;n!==null;){if(n.tag===3){Rm(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=ci(i,t),t=Yd(n,t,1),n=$a(n,t,1),t=Cn(),n!==null&&(Pt(n,1,t),Pn(n,t));break}}n=n.return}}function Xh(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()-Xc?br(t,0):Yc|=i),Pn(t,n)}function Lm(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 Zh(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Lm(t,i)}function ep(t,n){var i=0;switch(t.tag){case 13:var o=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:o=t.stateNode;break;default:throw Error(r(314))}o!==null&&o.delete(n),Lm(t,i)}var Mm;Mm=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,qh(t,n,i);Mn=(t.flags&131072)!==0}else Mn=!1,It&&(n.flags&1048576)!==0&&fd(n,en,n.index);switch(n.lanes=0,n.tag){case 2:var o=n.type;bo(t,n),t=n.pendingProps;var d=te(n,S.current);li(n,i),d=Ec(null,n,o,t,d,i);var g=Tc();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,B(o)?(g=!0,Ue(n)):g=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,wc(n),d.updater=yo,n.stateNode=d,d._reactInternals=n,Pc(n,o,t,i),n=Fc(null,n,o,!0,g,i)):(n.tag=0,It&&g&&mc(n),Nn(null,n,d,i),n=n.child),n;case 16:o=n.elementType;e:{switch(bo(t,n),t=n.pendingProps,d=o._init,o=d(o._payload),n.type=o,d=n.tag=np(o),t=vs(o,t),d){case 0:n=Oc(null,n,o,t,i);break e;case 1:n=im(null,n,o,t,i);break e;case 11:n=tm(null,n,o,t,i);break e;case 14:n=nm(null,n,o,vs(o.type,t),i);break e}throw Error(r(306,o,""))}return n;case 0:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:vs(o,d),Oc(t,n,o,d,i);case 1:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:vs(o,d),im(t,n,o,d,i);case 3:e:{if(lm(n),t===null)throw Error(r(387));o=n.pendingProps,g=n.memoizedState,d=g.element,wd(t,n),mo(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){d=ci(Error(r(423)),n),n=om(t,n,o,i,d);break e}else if(o!==d){d=ci(Error(r(424)),n),n=om(t,n,o,i,d);break e}else for(Gn=Rs(n.stateNode.containerInfo.firstChild),Vn=n,It=!0,gs=null,i=xd(n,null,o,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ai(),o===d){n=ca(t,n,i);break e}Nn(t,n,o,i)}n=n.child}return n;case 5:return Sd(n),t===null&&pc(n),o=n.type,d=n.pendingProps,g=t!==null?t.memoizedProps:null,k=d.children,Yi(o,d)?k=null:g!==null&&Yi(o,g)&&(n.flags|=32),rm(t,n),Nn(t,n,k,i),n.child;case 6:return t===null&&pc(n),null;case 13:return cm(t,n,i);case 4:return jc(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=ri(n,null,o,i):Nn(t,n,o,i),n.child;case 11:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:vs(o,d),tm(t,n,o,d,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,d=n.pendingProps,g=n.memoizedProps,k=d.value,u(oo,o._currentValue),o._currentValue=k,g!==null)if(Tn(g.value,k)){if(g.children===d.children&&!w.current){n=ca(t,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var I=g.dependencies;if(I!==null){k=g.child;for(var H=I.firstContext;H!==null;){if(H.context===o){if(g.tag===1){H=oa(-1,i&-i),H.tag=2;var me=g.updateQueue;if(me!==null){me=me.shared;var $e=me.pending;$e===null?H.next=H:(H.next=$e.next,$e.next=H),me.pending=H}}g.lanes|=i,H=g.alternate,H!==null&&(H.lanes|=i),xc(g.return,i,n),I.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,I=k.alternate,I!==null&&(I.lanes|=i),xc(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,d.children,i),n=n.child}return n;case 9:return d=n.type,o=n.pendingProps.children,li(n,i),d=ts(d),o=o(d),n.flags|=1,Nn(t,n,o,i),n.child;case 14:return o=n.type,d=vs(o,n.pendingProps),d=vs(o.type,d),nm(t,n,o,d,i);case 15:return sm(t,n,n.type,n.pendingProps,i);case 17:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:vs(o,d),bo(t,n),n.tag=1,B(o)?(t=!0,Ue(n)):t=!1,li(n,i),Kd(n,o,d),Pc(n,o,d,i),Fc(null,n,o,!0,t,i);case 19:return dm(t,n,i);case 22:return am(t,n,i)}throw Error(r(156,n.tag))};function zm(t,n){return ji(t,n)}function tp(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 tp(t,n,i,o)}function iu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function np(t){if(typeof t=="function")return iu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===_e)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 Ro(t,n,i,o,d,g){var k=2;if(o=t,typeof t=="function")iu(t)&&(k=1);else if(typeof t=="string")k=5;else e:switch(t){case oe:return jr(i.children,d,g,n);case ce:k=8,d|=8;break;case pe:return t=as(12,i,n,d|2),t.elementType=pe,t.lanes=g,t;case ue:return t=as(13,i,n,d),t.elementType=ue,t.lanes=g,t;case q:return t=as(19,i,n,d),t.elementType=q,t.lanes=g,t;case Z:return Lo(i,d,g,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Ee:k=10;break e;case Ae:k=9;break e;case _e: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,d),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 Lo(t,n,i,o){return t=as(22,t,o,n),t.elementType=Z,t.lanes=i,t.stateNode={isHidden:!1},t}function lu(t,n,i){return t=as(6,t,null,n),t.lanes=i,t}function ou(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 sp(t,n,i,o,d){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=Mr(0),this.expirationTimes=Mr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mr(0),this.identifierPrefix=o,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function cu(t,n,i,o,d,g,k,I,H){return t=new sp(t,n,i,I,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},wc(g),t}function ap(t,n,i){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:o==null?null:""+o,children:t,containerInfo:n,implementation:i}}function Pm(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 Im(t,n,i,o,d,g,k,I,H){return t=cu(i,o,!0,t,d,g,k,I,H),t.context=Pm(null),i=t.current,o=Cn(),d=Ra(i),g=oa(o,d),g.callback=n??null,$a(i,g,d),t.current.lanes=d,Pt(t,d,o),Pn(t,o),t}function Mo(t,n,i,o){var d=n.current,g=Cn(),k=Ra(d);return i=Pm(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(d,n,k),t!==null&&(bs(t,d,k,g),uo(t,d,k)),k}function zo(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 Dm(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<n?i:n}}function uu(t,n){Dm(t,n),(t=t.alternate)&&Dm(t,n)}function rp(){return null}var Om=typeof reportError=="function"?reportError:function(t){console.error(t)};function du(t){this._internalRoot=t}Po.prototype.render=du.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(r(409));Mo(t,n,null,null)},Po.prototype.unmount=du.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;xr(function(){Mo(null,t,null,null)}),n[ps]=null}};function Po(t){this._internalRoot=t}Po.prototype.unstable_scheduleHydration=function(t){if(t){var n=Ni();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 mu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Io(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Fm(){}function ip(t,n,i,o,d){if(d){if(typeof o=="function"){var g=o;o=function(){var me=zo(k);g.call(me)}}var k=Im(n,o,t,0,null,!1,!1,"",Fm);return t._reactRootContainer=k,t[ps]=k.current,ka(t.nodeType===8?t.parentNode:t),xr(),k}for(;d=t.lastChild;)t.removeChild(d);if(typeof o=="function"){var I=o;o=function(){var me=zo(H);I.call(me)}}var H=cu(t,0,!1,null,null,!1,!1,"",Fm);return t._reactRootContainer=H,t[ps]=H.current,ka(t.nodeType===8?t.parentNode:t),xr(function(){Mo(n,H,i,o)}),H}function Do(t,n,i,o,d){var g=i._reactRootContainer;if(g){var k=g;if(typeof d=="function"){var I=d;d=function(){var H=zo(k);I.call(H)}}Mo(n,k,t,d)}else k=ip(i,n,t,d,o);return zo(k)}ki=function(t){switch(t.tag){case 3:var n=t.stateNode;if(n.current.memoizedState.isDehydrated){var i=Xn(n.pendingLanes);i!==0&&(zr(n,i|1),Pn(n,Lt()),(vt&6)===0&&(mi=Lt()+500,bt()))}break;case 13:xr(function(){var o=la(t,1);if(o!==null){var d=Cn();bs(o,t,1,d)}}),uu(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)}uu(t,134217728)}},Si=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)}uu(t,n)}},Ni=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 d=hr(o);if(!d)throw Error(r(90));he(o),ge(o,d)}}}break;case"textarea":ke(t,i);break;case"select":n=i.value,n!=null&&fe(t,!!i.multiple,n,!1)}},Me=su,mt=xr;var lp={usingClientEntryPoint:!1,Events:[fr,aa,hr,je,Ce,su]},fl={findFiberByHostInstance:Ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},op={bundleType:fl.bundleType,version:fl.version,rendererPackageName:fl.rendererPackageName,rendererConfig:fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:J.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=wi(t),t===null?null:t.stateNode},findFiberByHostInstance:fl.findFiberByHostInstance||rp,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 Oo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Oo.isDisabled&&Oo.supportsFiber)try{Va=Oo.inject(op),fn=Oo}catch{}}return In.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=lp,In.createPortal=function(t,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!mu(n))throw Error(r(200));return ap(t,n,null,i)},In.createRoot=function(t,n){if(!mu(t))throw Error(r(299));var i=!1,o="",d=Om;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=cu(t,1,!1,null,null,i,!1,o,d),t[ps]=n.current,ka(t.nodeType===8?t.parentNode:t),new du(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=wi(n),t=t===null?null:t.stateNode,t},In.flushSync=function(t){return xr(t)},In.hydrate=function(t,n,i){if(!Io(n))throw Error(r(200));return Do(null,t,n,!0,i)},In.hydrateRoot=function(t,n,i){if(!mu(t))throw Error(r(405));var o=i!=null&&i.hydratedSources||null,d=!1,g="",k=Om;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(k=i.onRecoverableError)),n=Im(n,null,t,1,i??null,d,!1,g,k),t[ps]=n.current,ka(t),o)for(t=0;t<o.length;t++)i=o[t],d=i._getVersion,d=d(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,d]:n.mutableSourceEagerHydrationData.push(i,d);return new Po(n)},In.render=function(t,n,i){if(!Io(n))throw Error(r(200));return Do(null,t,n,!1,i)},In.unmountComponentAtNode=function(t){if(!Io(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=su,In.unstable_renderSubtreeIntoContainer=function(t,n,i,o){if(!Io(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 Km;function Bf(){if(Km)return pu.exports;Km=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(),pu.exports=vp(),pu.exports}var Qm;function yp(){if(Qm)return Fo;Qm=1;var a=Bf();return Fo.createRoot=a.createRoot,Fo.hydrateRoot=a.hydrateRoot,Fo}var xp=yp();const Uf=[{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"]}];Uf.map(a=>({id:a.id,label:a.label}));function bp(a){return`theme-${String(a||"").trim()||"dark"}`}function Jm(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(bp(a))}catch{}}const Du=[{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}],Ou=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function wp(a){const s=String(a).trim();return Du.find(r=>r.id===s)||Du[1]}function jp(a){const s=String(a).trim();return Ou.find(r=>r.id===s)||Ou[1]}function Ym(a){try{const s=document.documentElement,r=wp(a.font_scale||"md"),l=jp(a.header_density||"standard");s.style.setProperty("--font-scale",String(r.scale)),s.style.setProperty("--header-density",String(l.density))}catch{}}var Wf=Bf();function hi(...a){return a.filter(Boolean).join(" ")}function $r({value:a,options:s,placeholder:r="Select…",disabled:l=!1,loading:c=!1,searchable:m=!0,searchPlaceholder:f="Search…",allowCustom:p=!1,clearable:_=!1,minPopoverWidth:y=240,variant:b="panel",className:x,triggerClassName:N,ariaLabel:C,id:O,includeValueOption:E=!1,onOpen:D,customOptionLabel:P,validateCustomValue:G,onChange:F,renderOption:J,renderValue:$}){const ee=h.useRef(null),oe=h.useRef(null),ce=h.useRef(null),pe=h.useRef(D),Ee=h.useId(),Ae=O||`af-select-${Ee.replace(/[^a-zA-Z0-9_-]/g,"")}`,_e=`${Ae}-listbox`,[ue,q]=h.useState(!1),[L,W]=h.useState(""),[Z,z]=h.useState(0),[de,V]=h.useState("bottom"),[j,R]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{pe.current=D},[D]);const U=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]),le=h.useMemo(()=>{const ie=String(a??"");return U.find(fe=>fe.value===ie)||null},[U,a]),ae=h.useMemo(()=>(le==null?void 0:le.label)||String(a||"").trim()||"",[le,a]),M=h.useMemo(()=>{const ie=L.trim().toLowerCase();return ie?U.filter(fe=>fe.label.toLowerCase().includes(ie)||fe.value.toLowerCase().includes(ie)):U},[U,L]),ye=h.useMemo(()=>{if(!p)return null;const ie=L.trim();if(!ie||U.some(K=>K.value===ie))return null;const we=(G==null?void 0:G(ie,{options:U}))||"";return{value:ie,label:P?P(ie):`Use "${ie}"`,disabled:!!we,reason:we}},[p,P,U,L,G]),xe=h.useMemo(()=>{const ie=ye?[ye,...M]:M;if(ie.length>0)return ie;const fe=String(a??"").trim();return c&&fe?[{value:fe,label:ae||fe}]:ie},[ye,M,c,ae,a]),Oe=h.useCallback(()=>{const ie=ee.current;if(!ie)return;const fe=ie.getBoundingClientRect(),we=Math.max(fe.width,y),K=Math.max(8,Math.min(fe.left,window.innerWidth-we-8)),ke=window.innerHeight-fe.bottom,Ye=fe.top,Y=ke>=220||ke>=Ye?"bottom":"top";V(Y);const A=Y==="bottom"?fe.bottom+6:fe.top-6;R({left:K,top:A,width:we})},[y]),Fe=h.useCallback(()=>{q(!1),W("")},[]);h.useEffect(()=>{var ie;ue&&((ie=pe.current)==null||ie.call(pe))},[ue]),h.useEffect(()=>{if(!ue)return;Oe();const ie=()=>Oe();return window.addEventListener("resize",ie),window.addEventListener("scroll",ie,!0),()=>{window.removeEventListener("resize",ie),window.removeEventListener("scroll",ie,!0)}},[ue,Oe]),h.useEffect(()=>{if(!ue)return;const ie=fe=>{var K,ke;const we=fe.target;we&&((K=ee.current)!=null&&K.contains(we)||(ke=oe.current)!=null&&ke.contains(we)||Fe())};return document.addEventListener("mousedown",ie,!0),()=>document.removeEventListener("mousedown",ie,!0)},[ue,Fe]),h.useEffect(()=>{if(!ue)return;const ie=Math.max(0,xe.findIndex(fe=>fe.value===a));z(ie===-1?0:ie),m&&setTimeout(()=>{var fe;return(fe=ce.current)==null?void 0:fe.focus()},0)},[ue,m,a,xe]);const Ze=ie=>{var we;const fe=xe.find(K=>K.value===ie);fe!=null&&fe.disabled||(F(ie),Fe(),(we=ee.current)==null||we.focus())},he=ie=>{var fe,we;if(ie.key==="Escape")return ie.preventDefault(),Fe(),(fe=ee.current)==null||fe.focus(),!0;if(ie.key==="Tab")return Fe(),(we=ee.current)==null||we.focus(),!1;if(ie.key==="ArrowDown")return ie.preventDefault(),z(K=>Math.min(K+1,Math.max(0,xe.length-1))),!0;if(ie.key==="ArrowUp")return ie.preventDefault(),z(K=>Math.max(K-1,0)),!0;if(ie.key==="Home")return ie.preventDefault(),z(0),!0;if(ie.key==="End")return ie.preventDefault(),z(Math.max(0,xe.length-1)),!0;if(ie.key==="Enter"){ie.preventDefault();const K=xe[Z];return K&&Ze(K.value),!0}return!1},Re=ie=>{if(!l){if(ue){if(he(ie))return;if(ie.key===" "&&!m){ie.preventDefault();const fe=xe[Z];fe&&Ze(fe.value)}return}(ie.key==="Enter"||ie.key===" "||ie.key==="ArrowDown"||ie.key==="ArrowUp")&&(ie.preventDefault(),q(!0))}},Pe=!!String(a||"").trim(),se=Pe?ae:r,be=ye!=null&&ye.disabled?ye.reason||"Unavailable":"",ge=ue&&xe.length>0?`${Ae}-opt-${Z}`:void 0,qe=e.jsx("span",{className:hi("af-select-value",!Pe&&"af-select-value--placeholder"),children:c&&!Pe?"Loading…":se}),Je=$?$(le,String(a||"")):qe;return e.jsxs("span",{className:hi("af-select",b==="pin"?"af-select--pin":"af-select--panel",x),children:[e.jsxs("button",{ref:ee,id:Ae,type:"button",className:hi("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:m?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":ue,"aria-controls":ue?_e:void 0,"aria-activedescendant":m?void 0:ge,"aria-label":C,children:[Je,e.jsx("span",{className:hi("af-select-caret",ue&&"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(""),Fe(),(fe=ee.current)==null||fe.focus()},title:"Clear",children:"×"}):null,ue?Wf.createPortal(e.jsxs("div",{ref:oe,className:hi("af-select-popover",de==="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:he,tabIndex:-1,children:[m?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:ce,className:"af-select-search-input",value:L,onChange:ie=>W(ie.target.value),placeholder:f,onKeyDown:he,role:"combobox","aria-expanded":!0,"aria-controls":_e,"aria-activedescendant":ge,"aria-invalid":!!be,"aria-describedby":be?`${Ae}-custom-error`:void 0}),be?e.jsx("div",{id:`${Ae}-custom-error`,className:"af-select-custom-error",role:"alert",children:be}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:_e,"aria-label":C,children:c&&xe.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):xe.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):xe.map((ie,fe)=>{var A;const we=ie.value===a,K=fe===Z,ke=String(ie.group||"").trim(),Ye=fe>0?String(((A=xe[fe-1])==null?void 0:A.group)||"").trim():"",Y=!!ke&&ke!==Ye;return e.jsxs(Kt.Fragment,{children:[Y?e.jsx("div",{className:"af-select-group",role:"presentation",children:ke}):null,e.jsx("div",{id:`${Ae}-opt-${fe}`,role:"option","aria-selected":we,className:hi("af-select-option",we&&"af-select-option--selected",K&&"af-select-option--highlighted",ie.disabled&&"af-select-option--disabled"),title:ie.disabled?ie.reason||"Unavailable":void 0,onMouseEnter:()=>z(fe),onMouseDown:X=>{X.preventDefault(),X.stopPropagation()},onClick:()=>Ze(ie.value),"aria-disabled":ie.disabled?!0:void 0,children:J?J(ie,{selected:we,highlighted:K}):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]}),we?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},ie.value)})})]}),document.body):null]})}function kp(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 Sp(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 Np(a){const s=a.disabled===!0,r=a.layout||"stack",l=a.allowGatewayDefault!==!1,c=String(a.gatewayDefaultLabel||"(gateway default)"),m=String(a.providerLabel||"Provider"),f=String(a.modelLabel||"Model"),p=String(a.providerPlaceholder||"(select)"),_=String(a.modelPlaceholder||"(select)"),y=String(a.provider||"").trim(),b=String(a.model||"").trim(),x=kp(a.providers),N=Sp(a.models),C=s||!!a.loadingProviders,O=s||!!a.loadingModels,E=[...l?[{value:"",label:c}]:[],...x.map(P=>({value:P.name,label:P.display_name?`${P.display_name} (${P.name})`:P.name}))],D=[...l?[{value:"",label:c}]:[],...N.map(P=>({value:P,label:P}))];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:m}),e.jsx($r,{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:m,onChange:P=>a.onChange({provider:String(P||"").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:f}),e.jsx($r,{value:b,options:D,placeholder:l?c:_,disabled:O,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:f,onChange:P=>a.onChange({provider:y,model:String(P||"").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 Cp(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 $p(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 Xm(a){const s=Cp(a);return s===!1?"off":s?String(s.num_draft_tokens):""}function Ep(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 Tp(a){const s=$p(a.capabilities),r=Xm(a.value),l=(s==null?void 0:s.supported_depths.map(String))||[],c=Xm(s==null?void 0:s.default),m=a.inheritLabel||"Workflow / Gateway default",f=c?`${m} (${c==="off"?"Off":`depth ${c}`})`:m,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($r,{ariaLabel:"MTP depth",value:r,placeholder:f,disabled:a.disabled||a.loading,options:[{value:"",label:f},{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(Ep(_))}),p?e.jsx("div",{role:"status",className:"af-pmp__hint",children:p}):null]})}function Ap(a){var z,de;const s=a.disabled===!0,r=a.value||{provider:"",model:""},l=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[c,m]=h.useState(!l),f=l&&!c,p=h.useRef(l);h.useEffect(()=>{l&&!p.current&&m(!1),p.current=l},[l]);const[_,y]=h.useState([]),[b,x]=h.useState(!1),[N,C]=h.useState(""),[O,E]=h.useState([]),[D,P]=h.useState(!1),[G,F]=h.useState(""),J=h.useRef(a);J.current=a,h.useEffect(()=>{if(f||s)return;let V=!0;return x(!0),(async()=>{try{const j=await J.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}},[f,s]);const $=String(r.provider||"").trim();h.useEffect(()=>{if(!$||s){E([]),F(""),P(!1);return}let V=!0;return E([]),P(!0),F(""),(async()=>{try{const j=await J.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&&P(!1)}})(),()=>{V=!1}},[$,s]);const ee=h.useMemo(()=>{const V=[..._];return $&&!V.some(j=>j.name===$)&&V.unshift({name:$}),V},[_,$]),oe=String(r.model||"").trim(),ce=h.useMemo(()=>{const V=[...O];return oe&&!V.includes(oe)&&V.unshift(oe),V},[O,oe]),pe=a.defaultModeLabel||"Gateway default",Ee=a.customModeLabel||"Custom",Ae=$||((z=a.effectiveDefault)==null?void 0:z.provider)||"",_e=oe||($?"":(de=a.effectiveDefault)==null?void 0:de.model)||"",[ue,q]=h.useState({levels:[],error:"",loading:!1}),L=!!a.fetchModelCapabilities,[W,Z]=h.useState();return h.useEffect(()=>{let V=!0;if(Z(void 0),q({levels:[],error:"",loading:L&&!!_e}),!(!L||!_e||s))return J.current.fetchModelCapabilities(_e,Ae).then(j=>{var ae;if(!V)return;if(j!=null&&j.error)throw new Error(String(j.error));Z(j);const R=(j==null?void 0:j.capabilities)||j||{},U=R.reasoning_levels||R.thinking_levels,le=Array.isArray(U)?[...new Set(U.filter(M=>typeof M=="string"&&!!M.trim()))]:[];!le.length&&R.thinking_support===!0&&((ae=R.thinking_control)!=null&&ae.prompt_disable_token)&&le.push("off","auto"),q({levels:le,error:"",loading:!1})}).catch(j=>{V&&q({levels:[],error:`Reasoning options unavailable: ${String((j==null?void 0:j.message)||j)}`,loading:!1})}),()=>{V=!1}},[Ae,_e,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":f,className:`af-pmp__seg-btn${f?" is-active":""}`,onClick:()=>{m(!1),a.onChange({...r,provider:"",model:"",...L?{reasoning:""}:{}})},disabled:s,children:pe}),e.jsx("button",{type:"button",role:"tab","aria-selected":!f,className:`af-pmp__seg-btn${f?"":" is-active"}`,onClick:()=>{m(!0)},disabled:s,children:Ee})]}),f?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(Np,{provider:$,model:oe,providers:ee,models:ce,disabled:s,loadingProviders:b,loadingModels:D,providerError:N||void 0,modelError:G||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&&(ue.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx($r,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:r.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...ue.levels.map(V=>({value:V,label:V})),...r.reasoning&&!ue.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:s||ue.loading,onChange:V=>a.onChange({...r,reasoning:V})})]}):null,ue.error?e.jsx("div",{role:"status",className:"af-pmp__hint",children:ue.error}):null,a.enableSpeculation?e.jsx(Tp,{value:r.speculation,onChange:V=>a.onChange({...r,speculation:V}),capabilities:W,disabled:s,loading:ue.loading,error:ue.error?ue.error.replace("Reasoning options","MTP options"):void 0}):null]})}function Zm(...a){return a.filter(Boolean).join(" ")}function Rp({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:m="token: missing",showGatewayUrl:f=!1,gatewayUrl:p="",gatewayUrlPlaceholder:_="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:b,userPlaceholder:x="admin",onUserIdChange:N,token:C,tokenPlaceholder:O="Paste Gateway user token",showToken:E=!1,onTokenChange:D,onShowTokenChange:P,remember:G=!1,rememberLabel:F="Remember this browser",onRememberChange:J,loading:$=!1,submitting:ee=!1,submitDisabled:oe=!1,submitLabel:ce="Sign in",submittingLabel:pe="Signing in...",closeLabel:Ee="Close",signOutLabel:Ae="Sign out",showClose:_e=!1,showSignOut:ue=!1,error:q,message:L,className:W,onSubmit:Z,onClose:z,onSignOut:de}){const V=$||ee,j=V||oe||!String(b||"").trim()||!String(C||"").trim(),R=U=>{U.preventDefault(),!j&&Z()};return e.jsxs("form",{className:Zm("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:Zm("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:l}),m?e.jsx("span",{className:"af-gateway-signin__source",children:m}):null]}),e.jsxs("div",{className:"af-gateway-signin__form",children:[f?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:U=>y==null?void 0:y(U.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:U=>N(U.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:U=>D(U.target.value),placeholder:O,autoComplete:"current-password",disabled:V}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>P==null?void 0:P(!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:!!G,onChange:U=>J==null?void 0:J(U.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:[_e?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:z,disabled:V,children:Ee}):null,ue?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(de==null?void 0:de()),disabled:V,children:Ae}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:j,children:ee?pe:ce})]})]})}function Lp(a){return a==="light"?"Light":"Dark"}function Mp(a){const s=a.themes&&a.themes.length?a.themes:Uf,r=a.showSwatches!==!1,l=a.variant||"panel",c=h.useMemo(()=>{const f={};for(const p of s)f[p.id]=p;return f},[s]),m=h.useMemo(()=>s.map(f=>({value:f.id,label:f.label,group:Lp(f.group)})),[s]);return e.jsx($r,{value:a.value,options:m,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:l,className:a.className,triggerClassName:a.triggerClassName,onChange:f=>a.onChange(String(f||"").trim()),renderValue:(f,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,O)=>e.jsx("span",{className:"af-theme-swatch",style:{background:C}},`${_}:${O}`))}):null]})},renderOption:(f,p)=>{const _=String(f.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:f.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 zp(a){const s=a.scales&&a.scales.length?a.scales:Du,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx($r,{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 Pp(a){const s=a.densities&&a.densities.length?a.densities:Ou,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx($r,{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 Ip=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function Dp(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 m=l?void 0:!0,f=Ip.has(a);return e.jsxs("svg",{width:s,height:s,viewBox:f?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:f?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":m,role:l?"img":"presentation",...c,children:[l?e.jsx("title",{children:l}):null,Dp(a)]})}const vu=1;function Da(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const Op=["granted","denied","structurally_unavailable","trust_gated"],Fp=["attachable","requires_review","blocked"],qp=["default","operator","structural"],Bp=["grant","deny","clear"],Up=new Set(["__proto__","constructor","prototype"]);function Wp(a,s){if(!Da(a))return{ok:!1,reason:`${s}: cell is not an object`};const r=String(a.availability||"");if(!Op.includes(r))return{ok:!1,reason:`${s}: unknown availability "${r}"`};const l=String(a.provenance||"");if(!qp.includes(l))return{ok:!1,reason:`${s}: unknown provenance "${l}"`};let c;if(r==="trust_gated"){const m=String(a.trust_state||"");if(!Fp.includes(m))return{ok:!1,reason:`${s}: trust_gated cell without a valid trust_state ("${m}")`};c=m}for(const m of["assigned","resolved_value","executable"]){const f=a[m];if(f!==void 0&&typeof f!="boolean")return{ok:!1,reason:`${s}: "${m}" 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 Hf(a){if(!Da(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)!==vu)return{ok:!1,reason:`unsupported schema_version ${s} (this build understands ${vu}); 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 f of a.phases){if(!Da(f)||typeof f.id!="string"||!f.id.trim())return{ok:!1,reason:"phase without a string id"};const p=f.id.trim();if(Up.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 f.label=="string"?f.label:void 0,hint:typeof f.hint=="string"?f.hint:void 0})}const c=[],m=new Set;for(const f of a.sections){if(!Da(f)||typeof f.id!="string"||!f.id.trim())return{ok:!1,reason:"section without a string id"};const p=f.id.trim();if(m.has(p))return{ok:!1,reason:`duplicate section id "${p}"`};if(m.add(p),!Array.isArray(f.items))return{ok:!1,reason:`section "${p}" has no items array`};const _=[],y=new Set;for(const b of f.items){if(!Da(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&&!Da(b.cells))return{ok:!1,reason:`section "${p}" item "${x}": cells is not an object`};const N=Object.create(null),C=Da(b.cells)?b.cells:{};for(const[O,E]of Object.entries(C)){if(!l.has(O))return{ok:!1,reason:`section "${p}" item "${x}": cell for undeclared phase "${O}"`};const D=Wp(E,`section "${p}" item "${x}" phase "${O}"`);if(!D.ok)return D;N[O]=D.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 f.label=="string"?f.label:void 0,items:_})}return{ok:!0,payload:{schema_version:vu,phases:r,sections:c}}}function Hp(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 nd(a,s,r,l,c){const m=a.sections.find(O=>O.id===r),f=m==null?void 0:m.items.find(O=>O.id===l),p=f&&f.cells[c]||null,_=Hp(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 Vp(a,s,r){const l=nd(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)),m=l.cell;return r.op==="clear"?m.assigned?[...c,r]:c:m.assigned&&m.provenance==="operator"&&m.resolved_value===(r.op==="grant")?c:[...c,r]}function Gp(a,s){const r=new Set,l=[];for(const c of s){if(!Da(c)||!Bp.includes(c.op))continue;const m=`${c.section}\0${c.item}\0${c.phase}`;if(r.has(m))continue;r.add(m);const f=nd(a,[],c.section,c.item,c.phase);!f.cell||!f.interactive||l.push(c)}return l}function Kp(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function Qp(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,m=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(f=>e.jsx("button",{type:"button","aria-pressed":l.active_op===f,className:`af-matrix__tri-btn is-${f} ${l.active_op===f?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(f),children:Kp(f)},f))}),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:m}),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 Jp(a){const s=a.disabled===!0,r=h.useMemo(()=>Hf(a.payload),[a.payload]),l=h.useMemo(()=>r.ok?Gp(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,m=(f,p,_,y)=>{if(s)return;const b=Vp(c,l,{section:f,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(f=>e.jsxs("th",{className:"af-matrix__phase",title:f.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:f.label||f.id}),f.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:f.hint}):null]},f.id))]})}),c.sections.map(f=>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:f.label||f.id})}),f.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=nd(c,l,f.id,p.id,_.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(Qp,{view:y,cellLabel:`${p.label||p.id} — ${_.label||_.id}`,disabled:s,onAct:b=>m(f.id,p.id,_.id,b)})},_.id)})]},p.id)),f.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]},f.id))]})})]})}async function Fu(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 Yp(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 Vf(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 yu(a){let s=String(a||"").trim();for(let r=0;r<2&&s;r+=1){try{const m=JSON.parse(s);if(typeof m=="string"&&m!==s){s=m.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 Xp(a){var m,f;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const s=a.gateway||{},r=(m=s.principal)==null?void 0:m.user_id,l=(f=s.principal)==null?void 0:f.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 Zp(a){const s=a.connectionPath||"/api/connection/gateway",[r,l]=h.useState(!1),[c,m]=h.useState(!1),[f,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"),[O,E]=h.useState(""),[D,P]=h.useState(!1),[G,F]=h.useState(!0),[J,$]=h.useState(""),[ee,oe]=h.useState(""),ce=h.useMemo(()=>Xp(f),[f]),pe=ue=>{var q;p(ue),(q=a.onStatusChange)==null||q.call(a,ue)},Ee=h.useRef(!1);if(h.useEffect(()=>{var q;if(!a.isOpen)return;const ue=!Ee.current;if(Ee.current=!0,ue&&a.initialStatus!==void 0&&a.initialStatus!==null){const L=a.initialStatus;pe(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&x(yu(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),$(""),Fu(s).then(L=>{var Z;pe(L),typeof L.gateway_url=="string"&&L.gateway_url.trim()&&x(yu(L.gateway_url));const W=(Z=L.gateway)==null?void 0:Z.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 ue=q=>{q.key==="Escape"&&!q.defaultPrevented&&!a.blocking&&(q.preventDefault(),a.onClose())};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||_)return null;const Ae=async()=>{m(!0),$(""),oe("");try{const ue=yu(b);x(ue);const q=await Yp({gateway_url:ue,gateway_user_id:N,gateway_token:O,persist:G},s);pe(q),E(""),y(!0),a.onClose()}catch(ue){$(String((ue==null?void 0:ue.message)||ue))}finally{m(!1)}},_e=async()=>{m(!0),$(""),oe("");try{await Vf(s),E("");const ue=await Fu(s).catch(()=>null);pe(ue),oe("Signed out. This browser no longer holds a gateway session.")}catch(ue){$(String((ue==null?void 0:ue.message)||ue))}finally{m(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:ue=>{!a.blocking&&ue.target===ue.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Rp,{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:ce.label,statusTone:ce.tone,tokenSourceLabel:f!=null&&f.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:b,onGatewayUrlChange:ue=>x(ue),userId:N,onUserIdChange:C,token:O,tokenPlaceholder:f!=null&&f.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:D,onTokenChange:E,onShowTokenChange:P,remember:G,rememberLabel:"Keep this browser signed in",onRememberChange:F,loading:r,submitting:c,submittingLabel:"Signing in...",showClose:!a.blocking,onClose:a.onClose,showSignOut:!a.blocking&&!!(f!=null&&f.has_session),onSignOut:_e,error:J,message:ee,onSubmit:Ae})})})}function e_(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function t_(a){const s=a||{},r=s.connectionPath||"/api/connection/gateway",l=s.variant||"dismissable",c=h.useRef(s.onStatusChange);c.current=s.onStatusChange;const m=h.useRef(l);m.current=l;const f=h.useRef(!!s.autoOpenMidSession);f.current=!!s.autoOpenMidSession;const[p,_]=h.useState(null),[y,b]=h.useState("loading"),[x,N]=h.useState(!1),C=h.useRef(!1),O=h.useRef(!1),E=h.useRef("loading"),D=h.useRef("none"),P=h.useRef(!1),G=h.useRef(0),F=h.useCallback(q=>{var W;G.current+=1,_(q),(W=c.current)==null||W.call(c,q);const L=e_(q);if(L)b("connected"),E.current="connected",C.current=!1,D.current="none",O.current||N(!1);else if(q!==null){const Z=E.current;b("disconnected"),E.current="disconnected",Z!=="disconnected"&&(D.current=P.current?"signout":Z==="connected"?"mid":"boot");const z=m.current==="blocking"||D.current!=="mid"||f.current;!C.current&&z&&N(!0)}q!==null&&(O.current=L)},[]),J=h.useCallback(async()=>{const q=G.current;try{const L=await Fu(r);if(G.current!==q)return;F(L)}catch{if(G.current!==q)return;F(null)}},[r,F]),[$,ee]=h.useState(!1),[oe,ce]=h.useState(null),pe=h.useCallback(async()=>{ee(!0),ce(null),G.current+=1;let q=null;try{await Vf(r)}catch(L){q=String((L==null?void 0:L.message)||L||"Sign-out request failed")}P.current=!0;try{await J()}finally{P.current=!1}ce(q),ee(!1)},[r,J]),Ee=h.useRef(!1);h.useEffect(()=>{Ee.current||(Ee.current=!0,J())},[J]);const Ae=h.useCallback(()=>{N(!0)},[]),_e=h.useCallback(()=>{const q=E.current;l==="blocking"&&q==="disconnected"||(q==="disconnected"&&(C.current=!0),N(!1))},[l]),ue=h.useMemo(()=>({isOpen:x,onClose:_e,blocking:l==="blocking"&&y!=="connected",appName:s.appName,connectionPath:r,defaultGatewayUrl:s.defaultGatewayUrl,initialStatus:p,onStatusChange:F}),[x,_e,l,y,s.appName,r,s.defaultGatewayUrl,p,F]);return{status:p,phase:y,connected:y==="connected",modalOpen:x,signingOut:$,signOutError:oe,openModal:Ae,refresh:J,signOut:pe,modalProps:ue}}const xu={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},n_=/^var\(--[a-z0-9-]+\)$/i;function s_(a,s){const r=a||"neutral";if(r==="custom"){const l=String(s||"").trim();return n_.test(l)?l:xu.neutral}return xu[r]||xu.neutral}function a_(a,s,r){return[a,`${a}--${s.tone||"neutral"}`,s.size==="sm"?`${a}--sm`:"",r||"",s.className||""].filter(Boolean).join(" ")}function r_(a){return{"--af-chip-hue":s_(a.tone,a.hue)}}function Dn(a){return e.jsxs("span",{className:a_("af-chip",a,a.onRemove?"af-chip--removable":""),style:r_(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 i_(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})]})}function l_(a){const{connection:s}=a,r=s.phase,l=s.signingOut===!0,c=l?"Signing out…":r==="connected"?"Disconnect":r==="loading"?"Connecting…":"Connect",m=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,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:m,"aria-label":m,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:c})]})]})}const Ko={theme:"dark",font_scale:"md",header_density:"standard"};function o_(a){const s=a&&typeof a=="object"?a:{};return{theme:typeof s.theme=="string"&&s.theme?s.theme:Ko.theme,font_scale:typeof s.font_scale=="string"&&s.font_scale?s.font_scale:Ko.font_scale,header_density:typeof s.header_density=="string"&&s.header_density?s.header_density:Ko.header_density}}function c_(a){return`af_appearance_${a}_v1`}function u_(a,s){const r=c_(a),l=h.useMemo(()=>({...Ko}),[JSON.stringify({})]),[c,m]=h.useState(()=>{let f=l;try{const p=localStorage.getItem(r)??(s!=null&&s.legacyKey?localStorage.getItem(s.legacyKey):null);p&&(f=o_({...l,...JSON.parse(p)}))}catch{}try{Jm(f.theme),Ym({font_scale:f.font_scale,header_density:f.header_density})}catch{}return f});return h.useEffect(()=>{Jm(c.theme),Ym({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(r,JSON.stringify(c))}catch{}},[r,c]),[c,m]}function d_(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(Mp,{value:a.value.theme,onChange:s=>a.onChange({...a.value,theme:s})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(zp,{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(Pp,{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*m_(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 f=await r.json().catch(()=>null),p=f&&typeof f=="object"&&f.detail?String(f.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 m="";for(;;){const{done:f,value:p}=await l.read();if(f)break;m+=c.decode(p,{stream:!0});let _;for(;(_=m.indexOf(`
|
|
41
|
+
`))>=0;){const y=m.slice(0,_).trim();if(m=m.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 O=0;O<N.length;O+=1)C[O]=N.charCodeAt(O);yield C.buffer}if(b&&(b.type==="done"||b.type==="cancelled"))return}}}finally{s.abort()}}function f_(){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 h_(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function p_(){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 bu(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 m=l(r);if(m&&typeof m.then=="function")return await m}catch{}return await new Promise((m,f)=>{try{l(r,m,f)}catch(p){f(p)}})}function __(a){const s=new Uint8Array(a);if(s.length<44)return null;const r=m=>String.fromCharCode(s[m],s[m+1],s[m+2],s[m+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const l=new DataView(a);let c=12;for(;c+8<=s.length;){const m=r(c),f=l.getUint32(c+4,!0);if(m==="data")return s.slice(0,c+8);c+=8+f+f%2}return null}function g_(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 Gf(a){const s=h.useRef(a);s.current=a;const r=he=>{var Re,Pe;return(Pe=(Re=s.current).on_error)==null?void 0:Pe.call(Re,he)},l=h.useMemo(()=>h_()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),c=h.useMemo(()=>f_()&&typeof a.transcribe=="function",[a.transcribe]),[m,f]=h.useState({key:"",status:"idle"}),p=h.useRef(m),_=h.useCallback(he=>{p.current=he,f(Re=>Re.key===he.key&&Re.status===he.status?Re:he)},[]),y=h.useRef(""),b=h.useRef(""),x=h.useRef(null),N=h.useRef(null),C=h.useRef(null),O=h.useRef(null),E=h.useRef(0),D=h.useRef(0),P=h.useRef(0),G=h.useRef([]),F=h.useRef(0),J=h.useRef(!0),$=h.useRef(!1),ee=()=>{try{const he=globalThis,Re=(he==null?void 0:he.AudioContext)||(he==null?void 0:he.webkitAudioContext);if(!Re)return null;if(!x.current){const be=new Re,ge=be.createGain();ge.gain.value=1,ge.connect(be.destination),x.current=be,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 he=C.current;if(C.current=null,!!he){try{he.onended=null}catch{}try{he.stop()}catch{}try{he.disconnect()}catch{}}},[]),ce=h.useCallback(()=>{oe(),P.current+=1,G.current=[],F.current=0,J.current=!0,$.current=!1,b.current="",y.current="",O.current=null,E.current=0,D.current=0,_({key:"",status:"idle"})},[oe,_]);h.useEffect(()=>()=>{var he,Re;ce();try{(he=N.current)==null||he.disconnect()}catch{}try{(Re=x.current)==null||Re.close()}catch{}x.current=null,N.current=null,O.current=null},[]);const pe=async(he,Re,Pe)=>{const se=P.current,be=ee();if(!be)throw new Error("TTS playback is not supported in this browser");const{ctx:ge,gain:qe}=be;try{ge.state==="suspended"&&await ge.resume()}catch{}if(se!==P.current)return;oe();const Je=ge.createBufferSource();Je.buffer=Re,Je.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));D.current=ge.currentTime-fe,E.current=fe,C.current=Je,y.current=he,Je.onended=()=>{C.current===Je&&(C.current=null,E.current=0,D.current=0,y.current="",_({key:"",status:"idle"}))},Je.start(0,fe),_({key:he,status:"playing"})},Ee=(he,Re)=>{if(Re!==P.current)return;const Pe=ee();if(!Pe)return;const se=G.current,be=F.current;if(be>=se.length){J.current&&(y.current="",E.current=0,D.current=0,_({key:"",status:"idle"}));return}const ge=se[be],{ctx:qe,gain:Je}=Pe;oe();const ie=qe.createBufferSource();ie.buffer=ge,ie.connect(Je);const fe=Number.isFinite(Number(ge.duration))?Number(ge.duration):0,we=Math.max(0,Math.min(Number(E.current||0),fe>0?Math.max(0,fe-.01):0));D.current=qe.currentTime-we,C.current=ie,y.current=he,ie.onended=()=>{Re===P.current&&C.current===ie&&(C.current=null,F.current=be+1,E.current=0,Ee(he,Re))};try{qe.state==="suspended"&&qe.resume()}catch{}ie.start(0,we),_({key:he,status:"playing"})},Ae=async(he,Re,Pe)=>{const se=ee();if(!se){r==null||r("TTS playback is not supported in this browser.");return}oe();const be=++P.current;G.current=[],F.current=0,J.current=!1,$.current=!1,O.current=null,E.current=0,D.current=0,y.current=he,b.current=he,_({key:he,status:"loading"}),r==null||r("");let ge=null;try{for await(const qe of Pe(Re)){if(be!==P.current)return;let Je;try{Je=await bu(se.ctx,qe),ge||(ge=__(qe))}catch{if(!ge)continue;try{Je=await bu(se.ctx,g_(ge,qe))}catch{continue}}if(be!==P.current)return;G.current.push(Je),!C.current&&!$.current&&(b.current="",Ee(he,be))}if(be!==P.current)return;if(J.current=!0,G.current.length===0){r==null||r("TTS stream produced no audio."),ce();return}!C.current&&!$.current&&Ee(he,be)}catch(qe){if(be!==P.current)return;r==null||r(String((qe==null?void 0:qe.message)||qe||"TTS stream failed")),ce()}},_e=h.useCallback(async(he,Re)=>{const Pe=String(he||"").trim(),se=String(Re||"").trim();if(!Pe||!se)return;const be=s.current.tts,ge=s.current.tts_stream;if(typeof be!="function"&&typeof ge!="function"){r==null||r("TTS is not available.");return}const qe=ee();if(!qe){r==null||r("TTS playback is not supported in this browser.");return}const Je=p.current,ie=Je.key===Pe;if(ie&&Je.status==="playing"){if(C.current){const we=Math.max(0,qe.ctx.currentTime-Number(D.current||0));E.current=we}else E.current=0;$.current=!0,oe(),_({key:Pe,status:"paused"});return}if(ie&&Je.status==="paused"){if(G.current.length>0){r==null||r(""),$.current=!1,_({key:Pe,status:"playing"}),Ee(Pe,P.current);return}const we=O.current;if(we){r==null||r(""),$.current=!1;try{await pe(Pe,we,E.current)}catch(K){r==null||r(String((K==null?void 0:K.message)||K||"TTS play failed")),_({key:"",status:"idle"})}return}}if(ie&&Je.status==="loading")return;if(typeof ge=="function"){await Ae(Pe,se,ge);return}oe(),P.current+=1;const fe=P.current;G.current=[],F.current=0,J.current=!0,$.current=!1,O.current=null,E.current=0,D.current=0,y.current=Pe,b.current=Pe,_({key:Pe,status:"loading"}),r==null||r("");try{const we=await be(se);if(b.current!==Pe||P.current!==fe)return;const K=await bu(qe.ctx,we);if(b.current!==Pe||P.current!==fe)return;O.current=K,E.current=0,await pe(Pe,K,0)}catch(we){if(P.current!==fe)return;b.current===Pe&&(b.current="",y.current="",_({key:"",status:"idle"})),r==null||r(String((we==null?void 0:we.message)||we||"TTS failed"))}},[]),[ue,q]=h.useState(!1),[L,W]=h.useState(!1),Z=h.useRef(!1),z=h.useRef(c);z.current=c;const de=h.useCallback(he=>{Z.current=he,q(Re=>Re===he?Re:he)},[]),V=h.useRef(!1),j=h.useRef(null),R=h.useRef(null),U=h.useRef([]),le=h.useRef(""),ae=h.useRef(0),M=h.useRef(!1);function ye(){var he,Re;try{(Re=(he=j.current)==null?void 0:he.getTracks)==null||Re.call(he).forEach(Pe=>{try{Pe.stop()}catch{}})}catch{}j.current=null}const xe=h.useCallback(()=>{ae.current+=1,M.current=!1;const he=R.current;if(he){he.onstop=null,he.ondataavailable=null,he.onerror=null;try{he.stop()}catch{}}R.current=null,ye(),de(!1),V.current=!1,W(!1),U.current=[]},[de]);h.useEffect(()=>()=>xe(),[xe]);async function Oe(he,Re){var be,ge;if(r==null||r(""),!he||!he.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=ae.current;W(!0);try{const qe=String(await Pe(he,Re)||"").trim();se===ae.current&&qe&&((ge=(be=s.current).on_transcript)==null||ge.call(be,qe))}catch(qe){se===ae.current&&(r==null||r(String((qe==null?void 0:qe.message)||qe||"Transcription failed")))}finally{se===ae.current&&(V.current=!1,W(!1))}}const Fe=h.useCallback(async()=>{if(r==null||r(""),!z.current){r==null||r("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(V.current||M.current||Z.current||R.current)return;U.current=[];const he=ae.current;M.current=!0;try{const Re=await navigator.mediaDevices.getUserMedia({audio:!0});if(he!==ae.current){Re.getTracks().forEach(be=>be.stop());return}j.current=Re;const Pe=p_();le.current=Pe;const se=Pe?new MediaRecorder(Re,{mimeType:Pe}):new MediaRecorder(Re);R.current=se,se.ondataavailable=be=>{if(he===ae.current)try{be!=null&&be.data&&U.current.push(be.data)}catch{}},se.onerror=()=>{he===ae.current&&(r==null||r("Recording failed."))},se.onstop=()=>{if(he===ae.current){de(!1),ye(),R.current=null;try{const be=new Blob(U.current,{type:le.current||""});Oe(be,le.current)}catch(be){r==null||r(String((be==null?void 0:be.message)||be||"Failed to build recording"))}}},se.start(),de(!0)}catch(Re){if(he!==ae.current)return;ye(),R.current=null,de(!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{he===ae.current&&(M.current=!1)}},[]),Ze=h.useCallback(()=>{const he=R.current;if(!(!Z.current||!he)){de(!1);try{he.stop()}catch(Re){r==null||r(String((Re==null?void 0:Re.message)||Re||"Failed to stop recording"))}}},[]);return h.useEffect(()=>{if(!ue)return;const he=()=>Ze();return window.addEventListener("pointerup",he),window.addEventListener("pointercancel",he),()=>{window.removeEventListener("pointerup",he),window.removeEventListener("pointercancel",he)}},[ue]),{tts_supported:l,tts_playback:m,toggle_tts:_e,stop_tts:ce,voice_ptt_supported:c,voice_ptt_recording:ue,voice_ptt_busy:L,start_voice_ptt_recording:Fe,stop_voice_ptt_recording:Ze,cancel_voice_ptt_recording:xe}}function v_(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 y_=3,x_=Number.MAX_SAFE_INTEGER;function Kf(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function Qf(a){return Array.isArray(a)}function b_(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function gi({kind:a,children:s}){return e.jsx("span",{className:`pc-json-token ${a}`,children:s})}function w_(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(m=>!m),"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(gi,{kind:"string",children:s})}function j_(a,s,r){return a===null?e.jsx(gi,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(w_,{value:a,expansionMode:s,expansionVersion:r}):typeof a=="number"?e.jsx(gi,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx(gi,{kind:"boolean",children:a?"true":"false"}):e.jsx(gi,{kind:"string",children:JSON.stringify(String(a))})}function k_(a){return Qf(a)?a.length===1?"1 item":`${a.length} items`:Kf(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function Jf(a){const{label:s,value:r,depth:l,collapseAfterDepth:c,expansionMode:m,expansionVersion:f,trailingComma:p}=a,_=l*14,y=Kf(r),b=Qf(r),x=y||b,N=l<c,[C,O]=h.useState(N);h.useEffect(()=>{O(N)},[N,f]);const E=s?e.jsxs(e.Fragment,{children:[e.jsx(gi,{kind:"key",children:JSON.stringify(s)}),": "]}):null;if(!x)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[E,j_(r,m,f),p?",":""]});const D=b?"[":"{",P=b?"]":"}",G=k_(r),F=C?`${D}`:`${D}…${P}${G?` (${G})`:""}`,J=b?r.map(($,ee)=>({key:String(ee),label:void 0,value:$})):Object.entries(r).map(([$,ee])=>({key:$,label:$,value:ee}));return e.jsxs("details",{className:"pc-json-viewer__details",open:C,onToggle:$=>O($.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:J.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:P}),p?",":""]}):e.jsxs(e.Fragment,{children:[J.map(($,ee)=>{const oe=ee===J.length-1;return e.jsx(Jf,{label:$.label,value:$.value,depth:l+1,collapseAfterDepth:c,expansionMode:m,expansionVersion:f,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:P}),p?",":""]})]})}):null]})}function S_(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 Qo(a){const{value:s,className:r,showCopy:l=!0}=a,[c,m]=h.useState({mode:"folded",version:0}),f=typeof a.collapseAfterDepth=="number"&&(Number.isFinite(a.collapseAfterDepth)||a.collapseAfterDepth===1/0)&&a.collapseAfterDepth>=0?a.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(a.collapseAfterDepth):y_,p=c.mode==="unfolded"?x_:f,_=h.useMemo(()=>typeof s=="string"?S_(s):s,[s]),y=h.useMemo(()=>b_(s),[s]),b=["pc-json-viewer",r].filter(Boolean).join(" ");h.useEffect(()=>{m(N=>({mode:"folded",version:N.version+1}))},[_]);const x=()=>{m(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(Jf,{value:_,depth:0,collapseAfterDepth:p,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function pl(a,s){const r=String(a??"");if(!s||!s.needles.length)return[r];const l=[],c=r.toLowerCase();let m=0;for(;m<r.length;){let f=-1,p="";for(let b=0;b<s.needlesLower.length;b++){const x=s.needlesLower[b];if(!x)continue;const N=c.indexOf(x,m);if(N===-1)continue;const C=s.needles[b]||"";C&&(f===-1||N<f||N===f&&C.length>p.length)&&(f=N,p=C)}if(f===-1||!p){l.push(r.slice(m));break}f>m&&l.push(r.slice(m,f));const _=s.hits===0&&s.id?s.id:void 0,y=r.slice(f,f+p.length);l.push(e.jsx("span",{id:_,className:s.className,children:y},`hl:${s.hits}`)),s.hits+=1,m=f+p.length}return l}function qu(a){const s=String(a||"").trim();if(s&&/^(https?:|mailto:|tel:|#|\/)/i.test(s))return s}function Oa(a,s){const r=[],l=String(a??"");let c=0,m="";const f=()=>{if(m){for(const p of pl(m,s))r.push(p);m=""}};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=qu(l.slice(_+2,y));if(x){f(),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?pl(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=qu(l.slice(_+2,y));if(x){f(),r.push(e.jsx("a",{className:"pc-md_link",href:x,target:x.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Oa(b,s)},`link:${c}`)),c=y+1;continue}}}}if(p==="`"){const _=l.indexOf("`",c+1);if(_!==-1){f();const y=l.slice(c+1,_);r.push(e.jsx("code",{children:s?pl(y,s):y},`code:${c}`)),c=_+1;continue}}if(p==="*"&&l[c+1]==="*"){const _=l.indexOf("**",c+2);if(_!==-1){f();const y=l.slice(c+2,_);r.push(e.jsx("strong",{children:s?pl(y,s):y},`bold:${c}`)),c=_+2;continue}}if(p==="*"&&l[c+1]!=="*"){const _=l.indexOf("*",c+1);if(_!==-1){f();const y=l.slice(c+1,_);r.push(e.jsx("em",{children:s?pl(y,s):y},`em:${c}`)),c=_+1;continue}}m+=p,c+=1}return f(),r}function N_(a){return String(a??"").replace(/\r\n/g,`
|
|
42
|
+
`).replace(/\r/g,`
|
|
43
|
+
`).split(`
|
|
44
|
+
`)}function Jo(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 C_(a){const s=[];for(const c of a){const m=Jo(c);m?s.push(m):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 m=l.length>0?l[l.length-1]:null;if(m&&c.indent>m.indent){const f=m.node.items,p=f[f.length-1];if(p){const _={ordered:c.ordered,start:c.start,items:[]};p.children.push(_),l.push({indent:c.indent,node:_}),m=l[l.length-1]}}else if(m&&m.node.ordered!==c.ordered){l.pop();const f=l.length>0?l[l.length-1]:null,p={ordered:c.ordered,start:c.start,items:[]};if(f){const _=f.node.items,y=_[_.length-1];y?y.children.push(p):f.node.items.push({content:"",children:[p]})}else r.push(p);l.push({indent:c.indent,node:p}),m=l[l.length-1]}if(!m){const f={ordered:c.ordered,start:c.start,items:[]};r.push(f),l.push({indent:c.indent,node:f}),m=l[l.length-1]}m.node.items.push({content:c.content,children:[]})}return r}function Yf(a,s,r){const l=a.items.map((c,m)=>e.jsxs("li",{children:[Oa(c.content,s),c.children.map((f,p)=>Yf(f,s,`${r}:${m}:${p}`))]},`${r}:li:${m}`));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 $_(a,s,r){return C_(a).map((l,c)=>Yf(l,s,`${r}:${c}`))}function ef(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 tf(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({text:a,className:s,highlight:r,highlights:l,highlightClassName:c,highlightId:m}){const f=N_(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:m,hits:0}:null;let x=0;for(;x<f.length;){const C=String(f[x]??"");if(!C.trim()){x+=1;continue}const O=C.trim();if(/^([-_*])(\s*\1){2,}$/.test(O)){p.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}const E=C.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(E){const G=qu(E[2]||"");if(G){const F=E[1]||"";p.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:G,alt:F,loading:"lazy"}),F?e.jsx("figcaption",{children:Oa(F,b)}):null]},`figure:${x}`)),x+=1;continue}}if(C.trim().startsWith("```")){const F=C.trim().replace(/```/g,"").trim(),J=[];for(x+=1;x<f.length&&!String(f[x]??"").trim().startsWith("```");)J.push(String(f[x]??"")),x+=1;x<f.length&&(x+=1);const $=J.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 D=C.match(/^(#{1,5})\s+(.*)$/);if(D){const G=D[1].length,F=D[2]||"",J=Oa(F,b);G===1?p.push(e.jsx("h1",{children:J},`h1:${x}`)):G===2?p.push(e.jsx("h2",{children:J},`h2:${x}`)):G===3?p.push(e.jsx("h3",{children:J},`h3:${x}`)):G===4?p.push(e.jsx("h4",{children:J},`h4:${x}`)):p.push(e.jsx("h5",{children:J},`h5:${x}`)),x+=1;continue}if(C.trimStart().startsWith(">")){const G=[];for(;x<f.length&&String(f[x]??"").trimStart().startsWith(">");){const J=String(f[x]??"").trimStart();G.push(J.replace(/^>\s?/,"")),x+=1}p.push(e.jsx("blockquote",{className:"pc-md_quote",children:G.map((F,J)=>e.jsxs(Kt.Fragment,{children:[Oa(F,b),J<G.length-1?e.jsx("br",{}):null]},`q:${x}:${J}`))},`quote:${x}`));continue}if(C.includes("|")&&x+1<f.length&&tf(String(f[x+1]??""))){const G=ef(C),F=Math.max(1,G.length),J=[];for(x+=2;x<f.length;){const $=String(f[x]??"");if(!$.trim()||!$.includes("|"))break;const ee=ef($),oe=[];for(let ce=0;ce<F;ce++)oe.push(ee[ce]??"");J.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:G.slice(0,F).map(($,ee)=>e.jsx("th",{children:Oa($,b)},`th:${x}:${ee}`))})}),e.jsx("tbody",{children:J.map(($,ee)=>e.jsx("tr",{children:$.map((oe,ce)=>e.jsx("td",{children:Oa(oe,b)},`td:${x}:${ee}:${ce}`))},`tr:${x}:${ee}`))})]})},`table:${x}`));continue}if(Jo(C)){const G=[];for(;x<f.length;){const F=String(f[x]??"");if(!F.trim()||F.trimStart().startsWith("```"))break;if(Jo(F)||/^\s{2,}\S/.test(F)){G.push(F),x+=1;continue}break}p.push(e.jsx(Kt.Fragment,{children:$_(G,b,`list:${x}`)},`list:${x}`));continue}const P=[];for(;x<f.length&&String(f[x]??"").trim()&&!(P.length>0&&Jo(String(f[x]??"")));){const G=String(f[x]??"");if(P.length>0&&G.includes("|")&&x+1<f.length&&tf(String(f[x+1]??"")))break;P.push(G),x+=1}p.push(e.jsx("p",{className:"pc-md_p",children:P.map((G,F)=>e.jsxs(Kt.Fragment,{children:[Oa(G,b),F<P.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 E_(a){const s=String(a.text??""),r=h.useMemo(()=>v_(s),[s]),l=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:l,children:e.jsx(Qo,{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})})}function Xf(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function T_(a){const s=Xf(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(m=>r.find(([f])=>f===m)).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 Zf({tool:a,showCopy:s=!0}){const[r,l]=h.useState(!1),c=Xf(a.arguments),m=T_(a.arguments),f=["file path","path"].includes(m.label)&&m.value.length>60?`${m.value.split(/[\\/]/).pop()} · ${m.value.slice(0,24)}…`:m.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:m.value,children:m.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:m.label}),f]}):"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(Kt.Fragment,{children:[e.jsx("dt",{children:x}),e.jsx("dd",{children:N&&typeof N=="object"?e.jsx(Qo,{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(Qo,{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(Qo,{value:a.output})})]}):null]})]})}function A_({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(Zf,{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`},eh=a=>a===void 0?xn:`${Math.round(a).toLocaleString()} tok/s`,R_=(a,s)=>s>0?`${Math.round(a/s*100)}%`:"",Cr=(a,s,r=`${s}s`)=>`${a.toLocaleString()} ${a===1?s:r}`,L_=a=>{const s=a.split("#")[0].replace(/\/+$/,"");return s.slice(s.lastIndexOf("/")+1)||a};function M_(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 Yo(a){const s=[],r=(a.models||[]).map(L_),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 z_(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 · ${Cr(a.llmCalls,"model call")}`,rows:l}),a.measuredCacheCalls){const m=a.cachedTokens||0,f=a.fedTokens||0,p=[{label:"Reused from cache",value:`${$n(m)}${m+f?` (${R_(m,m+f)})`:""}`},{label:"Newly processed",value:$n(a.fedTokens)},{label:"Outcome",value:M_(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(m=>m.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((m,f)=>[String(f+1),$n(m.inputTokens),m.cachedTokens===void 0?"—":$n(m.cachedTokens),m.fedTokens===void 0?"—":$n(m.fedTokens),$n(m.outputTokens),m.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?xn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:Yo(a)}}function qo(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 ${eh(r)}`:""}`),c.join(" · ")}function P_(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)} · ${Cr(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),c.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Fn(a.toolTimeMs)} · ${Cr(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 m=[],f=a.ttftCalls||0,p=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?m.push({label:f&&f===p?"Prefill (TTFT)":"Prefill",value:qo(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:f===p?"measured time to first token":f?`TTFT measured on ${f} of ${p}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?m.push({label:"Prefill",value:qo(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?m.push({label:"Prefill",value:`${Fn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${eh(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):m.push({label:"Prefill",value:xn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&m.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),m.push({label:"Generation",value:a.generationPhaseMs!==void 0?qo(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):qo(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&m.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:m});const _=a.speculation;if(_){const N=(_.draftKinds||[]).map(O=>O.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)} · ${Cr(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Fn(a.slowestToolBatch.ms)} · ${th(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:Yo(a)}}function th(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${Cr(a.calls,"call")} (${a.tools.join(", ")})`}function I_(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:Yo(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 m=c.filter(([,p])=>p.errors&&Object.keys(p.errors).length);m.length&&s.push({heading:"Failures",rows:m.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 f=[{label:"Tool time",value:a.toolTimeMs===void 0?xn:`${Fn(a.toolTimeMs)} · ${Cr(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&f.push({label:"Slowest batch",value:`${Fn(a.slowestToolBatch.ms)} · ${th(a.slowestToolBatch)}`}),s.push({heading:"Timing",rows:f,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:`${Cr(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:s,footer:Yo(a)}}function wu(a,s){return a==="tokens"?z_(s):a==="time"?P_(s):I_(s)}function D_(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(Kt.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,m)=>e.jsx("tr",{children:c.map((f,p)=>e.jsx("td",{children:f},p))},m))})]}):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 O_(a){const[s,r]=h.useState(!!a.defaultOpen),[l,c]=h.useState(null),m=h.useRef(null),f=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 D=m.current,P=f.current;if(!D||!P)return;const G=D.getBoundingClientRect(),F=P.offsetWidth,J=P.offsetHeight,$=window.innerWidth,ee=window.innerHeight,oe=G.top-da-J,ce=G.bottom+da,pe=oe>=da?oe:ce+J<=ee-da?ce:Math.max(da,ee-da-J),Ee=Math.min(Math.max(da,G.left),Math.max(da,$-da-F));c({top:pe,left:Ee})};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=D=>{D.key==="Escape"&&r(!1)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[s]);const N=typeof a.onClick=="function",C=N?"button":"span",O=s?e.jsx(D_,{detail:a.detail,id:_,panelRef:f,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:m,...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})]}),O&&typeof document<"u"?Wf.createPortal(O,document.body):O]})}function F_(a){const s=a.totalTokens!==void 0?wu("tokens",a):null,r=wu("tools",a),l=a.durationMs!==void 0?wu("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 q_(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 B_(a){var D;const s=a.message,r=h.useMemo(()=>q_(s),[s.kind,s.level,s.role,s.title]),l=String(s.ts||"").trim(),c=h.useMemo(()=>{if(!l)return"";const P=new Date(l);return Number.isFinite(P.getTime())?P.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[l]),[m,f]=h.useState("idle"),p=h.useRef(null);h.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);const _=typeof a.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(s.content||"").trim(),y=_&&((D=a.getSpeakState)==null?void 0:D.call(a,s))||"idle",b=y==="loading"?"loader":y==="playing"?"pause":"speaker",x=y==="loading"?"Generating audio…":y==="playing"?"Pause":y==="paused"?"Resume":"Speak (TTS)",N=a.showCopy!==!1,C=Array.isArray(a.attachments)?a.attachments:[],O=s.statistics,E=h.useMemo(()=>Array.isArray(a.stats)?a.stats:O?F_(O):[],[a.stats,O]);return s.toolActivity?e.jsx(Zf,{tool:s.toolActivity,showCopy:a.showCopy}):e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,a.className].filter(Boolean).join(" "),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.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:[_?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":x,title:x,onClick:()=>{var P;return(P=a.onSpeakToggle)==null?void 0:P.call(a,s)},children:e.jsx(at,{name:b,size:22})}):null,N?e.jsx("button",{className:`pc-chat-icon-btn ${m!=="idle"?`pc-chat-icon-btn--${m}`:""}`.trim(),type:"button","aria-label":"Copy message",title:m==="idle"?"Copy":m==="copied"?"Copied":"Copy failed",onClick:async()=>{const P=await dn(String(s.content||""));f(P?"copied":"failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>f("idle"),900)},children:e.jsx(at,{name:"copy",size:22})}):null]})]}),e.jsx("div",{className:"pc-chat-body",children:e.jsx(E_,{text:String(s.content||""),renderMarkdown:a.renderMarkdown,jsonCollapseAfterDepth:a.jsonCollapseAfterDepth})}),C.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:C.slice(0,24).map((P,G)=>{const F=String(P.label||"").trim()||"attachment",J=String(P.target||"").trim(),$=String(P.title||"").trim(),ee=!!P.disabled||typeof P.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:$||F,onClick:ee?void 0:P.onClick,disabled:ee,children:[e.jsx(at,{name:"paperclip",size:14}),J?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${J}`,children:J}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:F})]},P.id||`${F}:${G}`)})}):null,E.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:E.slice(0,12).map((P,G)=>{const F=String(P.label||"").trim();if(!F)return null;if(P.detail)return e.jsx(O_,{label:F,detail:P.detail,icon:P.icon,onClick:P.onClick},P.id||`${F}:${G}`);const J=String(P.title||"").trim(),$=typeof P.onClick=="function",ee=$?"button":"span";return e.jsxs(ee,{...$?{type:"button"}:{},className:["pc-chat-stat",$?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:J||void 0,onClick:$?()=>{var oe;return(oe=P.onClick)==null?void 0:oe.call(P)}:void 0,children:[P.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:P.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:F})]},P.id||`${F}:${G}`)})}):null]})}function U_(a,s){const r=Math.max(0,Math.trunc(s));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function sd(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),[m,f]=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=()=>{f(U_(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||!m)return;const b=l.current;b&&(b.scrollTop=b.scrollHeight)},[r,m,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 O;const N=b[0],C=String(N.id||"")||String(N.ts||"")+":"+String(N.role||"")+":"+x;return N.toolActivity?e.jsx(A_,{tools:b.map(E=>E.toolActivity),showCopy:(O=a.messageProps)==null?void 0:O.showCopy},C):e.jsx(B_,{message:N,...a.messageProps||{}},C)}),a.after,e.jsx("div",{ref:c})]})}const Xo=Kt.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,m=!!s.busy,f=!c&&!m&&!!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(),f&&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:!f,onClick:()=>s.onSubmit(),children:m?s.busyLabel||"Thinking…":s.sendLabel||"Send"})]}),s.overlay]})});function W_(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function H_(a){const[s,r]=h.useState([]),l=a.messages??s,c=E=>{a.onMessagesChange&&a.onMessagesChange(E),a.messages===void 0&&r(E)},m=h.useRef(l);m.current=l;const[f,p]=h.useState(""),[_,y]=h.useState(!1),b=h.useRef(null),x=a.assistantName||"Assistant",N=!!a.blockedNotice,C=async E=>{const D=String(E||"").trim();if(!D||_||N)return;p("");const P=m.current,G=[...P,{role:"user",content:D,ts:new Date().toISOString()}];c(G),y(!0);const F=new AbortController;b.current=F;try{const J=a.ask(D,{signal:F.signal,history:P});if(W_(J)){let $="";const ee=[...G,{role:"assistant",title:x,content:"",ts:new Date().toISOString()}];c(ee);for await(const oe of J){if(F.signal.aborted)break;$+=String(oe??""),c([...G,{role:"assistant",title:x,content:$,ts:new Date().toISOString()}])}!$.trim()&&!F.signal.aborted&&c([...G,{role:"assistant",title:x,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const $=String(await J??"").trim();c([...G,$?{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(J){F.signal.aborted||c([...m.current,{role:"assistant",title:x,content:`#FALLBACK assistant request failed: ${String((J==null?void 0:J.message)||J||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{b.current===F&&(b.current=null),y(!1)}},O=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:[O,e.jsx(sd,{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(Xo,{value:f,onChange:p,onSubmit:()=>void C(f),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 pi(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 _l(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 nf="abstractcontinuum_gateway_csrf",V_="x-abstractcontinuum-csrf",G_="x-abstract-csrf";function sf(a,s){const r=(a||"").trim().replace(/\/+$/,"");return r?`${r}${s}`:s}function af(a){var l;const s=(a||"").trim(),r={};s&&(r.Authorization=`Bearer ${s}`);try{const c=(l=document.cookie.split(";").map(m=>m.trim()).find(m=>m.startsWith(`${nf}=`)))==null?void 0:l.slice(`${nf}=`.length);if(c){const m=decodeURIComponent(c);r[V_]=m,r[G_]=m}}catch{}return r}function rf(a){const s={},r=(l,c)=>{const m=String(c||"").trim();m&&(s[l]=m)};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 K_(a){try{const s=await a.text();return s!=null&&s.trim()?s.trim():`${a.status}`}catch{return`${a.status}`}}class Q_ extends Error{constructor(r,l,c){super(r);kr(this,"status");kr(this,"body");this.name="GatewayRequestError",this.status=l,this.body=c}}const ju=[15,30,60,120];class J_{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(sf(this._cfg.base_url,r),{...l,headers:{...l==null?void 0:l.headers,...af(this._cfg.auth_token)}});if(c.ok)return this._backoff_step=0,this._backoff_until=0,c;const m=await K_(c);let f=null;try{f=JSON.parse(m)}catch{}let p=m;if(f&&typeof f=="object"&&f.detail!==void 0&&(p=typeof f.detail=="string"?f.detail:JSON.stringify(f.detail)),c.status===429||/too many requests|auth lockout|locked/i.test(p)){const y=ju[Math.min(this._backoff_step,ju.length-1)];this._backoff_until=Date.now()+y*1e3,this._backoff_step<ju.length-1&&(this._backoff_step+=1)}throw new Q_(`${s} failed: ${p}`,c.status,f)}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(),m=String(r||"").trim();if(!c)throw new Error("download_run_artifact_content: run_id is required");if(!m)throw new Error("download_run_artifact_content: artifact_id is required");const f=String((l==null?void 0:l.access)||"").trim(),p=f?`?access=${encodeURIComponent(f)}`:"";return await(await this._fetch("download_run_artifact_content",`/api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(m)}/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 m=String((l==null?void 0:l.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",f=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,m),p.append("filename",m),f&&p.append("content_type",f);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 f={audio_artifact:c},p=String((r==null?void 0:r.language)||"").trim();p&&(f.language=p);const _=String((r==null?void 0:r.request_id)||"").trim();_&&(f.request_id=_);const y=await this._post_json("audio_transcribe",`/api/gateway/runs/${encodeURIComponent(l)}/audio/transcribe`,f);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 m={text:c,...rf(r)},f=String((r==null?void 0:r.format)||"").trim();f&&(m.format=f),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(m.timeout_s=r.timeout_s);const p=String((r==null?void 0:r.request_id)||"").trim();p&&(m.request_id=p);const _=await this._post_json("voice_tts",`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts`,m);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:sf(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...rf(r)},headers:af(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",lf(s,"bug_report_create"))}async feature_report_create(s){return await this._post_json("feature_report_create","/api/gateway/features/report",lf(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 m=String((s==null?void 0:s.since)||"").trim();m&&r.set("since",m);const f=String((s==null?void 0:s.status)||"").trim();return f&&r.set("status",f),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,m=String((r==null?void 0:r.account)||"").trim();m&&c.set("account",m);const f=String((r==null?void 0:r.mailbox)||"").trim();f&&c.set("mailbox",f);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 m={action:c};if(c==="defer"){const f=r==null?void 0:r.defer_days;typeof f=="number"&&Number.isFinite(f)&&f>0&&(m.defer_days=Number(f))}return await this._post_json("apply_triage_decision",`/api/gateway/triage/decisions/${encodeURIComponent(l)}/apply`,m)}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)??"")},m=String((s==null?void 0:s.expected_sha256)||"").trim();return m&&(c.expected_sha256=m),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 m={kind:r,package:l,title:c},f=String((s==null?void 0:s.task_type)||"").trim();f&&(m.task_type=f);const p=String((s==null?void 0:s.summary)||"").trim();p&&(m.summary=p);const _=(s==null?void 0:s.content)==null?"":String((s==null?void 0:s.content)??"");return _.trim()&&(m.content=_),await this._post_json("backlog_create","/api/gateway/backlog/create",m)}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(),m=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(m.length<2)throw new Error("backlog_merge: at least 2 items are required");const f={kind:r,package:l,title:c,items:m.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&&(f.task_type=p);const _=String((s==null?void 0:s.summary)||"").trim();return _&&(f.summary=_),await this._post_json("backlog_merge","/api/gateway/backlog/merge",f)}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 m=new FormData;return m.set("overwrite",(s==null?void 0:s.overwrite)===!0?"true":"false"),m.set("file",c,c.name||"attachment"),await this._post_form("backlog_upload_attachment",`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/attachments/upload`,m)}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 m={kind:r,package:l,title:c,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},f=String((s==null?void 0:s.summary)||"").trim();f&&(m.summary=f);const p=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");p.trim()&&(m.draft_markdown=p);const _=String((s==null?void 0:s.provider)||"").trim();_&&(m.provider=_);const y=String((s==null?void 0:s.model)||"").trim();y&&(m.model=y);const b=String((s==null?void 0:s.thinking)||"").trim();return b&&(m.thinking=b),await this._post_json("backlog_assist","/api/gateway/backlog/assist",m)}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(),m=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(!m)throw new Error("backlog_maintain: title is required");const f={kind:r,filename:l,package:c,title:m,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},p=String((s==null?void 0:s.summary)||"").trim();p&&(f.summary=p);const _=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");_.trim()&&(f.draft_markdown=_);const y=String((s==null?void 0:s.provider)||"").trim();y&&(f.provider=y);const b=String((s==null?void 0:s.model)||"").trim();return b&&(f.model=b),await this._post_json("backlog_maintain","/api/gateway/backlog/maintain",f)}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 m=String((s==null?void 0:s.thinking)||"").trim();m&&(r.thinking=m);const f=String((s==null?void 0:s.agent)||"").trim();f&&(r.agent=f),(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,m=String((s==null?void 0:s.execution_mode)||"").trim();m&&c.set("execution_mode",m);const f=String((s==null?void 0:s.executor)||"").trim();f&&c.set("executor",f);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 m=String((s==null?void 0:s.executor)||"").trim();m&&(l.executor=m);const f=String((s==null?void 0:s.target_model)||"").trim();f&&(l.target_model=f);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 m=typeof(s==null?void 0:s.max_bytes)=="number"&&Number.isFinite(s.max_bytes)?Number(s.max_bytes):0;m>0&&l.set("max_bytes",String(Math.floor(m)));const f=typeof(s==null?void 0:s.after_bytes)=="number"&&Number.isFinite(s.after_bytes)?Math.max(0,Math.floor(s.after_bytes)):null;return f!==null&&l.set("after_bytes",String(f)),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 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 lf(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 f of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const p=String((a==null?void 0:a[f])||"").trim();p&&(c[f]=p)}const m=a==null?void 0:a.context;return m&&typeof m=="object"&&(c.context=m),c}const Y_=/^[a-zA-Z0-9_-]+$/;function of(a){return Y_.test(String(a||"").trim())}async function X_(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(m=>m.toString(16).padStart(2,"0")).join("")}async function ad(a){const s=String(a||"").trim();if(!s)throw new Error("session_id is required");if(of(s)){const l=`session_memory_${s}`;if(of(l))return l}return`session_memory_sha_${(await X_(s)).slice(0,32)}`}const Fa=["bug","feature","improvement","task"];function $l(a){return String(a||"").trim().toLowerCase()}function nh(a){return Fa.includes($l(a))}function sh(a){const s=$l(a);return nh(s)?s:"task"}function ah(a){return a.toUpperCase()}function rh(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function ih(a){return nh(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Fa.join(" / ")})`}function lh(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 Bu(a=new Date){const s=p=>String(p).padStart(2,"0"),r=-a.getTimezoneOffset(),l=r>=0?"+":"-",c=Math.abs(r),m=s(Math.floor(c/60)),f=s(c%60);return`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())} ${l}${m}${f}`}function Z_(a){try{return JSON.parse(a)}catch{return null}}function cf(a,s){return a.scrollHeight-a.scrollTop-a.clientHeight<=s}function ku(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 Ds(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,m=Math.floor(l/60),f=m%24,p=Math.floor(m/24);return p>0?`${p}d ${f}h`:m>0?`${m}h ${c}m`:l>0?`${l}m ${r}s`:`${s}s`}async function Uu(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(m=>m.toString(16).padStart(2,"0")).join("")}function Nl(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 eg(a,s){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&s==="runs"?"completed,promoted":""}function gl(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:{},m=r.executor&&typeof r.executor=="object"?r.executor:{},f=String(c.last_message||"").trim(),p=String(r.target_model||m.model||"").trim(),_=String(r.target_reasoning_effort||m.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:m.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:tg(f)}}const Su=1200;function tg(a){const s=String(a||"");return s?s.length<=Su?s:`${s.slice(0,Su)}
|
|
47
|
+
… [#TRUNCATION: ${Su} 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(m=>String(m||"").trim().length>0),l=[];let c=0;for(let m=0;m<r.length;m+=1){const f=String(r[m]||"").trim(),p=Z_(f);if(!p||typeof p!="object"){c+=1,l.push({idx:m,type:"raw",payload:null,raw:f});continue}const _=String(p.type||p.event||"event");l.push({idx:m,type:_,payload:p,raw:f})}return{total:r.length,bad:c,events:l,raw:s}}function sg(a){if(!a)return null;let s=0,r=0,l=0,c=0,m=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"&&(m+=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:m}}function El(a,s=Date.now()){const r=ku(a==null?void 0:a.created_at),l=ku(a==null?void 0:a.started_at),c=ku(a==null?void 0:a.finished_at),m=String((a==null?void 0:a.status)||"").trim().toLowerCase(),f=c??(m==="running"?s:null),p=c!=null,_=r!=null&&l!=null?Math.max(0,l-r):null,y=l!=null&&f!=null?Math.max(0,f-l):null,b=r!=null&&f!=null?Math.max(0,f-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 ag(a,s){const r=String(s.package_name).trim()||"{Package}",l=lh(String(s.title||"").trim()||"{Title}"),c=String(s.summary||"").trim(),m=sh(s.task_type),f=`# {ID}-${r}: [${ah(m)}] ${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 O=0;O<_.length;O+=1){const E=String(_[O]||"");if(E.trim().startsWith("# ")){_[O]=f,y=!0;break}if(E.trim())break}y||(_.unshift("",f),_.shift());const b=`> Created: ${String(s.created_at||"").trim()}`.trim();let x=!1;for(let O=0;O<Math.min(_.length,40);O+=1)if(String(_[O]||"").trim().toLowerCase().startsWith("> created:")){_[O]=b,x=!0;break}if(!x){const O=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(O,0,b,"")}const N=`> Type: ${m}`.trim();let C=!1;for(let O=0;O<Math.min(_.length,60);O+=1)if(String(_[O]||"").trim().toLowerCase().startsWith("> type:")){_[O]=N,C=!0;break}if(!C){let O=-1;for(let E=0;E<Math.min(_.length,60);E+=1)if(String(_[E]||"").trim().toLowerCase().startsWith("> created:")){O=E;break}if(O>=0){const E=O+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 O=0;O<_.length;O+=1)if(String(_[O]||"").trim().toLowerCase()==="## summary"){let E=O+1;for(;E<_.length&&!String(_[E]||"").trim();)E+=1;(E<_.length?String(_[E]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?_[E]=c:_.splice(O+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 rg(a){const s=String(a.package_name||"").trim()||"{Package}",r=lh(String(a.title||"").trim()||"{Title}"),l=sh(a.task_type),c=String(a.created_at||"").trim()||Bu(),m=String(a.diagram||"").trim(),f=String(a.context||"").trim(),p=[];return p.push(`# {ID}-${s}: [${ah(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(m||`ASCII diagram of the system change.
|
|
51
|
+
Show inputs/outputs and where code lives.`),p.push("```"),p.push(""),p.push("## Context"),p.push(f||"(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 ig(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()),m=c.findIndex(_=>_.trim()==="## related");if(m<0)return`${String(a||"").trimEnd()}
|
|
53
|
+
|
|
54
|
+
## Related
|
|
55
|
+
- Attachments:
|
|
56
|
+
${r.map(y=>` - ${y}`).join(`
|
|
57
|
+
`)}
|
|
58
|
+
`;let f=-1;for(let _=m+1;_<l.length;_+=1){const y=c[_].trim();if(y.startsWith("## ")||y.startsWith("---"))break;if(y.startsWith("- attachments:")){f=_;break}}const p=["- Attachments:",...r.map(_=>` - ${_}`)];if(f>=0){let _=f+1;for(;_<l.length&&/^\s+-\s/.test(l[_]);)_+=1;l.splice(_,0,...r.map(y=>` - ${y}`))}else{let _=m+1;for(let y=m+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 lg(a,s){const r=Hf(a);if(!r.ok)return null;const l=r.payload.phases.map(f=>f.id),c=new Map;for(const f of s)c.set(`${f.section}\0${f.item}\0${f.phase}`,f.op);const m=[];for(const f of r.payload.sections)for(const p of f.items){const _=[];for(const y of l){const b=p.cells[y];if(!b)continue;const x=c.get(`${f.id}\0${p.id}\0${y}`);(x?x==="grant":!!b.assigned)&&_.push(y)}_.length&&(_.length===l.length?m.push({name:p.id}):m.push({name:p.id,phases:_}))}return m}function og(a){var $,ee;const{gateway:s,entity_name:r}=a,[l,c]=h.useState(null),[m,f]=h.useState(""),[p,_]=h.useState(!1),[y,b]=h.useState([]),[x,N]=h.useState(!1),[C,O]=h.useState(""),[E,D]=h.useState(""),P=h.useCallback(async()=>{_(!0),f("");try{c(await s.entity_skills(r))}catch(oe){c(null),f(String((oe==null?void 0:oe.message)||oe))}finally{_(!1)}},[s,r]);h.useEffect(()=>{b([]),D(""),O(""),P()},[P]);async function G(){if(!(l!=null&&l.matrix))return;const oe=lg(l.matrix,y);if(oe===null){O("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}N(!0),O("");try{const ce=await s.put_entity_skills(r,oe);c(ce),b([]),D("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>D(""),5e3)}catch(ce){O(String((ce==null?void 0:ce.message)||ce))}finally{N(!1)}}const F=Array.isArray(($=l==null?void 0:l.selection)==null?void 0:$.warnings)?l.selection.warnings.map(String):[],J=Array.isArray((ee=l==null?void 0:l.resolved)==null?void 0:ee.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 P(),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"})]})]}),m?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",m]}):null,F.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:F.join(" · ")}):null,J.length?e.jsx("div",{className:"entity_skills_resolved",children:J.map(oe=>{const ce=String((oe==null?void 0:oe.name)||""),pe=!!(oe!=null&&oe.active),Ee=!!(oe!=null&&oe.blocked),Ae=!!(oe!=null&&oe.requires_review),_e=oe==null?void 0:oe.requires_unmet,ue=Array.isArray(_e)?_e.map(String):_e&&typeof _e=="object"?Object.entries(_e).map(([Z,z])=>`${Z}: ${String(z)}`):[],q=pe?"ok":Ee?"danger":ue.length||Ae?"warn":"muted",L=pe?"active":Ee?"blocked":ue.length?"requires unmet":Ae?"requires review":"inactive",W=[...Array.isArray(oe==null?void 0:oe.reasons)?oe.reasons.map(String):[],...ue].join("; ");return e.jsxs("span",{className:`chip mono ${q}`,title:W||void 0,children:[ce," · ",L]},ce)})}):null,e.jsx(Jp,{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 G(),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 cg(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 m=String(r.status||"").toLowerCase();m==="queued"||m==="running"?c.active+=1:m==="promoted"?c.promoted+=1:m==="completed"?c.completed+=1:m==="failed"?c.failed+=1:m==="awaiting_qa"&&(c.awaiting_qa+=1);const f=El(r);f.run_ms!=null&&(c.total_run_ms+=f.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 ug(a){const{gateway:s,gateway_connected:r}=a,l=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[c,m]=h.useState(null),[f,p]=h.useState([]),[_,y]=h.useState([]),[b,x]=h.useState(""),[N,C]=h.useState(null),[O,E]=h.useState(!1),[D,P]=h.useState(""),[G,F]=h.useState(!1),[J,$]=h.useState(""),[ee,oe]=h.useState(null),ce=h.useRef(0);async function pe(){if(!r||O)return;const j=++ce.current;E(!0),P("");try{const[R,U,le]=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!==ce.current)return;m(R),p([...Array.isArray(U==null?void 0:U.requests)?U.requests:[],...Array.isArray(le==null?void 0:le.requests)?le.requests:[]])}catch(R){j===ce.current&&P(String((R==null?void 0:R.message)||R||"Failed to load agents"))}finally{ce.current,E(!1)}try{const R=await s.list_entities();if(j!==ce.current)return;y(Array.isArray(R==null?void 0:R.entities)?R.entities:[]),x("")}catch(R){if(j!==ce.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!==ce.current)return;const U=Array.isArray(R)?R:Array.isArray(R==null?void 0:R.executors)?R.executors:[];C(U)}catch{j===ce.current&&C(R=>R===null?null:R)}try{const R=await s.admin_runtime_config();j===ce.current&&F((R==null?void 0:R.writable)===!0)}catch{j===ce.current&&F(!1)}}async function Ee(){ce.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 Ae(){ce.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{m(await s.backlog_exec_config())}catch{}}async function _e(j){if(J)return;const R=`executor:${j}`;$(R),oe(null);try{await s.admin_runtime_config_update({executor:j}),await Ae()}catch(U){oe({key:R,text:String((U==null?void 0:U.message)||U||"Executor change refused")})}finally{$("")}}const[ue,q]=h.useState(null);async function L(j,R){if(J)return;const U=String(j.slug||j.name||"").trim();if(!U)return;const le=`entity:${U}`;$(le),oe(null);try{await s.entity_state(U,{state:R,reason:"by the operator via Continuum (Agents & Entities)"}),await Ee()}catch(ae){oe({key:le,text:String((ae==null?void 0:ae.message)||ae||"State change refused")})}finally{$("")}}h.useEffect(()=>{pe()},[r]);const W=h.useMemo(()=>cg(f),[f]),Z=!!(c!=null&&c.runner_alive),z=String((c==null?void 0:c.executor)||"").trim(),de=!z||z==="none",V=de?"No execution agent":z;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."}),D?e.jsx("span",{className:"page_error mono",children:D}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${O?"is_loading":""}`,onClick:()=>void pe(),disabled:!r||O,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"}):G?e.jsx("button",{className:"btn",disabled:!!J||j.available===!1,title:j.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":J&&J!==`executor:${j.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void _e(j.id),children:J===`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"})}),(ee==null?void 0:ee.key)===`executor:${j.id}`?e.jsx("div",{className:"detail_warn",children:ee.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:de?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${Z?"ok":de?"warn":"danger"}`,style:{marginLeft:"auto"},children:Z?"available":de?"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 M,ye,xe,Oe,Fe,Ze;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(((M=j.state)==null?void 0:M.state)||"unknown").toLowerCase(),U=R==="awake"?"ok":R==="asleep"?"info":R==="paused"?"warn":"muted",ae=String(j.liveness||((ye=j.state)==null?void 0:ye.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})]}),ae?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 ${U}`,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,(xe=j.state)!=null&&xe.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 ",(Oe=j.files)!=null&&Oe.spark?"✓":"—"," · memory ",(Fe=j.files)!=null&&Fe.memory?"✓":"—"," · book ",(Ze=j.files)!=null&&Ze.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!ae&&(R==="asleep"||R==="paused")?e.jsx("button",{className:"btn",disabled:!!J,title:J&&J!==`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:J===`entity:${j.slug||j.name}`?"Waking…":"Wake"}):null,!ae&&R==="awake"?e.jsx("button",{className:"btn",disabled:!!J,title:J&&J!==`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:J===`entity:${j.slug||j.name}`?"Sending…":"Sleep"}):null,ae?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(he=>he===(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:ue===(j.name||j.slug)?"Hide skills":"Skills"})]}),(ee==null?void 0:ee.key)===`entity:${j.slug||j.name}`?e.jsx("div",{className:"detail_warn",children:ee.text}):null]},j.entity_id||j.slug)})}):null,ue?e.jsx(og,{gateway:s,entity_name:ue,on_close:()=>q(null)}):null]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Capabilities"}),e.jsx("span",{className:"pane_subtitle",children:"live features link to their surface; pending ones name their owner"})]}),e.jsx("div",{className:"pane_body",children:e.jsxs("div",{className:"cap_rows",children:[e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Executor choice per task"}),e.jsx("span",{className:"chip mono ok",children:"live"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Watch runs execute under their chosen agent",children:"Open Executions"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Every Execute dialog (Board and Backlog) carries an Execution agent dropdown — codex, claude, cursor-agent, abstractcode, probed live by the gateway. The default is set on the executor cards above; runs attribute canonically in the track record."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Skills per run and per member"}),e.jsx("span",{className:"chip mono warn",children:"partial"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Run detail → Skills section shows which teachings rode each run",children:"View on a run"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Which skills rode each run renders in the run detail today (requested vs active, held verdicts verbatim). Per-MEMBER skill grants (trust levels, review badges) land when the gateway serves the abstractskill union contract over HTTP (c1778) — the cards above grow a Skills action that day."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"MCP access grants"}),e.jsx("span",{className:"chip mono muted",children:"pending contract"})]}),e.jsx("div",{className:"cap_row_detail",children:"Per-member MCP grants — the ruled home is the gateway's phases config family, endpoint mirroring tool-policy (c1554). No continuum surface until the gateway serves it; this row turns live then."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Agora charters and recruitment"}),e.jsx("span",{className:"chip mono info",children:"read live"}),a.on_open_team?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_team,title:"Team page → ⓘ About shows each channel's charter, purpose, SLA, and members",children:"Open Team"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Per-channel charters, purpose, SLA, and members render on the Team page (ⓘ About on any channel). Charter WRITES and recruitment criteria are the next hub-proxy slice — writes are governance acts and get their own confirmation surface."})]})]})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Track record"}),e.jsxs("span",{className:"pane_count",children:[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?Ds(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 Os(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 uf(a,s){const r=String(s||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function dg(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function mg(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 fg=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,hg=6;function pg(a){const s=[];for(const r of String(a||"").matchAll(fg)){const l=r[1];if(Os(l)&&(s.includes(l)||s.push(l),s.length>=hg))break}return s}function oh(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 m=Math.max(0,(s-c)/36e5);return{label:m<1?`claimed ${Math.max(1,Math.round(m*60))}m`:m<48?`claimed ${Math.round(m)}h`:`claimed ${Math.round(m/24)}d`,stale:m>=r}}const Tl=["P0","P1","P2","P3"],ch={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},uh=/^>\s*priority:\s*(p[0-3])\b/i,dh=/^>\s*labels:\s*(.+)$/i;function rd(a){return String(a||"").split(",").map(s=>s.trim().toLowerCase().replace(/\s+/g,"-")).filter(s=>!!s&&s.length<=40).slice(0,12)}function Nu(a,s){const r=[];let l=!1;for(const c of a){const m=c.trim();if(/^#{1,6}\s/.test(m)){l=s.test(m);continue}l&&r.push(c)}return r}const _g=["one paragraph describing","criterion 1 (clear, testable)"];function df(a){const s=a.trim().toLowerCase();return s?_g.some(r=>s.startsWith(r)):!0}function xi(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=uh.exec(y);b&&!r&&(r=b[1].toUpperCase());const x=dh.exec(y);x&&!l.length&&(l=rd(x[1]))}const c=[];for(const _ of Nu(s,/acceptance criteria/i)){const y=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(_);if(!y)continue;const b=y[2].trim();df(b)||c.push({text:b,checked:y[1].toLowerCase()==="x"})}const m=[];for(const _ of Nu(s,/testing/i))for(const y of _.matchAll(/`([^`]+)`/g)){const b=y[1].trim();!b||b==="..."||b.toLowerCase()==="n/a"||m.push(b)}const f=Nu(s,/^#{1,6}\s*summary\b/i).map(_=>_.trim()).filter(Boolean),p=f.length>0&&!f.every(df);return{priority:r,labels:l,acceptance:c,test_commands:m,has_summary:p}}function id(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}: "${mf(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}: \`${mf(s.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:l.every(c=>c.ok),checks:l}}function mf(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Wu(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 m=(Array.isArray(l.checks)?l.checks:Array.isArray(l.members)?l.members.flatMap(f=>(Array.isArray(f==null?void 0:f.checks)?f.checks:[]).map(p=>({...p,label:f!=null&&f.relpath?`${f.relpath}: ${String((p==null?void 0:p.label)||"")}`:p==null?void 0:p.label}))):[]).map(f=>({id:String((f==null?void 0:f.id)||""),label:String((f==null?void 0:f.label)||""),ok:(f==null?void 0:f.ok)===!0,evidence:f!=null&&f.evidence?String(f.evidence):void 0}));return m.length?{ok:m.every(f=>f.ok),checks:m}:null}function Hu(a,s){const l=[...String(a||"").split(/\r?\n/)];function c(m,f){const p=[];for(let y=0;y<Math.min(l.length,60);y+=1){const b=l[y].trim();if(/^##+\s/.test(b))break;m.test(b)&&p.push(y)}if(p.length){for(let y=p.length-1;y>=1;y-=1)l.splice(p[y],1);f?l[p[0]]=f:l.splice(p[0],1);return}if(!f)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(f);return}}l.splice(_+1,0,f)}return c(uh,s.priority?`> Priority: ${s.priority}`:null),c(dh,s.labels.length?`> Labels: ${s.labels.join(", ")}`:null),l.join(`
|
|
60
|
+
`)}const ff=[{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 Vu(a){const s=String(a||"").trim().toUpperCase();return Tl.includes(s)?s:null}function Gu(a){return a.priority!==void 0||a.labels!==void 0}const gg="decision-gate";function vg(a){return Array.isArray(a)&&a.some(s=>String(s||"").trim().toLowerCase()===gg)}function mh(a,s){return vg(a.labels!==void 0?a.labels:s==null?void 0:s.labels)}function fh(a){return a.priority!==void 0||a.labels!==void 0}function Ku(a,s){return a.priority!==void 0?a.priority:(s==null?void 0:s.priority)??null}function Qu(a,s){return a.labels!==void 0?a.labels:(s==null?void 0:s.labels)??[]}const yg=new Set(["queued","running"]);function xg(a){const s=String(a||"").split("/").filter(Boolean);return s.length?s[s.length-1]:""}const bg=/^batch\((\d+)\)$/i;function hf(a){const s=bg.exec(String(a||"").trim());return s?Number(s[1]):null}function wg(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()||xg(String(b.backlog_relpath||"")),O=hf(C),E=O!==null?"":C;return E&&N&&l.add(E),{key:E&&N?`file:${E}`:`req:${b.request_id}`,column:x,title:O!==null?`Batch execution (${O} 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:O!==null?O:void 0}};for(const b of a.active_requests){const x=String(b.status||"").trim().toLowerCase();yg.has(x)?r.push(c(b,"in_progress",!0)):x==="awaiting_qa"&&r.push(c(b,"in_review",!0))}const m=[...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)}),f=new Map;let p=0,_=0;for(const b of m){const x=String(b.status||"").trim().toLowerCase();if(x==="failed"){const N=String(b.backlog_filename||"").trim();N&&hf(N)===null&&f.set(N,(f.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:f.get(x)||void 0,priority:Gu(b)?Vu(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:Gu(b)?Vu(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 jg=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 m=new Set,f=new Set;for(const x of a){if(!x.filename||!x.package)continue;const N=uf(x.package,x.filename);N&&f.add(N)}const p=a.map(x=>{if(x.column!=="ready"||x.kind!=="planned"||!x.filename||!x.package)return x;const N=uf(x.package,x.filename);if(!N)return x;const C=r.get(N);return!C||!C.owner?x:(m.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(dg(N.card)):void 0;if(f.has(x)||C!==void 0){if(C!==void 0){const D=p[C],P={...D,work_id:D.work_id||x,card_path:D.card_path||N.card},G=r.get(x);G!=null&&G.owner&&(m.add(x),P.claim_owner||(P.claim_owner=G.owner,P.claim_started_at=G.started_at)),p[C]=P}continue}if(N.status==="deprecated")continue;const O=r.get(x),E=N.status==="completed"?"done":N.status==="planned"?O!=null&&O.owner?"in_progress":"ready":"triage";O!=null&&O.owner&&m.add(x),p.push({key:`work:${x}`,column:E,title:N.title||x,work_id:x,package:(b=Os(x))==null?void 0:b.package,summary:N.receipt,card_path:N.card,claim_owner:(O==null?void 0:O.owner)||(N.status==="completed"?N.owner:void 0),claim_started_at:O==null?void 0:O.started_at})}for(const[x,N]of r){if(m.has(x)||!N.owner)continue;const C=Os(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,jg)){if(y.has(x.item))continue;const N=Os(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 yi(a){const s=String((a==null?void 0:a.message)??a??"");return/backlog folder not available|backlog browsing not configured/i.test(s)}function pf(a){return String((a==null?void 0:a.message)??a??"").trim().replace(/^[a-z_]+ failed: /,"")}function ld(a,s,r){const[l,c]=h.useState({status:null,legacy:!1});return h.useEffect(()=>{if(!s)return;let m=!1;return(async()=>{try{const f=await a.backlog_status();m||c({status:f,legacy:!1})}catch(f){m||c({status:null,legacy:Number(f==null?void 0:f.status)===404})}})(),()=>{m=!0}},[a,s,r]),l}function Sg(){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 od(a){const{gateway:s,surface:r,status:l,legacy:c,on_changed:m}=a,[f,p]=h.useState(!1),[_,y]=h.useState(""),[b,x]=h.useState(!1),[N,C]=h.useState(""),[O,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(J=>{F||E((J==null?void 0:J.writable)===!0)}).catch(()=>{F||E(!1)}),()=>{F=!0}},[s,l==null?void 0:l.writable,c]);async function D(F){if(!b){x(!0),C("");try{await s.admin_runtime_config_update({triage_repo_root:F}),p(!1),m==null||m()}catch(J){C(pf(J))}finally{x(!1)}}}const P=String((l==null?void 0:l.reason)||"").trim()||(a.error?pf(a.error):""),G=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,P||"the gateway did not say why."]}),O===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[G?e.jsx("button",{className:"btn primary",disabled:b,onClick:()=>void D(G),title:G,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:b,onClick:()=>p(F=>!F),children:"Choose a folder…"})]}),G?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:G}),"; it is created with a starter overview and item template."]}):null,f?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:F=>{F.preventDefault(),_.trim()&&D(_.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]}):O===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(Sg,{})}):null]})]})}function Ng(a){const{status:s,on_create:r}=a,[l,c]=h.useState(!1),m=String((s==null?void 0:s.path)||"").trim(),f=m?`${m.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",p=m?`${m.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:[m?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:m}),e.jsx("button",{className:"btn",onClick:()=>{dn(m),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:f})," (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 Cg(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function hh(a){const{gateway:s,can_use_gateway:r,target:l,on_close:c,on_mutated:m,on_open_executions:f}=a,p=!!l,[_,y]=h.useState("spec"),[b,x]=h.useState(""),[N,C]=h.useState(""),[O,E]=h.useState(null),[D,P]=h.useState(!1),[G,F]=h.useState(""),[J,$]=h.useState(!1),[ee,oe]=h.useState(""),[ce,pe]=h.useState(!1),[Ee,Ae]=h.useState(""),[_e,ue]=h.useState(""),[q,L]=h.useState(!1),[W,Z]=h.useState([]),[z,de]=h.useState(!1),[V,j]=h.useState(null),[R,U]=h.useState(null),[le,ae]=h.useState(""),[M,ye]=h.useState(!1),[xe,Oe]=h.useState(""),[Fe,Ze]=h.useState({}),he=h.useMemo(()=>xi(b),[b]);h.useEffect(()=>{!p||!l||(y(l.initial_tab||"spec"),$(!1),F(""),Oe(""),ae(""),Ze({}),qe(!1),j(null),U(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}P(!0);try{let we=null,K=null;for(const Ye of Cg(fe))try{const Y=await s.backlog_content(Ye,fe.filename);we={kind:Ye,text:String((Y==null?void 0:Y.content)||"")};break}catch(Y){K=Y}if(!we)throw K||new Error("Spec not found in any backlog kind");E(we.kind),x(we.text),C(await Uu(we.text));const ke=xi(we.text);Ae(ke.priority||""),ue(ke.labels.join(", "))}catch(we){F(String((we==null?void 0:we.message)||we||"Failed to load the spec"))}finally{P(!1)}}async function Pe(fe){de(!0);try{const[we,K]=await Promise.all([s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),Ye=[...Array.isArray(we==null?void 0:we.requests)?we.requests:[],...Array.isArray(K==null?void 0:K.requests)?K.requests:[]].filter(A=>fe.filename&&String(A.backlog_filename||"").trim()===fe.filename||A.request_id===fe.request_id);Ye.sort((A,X)=>String(X.created_at||"").localeCompare(String(A.created_at||""))),Z(Ye);const Y=Ye.find(A=>String(A.status||"").toLowerCase()==="awaiting_qa")||null;if(j(Y),Y)try{const A=await s.backlog_exec_request(Y.request_id);U((A==null?void 0:A.payload)??null)}catch{U(null)}}catch{Z([])}finally{de(!1)}}async function se(){if(!l||ce)return;const fe=O||l.kind;if(fe){pe(!0),F("");try{const we=await s.backlog_update({kind:fe,filename:l.filename,content:ee,expected_sha256:N||null}),K=ee.endsWith(`
|
|
61
|
+
`)?ee:`${ee}
|
|
62
|
+
`;x(K),C(String((we==null?void 0:we.sha256)||"")),$(!1),await m()}catch(we){F(String((we==null?void 0:we.message)||we||"Save failed"))}finally{pe(!1)}}}async function be(){if(!l||q)return;const fe=O||l.kind;if(fe){L(!0),F("");try{const we=Hu(b,{priority:Ee||null,labels:rd(_e)}),K=await s.backlog_update({kind:fe,filename:l.filename,content:we,expected_sha256:N||null});x(we.endsWith(`
|
|
63
|
+
`)?we:`${we}
|
|
64
|
+
`),C(String((K==null?void 0:K.sha256)||"")),await m()}catch(we){F(String((we==null?void 0:we.message)||we||"Metadata save failed"))}finally{L(!1)}}}const[ge,qe]=h.useState(!1);async function Je(fe){if(!(!V||M)){if(fe==="feedback"&&!le.trim()){Oe("Feedback is required.");return}ye(!0),Oe("");try{fe==="feedback"?await s.backlog_exec_feedback({request_id:V.request_id,feedback:le}):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}),ae(""),qe(!1),l&&await Pe(l),await m()}catch(we){Oe(String((we==null?void 0:we.message)||we||"QA action failed"));try{const K=await s.backlog_exec_request(V.request_id);U((K==null?void 0:K.payload)??null)}catch{}}finally{ye(!1)}}}if(!p||!l)return null;const ie=he.acceptance.filter((fe,we)=>!Fe[`${we}:${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:[O||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/${O||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:[G?e.jsx("div",{className:"mono board_error",children:G}):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:Ee,onChange:fe=>Ae(fe.target.value),disabled:q,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),Tl.map(fe=>e.jsx("option",{value:fe,children:ch[fe]},fe))]}),e.jsx("input",{value:_e,onChange:fe=>ue(fe.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:q}),e.jsx("button",{className:"btn",onClick:()=>void be(),disabled:q||!r||D,children:q?"Saving…":"Save metadata"}),J?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>$(!1),disabled:ce,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void se(),disabled:ce,children:ce?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{oe(b),$(!0)},disabled:D,children:"Edit spec"})]}):null,D?e.jsx("div",{className:"mono muted",children:"Loading…"}):J?e.jsx("textarea",{className:"mono work_spec_editor",value:ee,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:[z?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!z&&!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 we=String(fe.status||"").toLowerCase(),K=El(fe);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Nl(we)}`,children:we}),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:K.run_ms!=null?`ran ${Ds(K.run_ms)}`:""}),fe.target_agent?e.jsx("span",{className:"chip mono muted",children:fe.target_agent}):null,we==="running"||we==="queued"||we==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>f(fe.request_id),children:we==="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."}),he.acceptance.length?e.jsx("div",{className:"work_dod_list",children:he.acceptance.map((fe,we)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Fe[`${we}:${fe.text}`],onChange:K=>Ze(ke=>({...ke,[`${we}:${fe.text}`]:K.target.checked}))}),e.jsx("span",{children:fe.text})]},`dod:${we}:${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(),we=String((R==null?void 0:R.candidate_relpath)||"").trim(),K=R==null?void 0:R.promotion_report,ke=!!(K!=null&&K.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,we?` • candidate: ${we}`:""]}),e.jsx("button",{className:"btn",onClick:()=>f(V.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),ke?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((K==null?void 0:K.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),he.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:le,onChange:fe=>ae(fe.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:M}),xe?e.jsx("div",{className:"mono board_error",children:xe}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void Je("deploy_uat"),disabled:M,children:"Restart UAT"}),ge?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void Je("promote"),disabled:M,children:["Confirm: promote to prod",ie>0?` (${ie} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>qe(!1),disabled:M,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>qe(!0),disabled:M,children:he.acceptance.length&&ie>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void Je("feedback"),disabled:M,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 $g(a){const{gateway:s,can_use_gateway:r,is_compact_layout:l,maint_provider:c,maint_model:m,maint_reasoning:f,advisor_agent:p,focus_kind:_,focus_type:y}=a,[b,x]=h.useState(!1),[N,C]=h.useState([]),[O,E]=h.useState(""),[D,P]=h.useState(!1),[G,F]=h.useState(""),[J,$]=h.useState(!1),[ee,oe]=h.useState([]),ce=h.useRef(null),pe=h.useRef(null),Ee=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[Ae,_e]=h.useState(""),[ue,q]=h.useState("");h.useEffect(()=>{(async()=>{try{const R=await ad(Ee);_e(R)}catch{_e("")}})()},[Ee]);const L=h.useMemo(()=>{if(!r)return{};const R=String(Ae||"").trim(),U=Ee;return{tts:async le=>{if(!R)throw new Error("Voice store not available (missing run_id).");const ae=await s.voice_tts(R,{text:le,request_id:Nr()}),M=ae==null?void 0:ae.audio_artifact,ye=M&&typeof M=="object"&&!Array.isArray(M)?String(M.$artifact||"").trim():"";if(!ye)throw new Error("TTS failed: missing audio artifact");return await(await s.download_run_artifact_content(R,ye)).arrayBuffer()},transcribe:async(le,ae)=>{if(!R)throw new Error("Voice input unavailable (missing run_id).");const M=String(ae||le.type||"").toLowerCase(),ye=M.includes("mp4")?"m4a":M.includes("ogg")?"ogg":M.includes("wav")?"wav":"webm",xe=new File([le],`recording.${ye}`,{type:M||"audio/webm"}),Oe=await s.attachments_upload(U,xe,{filename:xe.name,content_type:xe.type}),Fe=await s.audio_transcribe(R,{audio_artifact:Oe,request_id:Nr()});return String((Fe==null?void 0:Fe.text)||"").trim()}}},[r,s,Ae,Ee]),W=Gf({...L,on_error:q,on_transcript:R=>{const U=String(R||"").trim();U&&(E(le=>{const ae=String(le||"");return ae.trim()?`${ae.trimEnd()}
|
|
65
|
+
${U}`:U}),window.setTimeout(()=>{var le;return(le=ce.current)==null?void 0:le.focus()},0))}});h.useEffect(()=>{if(!b)return;const R=U=>{U.key==="Escape"&&(j(),x(!1))};return window.addEventListener("keydown",R),setTimeout(()=>{var U;return(U=ce.current)==null?void 0:U.focus()},0),()=>window.removeEventListener("keydown",R)},[b]);async function Z(){if(D||!r)return;if(W.voice_ptt_busy){q("Wait for transcription to finish.");return}F(""),q("");const R=O.trim();if(!R)return;const U={id:Nr(),role:"user",content:R,ts:new Date().toISOString()},le=[...N,U];C(le),E(""),P(!0);try{const ae=await s.backlog_advisor({messages:le.map(Oe=>({role:Oe.role,content:Oe.content})),provider:c||null,model:m||null,thinking:f||null,agent:p||null,include_trace:J,focus_kind:_,focus_type:y}),M=J&&Array.isArray(ae==null?void 0:ae.tool_trace)?ae.tool_trace:[],ye=String((ae==null?void 0:ae.run_id)||"").trim(),xe=String((ae==null?void 0:ae.reply)||"").trim();if(J&&M.length){const Oe={id:Nr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:ye||null,tool_trace:M},null,2)};C(Fe=>[...Fe,Oe])}xe&&C(Oe=>[...Oe,{id:Nr(),role:"assistant",content:xe,ts:new Date().toISOString()}])}catch(ae){F(String((ae==null?void 0:ae.message)||ae||"Backlog advisor failed"))}finally{P(!1)}}async function z(R){var xe;const U=Array.from(R||[]);if(!U.length)return;const le=[],ae=[],M=6,ye=2e4;for(const Oe of U.slice(0,M)){const Fe=String((Oe==null?void 0:Oe.name)||"").trim()||"attachment";ae.push(Fe);try{const Ze=await Oe.text(),he=Ze.length>ye?`${Ze.slice(0,ye)}
|
|
66
|
+
…(truncated)…
|
|
67
|
+
`:Ze;le.push(`[attached file: ${Fe}]
|
|
68
|
+
|
|
69
|
+
\`\`\`
|
|
70
|
+
${he}
|
|
71
|
+
\`\`\``)}catch{le.push(`[attached file: ${Fe}] (unreadable in browser)`)}}oe(Oe=>[...ae,...Oe].slice(0,12)),E(Oe=>{const Fe=String(Oe||"").trim(),Ze=le.join(`
|
|
72
|
+
|
|
73
|
+
`);return Fe?`${Fe}
|
|
74
|
+
|
|
75
|
+
${Ze}`:Ze});try{(xe=ce.current)==null||xe.focus()}catch{}}function de(R){const U=String(R.id||R.ts||"").trim(),le=String(R.content||"").trim();!U||!le||(q(""),W.toggle_tts(U,le))}function V(R){const U=String(R.id||R.ts||"").trim(),le=W.tts_playback;return!U||!le.key||le.key!==U?"idle":le.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 U=!R;return U||j(),U})},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)"," / ",m||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${J?"primary":""}`,onClick:()=>$(R=>!R),disabled:D,title:J?"Hide tool execution":"Show tool execution","aria-label":J?"Hide tool execution":"Show tool execution",children:[e.jsx(at,{name:"terminal",size:16}),l?null:J?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>C([]),disabled:D||!N.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{j(),x(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(sd,{messages:N,className:"drawer_chat_thread",messageProps:W.tts_supported&&r&&Ae.trim()?{onSpeakToggle:de,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 U=Array.from(R.currentTarget.files||[]);R.currentTarget.value="",U.length&&z(U)}}),e.jsx(Xo,{ref:ce,value:O,onChange:E,onSubmit:()=>void Z(),placeholder:"Message to backlog advisor…",disabled:!r,busy:D||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||!Ae.trim()||D||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 U,le;if(!(!r||!Ae.trim()||D||W.voice_ptt_busy||!W.voice_ptt_supported)){R.preventDefault();try{(le=(U=R.currentTarget)==null?void 0:U.setPointerCapture)==null||le.call(U,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:D,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(at,{name:"paperclip",size:16}),l?null:"Attach"]})]})}),ee.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",ee[0]]}):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,ue?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ue}):null,r?null:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Connect the gateway in Settings to use the advisor."})]})]})]})}):null]})}function qa({open:a,title:s,children:r,actions:l,variant:c="default",onClose:m}){if(h.useEffect(()=>{if(!a)return;const p=_=>{_.key==="Escape"&&m()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a,m]),!a)return null;const f=c==="fullscreen";return e.jsx("div",{className:`modal_backdrop${f?" fullscreen":""}`,onMouseDown:p=>{p.target===p.currentTarget&&m()},children:e.jsxs("div",{className:`modal_panel${f?" fullscreen":""}`,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:s}),e.jsx("button",{className:"btn",onClick:m,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),l?e.jsx("div",{className:"modal_footer",children:l}):null]})})}function Eg(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 ph(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 _h(a){const{value:s,onChange:r,disabled:l,inplace_warning:c,uat_note:m}=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:f=>r(f.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:m})]})}const Tg=["minimal","low","medium","high"];function gh(a){const{executors:s,value:r,onChange:l,disabled:c}=a;if(!s||!s.length)return null;const m=s.find(f=>f.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:f=>l(f.target.value),disabled:c,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",m?` (${m.display||m.id})`:""]}),s.map(f=>e.jsxs("option",{value:f.id,disabled:f.available===!1,children:[f.display||f.id,f.available===!1?" (unavailable on the gateway host)":""]},f.id))]})]})}function Ag(a){const{exec_cfg:s,model:r,set_model:l,effort:c,set_effort:m,disabled:f}=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:f})]})}),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=>m(p.target.value),disabled:f,children:[e.jsx("option",{value:"",children:"gateway default"}),Tg.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 vh(a){const{open:s,target:r,execute_mode:l,set_execute_mode:c,action_loading:m,action_error:f,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,[O,E]=Kt.useState(""),[D,P]=Kt.useState(""),[G,F]=Kt.useState(""),J=(r==null?void 0:r.filename)||"";Kt.useEffect(()=>{E(""),P(""),F("")},[J]);const $=O.trim()||D||G?{executor:G||void 0,target_model:O.trim()||void 0,target_reasoning_effort:D||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:m,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b($),disabled:m||_||!r||(p==null?void 0:p.can_execute)!==!0,children:m?"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(gh,{executors:a.executors??null,value:G,onChange:F,disabled:m}),e.jsx(Ag,{exec_cfg:p,model:O,set_model:E,effort:D,set_effort:P,disabled:m}),C?e.jsx(Eg,{readiness:N,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(_h,{value:l,onChange:c,disabled:m,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(ph,{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,f?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:f}):null]})}function Rg(a){const{open:s,batch_selected_items:r,batch_execute_mode:l,set_batch_execute_mode:c,batch_execute_loading:m,batch_execute_error:f,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:b,on_close:x}=a,[N,C]=Kt.useState("");return Kt.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:m,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b(N||void 0),disabled:m||_||r.length<2||(p==null?void 0:p.can_execute)!==!0,children:m?"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(gh,{executors:a.executors??null,value:N,onChange:C,disabled:m}),e.jsx(_h,{value:l,onChange:c,disabled:m,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(O=>e.jsxs("div",{children:["- docs/backlog/planned/",O.filename]},`batchitem:${O.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(ph,{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,f?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:f}):null]})}function Lg(a){const{open:s,batch_selected_items:r,merge_package:l,set_merge_package:c,merge_task_type:m,set_merge_task_type:f,merge_title:p,set_merge_title:_,merge_summary:y,set_merge_summary:b,merge_loading:x,merge_error:N,on_confirm:C,on_close:O}=a;return e.jsxs(qa,{open:s,title:"Merge planned items into master backlog?",onClose:O,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:O,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:m,onChange:E=>f(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 cd(a){const s=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,l]=h.useState(s);return h.useEffect(()=>{var f;if(typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia(a),m=()=>l(c.matches);return m(),typeof c.addEventListener=="function"?c.addEventListener("change",m):(f=c.addListener)==null||f.call(c,m),()=>{var p;typeof c.removeEventListener=="function"?c.removeEventListener("change",m):(p=c.removeListener)==null||p.call(c,m)}},[a]),r}function yh(a,s){const[r,l]=h.useState(null);return h.useEffect(()=>{if(!s){l(null);return}let c=!1;return(async()=>{try{const m=await a.admin_executors(),f=Array.isArray(m)?m:Array.isArray(m==null?void 0:m.executors)?m.executors:[];c||l(f)}catch{c||l(null)}})(),()=>{c=!0}},[s]),r}function ud(a){const{gateway:s,can_use_gateway:r,kind:l,completed_view:c,is_exec_view:m,is_compact_layout:f,set_compact_pane:p,on_status_transfer:_}=a,[y,b]=h.useState(null),[x,N]=h.useState(!1),[C,O]=h.useState(""),[E,D]=h.useState([]),[P,G]=h.useState(!1),[F,J]=h.useState(""),[$,ee]=h.useState(null),[oe,ce]=h.useState(null),[pe,Ee]=h.useState(!1),[Ae,_e]=h.useState(""),[ue,q]=h.useState(""),[L,W]=h.useState(!1),[Z,z]=h.useState(""),[de,V]=h.useState("events"),[j,R]=h.useState(""),[U,le]=h.useState(!1),[ae,M]=h.useState(""),[ye,xe]=h.useState(!1),[Oe,Fe]=h.useState(!0),Ze=h.useRef(null),he=h.useRef(!0),Re=h.useRef(null),Pe=h.useRef(!1),se=h.useRef(!1),be=1e6,ge=h.useMemo(()=>de!=="events"?null:ng(j),[j,de]),qe=h.useMemo(()=>sg(ge),[ge]),Je=El($);function ie(){ee(null),ce(null),_e(""),R(""),M(""),xe(!1),Re.current=null}async function fe(){if(!r)return null;if(x)return y;O(""),N(!0);try{const X=await s.backlog_exec_config();return b(X),X}catch(X){const Se=String((X==null?void 0:X.message)||X||"Failed to load backlog exec config");return O(Se),b(null),null}finally{N(!1)}}async function we(X,Se,Le){if(se.current)return E;se.current=!0,Le!=null&&Le.background||G(!0);const Ge=X||l;try{const tt=eg(Ge,Se||c),dt=await s.backlog_exec_requests({status:tt,limit:200}),yt=Array.isArray(dt==null?void 0:dt.requests)?dt.requests:[];J(""),D(yt);const pt=String(($==null?void 0:$.status)||"").trim().toLowerCase(),Tt=pt==="failed"||pt==="completed"||pt==="promoted";if(Ge==="processing"&&($!=null&&$.request_id)&&!Tt&&!yt.some(qt=>qt.request_id===$.request_id))try{const qt=await s.backlog_exec_request($.request_id),ze=qt==null?void 0:qt.payload,it=String((ze==null?void 0:ze.status)||"").trim().toLowerCase();(it==="failed"||it==="completed"||it==="promoted")&&(_(it),ce(ze),ee(gl(ze,$.request_id)))}catch{}if($!=null&&$.request_id){const qt=yt.find(ze=>ze.request_id===$.request_id)||null;qt&&ee(qt)}return yt}catch(tt){return J(String((tt==null?void 0:tt.message)||tt||"Failed to load backlog exec requests")),[]}finally{se.current=!1,Le!=null&&Le.background||G(!1)}}async function K(X){if(r){ee(X),f&&p("detail"),ce(null),_e(""),Ee(!0),z(""),q(""),R(""),M(""),xe(!1),Re.current=null;try{const Se=await s.backlog_exec_request(X.request_id);ce((Se==null?void 0:Se.payload)??null)}catch(Se){_e(String((Se==null?void 0:Se.message)||Se||"Failed to load request"))}finally{Ee(!1)}}}async function ke(X){if(!r)return;const Se=String(($==null?void 0:$.request_id)||"").trim();if(!Se||L)return;const Le=String(ue||"");if(!Le.trim()){z("Feedback is required.");return}z(""),W(!0);try{const Ge=await s.backlog_exec_feedback({request_id:Se,feedback:Le}),tt=(Ge==null?void 0:Ge.payload)??null;ce(tt),tt&&ee(gl(tt,Se)),q(""),await X()}catch(Ge){z(String((Ge==null?void 0:Ge.message)||Ge||"Failed to send feedback"))}finally{W(!1)}}async function Ye(X){if(!r)return;const Se=String(($==null?void 0:$.request_id)||"").trim();if(Se&&!L){z(""),W(!0);try{const Le=await s.backlog_exec_promote({request_id:Se,redeploy:!0}),Ge=(Le==null?void 0:Le.payload)??null;ce(Ge),Ge&&ee(gl(Ge,Se)),q(""),await X()}catch(Le){z(String((Le==null?void 0:Le.message)||Le||"Failed to promote to prod"));try{const Ge=await s.backlog_exec_request(Se),tt=(Ge==null?void 0:Ge.payload)??null;ce(tt),tt&&ee(gl(tt,Se))}catch{}}finally{W(!1)}}}async function Y(X){if(!r)return;const Se=String(($==null?void 0:$.request_id)||"").trim();if(Se&&!L){z(""),W(!0);try{const Le=await s.backlog_exec_deploy_uat({request_id:Se}),Ge=(Le==null?void 0:Le.payload)??null;ce(Ge),Ge&&ee(gl(Ge,Se)),await X()}catch(Le){z(String((Le==null?void 0:Le.message)||Le||"Failed to deploy to UAT"))}finally{W(!1)}}}async function A(X){if(!r)return;const Se=String((X==null?void 0:X.request_id)||($==null?void 0:$.request_id)||"").trim();if(!Se)return;const Le=(X==null?void 0:X.name)||de,Ge=typeof(X==null?void 0:X.max_bytes)=="number"&&Number.isFinite(X.max_bytes)?Number(X.max_bytes):16e4;if(!Pe.current){Pe.current=!0,M(""),le(!0);try{const tt=`${Se}::${String(Le)}`,dt=Re.current,yt=dt!==null&&dt.key===tt,pt=await s.backlog_exec_log_tail({request_id:Se,name:String(Le),max_bytes:Ge,...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(ze=>{let it=ze+qt;if(it.length>be){const et=it.length-be,kt=it.indexOf(`
|
|
78
|
+
`,et);it=kt>=0?it.slice(kt+1):it.slice(et),xe(!0)}return it}),Re.current={key:tt,offset:Number(pt.next_offset)}):(R(qt),xe(!!(pt!=null&&pt.truncated)),Re.current=Tt?{key:tt,offset:Number(pt.next_offset)}:null)}catch(tt){M(String((tt==null?void 0:tt.message)||tt||"Failed to load logs"))}finally{Pe.current=!1,le(!1)}}}return h.useEffect(()=>{r&&m&&fe()},[m,r]),h.useEffect(()=>{if(!r||!m)return;const Se=setInterval(()=>{s.is_backing_off()||we(l,void 0,{background:!0})},l==="processing"?2e3:5e3);return()=>clearInterval(Se)},[l,c,r,m,$==null?void 0:$.request_id]),h.useEffect(()=>{r&&m&&$!=null&&$.request_id&&A({request_id:$.request_id,name:de})},[$==null?void 0:$.request_id,de,m,r]),h.useEffect(()=>{he.current=!0},[$==null?void 0:$.request_id,de]),h.useEffect(()=>{if(!Ze.current||!he.current)return;const Se=window.requestAnimationFrame(()=>{const Le=Ze.current;Le&&(Le.scrollTop=Le.scrollHeight)});return()=>window.cancelAnimationFrame(Se)},[j,de,$==null?void 0:$.request_id]),h.useEffect(()=>{if(!r||!m||!($!=null&&$.request_id))return;const X=String($.status||"").trim().toLowerCase();if(X==="completed"||X==="promoted"||X==="failed"||X!=="running"&&Oe!==!0)return;const Le=setInterval(()=>{s.is_backing_off()||A({request_id:$.request_id,name:de})},X==="running"?1500:2500);return()=>clearInterval(Le)},[$==null?void 0:$.request_id,$==null?void 0:$.status,de,m,r,Oe]),{exec_cfg:y,exec_cfg_loading:x,exec_cfg_error:C,exec_requests:E,exec_loading:P,exec_error:F,exec_selected:$,set_exec_selected:ee,exec_detail:oe,set_exec_detail:ce,exec_detail_loading:pe,exec_detail_error:Ae,set_exec_detail_error:_e,exec_qa_feedback:ue,set_exec_qa_feedback:q,exec_qa_loading:L,exec_qa_error:Z,exec_log_name:de,set_exec_log_name:V,exec_log_text:j,exec_log_loading:U,exec_log_error:ae,exec_log_truncated:ye,exec_log_auto:Oe,set_exec_log_auto:Fe,exec_log_scroll_el_ref:Ze,exec_log_follow_ref:he,parsed_exec_events:ge,event_stats:qe,time_stats:Je,clear_exec_selection:ie,load_exec_config:fe,refresh_exec_list:we,load_exec_request:K,exec_send_feedback:ke,exec_promote_to_prod:Ye,exec_deploy_uat_now:Y,load_exec_log_tail:A}}const _f=[{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 Mg(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(),m=String(a.maintenance_ai_reasoning||"").trim(),f=String(a.backlog_advisor_agent||"").trim()||"basic-agent",p=a.default_execution_mode==="inplace"?"inplace":"uat",_=cd("(max-width: 900px)"),[y,b]=h.useState("planned"),[x,N]=h.useState([]),[C,O]=h.useState(!1),[E,D]=h.useState(""),[P,G]=h.useState(""),[F,J]=h.useState("all"),[$,ee]=h.useState(""),[oe,ce]=h.useState(new Set),pe=h.useRef(0),[Ee,Ae]=h.useState(null),[_e,ue]=h.useState([]),[q,L]=h.useState(null),[W,Z]=h.useState(p),[z,de]=h.useState(!1),V=yh(s,r),[j,R]=h.useState(""),[U,le]=h.useState(!1),[ae,M]=h.useState(p),[ye,xe]=h.useState(!1),[Oe,Fe]=h.useState(""),[Ze,he]=h.useState(!1),[Re,Pe]=h.useState(!1),[se,be]=h.useState("framework"),[ge,qe]=h.useState("task"),[Je,ie]=h.useState(""),[fe,we]=h.useState(""),[K,ke]=h.useState(!1),[Ye,Y]=h.useState(""),A=ud({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 X(){if(!r)return;const je=++pe.current;O(!0),D("");try{const Ce=await s.backlog_list(y);if(je!==pe.current)return;N(Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[])}catch(Ce){if(je!==pe.current)return;N([]),D(String((Ce==null?void 0:Ce.message)||Ce||"Failed to load backlog"))}finally{je===pe.current&&O(!1)}if(y==="planned")try{const Ce=await s.backlog_exec_active_items();if(je!==pe.current)return;const Me=new Set;for(const mt of Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[]){const _t=String((mt==null?void 0:mt.filename)||"").trim();_t&&Me.add(_t)}ce(Me)}catch{je===pe.current&&ce(new Set)}else ce(new Set)}h.useEffect(()=>{ue([]),ee(""),X()},[y,r]),h.useEffect(()=>{ue(je=>{const Ce=new Set(x.map(mt=>String(mt.filename||"").trim())),Me=je.filter(mt=>Ce.has(mt));return Me.length===je.length?je:Me})},[x]);const Se=h.useMemo(()=>{const je=P.trim().toLowerCase(),Ce=F.trim().toLowerCase();return x.filter(Me=>{if(Ce&&Ce!=="all"&&$l(Me.task_type)!==Ce)return!1;if(!je)return!0;const mt=Array.isArray(Me.labels)?Me.labels.join(" "):"";return`${Me.item_id||""} ${Me.package||""} ${Me.title||""} ${Me.task_type||""} ${Me.summary||""} ${Me.filename||""} ${mt} ${Me.priority||""}`.toLowerCase().includes(je)})},[x,P,F]),Le=h.useMemo(()=>x.filter(je=>_e.includes(String(je.filename||"").trim())),[x,_e]),Ge=yi(E),[tt,dt]=h.useState(0),yt=ld(s,r&&Ge,tt);function pt(je){Ae({filename:String(je.filename||""),kind:y,title:je.title||je.filename,initial_tab:"spec"})}async function Tt(je,Ce){ee("");try{await s.backlog_move({from_kind:y,to_kind:Ce,filename:String(je.filename||"")}),await X()}catch(Me){ee(String((Me==null?void 0:Me.message)||Me||"Move failed"))}}async function qt(je){const Ce=String(je.filename||"").trim();if(!Ce)return;let Me=null;try{const mt=await s.backlog_content("planned",Ce);Me=id({task_type:je.task_type},xi(String((mt==null?void 0:mt.content)||"")))}catch{Me=null}R(""),Z(p),L({filename:Ce,title:je.title||Ce,readiness:Me}),A.load_exec_config()}async function ze(je){if(!(!q||z)){de(!0),R("");try{const Ce=A.exec_cfg||await A.load_exec_config();if(!Ce||Ce.can_execute!==!0){R((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}const Me=!!(q.readiness&&!q.readiness.ok);await s.backlog_execute({kind:"planned",filename:q.filename,execution_mode:W,executor:je==null?void 0:je.executor,target_model:je==null?void 0:je.target_model,target_reasoning_effort:je==null?void 0:je.target_reasoning_effort,dor:"check",override:Me}),L(null),await X()}catch(Ce){const Me=Wu(Ce);Me?(L(mt=>mt&&{...mt,readiness:Me,server_refused:!0}),R("")):R(String((Ce==null?void 0:Ce.message)||Ce||"Execute failed"))}finally{de(!1)}}}async function it(je){if(!(ye||Le.length<2)){Fe(""),xe(!0);try{const Ce=A.exec_cfg||await A.load_exec_config();if(!Ce||Ce.can_execute!==!0){Fe((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}await s.backlog_execute_batch({items:Le.map(Me=>({kind:"planned",filename:String(Me.filename||"")})),execution_mode:ae,executor:je,dor:"check",override:Ze}),le(!1),ue([]),he(!1),await X()}catch(Ce){const Me=Wu(Ce);if(Me){const mt=Me.checks.filter(_t=>!_t.ok);he(!0),Fe(`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 Fe(String((Ce==null?void 0:Ce.message)||Ce||"Execute batch failed"))}finally{xe(!1)}}}async function et(){if(K||Le.length<2)return;const je=Je.trim();if(!je){Y("Title is required.");return}Y(""),ke(!0);try{await s.backlog_merge({kind:"planned",items:Le.map(Ce=>({kind:"planned",filename:String(Ce.filename||"")})),package:se.trim()||"framework",task_type:ge,title:je,summary:fe.trim()||void 0}),Pe(!1),ue([]),await X()}catch(Ce){Y(String((Ce==null?void 0:Ce.message)||Ce||"Merge failed"))}finally{ke(!1)}}function kt(je){const Ce=String(je||"").trim();ue(Me=>Me.includes(Ce)?Me.filter(mt=>mt!==Ce):[...Me,Ce])}function ht(je){if(y==="planned"){const Ce=oe.has(String(je.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void qt(je),disabled:!r||Ce,title:Ce?"A live execution request already exists for this item":void 0,children:Ce?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void Tt(je,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(je,"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(je,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void Tt(je,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(je,"trash"),disabled:!r,children:"Trash"})]}):y==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void Tt(je,"trash"),disabled:!r,children:"Trash"}):y==="deprecated"||y==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void Tt(je,"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:_f.map(je=>e.jsx("button",{"aria-pressed":y===je.id,className:`seg_btn ${y===je.id?"active":""}`,onClick:()=>b(je.id),children:je.label},je.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 X(),disabled:!r||C,title:"Refresh","aria-label":"Refresh",children:[e.jsx(at,{name:"refresh",size:16}),C?"Refreshing":"Refresh"]})]}),Ge?e.jsx(od,{gateway:s,surface:"the backlog archive",status:yt.status,legacy:yt.legacy,error:E,on_changed:()=>{dt(je=>je+1),X()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:P,onChange:je=>G(je.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:F,onChange:je=>J(je.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(je=>e.jsx("option",{value:je,children:je},je))]}),e.jsx("div",{className:"page_toolbar_spacer"}),y==="planned"&&_e.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[_e.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:_e.length<2,onClick:()=>{Fe(""),M(p),he(!1),le(!0),A.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:_e.length<2,onClick:()=>{const je=Le.map(Ce=>String(Ce.package||"").trim()).filter(Boolean);be(je.length&&je.every(Ce=>Ce===je[0])?je[0]:"framework"),qe("task"),ie(`Master backlog (${Le.length} items)`),we(""),Y(""),Pe(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[Se.length,"/",x.length]})]}),E&&!Ge?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=_f.find(je=>je.id===y))==null?void 0:Qt.label}),e.jsxs("span",{className:"pane_count",children:[Se.length," item",Se.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:Se.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:Se.map(je=>{const Ce=String(je.filename||"").trim(),Me=$l(je.task_type),mt=Gu(je)?Vu(je.priority):null,_t=Array.isArray(je.labels)?je.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>pt(je),children:[y==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:gt=>gt.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:_e.includes(Ce),onChange:()=>kt(Ce),"aria-label":`Select ${Ce}`})}):null,e.jsx("td",{className:"mono muted col_id",children:je.item_id||""}),e.jsx("td",{className:"col_type",children:Me?e.jsx("span",{className:`chip mono ${rh(Me)}`,title:ih(Me),children:Me}):null}),e.jsx("td",{className:"mono muted col_package",title:je.package||"",children:je.package||""}),e.jsx("td",{className:"backlog_table_title",title:Ce,children:je.title||Ce}),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(je)})}):null]},`${y}:${Ce}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:C?"Loading…":"No items."})})]})]}),e.jsx(vh,{open:!!q,target:q?{kind:"planned",filename:q.filename,title:q.title}:null,execute_mode:W,set_execute_mode:Z,action_loading:z,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 je=q;L(null),Ae({filename:je.filename,kind:"planned",title:je.title,initial_tab:"spec"})}:void 0,on_confirm:je=>void ze(je),on_close:()=>L(null)}),e.jsx(Rg,{open:U,batch_selected_items:Le,batch_execute_mode:ae,set_batch_execute_mode:M,batch_execute_loading:ye,batch_execute_error:Oe,executors:V,exec_cfg:A.exec_cfg,exec_cfg_loading:A.exec_cfg_loading,exec_cfg_error:A.exec_cfg_error,on_confirm:je=>void it(je),on_close:()=>{le(!1),Fe(""),he(!1)}}),e.jsx(Lg,{open:Re,batch_selected_items:Le,merge_package:se,set_merge_package:be,merge_task_type:ge,set_merge_task_type:qe,merge_title:Je,set_merge_title:ie,merge_summary:fe,set_merge_summary:we,merge_loading:K,merge_error:Ye,on_confirm:()=>void et(),on_close:()=>{Pe(!1),Y("")}}),e.jsx(hh,{gateway:s,can_use_gateway:r,target:Ee,on_close:()=>Ae(null),on_mutated:async()=>{await X()},on_open_executions:je=>{var Ce;return(Ce=a.on_open_executions)==null?void 0:Ce.call(a,je)}}),e.jsx($g,{gateway:s,can_use_gateway:r,is_compact_layout:_,maint_provider:l,maint_model:c,maint_reasoning:m,advisor_agent:f,focus_kind:y,focus_type:F,voice_session_id:a.voice_session_id})]})}function zg(a){const{open:s,gateway:r,can_use_gateway:l,maint_provider:c,maint_model:m,maint_reasoning:f,on_close:p,on_created:_}=a,[y,b]=h.useState(""),[x,N]=h.useState(!1),[C,O]=h.useState(""),[E,D]=h.useState("proposed"),[P,G]=h.useState("feature"),[F,J]=h.useState("framework"),[$,ee]=h.useState(""),[oe,ce]=h.useState(""),[pe,Ee]=h.useState(""),[Ae,_e]=h.useState(""),[ue,q]=h.useState(""),[L,W]=h.useState(""),[Z,z]=h.useState(!1),[de,V]=h.useState(""),[j,R]=h.useState(""),[U,le]=h.useState(""),[ae,M]=h.useState(""),[ye,xe]=h.useState(""),[Oe,Fe]=h.useState(""),[Ze,he]=h.useState(""),[Re,Pe]=h.useState(""),[se,be]=h.useState(""),[ge,qe]=h.useState(""),[Je,ie]=h.useState([]),[fe,we]=h.useState(!1),[K,ke]=h.useState(""),[Ye,Y]=h.useState([]),[A,X]=h.useState(""),[Se,Le]=h.useState(!1);function Ge(){D("proposed"),G("feature"),J("framework"),ee(""),ce(""),Ee(""),_e(""),q(""),W(""),z(!1),V(""),R(""),le(""),M(""),xe(""),Fe(""),he(""),Pe(""),be(""),qe(""),ie([]),we(!1),ke(""),Y([]),X(""),Le(!1)}function tt(){p(),Ge()}async function dt(){const ze=String(y||"").trim();if(ze)return ze;if(x)return"";O(""),N(!0);try{const it=await r.backlog_template(),et=String((it==null?void 0:it.content)||"");return b(et),et}catch(it){return O(String((it==null?void 0:it.message)||it||"Failed to load backlog template")),""}finally{N(!1)}}async function yt(ze){if(!l)return;const it=(ze==null?void 0:ze.force)===!0;if(!it&&ue.trim())return;const et=await dt();if(!et.trim())return;const kt=String(F||"").trim().toLowerCase()||"{Package}",ht=Bu(),Qt=ag(et,{package_name:kt,title:$,task_type:P,summary:oe,created_at:ht});q(je=>it||!String(je||"").trim()?Qt:je)}h.useEffect(()=>{s&&l&&yt()},[s,l]);function pt(ze){if(ue.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const it=String(F||"").trim().toLowerCase()||"{Package}",et=Bu(),kt=rg({package_name:it,title:$,task_type:P,summary:oe,diagram:de,context:j,included:Pa(U),excluded:Pa(ae),plan:Pa(ye),dependencies:Pa(Oe),acceptance:Pa(Ze),tests_a:Pa(Re),tests_b:Pa(se),tests_c:Pa(ge),created_at:et,attachments:[]});q(kt)}async function Tt(){var it;if(Z)return;W(""),z(!0),ke("");let ze="";try{const et=String(F||"").trim().toLowerCase(),kt=rd(Ae),ht=!!(pe||kt.length);let Qt=ue||"";ht&&Qt.trim()&&(Qt=Hu(Qt,{priority:pe||null,labels:kt}));const je=await r.backlog_create({kind:E,package:et,title:$,task_type:P,summary:oe||null,content:Qt||null}),Ce=String((je==null?void 0:je.kind)||"").trim(),Me=String((je==null?void 0:je.filename)||"").trim();if(ht&&!Qt.trim()&&Ce&&Me)try{const _t=await r.backlog_content(Ce,Me),gt=String((_t==null?void 0:_t.content)||""),Xt=await Uu(gt),mn=Hu(gt,{priority:pe||null,labels:kt});await r.backlog_update({kind:Ce,filename:Me,content:mn,expected_sha256:Xt||null})}catch(_t){ze=[ze,`metadata lines not written: ${String((_t==null?void 0:_t.message)||_t)}`].filter(Boolean).join("; ")}const mt=[...Je||[]];if(Ce&&Me&&mt.length){we(!0);const _t=[];try{for(const gt of mt){const Xt=await r.backlog_upload_attachment({kind:Ce,filename:Me,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){ze=[ze,String((gt==null?void 0:gt.message)||gt||"Attachment upload failed")].filter(Boolean).join("; "),ke(ze)}finally{if(_t.length)try{const gt=await r.backlog_content(Ce,Me),Xt=String((gt==null?void 0:gt.content)||""),mn=await Uu(Xt),Bt=ig(Xt,_t);await r.backlog_update({kind:Ce,filename:Me,content:Bt,expected_sha256:mn||null})}catch(gt){ze=[ze,`uploaded files not linked: ${String((gt==null?void 0:gt.message)||gt)}`].filter(Boolean).join("; ")}we(!1)}}p(),Ge();try{await _(Ce,Me,ze)}catch{}}catch(et){W(String((et==null?void 0:et.message)||et||"Create failed"))}finally{z(!1)}}async function qt(){if(Se)return;W("");const ze=A.trim();if(!ze)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:ze,ts:new Date().toISOString()},kt=[...Ye,et];Y(kt),X(""),Le(!0);try{const ht=await r.backlog_assist({kind:E,package:it,title:$,summary:oe||null,draft_markdown:ue||null,messages:kt.map(Ce=>({role:Ce.role,content:Ce.content})),provider:c||null,model:m||null,thinking:f||null}),Qt=String((ht==null?void 0:ht.reply)||"").trim(),je=String((ht==null?void 0:ht.draft_markdown)||"").trim();Qt&&Y(Ce=>[...Ce,{id:Nr(),role:"assistant",content:Qt,ts:new Date().toISOString()}]),je&&q(je)}catch(ht){W(String((ht==null?void 0:ht.message)||ht||"AI assist failed"))}finally{Le(!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:Z||Se,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Tt(),disabled:Z||!$.trim()||!F.trim(),children:Z?"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:ze=>D(ze.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:P,onChange:ze=>G(ze.target.value),children:Fa.map(ze=>e.jsx("option",{value:ze,children:ze},ze))})]})}),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:ze=>J(ze.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:$,onChange:ze=>ee(ze.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:ze=>Ee(ze.target.value),children:[e.jsx("option",{value:"",children:"unset"}),Tl.map(ze=>e.jsx("option",{value:ze,children:ch[ze]},ze))]})]})}),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:Ae,onChange:ze=>_e(ze.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:ze=>ce(ze.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:de,onChange:ze=>V(ze.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:ze=>R(ze.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:U,onChange:ze=>le(ze.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:ae,onChange:ze=>M(ze.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:ye,onChange:ze=>xe(ze.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:Oe,onChange:ze=>Fe(ze.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:Ze,onChange:ze=>he(ze.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:ze=>Pe(ze.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:ze=>be(ze.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:ze=>qe(ze.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:Z||Se,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:ze=>{const it=Array.from(ze.target.files||[]);it.length&&(ie(et=>[...et,...it]),ze.currentTarget.value="")}})}),Je.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Je.map((ze,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:[ze.name," (",Math.round(ze.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>ie(et=>et.filter((kt,ht)=>ht!==it)),disabled:Z||fe,children:"Remove"})]},`${ze.name}_${ze.size}_${it}`))}):null,fe?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,K?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:K}):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:()=>{ue.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||yt({force:!0})},disabled:Z||Se||x||!l,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:ue,onChange:ze=>q(ze.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(sd,{messages:Ye,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(Xo,{value:A,onChange:X,onSubmit:()=>void qt(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!l||!$.trim(),busy:Se,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 xh extends Kt.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,m;try{(m=(c=this.props).onError)==null||m.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 dd{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"}:{}}}),m=await c.text();let f=null;try{f=JSON.parse(m)}catch{}if(!c.ok){const p=f&&typeof f=="object"&&(f.detail||f.error)||m,_=new Error(`${s} failed: ${p}`);throw _.status=c.status,_}return f}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)}),m=await c.text();let f=null;try{f=JSON.parse(m)}catch{}if(!c.ok){const p=f&&typeof f=="object"&&(f.detail||f.error)||m,_=new Error(`upload failed: ${p}`);throw _.status=c.status,_}if(!f||typeof f!="object"||!f.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return f}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 m={value:l,note:c};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(m)})}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,m=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:l,value:c,note:m})})}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 Pg=["commons"],Ig=3e4,Dg=5*6e4,gf={live:new Map,done:[],work:new Map},vf=new Set(["proposed","planned","completed","deprecated"]);function Og(a,s){const r=s&&typeof s=="object"?String(s.item||""):"";if(r&&Os(r))return r;const l=a.startsWith("claim:")?a.slice(6):"";return l&&Os(l)?l:null}function Fg(a){const[s,r]=h.useState(gf),l=h.useRef(new dd),c=h.useRef(new Map),m=h.useRef(0),f=h.useRef(!1);return h.useEffect(()=>{let p=!0;const _=async()=>{if(!(f.current||Date.now()<m.current)){f.current=!0;try{const b=new Map,x=[],N=new Map;for(const C of Pg){let O=!1;try{const D=await l.current.work_rows(C);for(const P of D){const G=String(P.id||P.item||""),F=String(P.status||"").toLowerCase();!Os(G)||!vf.has(F)||N.set(G,{item:G,title:typeof P.title=="string"?P.title:void 0,status:F,owner:typeof P.owner=="string"?P.owner:void 0,receipt:typeof P.receipt=="string"?P.receipt:void 0,card:typeof P.card=="string"?P.card:void 0,updated_at:P.updated_at})}O=!0}catch{}const E=await l.current.store_keys(C);for(const D of E){const P=String(D.key||"");if(P.startsWith("work:")){if(O)continue;const ce=P.slice(5);if(!Os(ce))continue;const pe=Number(D.version||0),Ee=`${C}\0${P}`,Ae=c.current.get(Ee);let _e;if(Ae&&Ae.version===pe)_e=Ae.value;else{const q=await l.current.store_get(C,P);_e=q==null?void 0:q.value,c.current.set(Ee,{version:pe,value:_e})}const ue=_e&&typeof _e=="object"?String(_e.status||"").toLowerCase():"";if(!vf.has(ue))continue;N.set(ce,{item:ce,title:typeof _e.title=="string"?_e.title:void 0,status:ue,owner:typeof _e.owner=="string"?_e.owner:void 0,receipt:typeof _e.receipt=="string"?_e.receipt:void 0,card:typeof _e.card=="string"?_e.card:void 0,updated_at:D.updated_at});continue}if(!P.startsWith("claim:"))continue;const G=Number(D.version||0),F=`${C}\0${P}`,J=c.current.get(F);let $;if(J&&J.version===G)$=J.value;else{const ce=await l.current.store_get(C,P);$=ce==null?void 0:ce.value,c.current.set(F,{version:G,value:$})}if(!$||typeof $!="object"||typeof $.owner!="string"||!$.owner)continue;const ee=Og(P,$)||P.slice(6);if(!ee)continue;!!$.done||String($.status||"").toLowerCase()==="done"?x.push({item:ee,owner:$.owner,receipt:typeof $.receipt=="string"?$.receipt:void 0,updated_at:D.updated_at}):b.has(ee)||b.set(ee,$)}}x.sort((C,O)=>(O.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{m.current=Date.now()+Dg,p&&r(b=>b.live.size||b.done.length||b.work.size?gf:b)}finally{f.current=!1}}};_();const y=setInterval(()=>void _(),Ig);return()=>{p=!1,clearInterval(y)}},[a]),s}const qg=40,Bg=4;function Ug(a){const{gateway:s,can_use_gateway:r,data_nonce:l}=a,[c,m]=h.useState([]),[f,p]=h.useState(!1),[_,y]=h.useState(""),[b,x]=h.useState(""),[N,C]=h.useState(null),[O,E]=h.useState(null),[D,P]=h.useState({}),G=h.useRef({}),F=h.useRef(!1),J=h.useCallback(async ce=>{if(r&&!F.current){F.current=!0,ce!=null&&ce.background||p(!0);try{const[pe,Ee,Ae,_e,ue]=await Promise.allSettled([s.backlog_list("proposed"),s.backlog_list("planned"),s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:60}),s.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200})]),q=[],L=[],W=(ye,xe)=>ye.status==="fulfilled"?ye.value:(q.push(xe),L.push(ye.reason),null),Z=W(pe,"proposed list"),z=W(Ee,"planned list"),de=W(Ae,"live requests"),V=W(_e,"recent history"),j=W(ue,"busy set");if(C(L.find(ye=>yi(ye))??null),!Z&&!z&&!de&&!V){y("Failed to load the board (all sources failed)");return}y("");const R=Array.isArray(de==null?void 0:de.requests)?de.requests:[];let U=Array.isArray(j==null?void 0:j.items)?j.items:[];j||(U=R.map(ye=>({request_id:String(ye.request_id||""),status:String(ye.status||""),kind:"planned",filename:String(ye.backlog_filename||"").trim(),relpath:String(ye.backlog_relpath||"").trim()})).filter(ye=>ye.filename&&!/^batch\(\d+\)$/i.test(ye.filename)));const le=Array.isArray(Z==null?void 0:Z.items)?Z.items:[],ae=Array.isArray(z==null?void 0:z.items)?z.items:[];E(Z&&z?le.length+ae.length:null);const M=wg({proposed:le,planned:ae,active_requests:R,terminal_requests:Array.isArray(V==null?void 0:V.requests)?V.requests:[],active_items:U});m(M),x(q.length?`#FALLBACK partial board — failed: ${q.join(", ")}`:""),$(M,le,ae)}finally{F.current=!1,ce!=null&&ce.background||p(!1)}}},[s,r]);async function $(ce,pe,Ee){const Ae=new Map;for(const L of pe)Ae.set(String(L.filename||"").trim(),"proposed");for(const L of Ee)Ae.set(String(L.filename||"").trim(),"planned");const _e=ce.filter(L=>L.filename&&!G.current[L.filename]&&Ae.has(L.filename)).filter(L=>!fh(L)||L.column==="ready").slice(0,qg).map(L=>({filename:L.filename,kind:Ae.get(L.filename)}));if(!_e.length)return;const ue=[..._e],q=Array.from({length:Math.min(Bg,ue.length)},async()=>{for(;;){const L=ue.shift();if(!L)return;try{const W=await s.backlog_content(L.kind,L.filename),Z=xi(String((W==null?void 0:W.content)||""));G.current={...G.current,[L.filename]:Z}}catch{}}});await Promise.all(q),P(G.current)}const ee=h.useCallback(async(ce,pe)=>{try{const Ee=await s.backlog_content(ce,pe),Ae=xi(String((Ee==null?void 0:Ee.content)||""));G.current={...G.current,[pe]:Ae},P(G.current)}catch{}},[s]);return h.useEffect(()=>{J()},[J,l]),h.useEffect(()=>{if(!r)return;const ce=setInterval(()=>{s.is_backing_off()||J({background:!0})},1e4);return()=>clearInterval(ce)},[r,J,s]),{cards:c,loading:f,error:_,degraded:b,unconfigured:N!==null,unavailable:N,item_count:O,metadata:D,refresh:J,refresh_item_metadata:ee}}function yf(a,s){return a.length<=s?a:`${a.slice(0,s-1).trimEnd()}…`}const Wg=new dd;function Hg(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 Vg(a){const{card:s}=a,r=s.work_id||"",l=!!(r&&Os(r)),[c,m]=h.useState({loading:l,error:"",claims:[],decisions:[],messages:[]});h.useEffect(()=>{let _=!0;if(l)return m(y=>({...y,loading:!0,error:""})),Wg.work(r).then(y=>{_&&m({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=>{_&&m({loading:!1,error:String((y==null?void 0:y.message)||y||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{_=!1}},[r,l]);const f=c.messages[0],p=s.claim_started_at!==void 0&&s.claim_owner?oh({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," · ",Hg(_.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:yf(String(_.title),140)}):null,_.body?e.jsx("div",{className:"board_activity_msg_body muted",children:yf(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(f?{channel:String(f.channel||"commons"),message_id:String(f.id||""),seq:Number(f.seq)}:{channel:"commons"}),title:f?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function Gg(a){var we;const{gateway:s,gateway_connected:r,data_nonce:l,on_mutated:c,on_open_executions:m}=a,f=a.default_execution_mode==="inplace"?"inplace":"uat",p=cd("(max-width: 900px)"),_=yh(s,r),y=Ug({gateway:s,can_use_gateway:r,data_nonce:l}),[b,x]=h.useState(0),N=ld(s,r,l+b),C=y.unconfigured||((we=N.status)==null?void 0:we.available)===!1,O=!C&&y.item_count===0&&!y.error,E=Fg(!0),D=h.useMemo(()=>kg(y.cards,E),[y.cards,E]),P=ud({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:()=>{}}),[G,F]=h.useState("");h.useEffect(()=>{var ke;if(!a.query_preset)return;const K=Os(a.query_preset);F(K?K.num.padStart(4,"0"):a.query_preset),(ke=a.on_query_preset_consumed)==null||ke.call(a)},[a.query_preset]);const[J,$]=h.useState("all"),[ee,oe]=h.useState("all"),[ce,pe]=h.useState(""),[Ee,Ae]=h.useState(!1),[_e,ue]=h.useState(null),[q,L]=h.useState(null),[W,Z]=h.useState(null),[z,de]=h.useState("uat"),[V,j]=h.useState(!1),[R,U]=h.useState(""),[le,ae]=h.useState(""),[M,ye]=h.useState(null),xe=h.useRef(null),Oe=D.some(K=>K.column==="in_progress"),[,Fe]=h.useState(0);h.useEffect(()=>{if(!Oe)return;const K=setInterval(()=>Fe(ke=>(ke+1)%3600),1e3);return()=>clearInterval(K)},[Oe]);const Ze=h.useMemo(()=>{const K=new Set;for(const ke of D)ke.package&&K.add(ke.package);return[...K].sort()},[D]),he=h.useMemo(()=>D.filter(K=>K.filename&&K.kind).length,[D]),Re=h.useMemo(()=>D.filter(K=>K.filename&&K.kind&&(fh(K)||y.metadata[K.filename])).length,[D,y.metadata]),Pe=h.useMemo(()=>{const K=new Map;for(const ke of D)if(ke.filename)for(const Ye of Qu(ke,y.metadata[ke.filename]))K.set(Ye,(K.get(Ye)||0)+1);return[...K.entries()].sort((ke,Ye)=>Ye[1]-ke[1]).slice(0,12)},[D,y.metadata]),se=h.useMemo(()=>{const K=G.trim().toLowerCase();return D.filter(ke=>{if(J!=="all"&&(ke.package||"")!==J||ee!=="all"&&String(ke.task_type||"").toLowerCase()!==ee)return!1;const Ye=ke.filename?y.metadata[ke.filename]:void 0,Y=Qu(ke,Ye);return ce&&!Y.includes(ce)||Ee&&!Y.some(X=>{const Se=X.toLowerCase();return Se==="decision-gate"||Se.startsWith("wave-")||Se.startsWith("seat-")})?!1:K?`${ke.item_id||""} ${ke.title} ${ke.filename||""} ${ke.package||""} ${ke.summary||""} ${ke.exec_status||""} ${Y.join(" ")} ${Ku(ke,Ye)||""}`.toLowerCase().includes(K):!0})},[D,y.metadata,G,J,ee,ce,Ee]),be=h.useMemo(()=>{var Ye;const K=new Map;for(const Y of ff)K.set(Y.id,[]);for(const Y of se)(Ye=K.get(Y.column))==null||Ye.push(Y);const ke=Y=>{const A=Y.filename?Ku(Y,y.metadata[Y.filename]):null;return A?Tl.indexOf(A):Tl.length};for(const[Y,A]of K)(Y==="triage"||Y==="ready")&&A.sort((X,Se)=>ke(X)-ke(Se)||(Se.item_id||0)-(X.item_id||0));return K},[se,y.metadata]);async function ge(K,ke){if(!(!K.filename||!K.kind||K.kind==="completed")&&K.kind!==ke){ae("");try{await s.backlog_move({from_kind:K.kind,to_kind:ke,filename:K.filename}),await y.refresh(),c()}catch(Ye){ae(String((Ye==null?void 0:Ye.message)||Ye||"Move failed"))}}}async function qe(K){if(!K.filename)return;let ke=y.metadata[K.filename];if(!ke)try{const Y=await s.backlog_content("planned",K.filename);ke=xi(String((Y==null?void 0:Y.content)||""))}catch{ke=void 0}const Ye=ke?id({task_type:K.task_type},ke):null;U(""),de(f),Z({filename:K.filename,title:K.title,readiness:Ye}),P.load_exec_config()}async function Je(K){if(!(!W||V)){j(!0),U("");try{const ke=P.exec_cfg||await P.load_exec_config();if(!ke||ke.can_execute!==!0){U((ke==null?void 0:ke.runner_error)||"Backlog exec is not available on this gateway.");return}const Ye=!!(W.readiness&&!W.readiness.ok);await s.backlog_execute({kind:"planned",filename:W.filename,execution_mode:z,executor:K==null?void 0:K.executor,target_model:K==null?void 0:K.target_model,target_reasoning_effort:K==null?void 0:K.target_reasoning_effort,dor:"check",override:Ye}),Z(null),await y.refresh(),c()}catch(ke){const Ye=Wu(ke);Ye?(Z(Y=>Y&&{...Y,readiness:Ye,server_refused:!0}),U("")):U(String((ke==null?void 0:ke.message)||ke||"Execute failed"))}finally{j(!1)}}}function ie(K){if(!K.filename&&!K.request_id){const ke=mg(K.card_path);if(ke&&r){s.backlog_content(ke.kind,ke.filename).then(()=>{ue({filename:ke.filename,kind:ke.kind,title:K.title,work_id:K.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>L(K));return}L(K);return}ue({filename:K.filename||"",kind:K.kind||null,request_id:K.request_id,title:K.title,work_id:K.work_id,has_live_request:K.column==="in_progress"||K.column==="in_review",initial_tab:K.column==="in_review"?"review":K.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:G,onChange:K=>F(K.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:J,onChange:K=>$(K.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),Ze.map(K=>e.jsx("option",{value:K,children:K},K))]}),e.jsxs("select",{value:ee,onChange:K=>oe(K.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(K=>e.jsx("option",{value:K,children:K},K))]}),e.jsx("button",{className:`chip mono board_facet ${Ee?"active":"muted"}`,onClick:()=>Ae(K=>!K),"aria-pressed":Ee,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,le?e.jsx("span",{className:"mono board_error",children:le}):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(od,{gateway:s,surface:"the board",status:N.status,legacy:N.legacy,error:y.unavailable,on_changed:()=>{x(K=>K+1),y.refresh()}}):null,O?e.jsx(Ng,{status:N.status,on_create:a.on_new_task}):null,!C&&(Pe.length||he)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),Pe.map(([K,ke])=>e.jsxs("button",{className:`chip mono board_facet ${ce===K?"active":"info"}`,onClick:()=>pe(Ye=>Ye===K?"":K),title:`${ke} scanned card(s) carry ${K} — click to filter (sprints are labels: sprint-N)`,children:[K," ",e.jsx("span",{className:"muted",children:ke})]},K)),ce?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>pe(""),children:"clear ✕"}):null,Re<he?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,"/",he]}):null]}):null,e.jsx("div",{className:"board_columns",style:C?{display:"none"}:void 0,children:ff.map(K=>{const ke=be.get(K.id)||[],Ye=fe[K.id];return e.jsxs("div",{className:`board_column board_column_${K.id} ${M===K.id?"drag_over":""}`,onDragOver:Y=>{!Ye||!xe.current||(Y.preventDefault(),ye(K.id))},onDragLeave:()=>ye(Y=>Y===K.id?null:Y),onDrop:Y=>{Y.preventDefault(),ye(null);const A=xe.current;xe.current=null,A&&Ye&&ge(A,Ye)},children:[e.jsxs("div",{className:"board_column_header",title:K.hint,children:[e.jsx("span",{className:"board_column_title",children:K.label}),e.jsx("span",{className:"board_column_count mono",children:ke.length})]}),e.jsxs("div",{className:"board_column_body",children:[ke.map(Y=>{const A=mh(Y,Y.filename?y.metadata[Y.filename]:void 0);return e.jsx(Kg,{card:Y,metadata:Y.filename?y.metadata[Y.filename]:void 0,draggable:!A&&!!(Y.kind&&Y.filename&&(Y.column==="triage"||Y.column==="ready")),on_drag_start:()=>{xe.current=Y},on_drag_end:()=>{xe.current=null,ye(null)},on_open:()=>ie(Y),on_promote:!A&&K.id==="triage"?()=>void ge(Y,"planned"):void 0,on_demote:!A&&K.id==="ready"?()=>void ge(Y,"proposed"):void 0,on_execute:!A&&K.id==="ready"?()=>void qe(Y):void 0,on_follow:Y.exec_status==="running"||Y.exec_status==="queued"?()=>m(Y.request_id):void 0},Y.key)}),ke.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},K.id)})}),e.jsx(vh,{open:!!W,target:W?{kind:"planned",filename:W.filename,title:W.title}:null,execute_mode:z,set_execute_mode:de,action_loading:V,action_error:R,exec_cfg:P.exec_cfg,exec_cfg_loading:P.exec_cfg_loading,exec_cfg_error:P.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 K=W;Z(null),ue({filename:K.filename,kind:"planned",title:K.title,initial_tab:"spec"})}:void 0,on_confirm:K=>void Je(K),on_close:()=>Z(null)}),e.jsx(hh,{gateway:s,can_use_gateway:r,target:_e,on_close:()=>ue(null),on_mutated:async()=>{_e!=null&&_e.filename&&(_e.kind==="proposed"||_e.kind==="planned")&&await y.refresh_item_metadata(_e.kind,_e.filename),await y.refresh(),c()},on_open_executions:m}),q?e.jsx(Vg,{card:q,on_close:()=>L(null),on_open_team:a.on_open_team}):null]})}function Kg(a){const{card:s,metadata:r,draggable:l,on_drag_start:c,on_drag_end:m,on_open:f,on_promote:p,on_demote:_,on_execute:y,on_follow:b}=a,x=Ku(s,r),N=mh(s,r),C=!N&&r?id({task_type:s.task_type},r):null,O=$l(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:f,role:"button",tabIndex:0,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),f())},draggable:l,onDragStart:l?c:void 0,onDragEnd:l?m: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(D=>!D.ok).map(D=>D.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,O&&!N?e.jsx("span",{className:`chip mono ${rh(O)}`,title:ih(O),children:O}):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,Qu(s,r).filter(D=>!N||D.toLowerCase()!=="decision-gate").slice(0,3).map(D=>e.jsx("span",{className:"chip mono info",children:D},D)),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:Ds(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 D=oh({owner:s.claim_owner,started_at:s.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${D!=null&&D.stale?"warn":"info"}`,title:`Live hub claim${s.work_id?` (claim:${s.work_id})`:""}${D!=null&&D.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",s.claim_owner,D?` · ${D.label.replace("claimed ","")}`:""]})})():null]}),p||_||y||b?e.jsxs("div",{className:"board_card_actions",onClick:D=>D.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 Cu(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 Qg(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 bh(a){const s=String(a||"").trim();if(!s)return"";const r=s.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?Qg(String(r[1]||"").trim()):s}function Jg(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 m=String(c.status||"").trim().toLowerCase();if(m==="failed")return"error";const f=c.exit_code,p=typeof f=="number"?f:Number.isFinite(Number(f))?Number(f):null;if(p!=null)return p===0?"ok":"error";if(m==="completed")return"ok"}return"info"}function Yg(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():"",m=l?String(l.text||"").trim():"",f=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"&&f)return bh(f)||f;if(c==="todo_list"&&p.length>0){const b=p.length,x=p.filter(P=>(P&&P.completed)===!0).length,N=p.find(P=>(P&&P.completed)!==!0),C=String((N==null?void 0:N.text)||"").trim(),O=b>1?` (+${b-1})`:"",E=b>0?` (${x}/${b})`:"",D=C?`todo: ${C}${O}`:`todo list (${b})`;return Cu(`${D}${E}`,96)}return m?Cu(m,96)||m:_?Cu(_,96)||_:c||String(a||"").trim()||"event"}function xf(a){const s=new Date(a),r=l=>String(l).padStart(2,"0");return`${r(s.getHours())}:${r(s.getMinutes())}`}function Xg(a){var l,c,m;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,(m=s.item)==null?void 0:m.timestamp];for(const f of r)if(f!=null){if(typeof f=="number"&&Number.isFinite(f)){const p=f>1e11?f:f*1e3;return xf(p)}if(typeof f=="string"){const p=f.trim();if(!p)continue;const _=Date.parse(p.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(_))return xf(_)}}return null}function Zg(a){var D;const{exec_selected:s,exec_detail:r,is_compact_layout:l,exec_log_name:c,set_exec_log_name:m,exec_log_text:f,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:O,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:P=>m(P.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(P=>!P),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"&&O?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:P=>{C.current=cf(P.currentTarget,12)},children:O.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):O.events.map(P=>{var de;const G=P.payload,F=G&&typeof G.item=="object"?G.item:null,J=F?String(F.type||"").trim():"",$=F?String(F.id||"").trim():"",ee=G?String(G.thread_id||"").trim():"",oe=Jg(P.type,G),ce=oe==="error"?"danger":oe==="ok"?"ok":"info",pe=Xg(G),Ee=Yg(P.type,G),Ae=String((G==null?void 0:G.message)||((de=G==null?void 0:G.error)==null?void 0:de.message)||"").trim(),_e=F?String(F.text||"").trim():"",ue=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():"",Z=F&&Array.isArray(F.items)?F.items:[],z=ue?bh(ue)||ue:"";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:Ee,children:Ee}),e.jsx("span",{className:`chip mono ${ce}`,children:J||P.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:P.type}),$?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:$}):null,ee?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",fa(ee,18)]}):null]}),Ae?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ae}):null,Z&&Z.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Z.map((V,j)=>e.jsxs("div",{children:[(V&&V.completed)===!0?"✓":"○"," ",String((V==null?void 0:V.text)||"").trim()]},`${P.idx}-todo-${j}`))}):null,ue?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",q?`(${q})`:""," ",L?`exit=${L}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:z})]}):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,_e?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(rs,{className:"md_doc",text:_e})}):null]})]},`${P.idx}-${$}-${P.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",O.bad?` (${O.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:O.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:P=>{C.current=cf(P.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var G;if(String(f||"").trim())return f;if(c==="last_message"){const F=String(((G=r==null?void 0:r.result)==null?void 0:G.last_message)||s.last_message||"").trim();if(F)return F;const J=String(s.status||"").trim().toLowerCase();return J==="queued"||J==="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)"})()})}),(D=r==null?void 0:r.result)!=null&&D.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 ev(a){const{pipeline:s,is_compact_layout:r,on_back_to_list:l,on_send_feedback:c,on_promote:m,on_deploy_uat:f}=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:O,event_stats:E,time_stats:D,exec_log_name:P}=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 G=String(p.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${Nl(G)}`,children:G||"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 J;const F=(Array.isArray((J=_==null?void 0:_.backlog_queue)==null?void 0:J.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(tv,{exec_selected:p,exec_detail:_,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:C,exec_qa_error:O,on_send_feedback:c,on_promote:m,on_deploy_uat:f}),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,D.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Ds(D.age_ms)})]}):null,D.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:Ds(D.queue_delay_ms)})]}):null,D.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:Ds(D.run_ms)})]}):null,D.total_ms!=null&&D.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Ds(D.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:P==="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(rv,{exec_detail:_}),e.jsx(sv,{exec_detail:_,exec_qa_loading:C,status:String(p.status||"")}),e.jsx(av,{exec_detail:_}),e.jsx(iv,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_divider"}),e.jsx(Zg,{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:G=>s.set_exec_log_auto(G),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 tv(a){const{exec_selected:s,exec_detail:r,exec_qa_feedback:l,set_exec_qa_feedback:c,exec_qa_loading:m,exec_qa_error:f,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(),O=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),E=String((r==null?void 0:r.uat_current_relpath)||"").trim(),D=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),P=!!(r!=null&&r.uat_lock_acquired),G=!!(r!=null&&r.uat_pending),F=(r==null?void 0:r.uat_deploy)??null,J=String((r==null?void 0:r.uat_deploy_error)||"").trim(),$=r==null?void 0:r.attempt,ee=(r==null?void 0:r.promotion_report)??null,oe=!!(ee!=null&&ee.blocked),ce=String((ee==null?void 0:ee.reason)||"").trim(),pe=Array.isArray(ee==null?void 0:ee.conflicts)?(ee==null?void 0:ee.conflicts).slice(0,8):[],Ee=typeof(ee==null?void 0:ee.conflicts_total)=="number"?Number(ee.conflicts_total):pe.length;let Ae="",_e="";const ue=[];try{const q=F==null?void 0:F.processes;if(q&&typeof q=="object"&&!Array.isArray(q)){typeof q.status=="string"&&(Ae=String(q.status||"").trim()),typeof q.reason=="string"&&(_e=String(q.reason||"").trim());for(const[L,W]of Object.entries(q)){if(!W||typeof W!="object"||Array.isArray(W))continue;const Z=W.probe;!Z||typeof Z!="object"||Z.ok===!1&&ue.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"&&D?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[fa(D,18),P?" (owned)":G?" (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,O?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:O})]}):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"&&G&&D&&!P?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",fa(D,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):x==="uat"&&P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"detail_hint",children:["UAT URLs: gateway ",e.jsx("code",{children:"http://localhost:6081"}),", observer ",e.jsx("code",{children:"http://localhost:6082"}),", code ",e.jsx("code",{children:"http://localhost:6083"}),", flow"," ",e.jsx("code",{children:"http://localhost:6084"})]}),e.jsx("div",{className:"detail_hint",children:"UAT is intentionally short-lived: promoting or iterating will stop the shared UAT services."}),ue.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",ue.slice(0,4).join(", "),ue.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,x==="uat"&&Ae==="skipped"&&_e==="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,J?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",J]}):null,oe&&ce==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",Ee," conflict",Ee===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:m,children:[e.jsx(at,{name:"copy",size:16}),"Copy patch path"]}):null,O?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(O),disabled:m,children:[e.jsx(at,{name:"copy",size:16}),"Copy manifest path"]}):null,N?e.jsxs("button",{className:"btn btn_icon",onClick:()=>dn(N),disabled:m,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:m})}),f?e.jsx("div",{className:"detail_warn",children:f}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[x==="uat"?e.jsx("button",{className:"btn",onClick:y,disabled:m,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:_,disabled:m,children:x==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:p,disabled:m,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(),m=(r==null?void 0:r.promotion)??null,f=(r==null?void 0:r.promotion_report)??null,p=typeof(m==null?void 0:m.copied)=="number"?Number(m==null?void 0:m.copied):null,_=typeof(m==null?void 0:m.deleted)=="number"?Number(m==null?void 0:m.deleted):null,y=String((m==null?void 0:m.manifest_sha256)||"").trim(),b=String((m==null?void 0:m.mode)||"").trim(),x=(f==null?void 0:f.redeploy)??null,N=String((x==null?void 0:x.status)||"").trim(),C=String((x==null?void 0:x.reason)||"").trim(),O=String((f==null?void 0:f.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,O?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:O})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function sv(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,m=String((l==null?void 0:l.mode)||"").trim(),f=(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:[m?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:m})]}):null,f?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[f," 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 av(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(m=>String((m==null?void 0:m.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(m=>e.jsx("div",{children:m},`bq:${m}`))})]}):null}function rv(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:{},m=Array.isArray(s.verdicts)?s.verdicts:[];if(!r.length&&!l.length&&!m.length)return null;const f=new Set(l.map(x=>String(x))),p=m.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=f.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"),O=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,": ",O]},`verdict:${N}:${C}`)})]})}function iv(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 lv=10;function ov(a){const{gateway:s,gateway_connected:r}=a,l=cd("(max-width: 900px)"),[c,m]=h.useState("list"),[f,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=ud({gateway:s,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:l,set_compact_pane:m,on_status_transfer:()=>{O()}}),[b,x]=h.useState([]),[N,C]=h.useState("");async function O(){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((Z,z)=>{const de=String(Z.finished_at||Z.started_at||Z.created_at||"");return String(z.finished_at||z.started_at||z.created_at||"").localeCompare(de)}),x(W.slice(0,lv)),C("")}catch(L){C(String((L==null?void 0:L.message)||L||"Failed to load recent executions"))}}h.useEffect(()=>{if(!r)return;(async()=>{var z;const W=await y.refresh_exec_list("processing");await O();const Z=String(a.focus_request_id||"").trim();if(Z){const de=W.find(V=>V.request_id===Z);if(de)await y.load_exec_request(de);else try{const V=await s.backlog_exec_request(Z);V!=null&&V.payload&&await y.load_exec_request({request_id:Z,status:String(V.payload.status||"unknown")})}catch{}(z=a.on_focus_consumed)==null||z.call(a)}})();const L=setInterval(()=>{s.is_backing_off()||O()},15e3);return()=>clearInterval(L)},[r,a.focus_request_id]);const E=y.exec_requests.some(L=>String(L.status||"").toLowerCase()==="running"),[,D]=h.useState(0);h.useEffect(()=>{if(!E)return;const L=setInterval(()=>D(W=>(W+1)%3600),1e3);return()=>clearInterval(L)},[E]);const P=y.exec_requests,G=h.useMemo(()=>{let L=0,W=0,Z=0;for(const z of P){const de=String(z.status||"").trim().toLowerCase();de==="queued"?L+=1:de==="running"?W+=1:de==="awaiting_qa"&&(Z+=1)}return{queued:L,running:W,awaiting:Z}},[P]),F=y.exec_cfg,J=!!(F!=null&&F.runner_alive),$=String((F==null?void 0:F.executor)||"").trim(),ee=!$||$==="none",oe=ee?"execution agent":$,ce=!!(F!=null&&F.can_execute),pe=yi(y.exec_error)||yi(N),[Ee,Ae]=h.useState(0),_e=ld(s,r&&pe,Ee),ue=!l||c==="list",q=!l||c==="detail";return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&F?e.jsxs("span",{className:`chip mono ${ce?"ok":"warn"}`,title:F.codex_model?`${oe}: ${F.codex_model}${F.codex_reasoning_effort?` (reasoning ${F.codex_reasoning_effort})`:""}`:void 0,children:[ee?"no execution agent":`${oe} worker ${J?"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"),O(),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&&!ce&&!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:[ee?f!=null&&f.length?"No default executor selected":"No execution agent on this gateway":J?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:ee?"setup required":J?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!ee)return F.runner_error?`The worker reports: ${F.runner_error} — new executions queue until it comes back.`:J?"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(!(f!=null&&f.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=f.map(z=>z.display||z.id),W=L.slice(0,4).join(", ")+(L.length>4?` +${L.length-4} more`:"");return f.some(z=>z.available!==!1)?`The gateway's registry serves ${f.length} executor${f.length===1?"":"s"} (${W}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${f.length} executor${f.length===1?"":"s"} (${W}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(f!=null&&f.length)||!f.some(L=>L.available!==!1))&&(ee||!J)?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(od,{gateway:s,surface:"the execution pipeline",status:_e.status,legacy:_e.legacy,error:yi(y.exec_error)?y.exec_error:N,on_changed:()=>{Ae(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 ${G.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:G.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${G.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:G.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:G.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${ce?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:ce?"on":ee?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[oe,ee?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[ue?e.jsxs("div",{className:"exec_side",children:[e.jsxs("div",{className:"pane exec_pane_active",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Active"}),e.jsx("span",{className:"pane_count",children:P.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:P.length?P.map(L=>{var R;const W=String(L.status||"").trim().toLowerCase(),Z=El(L),z=((R=y.exec_selected)==null?void 0:R.request_id)===L.request_id,de=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 ${z?"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 ${Nl(W)}`,children:W||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:de!==null?`running ${Ds(de)}`:Z.queue_delay_ms!=null?`queued ${Ds(Z.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(),Z=El(L),z=((V=y.exec_selected)==null?void 0:V.request_id)===L.request_id,de=fa(L.backlog_filename||L.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${z?"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 ${Nl(W)}`,children:W||"?"}),e.jsx("span",{className:"recent_row_name",children:de}),e.jsx("span",{className:"recent_row_time mono",children:Z.run_ms!=null?Ds(Z.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 ${Nl(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(ev,{pipeline:y,is_compact_layout:l,on_back_to_list:()=>m("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 O()}),on_deploy_uat:()=>void y.exec_deploy_uat_now(async()=>{await y.refresh_exec_list("processing")})})})]}):null]})]})]})}function $u(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function cv(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 bf(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),m=s(l);if(c!==m)return c-m;const f=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 f<p?-1:f>p?1:0})}function uv(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 dv({gateway:a,gateway_connected:s}){const[r,l]=h.useState("prod"),[c,m]=h.useState(null),[f,p]=h.useState([]),[_,y]=h.useState(!1),[b,x]=h.useState(""),[N,C]=h.useState(!1),[O,E]=h.useState(null),[D,P]=h.useState([]),[G,F]=h.useState(!1),[J,$]=h.useState(""),[ee,oe]=h.useState({}),[ce,pe]=h.useState(!1),[Ee,Ae]=h.useState(null),[_e,ue]=h.useState(""),[q,L]=h.useState(""),[W,Z]=h.useState(!1),z=h.useRef(null),de=h.useMemo(()=>bf(f.filter(se=>!String((se==null?void 0:se.id)||"").trim().endsWith("_uat"))),[f]),V=h.useMemo(()=>bf(f.filter(se=>String((se==null?void 0:se.id)||"").trim().endsWith("_uat"))),[f]),j=r==="uat"?V:de,R=h.useCallback(async()=>{if(s){y(!0),x("");try{const se=await a.list_processes();m(!!(se!=null&&se.enabled));const be=Array.isArray(se==null?void 0:se.processes)?se.processes:[];p(be)}catch(se){x(String((se==null?void 0:se.message)||se||"Failed to list processes"))}finally{y(!1)}}},[a,s]),U=h.useCallback(async()=>{if(s){F(!0),$("");try{const se=await a.list_process_env_vars();E(!!(se!=null&&se.enabled));const be=Array.isArray(se==null?void 0:se.vars)?se.vars:[];P(be);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]),le=h.useCallback(async()=>{if(!s)return;const se=Ee;if(se){Z(!0);try{const be=await a.process_log_tail(String(se.id||""),{max_bytes:16e4}),ge=String((be==null?void 0:be.content)||""),qe=typeof(be==null?void 0:be.bytes)=="number"?Number(be.bytes):0,Je=!!(be!=null&&be.truncated),ie=String((be==null?void 0:be.log_relpath)||"");ue(ge),L(`${qe.toLocaleString()} bytes${Je?" (tail)":""}${ie?` • ${ie}`:""}`)}catch(be){ue(""),L(String((be==null?void 0:be.message)||be||"Failed to read logs"))}finally{Z(!1)}}},[a,s,Ee]),ae=h.useCallback(async se=>{Ae(se),pe(!0)},[]),M=h.useCallback(()=>{pe(!1),Ae(null),ue(""),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"&&U()},[s,r,U]),h.useEffect(()=>{if(s&&ce)return le(),z.current&&window.clearInterval(z.current),z.current=window.setInterval(()=>{a.is_backing_off()||le()},1500),()=>{z.current&&window.clearInterval(z.current),z.current=null}},[s,ce,le]);const ye=h.useRef(!1),[xe,Oe]=h.useState(!1);async function Fe(se,be){if(!ye.current){ye.current=!0,Oe(!0),x("");try{be==="start"?await a.start_process(se.id):be==="stop"?await a.stop_process(se.id):be==="restart"?await a.restart_process(se.id):be==="redeploy"&&await a.redeploy_process(se.id),await R()}catch(ge){x(String((ge==null?void 0:ge.message)||ge||`Failed to ${be}`))}finally{ye.current=!1,Oe(!1)}}}async function Ze(se){const be=String(se||"").trim();if(be){$("");try{const ge=String((ee==null?void 0:ee[be])??""),qe=await a.update_process_env_vars({set:{[be]:ge}});E(!!(qe!=null&&qe.enabled)),P(Array.isArray(qe==null?void 0:qe.vars)?qe.vars:[]),oe(ie=>({...ie||{},[be]:""}));const Je=String((qe==null?void 0:qe.error)||"").trim();Je&&$(Je)}catch(ge){$(String((ge==null?void 0:ge.message)||ge||"Failed to set env var"))}}}async function he(se){const be=String(se||"").trim();if(be){$("");try{const ge=await a.update_process_env_vars({unset:[be]});E(!!(ge!=null&&ge.enabled)),P(Array.isArray(ge==null?void 0:ge.vars)?ge.vars:[]),oe(Je=>({...Je||{},[be]:""}));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=O===null?"…":O?"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 ${O===!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 ${G?"is_loading":""}`,onClick:()=>void U(),disabled:!s||G,children:[e.jsx(at,{name:"refresh",size:16}),G?"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"&&O===!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"&&J?e.jsx("div",{className:"page_error mono",children:J}):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 be=String(se.id||"").trim(),ge=String(se.label||be).trim()||be,qe=cv(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()):[],we=fe.includes("start"),K=fe.includes("stop"),ke=fe.includes("restart"),Ye=fe.includes("redeploy"),Y=fe.includes("logs"),A=typeof(se==null?void 0:se.pid)=="number"?Number(se.pid):null,X=String((se==null?void 0:se.url)||"").trim(),Se=String((se==null?void 0:se.description)||"").trim(),Le=String((se==null?void 0:se.last_error)||"").trim(),Ge=typeof(se==null?void 0:se.exit_code)=="number"?Number(se.exit_code):null,tt=[];A&&tt.push(`pid ${A}`),Ge!==null&&tt.push(`exit ${Ge}`);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:be}),dt?e.jsx("span",{className:"entity_card_sub mono",children:dt}):null]}),Se?e.jsx("div",{className:"entity_card_sub mono",children:$u(Se,220)}):null,X?e.jsx("div",{className:"entity_card_sub mono",children:ie?e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:X}):e.jsx("span",{className:"mono",children:X})}):null,Le?e.jsx("div",{className:"page_error mono",children:$u(Le,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[we?e.jsx("button",{className:"btn primary",onClick:()=>void Fe(se,"start"),disabled:_||xe,children:"Start"}):null,K?e.jsx("button",{className:"btn danger",onClick:()=>void Fe(se,"stop"),disabled:_||xe,children:"Stop"}):null,ke?e.jsx("button",{className:"btn",onClick:()=>void Fe(se,"restart"),disabled:_||xe,children:"Restart"}):null,Ye?e.jsx("button",{className:"btn",onClick:()=>void Fe(se,"redeploy"),disabled:_||xe,children:"Redeploy"}):null,Y?e.jsx("button",{className:"btn",onClick:()=>void ae(se),disabled:_,children:"Logs"}):null]})]},be)})]})]}):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:D.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:[D.map(se=>{const be=String((se==null?void 0:se.key)||"").trim();if(!be)return null;const ge=String((se==null?void 0:se.label)||be).trim()||be,qe=String((se==null?void 0:se.description)||"").trim(),Je=String((se==null?void 0:se.source)||"").trim(),ie=!!(se!=null&&se.secret),fe=String((se==null?void 0:se.updated_at)||"").trim(),we=uv(Je),K=String((ee==null?void 0:ee[be])??"");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 ${we.cls}`,children:we.label}),e.jsx("span",{className:"chip mono muted",children:be})]}),qe?e.jsx("div",{className:"entity_card_sub mono",children:$u(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:K,onChange:ke=>oe(Ye=>({...Ye||{},[be]:String(ke.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 Ze(be),disabled:G,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void he(be),disabled:G,children:"Unset"})]})]},`env:${be}`)}),D.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,ce&&Ee?e.jsxs(qa,{open:ce,title:`${String(Ee.label||Ee.id||"logs").trim()||"Logs"}`,onClose:M,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 le(),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(_e||"")}catch{}},disabled:!_e,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:_e||"(no logs yet)"})]}):null]})})}function wf(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function vl(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Eu(a){const s=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return s.length<=1?s[0]||"":s}function mv(a){const s=a.gateway,[r,l]=h.useState([]),[c,m]=h.useState(""),[f,p]=h.useState(""),[_,y]=h.useState(""),[b,x]=h.useState("7d"),[N,C]=h.useState("unread"),[O,E]=h.useState(25),[D,P]=h.useState(!1),[G,F]=h.useState(!1),[J,$]=h.useState(!1),[ee,oe]=h.useState(!1),[ce,pe]=h.useState(""),[Ee,Ae]=h.useState(""),[_e,ue]=h.useState(""),[q,L]=h.useState([]),[W,Z]=h.useState(""),[z,de]=h.useState(null),[V,j]=h.useState(!1),[R,U]=h.useState(""),[le,ae]=h.useState(""),[M,ye]=h.useState(""),[xe,Oe]=h.useState(""),[Fe,Ze]=h.useState(""),he=a.enabled,Re=h.useMemo(()=>(Array.isArray(r)?r:[]).map(X=>({account:String((X==null?void 0:X.account)||"").trim(),can_read:(X==null?void 0:X.can_read)!==!1,can_send:(X==null?void 0:X.can_send)!==!1,label:""})).filter(X=>!!X.account),[r]),Pe=h.useMemo(()=>{const A=String(f||"").trim();return A&&Re.find(X=>X.account===A)||null},[Re,f]),se=!!(Pe!=null&&Pe.can_read),be=!!(Pe!=null&&Pe.can_send),ge=h.useMemo(()=>Re.map(A=>{const X=A.can_read?A.can_send?"":" (read-only)":" (send-only)";return{...A,label:`${A.account}${X}`}}),[Re]);async function qe(){if(he){pe(""),P(!0);try{const A=await s.email_list_accounts();l(Array.isArray(A==null?void 0:A.accounts)?A.accounts:[]),m(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([]),m("")}finally{P(!1)}}}h.useEffect(()=>{qe()},[he]),h.useEffect(()=>{if(!he)return;const A=String(f||"").trim();if(A&&Re.some(Se=>Se.account===A))return;const X=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(X&&Re.some(Se=>Se.account===X)){p(X);return}if(c&&Re.some(Se=>Se.account===c)){p(c);return}Re.length&&p(Re[0].account)},[he,f,c,Re]),h.useEffect(()=>{const A=String(f||"").trim();A&&localStorage.setItem("abstractcontinuum_email_account",A)},[f]);async function Je(){if(!he)return;const A=String(f||"").trim();if(A){if(!se){pe("Selected account is not allowed to read email."),L([]),Z(""),de(null);return}pe(""),F(!0);try{const X=await s.email_list_messages({account:A,mailbox:String(_||"").trim()||void 0,since:String(b||"").trim()||void 0,status:N,limit:O}),Se=Array.isArray(X==null?void 0:X.messages)?X.messages:[];L(Se);const Le=String(W||"").trim();Le&&!Se.some(Ge=>String((Ge==null?void 0:Ge.uid)||"").trim()===Le)&&(Z(""),de(null))}catch(X){pe(String((X==null?void 0:X.message)||X||"Failed to list emails")),L([]),Z(""),de(null)}finally{F(!1)}}}h.useEffect(()=>{he&&String(f||"").trim()&&Je()},[he,f]);async function ie(A){if(!he)return;const X=String(f||"").trim(),Se=String(A||"").trim();if(!(!X||!Se)&&se){Z(Se),de(null),Ae(""),$(!0);try{const Le=await s.email_read_message(Se,{account:X,mailbox:String(_||"").trim()||void 0,max_body_chars:2e4});de(Le)}catch(Le){Ae(String((Le==null?void 0:Le.message)||Le||"Failed to read email"))}finally{$(!1)}}}function fe(A){ue(""),U(String((A==null?void 0:A.to)||"").trim()),ae(""),ye(""),Oe(String((A==null?void 0:A.subject)||"").trim()),Ze(String((A==null?void 0:A.body)||"")),j(!0)}function we(){if(!z)return;const A=String((z==null?void 0:z.from)||"").trim(),X=String((z==null?void 0:z.subject)||"").trim(),Se=X.toLowerCase().startsWith("re:")?X:`Re: ${X||"(no subject)"}`,Le=String((z==null?void 0:z.body_text)||"").trim(),Ge=`
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
On ${wf((z==null?void 0:z.date)||"")}, ${A} wrote:
|
|
89
|
+
|
|
90
|
+
${Le}`;fe({to:A,subject:Se,body:Ge})}async function K(){if(!he||ee)return;const A=String(f||"").trim();if(A){if(!be){ue("Selected account is not allowed to send email.");return}ue(""),oe(!0);try{const X=Eu(R);if(!X)throw new Error("to is required");const Se=String(xe||"").trim();if(!Se)throw new Error("subject is required");const Le=String(Fe||"").trim();if(!Le)throw new Error("body is required");await s.email_send({account:A,to:X,subject:Se,body_text:Le,cc:Eu(le),bcc:Eu(M)}),j(!1),U(""),ae(""),ye(""),Oe(""),Ze(""),await Je()}catch(X){ue(String((X==null?void 0:X.message)||X||"Failed to send email"))}finally{oe(!1)}}}const ke=h.useMemo(()=>{const A=String(W||"").trim();return A&&q.find(X=>String((X==null?void 0:X.uid)||"").trim()===A)||null},[q,W]),Ye=String((z==null?void 0:z.body_text)||"").trim()||String((z==null?void 0:z.body_html)||"").trim(),Y=String((z==null?void 0:z.body_text)||"").trim()?"Body (text)":String((z==null?void 0:z.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:f,onChange:A=>p(String(A.target.value||"")),disabled:!he||D,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:!he||D,children:D?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void Je(),disabled:!he||G||!String(f||"").trim()||!se,children:G?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>fe(),disabled:!he||!String(f||"").trim()||!be,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(O),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 Je(),disabled:!he||G||!String(f||"").trim()||!se,children:"Apply"})})]}),ce?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ce}):null,e.jsx("div",{className:"inbox_list",children:q.length?q.map((A,X)=>{const Se=String((A==null?void 0:A.uid)||"").trim(),Le=!!Se&&Se===String(W||"").trim(),Ge=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 ${Le?"active":""}`,onClick:()=>void ie(Se),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:vl(Ge,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:vl(tt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[vl(dt,36)||"(date?)"," • uid ",vl(Se,10)]})]},Se||`idx:${X}`)}):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?J?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):Ee?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ee}):z?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((z==null?void 0:z.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((z==null?void 0:z.account)||"").trim()||f}),e.jsx("span",{className:"pill muted",children:String((z==null?void 0:z.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",vl(String((z==null?void 0:z.uid)||W),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>dn(String((z==null?void 0:z.message_id)||"")),disabled:!String((z==null?void 0:z.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:()=>we(),disabled:!be||!String((z==null?void 0:z.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((z==null?void 0:z.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((z==null?void 0:z.to)||"").trim()||"(to?)"})]}),String((z==null?void 0:z.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((z==null?void 0:z.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:wf(String((z==null?void 0:z.date)||(ke==null?void 0:ke.date)||"").trim())||String((z==null?void 0:z.date)||(ke==null?void 0:ke.date)||"").trim()||"(date?)"})]}),Array.isArray(z==null?void 0:z.attachments)&&z.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:z.attachments.map((A,X)=>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)||""}:${X}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:Y}),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:Ye||"(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(f||"").trim()||"account"})`,onClose:()=>{ee||j(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[_e?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:_e}):null,e.jsx("button",{className:"btn",onClick:()=>j(!1),disabled:ee,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void K(),disabled:ee,children:ee?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:R,onChange:A=>U(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:le,onChange:A=>ae(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:M,onChange:A=>ye(String(A.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:xe,onChange:A=>Oe(String(A.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Fe,onChange:A=>Ze(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 jf(a){const s=String(a||"").trim();if(!s)return"";const r=s.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Bo(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function _i(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function fv(a){const s=a.gateway,r=!!a.enable_triage,[l,c]=h.useState(r?"messages":"email"),[m,f]=h.useState([]),[p,_]=h.useState([]),[y,b]=h.useState([]),[x,N]=h.useState(!1),[C,O]=h.useState(""),[E,D]=h.useState(null),[P,G]=h.useState(""),[F,J]=h.useState(!1),[$,ee]=h.useState(""),[oe,ce]=h.useState("pending"),[pe,Ee]=h.useState(null),[Ae,_e]=h.useState(""),[ue,q]=h.useState(null),[L,W]=h.useState(""),[Z,z]=h.useState(!1),[de,V]=h.useState(!1),[j,R]=h.useState(""),[U,le]=h.useState(""),ae=!!U,[M,ye]=h.useState(""),[xe,Oe]=h.useState(""),[Fe,Ze]=h.useState(""),[he,Re]=h.useState(!1),Pe=a.gateway_connected;h.useEffect(()=>{!r&&l!=="email"&&c("email")},[r,l]);const se=h.useMemo(()=>l==="bugs"?m:l==="features"?p:[],[l,m,p]);h.useEffect(()=>{l==="email"&&(O(""),N(!1))},[l]);async function be(){const Y=await s.list_bug_reports();f(Array.isArray(Y==null?void 0:Y.items)?Y.items:[])}async function ge(){const Y=await s.list_feature_requests();_(Array.isArray(Y==null?void 0:Y.items)?Y.items:[])}async function qe(){const Y=await s.list_triage_decisions({status:oe||void 0,limit:500}),A=Array.isArray(Y==null?void 0:Y.decisions)?Y.decisions:[];b(A),pe&&!A.some(X=>X.decision_id===pe.decision_id)&&(Ee(null),_e(""),q(null),W(""))}async function Je(){if(Pe&&r&&l!=="email"){O(""),N(!0);try{l==="bugs"?await be():l==="features"?await ge():await qe()}catch(Y){O(String((Y==null?void 0:Y.message)||Y||"Refresh failed"))}finally{N(!1)}}}h.useEffect(()=>{Je()},[l,Pe,oe,r]);async function ie(Y){D(Y),G(""),ee(""),J(!0);try{if(Y.report_type==="bug"){const A=await s.get_bug_report_content(Y.filename);G(String((A==null?void 0:A.content)||""))}else{const A=await s.get_feature_request_content(Y.filename);G(String((A==null?void 0:A.content)||""))}}catch(A){ee(String((A==null?void 0:A.message)||A||"Failed to load report"))}finally{J(!1)}}async function fe(Y){Ee(Y),_e(""),q(null),W("");const A=jf(Y.report_relpath);if(A)try{if(Y.report_type==="bug"){const X=await s.get_bug_report_content(A);_e(String((X==null?void 0:X.content)||""))}else if(Y.report_type==="feature"){const X=await s.get_feature_request_content(A);_e(String((X==null?void 0:X.content)||""))}}catch(X){W(String((X==null?void 0:X.message)||X||"Failed to load report"))}}async function we(Y){W(""),q(null);const A=String(Y.draft_relpath||"").trim();if(!A)return;const X=jf(A);if(X)try{const Se=await s.backlog_content("proposed",X);q(Se)}catch(Se){W(String((Se==null?void 0:Se.message)||Se||"Failed to load draft (is repo root configured on gateway?)"))}}async function K(Y,A){if(pe&&!Z){W(""),z(!0);try{const X=await s.apply_triage_decision(pe.decision_id,{action:Y,defer_days:A??null});await qe();const Se=String(oe||"").trim().toLowerCase(),Le=String((X==null?void 0:X.status)||"").trim().toLowerCase();if(!(!Se||Se===Le))Ee(null),_e(""),q(null);else if(Ee(X),String(X.draft_relpath||"").trim())try{await we(X)}catch{}}catch(X){W(String((X==null?void 0:X.message)||X||"Decision action failed"))}finally{z(!1)}}}async function ke(){if(!de){O(""),V(!0);try{const Y=await s.triage_run({write_drafts:!1,enable_llm:!1});R(`Scanned ${(Y==null?void 0:Y.reports)??0} report(s); updated ${(Y==null?void 0:Y.updated_decisions)??0} decision(s).`),await qe()}catch(Y){O(String((Y==null?void 0:Y.message)||Y||"Triage failed"))}finally{V(!1)}}}h.useEffect(()=>{ae&&(Ze(""),Oe(""),Re(!1),ye(String(a.default_session_id||"").trim()))},[ae,a.default_session_id]);async function Ye(){var Y,A;if(U&&!he){Ze(""),Re(!0);try{const X=String(M||"").trim();if(!X)throw new Error("session_id is required");const Se=String(xe||"").trim();if(!Se)throw new Error("description is required");const Le={session_id:X,description:Se,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(((Y=globalThis==null?void 0:globalThis.navigator)==null?void 0:Y.userAgent)||""),url:String(((A=globalThis==null?void 0:globalThis.location)==null?void 0:A.href)||"")};if(U==="bug"){const Ge=await s.bug_report_create(Le),tt=String((Ge==null?void 0:Ge.filename)||"").trim();le(""),c("bugs");const dt=await s.list_bug_reports(),yt=Array.isArray(dt==null?void 0:dt.items)?dt.items:[];f(yt);const pt=yt.find(Tt=>Tt.filename===tt)||null;pt&&await ie(pt)}else{const Ge=await s.feature_report_create(Le),tt=String((Ge==null?void 0:Ge.filename)||"").trim();le(""),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(X){Ze(String((X==null?void 0:X.message)||X||"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:Y=>ce(String(Y.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 Je(),disabled:!Pe||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void ke(),disabled:!Pe||de,children:de?"Running…":"Run triage"})]}):l==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void Je(),disabled:!Pe||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>le("bug"),disabled:!Pe,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>le("feature"),disabled:!Pe,children:"File feature"})]}):null]}),l==="email"?e.jsx(mv,{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(Y=>{const A=(pe==null?void 0:pe.decision_id)===Y.decision_id,X=Array.isArray(Y.missing_fields)?Y.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${A?"active":""}`,onClick:()=>void fe(Y),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(Y.status||"").toLowerCase()}`,children:String(Y.status||"pending")}),e.jsx("span",{className:"mono",children:Y.report_type}),e.jsx("span",{className:"mono muted",children:_i(Y.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[X?`${X} missing`:"complete"," • ",Bo(Y.updated_at||Y.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:_i(Y.report_relpath||"",46)})]},Y.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(Y=>{const A=(E==null?void 0:E.filename)===Y.filename&&(E==null?void 0:E.report_type)===Y.report_type,X=String(Y.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${A?"active":""}`,onClick:()=>void ie(Y),children:[e.jsxs("div",{className:"inbox_item_title",children:[X?e.jsx("span",{className:`pill ${X}`,children:X}):null,e.jsx("span",{className:"mono",children:_i(Y.title||Y.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Bo(Y.created_at)||"(time?)"," • ",Y.session_id?_i(Y.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:Y.filename})]},Y.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:_i(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 we(pe),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void K("approve"),disabled:Z,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void K("defer",1),disabled:Z,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void K("defer",7),disabled:Z,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void K("reject"),disabled:Z,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[pe.updated_at?`updated ${Bo(pe.updated_at)}`:null,pe.created_at?`${pe.updated_at?" • ":""}created ${Bo(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(Y=>e.jsx("li",{children:Y},Y))}):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((Y,A)=>{const X=String((Y==null?void 0:Y.title)||(Y==null?void 0:Y.ref)||(Y==null?void 0:Y.kind)||"duplicate").trim(),Se=typeof(Y==null?void 0:Y.score)=="number"&&Number.isFinite(Y.score)?` (score ${Y.score.toFixed(2)})`:"";return e.jsxs("li",{children:[X,Se]},`${X}_${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)."})]})]}),ue?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(rs,{className:"md_doc",text:String(ue.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),Ae?e.jsx(rs,{className:"md_doc",text:Ae}):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:_i(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…"}):P?e.jsx(rs,{className:"md_doc",text:P}):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:ae,title:U==="bug"?"File bug report":"File feature request",onClose:()=>le(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>le(""),disabled:he,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Ye(),disabled:he,children:he?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:M,onChange:Y=>ye(Y.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:U==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:xe,onChange:Y=>Oe(Y.target.value),placeholder:U==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Fe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Fe}):null]})]})}const hv="/api/continuum/settings";async function wh(a){const s=await fetch(hv,{...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:"",m=new Error(c||`settings unavailable (HTTP ${s.status})`);throw m.status=s.status,m}return l}function pv(){return wh()}function _v(a,s){return wh({method:"PUT",body:JSON.stringify({[a]:s})})}const jh="abstractcontinuum_voice_override_v1",Tu={enabled:!1};function Ju(){try{const a=localStorage.getItem(jh);if(!a)return{...Tu};const s=JSON.parse(a);return!s||typeof s!="object"?{...Tu}:{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{...Tu}}}const Yu="abstractcontinuum:voice_override_changed";function gv(a){try{localStorage.setItem(jh,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(Yu))}catch{}}function kh(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 Sh(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={},m=Is(l.provider),f=Is(l.model),p=l.options,_=p&&typeof p=="object"?Is(p.voice):void 0;return m&&(c.provider=m),f&&(c.model=f),_&&(c.voice=_),c}function vv(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 yl={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function yv(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 m=String(r.provider||"").trim(),f=String(r.id||r.voice||r.name||"").trim();if(!f)continue;const p=m||"*";(s[p]||(s[p]=[])).push(f)}for(const r of Object.keys(s))s[r]=[...new Set(s[r])];return s}function Xu(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 Au(a){const s={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,l]of Object.entries(a)){const c=Xu(l);c.length&&(s[String(r)]=c)}return s}function xv(a){const{gateway:s,gateway_connected:r}=a,[l,c]=h.useState(()=>Ju()),[m,f]=h.useState(yl),[p,_]=h.useState(!1),[y,b]=h.useState(""),x=h.useRef(null),N=h.useCallback(F=>{c(J=>{const $={...J,...F};return gv($),$})},[]);h.useEffect(()=>{if(!r){f(yl);return}if(typeof(s==null?void 0:s.voice_voices)!="function"){f(yl);return}let F=!0;f($=>({...$,loading:!0,error:""}));let J;try{J=s.voice_voices()}catch($){f({...yl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")});return}return J.then($=>{if(!F)return;const ee=[...new Set([...Xu($==null?void 0:$.providers),...Xu($==null?void 0:$.tts_providers)])];f({loading:!1,error:"",providers:ee,models_by_provider:Au($==null?void 0:$.tts_models_by_provider),profiles_by_provider:Au($==null?void 0:$.tts_profiles_by_provider),voices_by_provider:Au($==null?void 0:$.tts_voices_by_provider),cloned_by_provider:yv($==null?void 0:$.items)})}).catch($=>{F&&f({...yl,error:String(($==null?void 0:$.message)||$||"voice catalog unavailable")})}),()=>{F=!1}},[s,r]);const C=l.provider||"",O=C&&m.models_by_provider[C]?m.models_by_provider[C]:[],E=C&&m.voices_by_provider[C]?m.voices_by_provider[C]:[],D=C&&m.profiles_by_provider[C]?m.profiles_by_provider[C]:[],P=[...C&&m.cloned_by_provider[C]?m.cloned_by_provider[C]:[],...m.cloned_by_provider["*"]||[]];async function G(){if(!(p||!r)){_(!0),b("");try{const F=await ad("abstractcontinuum_team_voice");let J={};if(typeof s.capability_defaults=="function")try{J=Sh(await s.capability_defaults())}catch{J={}}const $=await s.voice_tts(F,{text:"This is the voice AbstractContinuum will use to read your messages.",...J,...kh(l),timeout_s:30}),ee=$==null?void 0:$.audio_artifact,oe=ee&&typeof ee=="object"?String(ee.$artifact||"").trim():"";if(!oe)throw new Error("no audio returned");const ce=await s.download_run_artifact_content(F,oe),pe=URL.createObjectURL(ce);if(x.current)try{x.current.pause()}catch{}const Ee=x.current;if(Ee){try{Ee.pause()}catch{}const _e=Ee.src;_e.startsWith("blob:")&&URL.revokeObjectURL(_e)}const Ae=new Audio(pe);x.current=Ae,Ae.onended=()=>{URL.revokeObjectURL(pe),b("")};try{await Ae.play(),b("Playing…")}catch(_e){b(String((_e==null?void 0:_e.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((_e==null?void 0:_e.message)||_e).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"]}),m.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",m.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,m.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(Uo,{value:C,options:m.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(Uo,{value:l.model||"",options:O,placeholder:"default",onChange:F=>N({model:F})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(Uo,{value:l.profile||"",options:D,placeholder:"default",onChange:F=>N({profile:F})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(Uo,{value:l.voice||"",options:[...P,...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 G(),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 Uo(a){const s=Kt.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 bv=["minimal","low","medium","high","xhigh"];function wv(a){const{gateway:s,connected:r,model:l,value:c,onChange:m}=a,[f,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(O=>{if(C)return;const E=O!=null&&O.capabilities&&typeof O.capabilities=="object"?O.capabilities:{},D=E.thinking_support,P=Array.isArray(E.reasoning_levels)?E.reasoning_levels.map(G=>String(G)):[];p(D===!0?{state:"supported",levels:P}:D===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{C||p({state:"unknown",levels:[]})}),()=>{C=!0}},[l,r]),!String(l||"").trim())return null;const b=f.state==="unsupported"||f.state==="unknown"&&!_||f.state==="loading",x=f.state==="supported"&&f.levels.length?f.levels:f.state==="unknown"&&_?[...bv]:[];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=>m(String(N.target.value||"")),disabled:b,title:f.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":f.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":f.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:f.state==="unsupported"?"none — this model doesn't reason":f.state==="loading"?"checking…":f.state==="unknown"&&!_?"unknown — no served facts":"gateway default"}),x.map(N=>e.jsx("option",{value:N,children:N},N))]}),f.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,f.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||m("")}}),"set anyway (I know this model reasons)"]}):null]})}function jv(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:m=>c(m.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,m]=r[s]||[s,"muted",""];return e.jsx("span",{className:`chip mono ${c}`,title:m,"data-testid":"hub_seat_source",children:l})}function Sv(){var O;const[a,s]=h.useState(null),[r,l]=h.useState(""),[c,m]=h.useState(""),[f,p]=h.useState(!1),[_,y]=h.useState("");h.useEffect(()=>{let E=!1;return pv().then(D=>{var P;E||(s(D),m(String(((P=D.settings.hub_seat)==null?void 0:P.value)??"")))}).catch(D=>{E||l(String((D==null?void 0:D.message)||D))}),()=>{E=!0}},[]);async function b(E){var D;p(!0),y("");try{const P=await _v("hub_seat",E);s(P),m(String(((D=P.settings.hub_seat)==null?void 0:D.value)??""))}catch(P){y(String((P==null?void 0:P.message)||P||"Save refused"))}finally{p(!1)}}const x=a==null?void 0:a.settings.hub_seat,N=String((x==null?void 0:x.value)??""),C=!!((O=a==null?void 0:a.writable)!=null&&O.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=>m(E.target.value),placeholder:"your seat",disabled:f}),e.jsx("button",{className:"btn primary",disabled:f||!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:f,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 Nv(a){var _e,ue;const{gateway:s,gateway_connected:r,settings:l,set_settings:c}=a,m=(ue=(_e=a.connection)==null?void 0:_e.gateway)==null?void 0:ue.principal,[f,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),[O,E]=h.useState(null),[D,P]=h.useState([]),[G,F]=h.useState(""),[J,$]=h.useState(!1),[ee,oe]=h.useState(0);async function ce(q){if(!J){$(!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 Z=await s.backlog_exec_config(),z=!!(Z!=null&&Z.runner_enabled),de=!!(Z!=null&&Z.runner_alive),V=(Z==null?void 0:Z.can_execute)===!0;L.exec_pipeline=V?"on":z||de?"degraded":"off",L.exec_detail=V?"":z?de?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",L.executor=String((Z==null?void 0:Z.executor)||"").trim()}catch{L.exec_pipeline=null}try{const Z=await s.admin_runtime_config();if(Z&&typeof Z=="object"){q||(y(Z),L.process_manager=pi(Z.process_manager),L.backlog_root=((W=Z.triage_repo_root)==null?void 0:W.available)!==void 0?!!Z.triage_repo_root.available:pi(Z.triage_repo_root),p(L));return}}catch{}try{const Z=await s.list_processes();L.process_manager=!!(Z!=null&&Z.enabled)}catch{L.process_manager=null}try{await s.backlog_template(),L.backlog_root=!0}catch(Z){L.backlog_root=yi(Z)?!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:[]),P(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:[],Z=[];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 U of R){if((U==null?void 0:U.deprecated)===!0||!(Array.isArray(U==null?void 0:U.interfaces)?U.interfaces:[]).some(M=>String(M||"").trim().length>0))continue;const ae=String((U==null?void 0:U.name)||"").trim();Z.push({id:j,name:ae?`${j} · ${ae}`:j,description:String((U==null?void 0:U.description)||"").trim()||void 0})}}const z=new Set,de=Z.filter(V=>z.has(V.id)?!1:(z.add(V.id),!0));de.sort((V,j)=>V.name.localeCompare(j.name)),q||x(de)}catch{q||x(null)}})(),()=>{q=!0}},[s,r,ee]);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 Ee(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 Ae(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."]},[Z,z,de]=W[L]||[L,"muted",""];return e.jsx("span",{className:`chip mono ${z}`,title:de,"data-testid":"source_chip",children:Z})}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(Ap,{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(wv,{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 Z=W.target.value;Z==="__custom__"?C(!0):(C(!1),c(z=>({...z,backlog_advisor_agent:Z})))},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(Z=>({...Z,backlog_advisor_agent:String(W.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(xv,{gateway:s,gateway_connected:r}),e.jsx(Sv,{}),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:[m!=null&&m.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:m.user_id}),m.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):m.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,Z,z,de,V,j,R,U,le;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"}),Ee(f.backlog_root,"available","not available"),Ae((W=_==null?void 0:_.triage_repo_root)==null?void 0:W.source),e.jsxs("div",{className:"admin_row_action",children:[q&&((Z=_==null?void 0:_.triage_repo_root)!=null&&Z.default_path)&&_l(_==null?void 0:_.triage_repo_root)!==_.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:J,onClick:()=>{var ae;return void ce({triage_repo_root:((ae=_==null?void 0:_.triage_repo_root)==null?void 0:ae.default_path)||null})},title:_.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,q?e.jsx(jv,{current:_l(_==null?void 0:_.triage_repo_root),busy:J,on_apply:ae=>void ce({triage_repo_root:ae})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((z=_==null?void 0:_.triage_repo_root)==null?void 0:z.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",_l(_==null?void 0:_.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:_l(_==null?void 0:_.triage_repo_root)})]}):null,((de=_==null?void 0:_.triage_repo_root)==null?void 0:de.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"}),f.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${f.exec_pipeline==="on"?"ok":"warn"}`,children:f.exec_pipeline}),Ae((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:J,onClick:()=>void ce({backlog_exec_runner:pi(_==null?void 0:_.backlog_exec_runner)!==!0}),children:pi(_==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.",f.exec_detail?e.jsxs(e.Fragment,{children:[" — ",f.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"}),f.executor&&f.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:f.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),Ae((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:_l(_==null?void 0:_.executor),disabled:J,onChange:ae=>void ce({executor:String(ae.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:L.map(ae=>e.jsxs("option",{value:ae.id,disabled:ae.available===!1,children:[ae.display||ae.id,ae.available===!1?" (unavailable)":""]},ae.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"}),Ee(f.process_manager,"enabled","disabled"),Ae((U=_==null?void 0:_.process_manager)==null?void 0:U.source),e.jsx("div",{className:"admin_row_action",children:q?e.jsx("button",{className:"btn",disabled:J,onClick:()=>void ce({process_manager:pi(_==null?void 0:_.process_manager)!==!0}),children:pi(_==null?void 0:_.process_manager)===!0?"Disable":"Enable"}):null})]}),e.jsx("div",{className:"admin_row_detail",children:((le=_==null?void 0:_.process_manager)==null?void 0:le.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),G?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:G}):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:O?`server-side — ${O.length} registered home${O.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?O===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:[...O].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))})]})}),D.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 Cv=/^(```+|~~~+)\s*mermaid\s*$/i;function $v(a){const s=String(a||"").split(`
|
|
91
|
+
`),r=[];let l=[],c=0;for(;c<s.length;){const m=s[c].match(Cv);if(!m){l.push(s[c]),c+=1;continue}const f=m[1];let p=-1;for(let _=c+1;_<s.length;_++){const y=s[_].trimEnd();if(y.startsWith(f[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(y)&&y[0]===f[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 Ev="modulepreload",Tv=function(a){return"/"+a},kf={},Av=function(s,r,l){let c=Promise.resolve();if(r&&r.length>0){let f=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=f(r.map(y=>{if(y=Tv(y),y in kf)return;kf[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":Ev,b||(N.as="script"),N.crossOrigin="",N.href=y,_&&N.setAttribute("nonce",_),document.head.appendChild(N),b)return new Promise((C,O)=>{N.addEventListener("load",C),N.addEventListener("error",()=>O(new Error(`Unable to preload CSS for ${y}`)))})}))}function m(f){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=f,window.dispatchEvent(p),!p.defaultPrevented)throw f}return c.then(f=>{for(const p of f||[])p.status==="rejected"&&m(p.reason);return s().catch(m)})};let Ru=null;function Rv(){return Ru||(Ru=Av(()=>import("./mermaid.core-CkQqPHPZ.js").then(a=>a.bp),[]).then(a=>{const s=a.default||a;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),s})),Ru}let Lv=0;function Mv(a){const s=h.useRef(null),[r,l]=h.useState("");return h.useEffect(()=>{let c=!0;return l(""),Rv().then(async m=>{const f=`af_mermaid_${Lv+=1}`,{svg:p}=await m.render(f,a.text);c&&s.current&&(s.current.innerHTML=p)}).catch(m=>{c&&l(String((m==null?void 0:m.message)||m||"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 zv=400;function Pv(a){const s=new Map;for(const c of a)s.set(c.id,c);const r=c=>{let m=c,f=!1;const p=new Set([m.id]);for(let _=0;_<zv;_++){const y=String(m.reply_to||"");if(!y)break;const b=s.get(y);if(!b){f=m.id===c.id||f;break}if(p.has(b.id))break;p.add(b.id),m=b}return{root:m,orphan:f&&m.id===c.id}},l=new Map;for(const c of[...a].sort((m,f)=>(m.seq||0)-(f.seq||0))){const{root:m,orphan:f}=r(c);let p=l.get(m.id);p||(p={root:m,replies:[],orphan:m.id===c.id?f:!1,last_seq:m.seq||0},l.set(m.id,p)),c.id!==m.id&&(p.replies.push(c),p.last_seq=Math.max(p.last_seq,c.seq||0))}return[...l.values()].sort((c,m)=>c.last_seq-m.last_seq||(c.root.seq||0)-(m.root.seq||0))}const Sf=[{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 Nh(a,s,r){var c,m,f,p,_;if(a.retracted===!0)return s==="all"?!0:s==="unread"?!!((c=r.unread_seqs)!=null&&c.has(a.seq)||(m=r.unread_snapshot_seqs)!=null&&m.has(a.seq)):!1;const l=String(a.status||"").toLowerCase();switch(s){case"all":return!0;case"unread":return!!((f=r.unread_seqs)!=null&&f.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 Nf(a,s,r){return s==="all"?a:a.filter(l=>[l.root,...l.replies].some(c=>Nh(c,s,r)))}function Iv(a,s,r){return Nh(a,s,r)}function Dv(a){const s={},r={};for(const l of a){const c=String(l.channel||"");if(!c)continue;const m=Number(l.seq);if(Number.isFinite(m)){const f=s[c]||(s[c]=new Set);if(f.has(m))continue;f.add(m)}r[c]=(r[c]||0)+1}return r}function Ov(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 Fv(a,s){const r={};for(const l of a){const c=String(l.channel||""),m=Number(l.seq);if(!c||!Number.isFinite(m))continue;const f=String(l.status||"").toLowerCase(),p=Array.isArray(l.to)&&s?l.to.includes(s):!1;(f==="open"||f==="blocked"||(f==="reply"||f==="fyi")&&p)&&(r[c]||(r[c]=new Set)).add(m)}return r}function qv(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);if(!l||!Number.isFinite(c))continue;const m=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||m==="interrupt")&&(s[l]||(s[l]=new Set)).add(c)}return s}function Bv(a,s){const r=s?s.replace(/\/+$/,"")+"/":"",l=new Map,c=[];for(const m of a){const f=String(m.path||"");if(!f.startsWith(r))continue;const p=f.slice(r.length);if(!p)continue;const _=p.indexOf("/");if(_===-1)c.push(m);else{const y=p.slice(0,_);l.set(y,(l.get(y)||0)+1)}}return{dirs:[...l.entries()].map(([m,f])=>({name:m,path:r+m,count:f})).sort((m,f)=>m.name.localeCompare(f.name)),leaves:c.sort((m,f)=>m.path.localeCompare(f.path))}}function Cf(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 Uv(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function Wv(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 m=s.get(c);(m===void 0||m!==String(l.sender||""))&&r.add(c)}return r}const Hv=/(?:^|[\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,Vv=4;function Gv(a){const s=[];for(const r of String(a||"").matchAll(Hv)){const l=r[1],c=r.index===void 0?-1:r.index,m=c>=0?String(a).slice(Math.max(0,c-12),c+1):"";if(!(m.includes("://")||m.includes("/api/"))&&(s.includes(l)||s.push(l),s.length>=Vv))break}return s}function Kv(a,s,r){var c,m;const l=a.split("/").pop()||a;if(s!=null&&s.has(a))return{kind:"fs",path:a,rewritten:!1};for(let f=0;f<r.length;f++)if(String(((c=r[f])==null?void 0:c.filename)||"")===a)return{kind:"attachment",attachment_index:f};if(s){const f=[];for(const p of s)(p===l||p.endsWith(`/${l}`))&&f.push(p);if(f.length===1)return{kind:"fs",path:f[0],rewritten:f[0]!==a}}for(let f=0;f<r.length;f++){const p=String(((m=r[f])==null?void 0:m.filename)||"");if(p&&(p===l||p.split("/").pop()===l))return{kind:"attachment",attachment_index:f}}return null}const $f=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function Lu(a){const s=[];for(const l of a.matchAll($f)){const c=l[1].toLowerCase();s.includes(c)||s.push(c)}return{title:a.replace($f," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:s}}function Mu(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 zu(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 Ef=400,Tf=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Af=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Qv(a){if(!a||a.length<Ef)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 m of c){if(/\n/.test(m)||m.length<Ef){r.push(m);continue}const f=m.split(/(`[^`\n]*`)/);let p=0;for(const _ of f)_.startsWith("`")||(p+=(_.match(Tf)||[]).length+(_.match(Af)||[]).length);if(p<2){r.push(m);continue}r.push(f.map(_=>_.startsWith("`")?_:_.replace(Tf,`$1
|
|
95
|
+
|
|
96
|
+
$2 `).replace(Af,`$1
|
|
97
|
+
|
|
98
|
+
`)).join(""))}}return r.join("")}const Jv=/https?:\/\/[^\s<>()[\]{}"'`]+/g,Yv=/\.(png|jpe?g|gif|webp)$/i;function Xv(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 Zv(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]*?(?:```|$))/),m=[];for(let f=0;f<c.length;f++){const p=c[f];if(p.startsWith("```")){m.push(p);continue}const _=p.split(/(`[^`\n]*`)/);for(let y=0;y<_.length;y++){const b=_[y];if(b.startsWith("`")){m.push(b);continue}m.push(b.replace(Jv,(x,N)=>{const C=b.slice(Math.max(0,N-2),N);if(C.endsWith("](")||C.endsWith("("))return x;const O=x.replace(/[.,;:!?]+$/,""),E=x.slice(O.length);let D="";try{D=new URL(O).pathname}catch{return x}const P=Xv(O,r),G=Yv.test(D),F=P.startsWith("/")||l!==""&&P.startsWith(l+"/");return G&&F?`${E}`:`[${O}](${P})${E}`}))}}return m.join("")}const ey=/^\/api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function ty(a){const s=a.trim();return s.startsWith("/api/")?/\s/.test(s)||s.includes("..")?!0:!ey.test(s):!1}function Sl(a){if(!a||!a.includes("/api/"))return a;const s=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(s,(r,l,c,m)=>ty(String(m))?"`"+(String(c||"").trim()||String(m)).replace(/`/g,"")+" (blocked link)`":r)}function md(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,sy=160;function Rf(a,s){var y,b,x,N;const r=ny,l=Math.max(500,Math.floor(r/2)),c=[...a].sort((C,O)=>(C.seq||0)-(O.seq||0)),m=[];for(const C of c){const O=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("; ")}`:"",D=(N=(x=C.data)==null?void 0:x.answers)!=null&&N.length?` answers=[${C.data.answers.join(",")}]`:"",P=C.reply_to?` reply_to=${C.reply_to}`:"";let G=`#${C.seq} [${C.sender}] (${C.status})${O}${P}${E}${D}
|
|
99
|
+
${C.title?`title: ${C.title}
|
|
100
|
+
`:""}${String(C.body||"").trim()}`;G.length>l&&(G=G.slice(0,l)+`
|
|
101
|
+
[#TRUNCATION: message #${C.seq} clamped to fit the context budget]`),m.push(G)}let f=0,p=m.reduce((C,O)=>C+O.length+2,0);for(;m.length>1&&p>r-sy;){const C=m.shift();p-=C.length+2,f++}return(f>0?`#TRUNCATION: the ${f} oldest message(s) were dropped to fit the context budget.
|
|
102
|
+
|
|
103
|
+
`:"")+m.join(`
|
|
104
|
+
|
|
105
|
+
`)}function ay(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 ry(a,s){const r=Array.from(String(a??"")),l=(s??[]).filter(f=>Array.isArray(f)&&f.length>=2&&Number.isFinite(f[0])&&Number.isFinite(f[1])&&f[0]>=0&&f[1]>0).sort((f,p)=>f[0]-p[0]),c=[];let m=0;for(const[f,p]of l){if(f>=r.length)break;const _=Math.max(f,m),y=Math.min(f+p,r.length);y<=_||(_>m&&c.push({text:r.slice(m,_).join(""),hit:!1}),c.push({text:r.slice(_,y).join(""),hit:!0}),m=y)}return m<r.length&&c.push({text:r.slice(m).join(""),hit:!1}),!c.length&&r.length&&c.push({text:r.join(""),hit:!1}),c}const Wo=[{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"}],iy=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(iy.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 ly({url:a,name:s}){const[r,l]=Kt.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 oy({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:$v(a.text||"").map((l,c)=>l.kind==="mermaid"?e.jsx(Mv,{text:l.text},c):e.jsx(rs,{className:"md_doc",text:Sl(l.text)},c))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(ly,{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 cy=Kt.memo(rs),uy=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Lf(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 Ch{constructor(s){this.value=s}}function Mf(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 m=c[1]+(c[2]||""),p=parseInt(c[3],10)+1;let _;if(p<=-4||p>16){const y=m.length>1?`${m[0]}.${m.slice(1)}`:m[0],b=p-1,x=(b<0?"-":"+")+String(Math.abs(b)).padStart(2,"0");_=`${y}e${x}`}else p<=0?_="0."+"0".repeat(-p)+m:p>=m.length?_=m+"0".repeat(p-m.length)+".0":_=m.slice(0,p)+"."+m.slice(p);return(s?"-":"")+_}function Zu(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof Ch){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Mf(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):Mf(a)}if(typeof a=="string")return Lf(a);if(Array.isArray(a))return"["+a.map(Zu).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Lf(r)+":"+Zu(a[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof a}`)}async function dy(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 my(a,s,r){const l={};for(const c of uy)c!=="channel"&&(l[c]=s[c]??null);return l.channel=r,typeof l.created_at=="number"&&(l.created_at=new Ch(l.created_at)),await dy(a+`
|
|
106
|
+
`+Zu(l))}async function fy(a){const s=a.channel;let r="",l=0,c=0,m=null,f="";for(const _ of a.turns){if(_.hash===null||_.hash===void 0){l>0&&m===null&&(m=_.seq),c+=1,r="";continue}const y=await my(r,_,s);y!==_.hash&&m===null&&(m=_.seq),r=_.hash,f=y,l+=1}const p=m===null&&String(a.head||"")!==f;return{ok:m===null&&!p,broken_at:m,head_mismatch:p,computed_head:f,hashed:l,legacy:c}}const hy=5e3,py=6,ma=200,_y=50,Ho=380,zf=240,Pf=2,gy=12,xl=8,If=16*1024*1024,vy=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Cl=256*1024;function yy(){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 Df(){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 Vo(a){return a.length<=Cl?a:a.slice(0,Cl)+`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
#TRUNCATION: preview clamped at ${On(Cl)} of ${On(a.length)} — download the file for the full content.`}function Pu(a,s){try{return JSON.stringify(a)===JSON.stringify(s)}catch{return!1}}function Iu(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],m=s[l];if(!m||c.size!==m.size)return!1;for(const f of c)if(!m.has(f))return!1}return!0}function On(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 $h="abstractcontinuum_team_drafts_v1";function xy(){try{const a=window.localStorage.getItem($h),s=a?JSON.parse(a):{};return s&&typeof s=="object"?s:{}}catch{return{}}}function bl(a){try{window.localStorage.setItem($h,JSON.stringify(a))}catch{}}const Go="agora/0.4";function wl(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 jl(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function Of(a){return{color:`hsl(${md(a)}, 60%, 55%)`}}function Ia(a){const s=md(a),r=s>=40&&s<=190?36:45;return{background:`hsl(${s}, 55%, ${r}%)`,color:"#fff"}}const vi=[{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."}],by=[{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."}],Ff={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(vi.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function kl(a){const s=vi.find(r=>r.id===a);return s?s.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function wy(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function jy(a){var aa,hr,si,ra,_s,$t;const s=a.gateway,r=!!a.gateway_connected,l=h.useMemo(()=>new dd,[]),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(te=>({role:te.role,content:te.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]),m=!!c,[f,p]=h.useState(""),[_,y]=h.useState(()=>Ju()),[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 ad("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=Sh(v))}).catch(()=>{u&&(C.current={})}),()=>{u=!1}},[s,r]),h.useEffect(()=>{const u=()=>y(Ju());return window.addEventListener(Yu,u),window.addEventListener("storage",u),()=>{window.removeEventListener(Yu,u),window.removeEventListener("storage",u)}},[]);const O=h.useMemo(()=>{const u=String(f||"").trim();if(!(!r||!s||!u))return v=>{const S=s.voice_stream_transport(u,{text:v,...C.current,...kh(N.current)});return m_({path:S.path,body:S.body,headers:S.headers})}},[s,r,f]),E=Gf({tts_stream:O,on_error:x});h.useEffect(()=>{if(!b)return;ge(b);const u=setTimeout(()=>x(""),6e3);return()=>clearTimeout(u)},[b]);const[D,P]=h.useState(null),G=h.useRef(null);h.useEffect(()=>{G.current=D},[D]);const[F,J]=h.useState(""),[$,ee]=h.useState(null),[oe,ce]=h.useState([]),[pe,Ee]=h.useState({}),[Ae,_e]=h.useState({}),[ue,q]=h.useState({}),[L,W]=h.useState({}),[Z,z]=h.useState(null),[de,V]=h.useState(""),j=h.useRef(0),R=h.useRef(!1),U=h.useRef(!1);async function le(){if(!R.current&&!(Date.now()-j.current<3e4)){j.current=Date.now();try{const u=await l.desk();z(v=>v==="loading"?v:u),u.rows.length&&!U.current&&Zt(v=>v!==""?v:(U.current=!0,"desk"))}catch(u){((u==null?void 0:u.status)===403||(u==null?void 0:u.status)===404)&&(R.current=!0)}}}async function ae(){z("loading"),V("");try{const u=await l.desk();z(u),j.current=Date.now(),R.current=!1}catch(u){z(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[M,ye]=h.useState(""),[xe,Oe]=h.useState([]),[Fe,Ze]=h.useState("all"),he=h.useRef(null),[Re,Pe]=h.useState(null),se=h.useRef(""),[be,ge]=h.useState(""),[qe,Je]=h.useState(!1),[ie,fe]=h.useState({}),[we,K]=h.useState({}),[ke,Ye]=h.useState({}),Y=h.useRef(new Set),A=h.useRef(0),[X,Se]=h.useState(""),[Le,Ge]=h.useState(""),[tt,dt]=h.useState([]),[yt,pt]=h.useState(!1),Tt=h.useRef(null),[qt,ze]=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`)},[X,M]);const[et,kt]=h.useState("fyi"),[ht,Qt]=h.useState(""),[je,Ce]=h.useState(""),[Me,mt]=h.useState(null),[_t,gt]=h.useState({}),[Xt,mn]=h.useState(""),Bt=h.useRef(xy()),Ba=h.useRef(""),[Qn,qn]=h.useState(!1),[ha,Er]=h.useState(!1),[bi,ot]=h.useState(""),[Ht,Jn]=h.useState(null),[Rt,Ua]=h.useState(null),[Al,wi]=h.useState({});function Tr(u,v){v.length&&wi(S=>{const w={...S},T=new Set(w[u]||[]);for(const te of v)T.add(te);return w[u]=T,w})}function ji(u,v){const S=new Set(v.map(w=>String(w.agent_id||"")).filter(Boolean));S.size&&wi(w=>{const T=w[u];if(!T||![...T].some(ve=>S.has(ve)))return w;const te=new Set([...T].filter(ve=>!S.has(ve))),B={...w};return te.size?B[u]=te:delete B[u],B})}const Wa=h.useRef(0),[Rl,Ar]=h.useState(""),[Lt,Ll]=h.useState(null),[Ha,Fs]=h.useState(""),[is,Rr]=h.useState(!1),[pa,Va]=h.useState(""),[fn,Ml]=h.useState([]);function Sn(){l.delegations().then(u=>{Ll(u),Fs("")}).catch(u=>{Ll([]);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 Zo(){if(!(!pa||!fn.length||is)){Rr(!0),Fs("");try{await l.set_delegation(pa,fn),Va(""),Ml([]),Sn()}catch(u){Fs(String((u==null?void 0:u.message)||u||"delegation failed"))}finally{Rr(!1)}}}async function ec(u){if(!is){Rr(!0),Fs("");try{await l.revoke_delegation(u),Sn()}catch(v){Fs(String((v==null?void 0:v.message)||v||"resign failed"))}finally{Rr(!1)}}}const[Bn,Yn]=h.useState(null),[qs,Xn]=h.useState(null),[Dt,sn]=h.useState(""),[Lr,ws]=h.useState(null),[Bs,Mr]=h.useState([]),[Pt,js]=h.useState(""),[zr,ct]=h.useState(""),[Pr,ki]=h.useState(""),[Ga,Si]=h.useState(!1),[Ni,Ka]=h.useState(""),[ks,Us]=h.useState({open:!1,name:"",is_private:!1}),[Vt,hn]=h.useState(!1),[Ss,ls]=h.useState({}),[St,Zt]=h.useState(""),[Un,Ir]=h.useState(null),[Ws,zl]=h.useState(""),[Wn,Qa]=h.useState("channel"),[Ja,Pl]=h.useState(""),[Hs,os]=h.useState(null),[Vs,Ya]=h.useState(""),[Ci,Il]=h.useState(""),[Gs,Zn]=h.useState(""),[_a,Dr]=h.useState(null),[es,Xa]=h.useState(""),[cs,ga]=h.useState(""),[Or,Ut]=h.useState(null),[Fr,pn]=h.useState([]),[Ks,Za]=h.useState(""),[Qs,$i]=h.useState(!1),[qr,er]=h.useState(""),va=h.useRef(null),tr=h.useRef(0),Br=h.useRef(!1),Dl=h.useRef(0),[Ei,Ti]=h.useState(!1),Ur=h.useRef(""),En=h.useRef([]),Ns=h.useRef([]),Cs=h.useRef(null),Ai=h.useRef(!1),Ri=h.useRef(null);Ur.current=M,En.current=oe,Ns.current=xe,h.useEffect(()=>{for(const u of xe){const v=ba.current[u.id];v!==void 0&&u.ratings&&Number(u.ratings.mine||0)===v&&delete ba.current[u.id]}},[xe]);const Wr=h.useRef(!1);async function tc(u){var v;try{const S=await l.inbox(),w=Dv(S),T=Ov(S);_e(Ue=>Iu(Ue,T)?Ue:T);const te=Fv(S,((v=G.current)==null?void 0:v.seat)||"");q(Ue=>Iu(Ue,te)?Ue:te);const B=qv(S);W(Ue=>Iu(Ue,B)?Ue:B),le();const ve=u.slice(0,gy),Ie=await Promise.allSettled(ve.map(Ue=>l.digest(Ue.name))),Be={};for(const Ue of u)Be[Ue.name]={unread:w[Ue.name]||0,open_questions:0};Ie.forEach((Ue,Mt)=>{var Rn;const Et=ve[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)}}}),Ee(Ue=>Pu(Ue,Be)?Ue:Be)}catch{}}async function ya(u){if(Ai.current){Ri.current=u;return}Ai.current=!0;let v=u;try{for(;v;)Ri.current=null,await tc(v),v=Ri.current}finally{Ai.current=!1}}async function nr(){const v=[...await l.channels()];return v.sort((S,w)=>(w.last_at||0)-(S.last_at||0)),ce(S=>Pu(S,v)?S:v),En.current=v,v}async function us(){try{const[u,v]=await Promise.all([l.meta(),l.channels()]);P({seat:u.seat,seat_key_present:u.seat_key_present}),J(String(u.hub_url||"")),l.healthz().then(T=>ee(T)).catch(()=>ee(null)),l.presence().then(T=>{const te=[...new Set(T.map(B=>String(B.agent_id||"")).filter(B=>B&&B!==u.seat))].sort();Mr(te)}).catch(()=>Mr([]));const S=[...v];S.sort((T,te)=>(te.last_at||0)-(T.last_at||0)),ce(S);const w=S.filter(T=>!T.name.startsWith("dm:"));!M&&w.length&&ye(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,te;if(!u)return;const S=A.current;v!=null&&v.background||Je(!0);try{const B=Ns.current.length&&Ns.current[Ns.current.length-1].seq||0,ve=((w=En.current.find(rt=>rt.name===u))==null?void 0:w.last_seq)||0;let Ie=ve,Be=null;if(!(v!=null&&v.background))if(ve>0)Be=nr().catch(()=>null);else try{const rt=await nr();if(S!==A.current)return;Ie=((T=rt.find(bn=>bn.name===u))==null?void 0:T.last_seq)||0}catch{}const Ue=Math.max(0,Ie-ma),Mt=v!=null&&v.background&&B>0?Math.max(0,B-_y):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=((te=bn.find(We=>We.name===u))==null?void 0:te.last_seq)||0;if(bt>0&&bt<B){const We=Math.max(0,bt-ma),Ct=await l.messages(u,{since:We,limit:ma});if(S!==A.current)return;Ct.sort((ln,en)=>(ln.seq||0)-(en.seq||0)),Oe(Ct),ge("");return}}catch{}}}Et.sort((rt,bn)=>(rt.seq||0)-(bn.seq||0)),Oe(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)),We=new Map(Et.map(jt=>[jt.id,jt]));let Ct=0;const ln=rt.map(jt=>{const ft=We.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(We=>We.name===u))==null?void 0:rt.last_seq)||0;if(bt>0&&bt!==ve){const We=Math.max(0,bt-ma),Ct=await l.messages(u,{since:We,limit:ma});if(S!==A.current)return;Ct.sort((ln,en)=>(ln.seq||0)-(en.seq||0)),Oe(ln=>Pu(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&&Je(!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{Ti(!1),S+=1,setTimeout(T,Math.min(15e3,1e3*Math.max(1,S)));return}u.onopen=()=>{Ti(!0),w=Date.now(),(!En.current.length||!G.current)&&us()},u.onmessage=te=>{var B;try{const ve=JSON.parse(String(te.data||"{}"));if((ve==null?void 0:ve.type)!=="envelope")return;const Ie=String(((B=ve.envelope)==null?void 0:B.channel)||"");Ie&&Ie===Ur.current&&ds(Ie,{background:!0}),Ie&&!En.current.some(Be=>Be.name===Ie)&&nr(),Cs.current&&clearTimeout(Cs.current),Cs.current=setTimeout(()=>void ya(En.current),800)}catch{}},u.onclose=()=>{Ti(!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({}),K({}),Ye({}),Y.current=new Set,Jn(null),Ua(null);try{E.stop_tts()}catch{}Wa.current=0,ba.current={},lr("recency"),ta(null),ei(""),Dr(null),Xa(""),ga(""),Ut(null),Yn(null),Xn(null),ws(null),sn(""),ct(""),ls({}),pn([]),er(""),$i(!1),Za(""),Oe([]),Ze(he.current||"all"),he.current=null,mt(null),gt({}),mn(""),dt([]),Ba.current&&Ba.current!==M&&(X||Le?Bt.current[Ba.current]={text:X,title:Le,kind:et}:delete Bt.current[Ba.current],bl(Bt.current));const u=Bt.current[M];if(Se((u==null?void 0:u.text)||""),Ge((u==null?void 0:u.title)||""),kt((u==null?void 0:u.kind)||"fyi"),Ba.current=M,Wr.current=!0,ds(M),!M)return;St==="files"&&Di(),St==="members"&&Li();const v=setInterval(()=>{tr.current+=1,Br.current||(Br.current=!0,ds(M,{background:!0}).finally(()=>{Br.current=!1})),tr.current%py===0&&(nr().then(S=>ya(S)).catch(()=>ya(En.current)),l.healthz().then(ee).catch(()=>{}),l.meta().then(S=>P(S)).catch(()=>{}))},hy);return()=>clearInterval(v)},[M]);const Ol=h.useRef({text:"",title:"",kind:"fyi",selected:""});Ol.current={text:X,title:Le,kind:et,selected:M},h.useEffect(()=>{if(!M)return;const u=setTimeout(()=>{X||Le?Bt.current[M]={text:X,title:Le,kind:et}:delete Bt.current[M],bl(Bt.current)},300);return()=>clearTimeout(u)},[X,Le,et,M]),h.useEffect(()=>{const u=()=>{const v=Ol.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],bl(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||!xe.length)return;if(Wr.current){Wr.current=!1,u.scrollTop=u.scrollHeight;return}u.scrollHeight-u.scrollTop-u.clientHeight<240&&(u.scrollTop=u.scrollHeight)},[xe]),h.useEffect(()=>{if(Fe!=="unread"||!M){Pe(null);return}const u=Ae[M];Pe(new Set(u||[])),se.current=""},[Fe,M]),h.useEffect(()=>{if(Fe!=="unread"||!M||!Re||!Re.size)return;const u=Math.min(...Re),v=xe.length&&xe[0].seq||0;if(!u||!v||v<=u)return;const S=`${M}:${u}`;if(se.current===S)return;se.current=S;const w=A.current;l.messages(M,{since:Math.max(0,u-1),limit:ma}).then(T=>{w!==A.current||!T.length||Oe(te=>{const B=new Set(te.map(Ie=>Ie.id)),ve=T.filter(Ie=>!B.has(Ie.id));return ve.length?[...te,...ve].sort((Ie,Be)=>(Ie.seq||0)-(Be.seq||0)):te})}).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))})},[Fe,M,Re,xe]);function Fl(u){Y.current.has(u.id)||(Y.current.add(u.id),l.read_message(u.channel,u.id).catch(()=>{}),l.ack(u.channel,u.seq).catch(()=>{}),_e(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 ql(u){const v=!ie[u.id];fe(S=>({...S,[u.id]:v})),v&&Fl(u)}function Bl(u){const v=window.getSelection();if(v&&!v.isCollapsed)return;const S=String(u.body||""),w=u.status==="reply"?zf:Ho;S.length>w?ql(u):Fl(u)}async function nc(){if(!M||Ht==="running")return;const u=A.current;Jn("running");try{const v=await l.ledger(M),S=await fy(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 Li(){{const u=A.current;Ua("loading"),Yn(null),Ar(""),Xn(null),l.channel_info(M).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(M).then(v=>{u===A.current&&(Yn(v),Ar(""),ji(M,v))}).catch(v=>{u===A.current&&(Yn([]),Ar(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,Li(),Sn()}v==="leaderboard"&&Mi(Wn),v==="desk"&&ae()}function Mi(u){const v=A.current;Ir(null),zl(""),Pl(""),os(null),Zn(""),(u==="hub"?l.reputation_hub():l.reputation(M)).then(w=>{v===A.current&&Ir(w)}).catch(w=>{if(v!==A.current)return;const T=Number((w==null?void 0:w.status)||0);zl(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 Ul(u){const v=Ja===u?"":u;if(Pl(v),os(null),Zn(""),!v||Wn==="hub")return;const S=A.current;l.reputation_votes(M,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[zi,Wl]=h.useState(""),[$s,Js]=h.useState("");h.useEffect(()=>{if(!$s)return;const u=setTimeout(()=>Js(""),6e3);return()=>clearTimeout(u)},[$s]);async function sc(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 ${(D==null?void 0:D.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 Hr(u){const v=u.ratings;return v?ay(v,ba.current[u.id]):null}async function Pi(u,v){var T,te;const S=(D==null?void 0:D.seat)||"";if(!u||!S||zi)return;const w=Ns.current.find(B=>B.id===u)||((T=to.current)==null?void 0:T.find(B=>B.id===u));if(w){Wl(`${u}:${v}`),Zn("");try{const B=((te=Hr(w))==null?void 0:te.mine)??0;B===v?await l.unrate_message(M,u):await l.rate_message(M,u,v),ba.current[u]=B===v?0:v}catch(B){Zn(String((B==null?void 0:B.message)||B||"rating failed"))}finally{Wl("")}}}async function Ii(u,v,S){if(!Ci){Il(`${u}:${v}:${S}`),Zn("");try{await l.rate(M,u,v,S,Vs.trim()),Ya("");const w=A.current,[T,te]=await Promise.all([l.reputation(M),l.reputation_votes(M,u)]);w===A.current&&(Ir(T),os(te))}catch(w){Zn(String((w==null?void 0:w.message)||w||"vote failed"))}finally{Il("")}}}function Di(){const u=A.current;Dr(null),Xa(""),ga(""),l.fs_list(M).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||"?"} · ${jl(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(M,u.path);if(v!==A.current)return;const te=Sr(u.path,T.mime);Ut({name:u.path,mode:te==="image"?"text":te,text:Vo(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(M,{since:Math.max(0,T-3),limit:10}).then(te=>{w!==A.current||!te.length||Oe(B=>{const ve=new Set(B.map(Be=>Be.id)),Ie=te.filter(Be=>!ve.has(Be.id));return Ie.length?[...B,...Ie].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===M?sr():ye(u))},[a.focus]),h.useEffect(()=>{sr()},[xe]),h.useEffect(()=>{if(St!=="members"||!M)return;let u=0,v="";for(const w of xe){if(w.channel&&w.channel!==M||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(M).then(w=>{S===A.current&&(Wa.current=u,Yn(w),Ar(""),ji(M,w))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(v)&&l.list_blocks(M).then(w=>{S===A.current&&Xn(w)}).catch(()=>{})},[xe,St,M]);const[ac,ar]=h.useState(null),Vr=h.useRef(0);h.useEffect(()=>{if(ar(null),Vr.current=0,!M)return;const u=A.current;l.fs_list(M).then(v=>{u===A.current&&ar(new Set(v.map(S=>String(S.path||"")).filter(Boolean)))}).catch(()=>{u===A.current&&ar(null)})},[M]),h.useEffect(()=>{const u=xe.reduce((S,w)=>{if(w.channel&&w.channel!==M)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<=Vr.current)return;const v=A.current;l.fs_list(M).then(S=>{v===A.current&&(Vr.current=u,ar(new Set(S.map(w=>String(w.path||"")).filter(Boolean))))}).catch(()=>{})},[xe,M]);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(M,u);if(v!==A.current)return;const T=Sr(u,w.mime),te=w.updated_by?`${w.updated_by} · ${jl(w.updated_at)} · v${w.version??"?"}`:void 0;Ut({name:u,mode:T==="image"?"text":T,text:Vo(w.content),content_type:w.mime,meta:te,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>Cl){Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size,error:`too large to preview inline (${On(v.size)} > ${On(Cl)}) — download to view`});return}Ut({name:v.filename,mode:T,url:w,content_type:v.content_type,size:v.size,loading:!0});try{const te=await fetch(w);if(!te.ok)throw new Error(`fetch failed (${te.status})`);const B=await te.text();if(S!==A.current)return;Ut({name:v.filename,mode:T,url:w,content_type:v.content_type,size:v.size,text:Vo(B)})}catch(te){if(S!==A.current)return;Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size,error:String((te==null?void 0:te.message)||te||"failed to load")})}return}Ut({name:v.filename,mode:"download",url:w,content_type:v.content_type,size:v.size})}async function Gr(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(M,u):await l.block(M,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(M).catch(()=>null);T&&w===A.current&&Yn(T);const te=await l.list_blocks().catch(()=>null);te&&w===A.current&&Xn(te)}catch(w){ct(String((w==null?void 0:w.message)||w||"moderation refused"))}finally{js("")}}}async function Kr(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(M).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 rc(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 Hl(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 Qr(u){if(!Vt){hn(!0),ct("");try{let v={state:u},S;try{const w=await l.channel_meta(M);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(M,v,S),ot(u==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ot(""),3500),Li(),us()}catch(v){ct(String((v==null?void 0:v.message)||v||"channel state change refused"))}finally{hn(!1)}}}const[Oi,Fi]=h.useState("");async function Vl(u){if(!Vt){hn(!0),ge("");try{await l.leave(u),Fi(""),M===u&&ye(""),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[Gl,qi]=h.useState("");async function ic(u){if(!Vt){hn(!0),ge("");try{await l.archive(u),qi(""),M===u&&ye(""),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)?(qi(""),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 Kl(){const u=ks.name.trim();if(!(!u||Vt)){hn(!0),ge("");try{await l.create_channel(u,ks.is_private),Us({open:!1,name:"",is_private:!1}),await us(),ye(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 Ql(u,v){if(!c)throw new Error("AI advisor is not available");return c(u,v)}async function lc(u){if(!m)return;const v=u.root.id,S=A.current,w=u.replies.length+1;ls(T=>{var te;return{...T,[v]:{busy:!0,text:((te=T[v])==null?void 0:te.text)||"",error:"",count:w}}});try{const te=`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
|
+
${Rf([u.root,...u.replies])}`,B=await Ql(te,[]);if(S!==A.current)return;ls(ve=>({...ve,[v]:{busy:!1,text:B,error:"",count:w}}))}catch(T){if(S!==A.current)return;ls(te=>({...te,[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||!m)return;const S=A.current;Zt("assistant"),$i(!0),er(""),pn(w=>[...w,{role:"user",content:v}]);try{const w=Rf(xe),T=`You are the operator's analyst for the agora hub channel #${M}. 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}`,te=await Ql(T,Fr);if(S!==A.current)return;pn(B=>[...B,{role:"assistant",content:te}])}catch(w){if(S!==A.current)return;er(String((w==null?void 0:w.message)||w||"assistant failed"))}finally{S===A.current&&$i(!1)}}const[Ts,Bi]=h.useState(""),[ir,Ui]=h.useState("");async function Jl(u){if(!Qn){qn(!0),ge("");try{await l.retract_message(M,u.id),Ui(""),ot(`#${u.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ot(""),4e3),await ds(M,{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 Wi(u){if(!Qn){qn(!0),ge("");try{const v=Cf(M,Nt);await l.post_message(M,{body:"Resolved.",status:"resolved",to:v?[v]:void 0,reply_to:u.id}),Bi(""),ot(`Marked #${u.seq} resolved.`),setTimeout(()=>ot(""),3e3),await ds(M,{background:!0})}catch(v){ge(String((v==null?void 0:v.message)||v||"Resolve failed"))}finally{qn(!1)}}}async function Yl(u){if(!u||!u.length||yt)return;const v=Array.from(u);if(tt.length+v.length>xl){ge(`At most ${xl} attachments per message.`);return}const S=v.find(B=>B.size>If);if(S){ge(`"${S.name}" is ${On(S.size)} — the limit is ${On(If)}.`);return}const w=A.current,T=M;pt(!0),ge("");let te=0;try{for(const B of v){const ve=await l.upload_attachment(T,B);if(w!==A.current||M!==T)return;dt(Ie=>[...Ie,ve]),te+=1}}catch(B){const ve=B==null?void 0:B.status,Ie=String((B==null?void 0:B.message)||B||"");if(ve===404||/not found|hub_route_not_allowed/i.test(Ie))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?` (${te} of ${v.length} attached before this)`:"";ge(`${Ie||"attachment upload failed"}${Be}`)}}finally{pt(!1),Tt.current&&(Tt.current.value="")}}function oc(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 Hi(u){const{title:v,members:S}=Lu(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 te of S)try{const B=await fetch(l.attachment_url(u,te.id));if(!B.ok)throw new Error(`fetch ${B.status}`);const ve=await B.blob(),Ie=new File([ve],te.filename||"attachment",{type:te.content_type||ve.type||"application/octet-stream"}),Be=await l.upload_attachment(v,Ie);w.push({id:Be.id,filename:Be.filename||te.filename})}catch(B){T.push(`${te.filename||te.id.slice(0,8)} (${String((B==null?void 0:B.message)||B)})`)}return{migrated:w,att_failed:T}}async function Jr(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 Xl(u){var v,S;if(!(!M||!u)){Si(!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===M))!=null&&S.private);let te=null;if(T)te=await Jr(M,u,w||void 0);else try{await l.send_dm(u,{title:`join ${M}${w?`: ${w}`:""}`.slice(0,120),body:`You are invited to '${M}' (public)${w?` — ${w}`:""}. Join with join_channel(channel='${M}'), read the recent messages, and work the topic THERE.`})}catch(B){te=String((B==null?void 0:B.message)||B)}te?Ka(te.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${te}`):(Ka(`Invited @${u} — join pointer DM'd.`),ki(""),Tr(M,[u]))}finally{Si(!1),setTimeout(()=>Ka(""),8e3)}}}async function Yr(u,v){var S;try{const w=Lu(v).members;if(!w.length)return;const T=await l.members(u),te=new Set(T.map(Ue=>String(Ue.agent_id||""))),B=w.filter(Ue=>!te.has(Ue)&&Bs.includes(Ue)&&Ue!==Nt);if(!B.length)return;const ve=!!((S=En.current.find(Ue=>Ue.name===u))!=null&&S.private),Ie=[],Be=[];for(const Ue of B)if(ve){const Mt=await Jr(u,Ue);Mt?Be.push(`${Ue} (${Mt})`):Ie.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.`}),Ie.push(Ue)}catch(Mt){Be.push(`${Ue} (${String((Mt==null?void 0:Mt.message)||Mt)})`)}Ie.length&&(Tr(u,Ie),ot(`Posted — @${Ie.join(", @")} ${ve?"invited":"nudged"} (mentioned, not yet member${Ie.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 te,B;const{title:v,members:S}=u,w=[...tt],T=M;qn(!0),ge("");try{const ve=new Set(En.current.map(xt=>xt.name)),Ie=zu(v,ve);let Be=[],Ue=[],Mt=!1;try{const xt=await l.create_group({name:Ie,members:S,purpose:v,opening_post:((te=u.opening_body)==null?void 0:te.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(Ie,!0),await l.put_channel_meta(Ie,{purpose:v},0);for(const bt of S)try{const We=await l.create_invite(Ie,bt);await l.send_dm(bt,{title:`invite to ${Ie}: ${v}`.slice(0,120),body:`You are invited to '${Ie}' — focused room: ${v}. Join with join_channel(channel='${Ie}', invite_token='${We}'), read the opening post, and work the topic THERE (not in commons).`}),Be.push(bt)}catch(We){Ue.push(`${bt} (${String((We==null?void 0:We.message)||We)})`)}}const{migrated:Et,att_failed:Rn}=await ja(T,Ie,w);Mt?Et.length&&await l.post_message(Ie,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Et}):await l.post_message(Ie,{body:((B=u.opening_body)==null?void 0:B.trim())||v,title:v.slice(0,120),status:"open",attachments:Et.length?Et:void 0}),Tr(Ie,Be),ot(`Room '${Ie}' 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.`),Se(""),Ge(""),Ce(""),kt("fyi"),dt([]),delete Bt.current[M],bl(Bt.current),await us(),ye(Ie),setTimeout(()=>ot(""),6e3)}catch(ve){ge(`group creation failed: ${String((ve==null?void 0:ve.message)||ve)}`)}finally{qn(!1)}}async function Xr(){var te;const u=X.trim(),v=tt.length>0,S=!Me&&!M.startsWith("dm:")&&et==="group";if(!u&&!v&&!S||Qn||!M)return;if(S){const B=Mu(je);if(!B.length){ge("Group needs at least one member — write their names like: @entity @assistant");return}const ve=Le.trim()||(u?u.split(`
|
|
118
|
+
`)[0].slice(0,80):`focused work with ${B.join(", ")}`);await Zs({title:ve,members:B,opening_body:u});return}if(/^\/assistant(?=\s|$)/i.test(u)){if(!m){ge("AI advisor is not configured — connect a gateway or inject an advisor.");return}const B=u.replace(/^\/assistant/i,"").trim();Se(""),B?Tn(B):Zt("assistant");return}if(/^\/group(?=\s|$)/i.test(u)){await Hi(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=M.startsWith("dm:");if(Me&&(((te=Me.data)==null?void 0:te.asks)||[]).length&&!w.length&&Xt!=="void_reply"){mn("void_reply");return}if(!Me&&!T&&et==="ask"&&!Le.trim()&&Xt!=="untitled_open"){mn("untitled_open");return}if(!Me&&!T&&et==="dm"&&!ht.trim()){ge("Pick a recipient for the direct message.");return}qn(!0),ge("");try{if(!Me&&!T&&et==="dm"){const B=ht.trim(),ve=[...tt],Ie=M;await l.send_dm(B,{body:u||(ve.length?`(${ve.length} attachment${ve.length===1?"":"s"})`:u),title:Le.trim()||void 0});const Be=`dm:${[Nt,B].sort().join("--")}`;if(ve.length){const{migrated:Ue,att_failed:Mt}=await ja(Ie,Be,ve);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(),ye(Be)}else{const B=tt.map(Be=>({id:Be.id,filename:Be.filename})),ve=T?Cf(M,Nt):"";T&&!ve&&ge(`#FALLBACK this dm's pair does not include seat '${Nt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const Ie={body:u,title:Le.trim()||void 0,status:Uv({is_reply:!!Me,in_dm:T,kind:et}),to:ve?[ve]:void 0,reply_to:Me==null?void 0:Me.id,answers:Me&&w.length?w:void 0,attachments:B.length?B:void 0};try{await l.post_message(M,Ie)}catch(Be){if(ve&&/address non-members/i.test(String((Be==null?void 0:Be.message)||Be)))await l.post_message(M,{...Ie,to:void 0}),ge(`#FALLBACK '${ve}' 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(M,{background:!0}),!T&&u&&Yr(M,u)}Se(""),Ge(""),dt([]),mt(null),gt({}),kt("fyi"),Qt(""),mn(""),delete Bt.current[M],bl(Bt.current),setTimeout(()=>ot(""),3e3)}catch(B){ge(String((B==null?void 0:B.message)||B||"Post failed"))}finally{qn(!1)}}async function Zl(u){if(!(!M||!u||ha||qe)){Er(!0);try{await l.ack(M,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{Er(!1)}}}const _n=!!(D!=null&&D.seat_key_present)&&!($!=null&&$.paused),Nt=(D==null?void 0:D.seat)||"",Jt=M.startsWith("dm:"),Zr=(()=>{if(!Jt)return"";const u=M.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||M})(),eo=h.useMemo(()=>Wv(xe),[xe]),ms=h.useMemo(()=>({seat:Nt,unread_seqs:Ae[M],unread_snapshot_seqs:Fe==="unread"&&Re||void 0,escalated_seqs:L[M]}),[Nt,Ae,M,Fe,Re,L]),fs=h.useMemo(()=>{if(Me)return null;const u=new Set(oe.map(S=>S.name)),v=X.trimStart();if(/^\/group(\s|$)/i.test(v)){const{title:S,members:w}=Lu(v.replace(/^\/group/i,"").trim()),T=S||(w.length?`focused work with ${w.join(", ")}`:"");return{name:T?zu(T,u):"group",members:w,source:"slash"}}if(et==="group"&&!M.startsWith("dm:")){const S=Mu(je),w=Le.trim()||(S.length?`focused work with ${S.join(", ")}`:"");return{name:w?zu(w,u):"group",members:S,source:"kind"}}return null},[X,Me,oe,et,je,Le,M]),an=h.useMemo(()=>Pv(xe),[xe]),As=h.useMemo(()=>Nf(an,Fe,ms),[an,Fe,ms]),[ea,lr]=h.useState("recency"),[or,ta]=h.useState(null),to=h.useRef(null);h.useEffect(()=>{to.current=or},[or]);const[Vi,ei]=h.useState("");function At(){const u=A.current;ta(null),ei(""),l.messages(M,{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);ei((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 Gi(u){Ys.current={message_id:u.id,seq:u.seq},lr("recency"),requestAnimationFrame(()=>sr())}const[cr,ka]=h.useState(""),[na,Ki]=h.useState("all"),[rn,Sa]=h.useState(""),[gn,ur]=h.useState(null),[Qi,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"&&M?[M]: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 te=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(te)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":te})})}function ti(u){sa(u.trim(),na,rn)}function dr(){Hn.current+=1,ur(null),hs(null),Sa("")}function Ji(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"&&M?[M]:void 0}).then(T=>{if(w!==Hn.current)return;const te=ni(T,v);hs({label:u,kind:v,hits:te.hits,total:te.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 Yi(){const u=Qi,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"&&M?[M]:void 0}).then(w=>{if(S!==Hn.current)return;const T=ni(w,u.kind);hs(te=>te&&te.kind===u.kind?{...te,hits:[...te.hits,...T.hits],cursor:w.next_cursor??null,busy:!1}:te)}).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 ni(u,v){const S=Wo.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 cc(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===M?sr():ye(v))}async function no(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),te=Sr(S,T.mime);Ut({name:S,mode:te==="image"?"text":te,text:Vo(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 so(u){const v=u.kind==="message"&&!!u.channel,S=u.kind==="file"&&!!u.channel,w=v||S,T=ry(String(u.snippet||""),u.highlights),te=u.ratings,B=String(u.channel||""),ve=B?B.startsWith("dm:")?B:`#${B}`:"";return e.jsxs("div",{className:`team_search_hit${w?" clickable":""}`,onClick:w?()=>S?void no(u):cc(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,ve?e.jsx("span",{className:"team_search_chan mono",children:ve}):null,u.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${md(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,te&&(te.up||te.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",te.up," ▽",te.down]}):null,u.created_at?e.jsx("span",{className:"muted team_search_time",children:jl(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((Ie,Be)=>Ie.hit?e.jsx("mark",{children:Ie.text},Be):e.jsx(Kt.Fragment,{children:Ie.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 uc=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]),Xi=h.useMemo(()=>{const u={};for(const v of["asks","vigilance","fyi","resolved","to_me"])u[v]=Nf(an,v,ms).length;return u.unread=xe.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,xe,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(Dn,{tone:Rt.state==="open"?"success":"warning",size:"sm",children:Rt.state}):null,(u=Rt.channel)!=null&&u.private?e.jsx(Dn,{tone:"muted",size:"sm",children:"private"}):e.jsx(Dn,{tone:"muted",size:"sm",children:"public"}),Rt.response_sla_minutes?e.jsxs(Dn,{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:Sl(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:Pr,onChange:S=>ki(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=>!(Al[M]||new Set).has(S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),e.jsx("button",{className:"btn",disabled:!Pr||!!Ga,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void Xl(Pr),children:Ga?"Inviting…":"Invite"})]}):null,Ni?e.jsx("div",{className:"muted team_note",children:Ni}):null,(()=>{const S=[...Al[M]||[]].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}`))})(),Rl?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Rl.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 Gr(w,"kick"),children:Pt===`channel:kick:${w}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Dt===`channel:ban:${w}`?"team_danger":""}`,disabled:!!Pt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Dt===`channel:ban:${w}`?(sn(""),Gr(w,"ban")):sn(`channel:ban:${w}`)},children:Pt===`channel:ban:${w}`?"banning…":Dt===`channel:ban:${w}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Dt===`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:()=>{Dt===`hub:ban:${w}`?(sn(""),Gr(w,"ban","hub")):sn(`hub:ban:${w}`)},children:Pt===`hub:ban:${w}`?"hub-banning…":Dt===`hub:ban:${w}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Dt===`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:()=>{Dt===`retire:${w}`?(sn(""),Kr(w)):sn(`retire:${w}`)},children:Pt===`retire:${w}`?"retiring…":Dt===`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||""),te=T==="hub",B=te?"hub":"channel",ve=S.expires_at?` · until ${new Date(Number(S.expires_at)*1e3).toLocaleString()}`:" · indefinite",Ie=te?"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:[Ie,ve]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Pt,title:te?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void Gr(w,"unblock",B),children:Pt===`${B}:unblock:${w}`?"unblocking…":"unblock"})})]},`blocked:${T}:${w}`)})]}):null,!Jt&&Lr&&Lr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Lr.length,")"]}),Lr.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 ${Dt===`unretire:${w}`?"team_danger":""}`,disabled:!!Pt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Dt===`unretire:${w}`?(sn(""),rc(w)):sn(`unretire:${w}`)},children:Pt===`unretire:${w}`?"un-retiring…":Dt===`unretire:${w}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Dt===`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:()=>{Dt===`delete:${w}`?(sn(""),Hl(w)):sn(`delete:${w}`)},children:Pt===`delete:${w}`?"deleting…":Dt===`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):[],te=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?)",te?` · until ${new Date(te*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Dt===`resign:${w}`?"team_danger":""}`,disabled:is,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Dt===`resign:${w}`?(sn(""),ec(w)):sn(`resign:${w}`)},children:is?"resigning…":Dt===`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:[by.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=>Ml(T=>w.target.checked?[...T,S.id]:T.filter(te=>te!==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 Zo(),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:Vt,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void Qr("closed"),children:Vt?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:Vt,title:"Reopen this channel for member posts",onClick:()=>void Qr("open"),children:Vt?"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",")."]})}),zr?e.jsx("div",{className:"page_error mono",children:zr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function ao(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 te=`${w.id}:${T}`,B=l.attachment_url(u.channel,w.id);return vy.has(String(w.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${w.filename} · ${On(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:Ie=>{var Mt;const Be=Ie.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:On(w.size)})]})]},te):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${w.content_type} · ${On(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:On(w.size)})]},te)})}):null}function Na(u,v){var ve;const S=[],w=String(u.status||"").toLowerCase();(w==="open"||w==="blocked")&&(u.has_resolved_reply===!0||(u.id?eo.has(u.id):!1))?S.push(e.jsx(Dn,{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(Dn,{tone:w==="blocked"?"error":"warning",size:"sm",children:w},"st")):w==="resolved"&&v&&S.push(e.jsx(Dn,{tone:"success",size:"sm",children:"resolved"},"st")),u.critical&&S.push(e.jsx(Dn,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const te=((ve=u.data)==null?void 0:ve.answers)||[];w==="reply"&&te.length&&S.push(e.jsxs(Dn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${te.join(", ")} of its parent.`,children:["✓ answers ",te.join(",")]},"dis"));const B=u.to||[];for(const Ie of B.slice(0,2))S.push(e.jsxs(Dn,{tone:"muted",size:"sm",children:["@",Ie]},`to:${Ie}`));return B.length>2&&S.push(e.jsxs(Dn,{tone:"muted",size:"sm",title:B.map(Ie=>`@${Ie}`).join(" "),children:["+",B.length-2]},"to+")),S}function An(u,v){return e.jsx(xh,{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:Of(u.sender),children:u.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",u.seq," · ",wl(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?Ho:zf,te=w.length>T,B=te&&!S,ve=((xt=u.data)==null?void 0:xt.asks)||[],Ie=!!((rt=ms.unread_seqs)!=null&&rt.has(u.seq)),Be=Fe!=="all"&&Iv(u,Fe,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=(Me==null?void 0:Me.id)===u.id;return e.jsxs("div",{className:`team_row ${u.sender===Nt?"own":""} ${Be?"hit":""} ${Rn?"replying":""} ${Ie?"unread":""} ${u.retracted?"retracted":""}`,id:`hubmsg-${u.id}`,onClick:()=>Bl(u),title:te?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=ue[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:We=>{We.stopPropagation(),sc(u)},children:$s===u.id?"sure? declines on the record":"decline"})]}):Ie?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:Of(u.sender),children:u.sender}),Na(u,v.is_root),(()=>{const We=Hr(u);return!We||!We.up&&!We.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${We.mine>0?"pos":We.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:[We.up?`▲${We.up}`:"",We.up&&We.down?" ":"",We.down?`▼${We.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:jl(u.created_at),children:["#",u.seq," · ",wl(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(cy,{className:"md_doc",text:Sl(Zv(Qv(w),{hub_base:F}))})}),ao(u),(()=>{var jt;const We=Gv(`${String(u.title||"")}
|
|
121
|
+
${w}`),Ct=((jt=u.data)==null?void 0:jt.attachments)||u.attachments||[],ln=We.map(ft=>({mention:ft,res:Kv(ft,ac,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?pg(`${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 #${M}'s files)`:`Open ${zt.path} from #${M}'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(Df,{}),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}`))]})})(),ve.length?e.jsx("div",{className:"team_row_asks",children:ve.map(We=>e.jsxs("span",{className:"team_ask",title:We.text,children:["ask ",We.id,": ",We.text.length>90?We.text.slice(0,90)+"…":We.text]},We.id))}):null,te?e.jsx("button",{className:"team_row_expand",onClick:We=>{We.stopPropagation(),ql(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 We=Hr(u);return We?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${We.mine>0?"up_on":""}`,title:We.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!zi,onClick:Ct=>{Ct.stopPropagation(),Pi(u.id,1)},children:[e.jsx(at,{name:We.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),We.up?e.jsx("span",{className:"team_thumb_count",children:We.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${We.mine<0?"down_on":""}`,title:We.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!zi,onClick:Ct=>{Ct.stopPropagation(),Pi(u.id,-1)},children:[e.jsx(at,{name:We.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),We.down?e.jsx("span",{className:"team_thumb_count",children:We.down}):null]})]}):null})():null,E.tts_supported&&u.id?(()=>{const We=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 ${We||Ct?"team_speak_on":""}`,title:We?"Pause":Ct?"Synthesizing…":_.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":We?"Pause reading":"Read this message aloud",onClick:ln=>{ln.stopPropagation();const en=vv(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:We?"pause":Ct?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:ve.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:We=>{We.stopPropagation(),oc(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:We=>{We.stopPropagation(),ir===u.id?Jl(u):Ui(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:We=>{We.stopPropagation(),Ts===u.id?Wi(u):Bi(u.id)},children:Ts===u.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},u.id)}function ps(u){const v=u.replies.length,S=!!ke[u.root.id],w=!!we[u.root.id],T=S?[]:w||Fe!=="all"||v<=Pf+1?u.replies:u.replies.slice(v-Pf),te=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}),te>0||v>0||String(u.root.body||"").length>Ho?e.jsxs("div",{className:"team_trail_bar",children:[v>0?e.jsx("button",{className:"team_replies_more",onClick:()=>Ye(ve=>({...ve,[u.root.id]:!ve[u.root.id]})),children:S?`show ${v} repl${v===1?"y":"ies"}`:"fold thread"}):null,!S&&te>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>K(ve=>({...ve,[u.root.id]:!0})),children:["↓ ",te," earlier repl",te===1?"y":"ies"]}):null,!S&&m&&(v>0||String(u.root.body||"").length>Ho)?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 lc(u),children:B!=null&&B.busy?"✦ summarizing…":`✦ Summarize (${v+1})`}):null]}):null,!S&&v>0?e.jsx("div",{className:"team_replies",children:T.map(ve=>An(ve,{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(ve=>({...ve,[u.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(rs,{className:"md_doc",text:Sl(B.text)})]}):null,B!=null&&B.error?e.jsx("div",{className:"page_error mono",children:B.error}):null]},u.root.id)}const Zi=xe.length?xe[xe.length-1].seq:0,dc=Math.max(Zi,((aa=oe.find(u=>u.name===M))==null?void 0:aa.last_seq)||0),ro=((hr=oe.find(u=>u.name===M))==null?void 0:hr.member_count)||0,Ls=((si=(Bn||[]).find(u=>String(u.role||"")==="owner"))==null?void 0:si.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&&ze(!0))},onDragLeave:u=>{u.currentTarget.contains(u.relatedTarget)||ze(!1)},onDrop:u=>{var v,S;(S=(v=u.dataTransfer)==null?void 0:v.files)!=null&&S.length&&(u.preventDefault(),ze(!1),!(!_n||yt)&&Yl(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?Zr:`#${M}`]})}):null,$!=null&&$.protocol&&$.protocol!==Go||$!=null&&$.paused||be||Gs||bi||D&&!D.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[D&&!D.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!==Go?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${$.protocol}; this page was written against ${Go}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",$.protocol," ≠ ",Go]}):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,be?e.jsx("span",{className:"page_error mono",children:be}):null,Gs?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",Gs]}):null,bi?e.jsx("span",{className:"chip mono ok",children:bi}):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"&&Kl()}}),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()||Vt,onClick:()=>void Kl(),children:Vt?"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:be?"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=Gl===u.name;return e.jsxs("div",{className:`team_channel team_dm_row ${M===u.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>ye(u.name),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&ye(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!==M&&(he.current="unread"),ye(u.name),Ze("unread")},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.stopPropagation(),u.name!==M&&(he.current="unread"),ye(u.name),Ze("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!==M&&(he.current="asks"),ye(u.name),Ze("asks")},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.stopPropagation(),u.name!==M&&(he.current="asks"),ye(u.name),Ze("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:Vt,onClick:w=>{w.stopPropagation(),S?ic(u.name):qi(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 · ${wl(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(te=>te!==Nt).join("")||v.name,T=Oi===v.name;return e.jsxs("div",{className:`team_channel team_dm_row ${M===v.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>ye(v.name),onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&ye(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:Vt,onClick:te=>{te.stopPropagation(),T?Vl(v.name):Fi(v.name)},children:e.jsx(at,{name:T?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:T?"remove? click ✕":wl(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:M?Jt?`@${Zr} — direct`:`#${M}`:"Select a channel"}),M&&ro?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:[ro," 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=Fe==="all"?dc:uc;return e.jsx("button",{className:"btn",onClick:()=>void Zl(u),disabled:!M||!xe.length||!u||ha||qe,title:Fe==="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(M)},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})}),Ht&&Ht!=="running"&&typeof Ht=="object"&&"ok"in Ht?Ht.ok?e.jsxs(Dn,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Ht.hashed} hashed turns (${Ht.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Ht.hashed,")"]}):e.jsxs(Dn,{tone:"error",size:"sm",title:Ht.broken_at!==null?`Recomputed chain diverges at seq ${Ht.broken_at} — a hashed turn was edited, inserted, or reordered.`:"Chain internally consistent but the served head does not match the last turn — the hub is presenting a different commitment.",children:["TAMPERED",Ht.broken_at!==null?` at #${Ht.broken_at}`:" (head mismatch)"]}):null,Ht&&typeof Ht=="object"&&"error"in Ht?e.jsx(Dn,{tone:"warning",size:"sm",title:Ht.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void nc(),disabled:!M||Ht==="running",title:"Fetch the channel's verbatim ledger and recompute the sha256 hash chain in this browser — independent of the hub's own verified flag.",children:Ht==="running"?"Verifying…":"Verify transcript"})]})]}),e.jsxs("div",{className:"team_filterbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Message filters",children:Sf.map(u=>{const v=Fe===u.id,S=Xi[u.id];return e.jsxs("button",{className:`seg_btn ${v?"active":""}`,"aria-pressed":v,title:u.title,onClick:()=>Ze(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}ti(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 ${Ei?"on":""}`,title:Ei?"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:Ei?"● live":"◌ polling"})," · ",As.length!==an.length?`${As.length} of ${an.length} threads`:an.length?`${an.length} threads`:"",D!=null&&D.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",D.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(Qi){const T=Qi;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(te=>so(te)),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:Yi,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=Wo.filter(T=>{var te;return!((((te=v[T.id])==null?void 0:te.total)??0)>0)}),w=S.length<Wo.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 te=rn===T?"":T;Sa(te),sa(u.q,na,te)},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 te=T.target.checked?"channel":"all";Ki(te),sa(u.q,te,rn)}}),"this channel only"]})]}),Wo.map(T=>{const te=v[T.id],B=(te==null?void 0:te.shown)??0,ve=(te==null?void 0:te.total)??0,Ie=(te==null?void 0:te.hits)??[];return!te||!ve&&!Ie.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<ve?`showing ${B} of ${ve}`:`${ve}`}),B<ve&&T.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>Ji(T.label,T.kind),title:`All ${ve} ${T.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Ie.map(Be=>so(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"?Vi?e.jsx("div",{className:"muted team_note",children:Vi}):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:()=>Gi(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=wy(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&&M&&!qe?e.jsx("div",{className:"muted team_note",children:an.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((ra=Sf.find(u=>u.id===Fe))==null?void 0:ra.label)||Fe})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>Ze("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:u=>{u.key==="Escape"&&Me&&Xs()},children:[Me?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-${Me.id}`))==null||u.scrollIntoView({block:"center"})},children:["↩ #",Me.seq," (",Me.sender,") —"," ",(String(Me.title||"").trim()||String(Me.body||"").trim()).slice(0,80)||"(no text)"]}),(((_s=Me.data)==null?void 0:_s.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:((($t=Me.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 ",Me?"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,!Me&&!Jt&&(et==="ask"||et==="group")?e.jsx("input",{className:"team_ask_title",value:Le,onChange:u=>Ge(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,!Me&&!Jt&&et==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:je,onChange:u=>Ce(u.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!_n,list:"team_roster_options"}):null,!Me&&!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} · ${On(u.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void Es(M,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:On(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:[!Me&&!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"&&Ge(""),S!=="group"&&Ce("")},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,!Me&&!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:X,onChange:u=>Se(u.target.value),placeholder:_n?Me?`Reply to #${Me.seq} in #${M}…`:Jt?`Message ${Zr}…`:et==="dm"?`Direct message${ht.trim()?` to ${ht.trim()}`:""}…`:m?`Message #${M||"…"} as ${(D==null?void 0:D.seat)||"operator"} — or /assistant <question>`:`Message #${M||"…"} as ${(D==null?void 0:D.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&&(X.trim()||tt.length)&&Xr())}}),e.jsx("input",{ref:Tt,type:"file",multiple:!0,style:{display:"none"},onChange:u=>void Yl(u.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!_n||yt||tt.length>=xl,title:tt.length>=xl?`Attachment limit (${xl}) 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||!X.trim()&&!tt.length&&!(et==="group"&&!Me&&!Jt&&Mu(je).length>0),onClick:()=>void Xr(),children:Qn?"Sending…":fs!=null&&fs.members.length||!Me&&!Jt&&et==="group"?"Create room":Me?"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:["#",M]}),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:[Fr.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",M," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",xe.length," messages) and cites seqs. It never posts to the room."]}),Fr.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:Sl(u.content)})]},v)),Qs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,qr?e.jsx("div",{className:"page_error mono",children:qr}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(Xo,{value:Ks,onChange:Za,onSubmit:()=>{const u=Ks;Za(""),Tn(u)},placeholder:m?`Ask about #${M}…`:"AI advisor is not configured for this shell.",disabled:!m,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:["#",M]}),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:["#",M]}),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:["#",M||"…"]}),cs?cs.split("/").map((u,v,S)=>{const w=S.slice(0,v+1).join("/");return e.jsxs(Kt.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}=Bv(_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(yy,{})}),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||"?"} · ${jl(S.updated_at)} · v${S.version} · ${On(S.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Df,{})}),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:[On(S.size)," · ",wl(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":`#${M}`}),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"),Mi("channel")},disabled:!M,title:`This channel's board (#${M||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${Wn==="hub"?"active":""}`,onClick:()=>{Qa("hub"),Mi("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",...vi.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:Ff[T]||`${kl(T)} — reputation category.`,children:kl(T)},T))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),vi.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,te)=>e.jsxs(Kt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${Ja===T.target?"open":""}`,style:S,onClick:()=>Ul(T.target),role:"button",tabIndex:0,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),Ul(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 ${te<3?`top${te+1}`:""}`,"aria-hidden":"true",children:te<3?"●":te+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),ve=T.votes;return e.jsxs("span",{className:`team_lb_total ${B>0?"pos":B<0?"neg":""}`,title:(()=>{const Ie=Object.entries(T.breakdown||{}).filter(([,Be])=>Be&&Number(Be.score||0)!==0).map(([Be,Ue])=>`${kl(Be)} ${Number(Ue.score)>0?"+":""}${Number(Ue.score)}`).join(" · ");return`${T.target}: score ${B>0?"+":""}${B} = ${Ie||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${ve?` — total: ${ve.up} up, ${ve.down} down`:""}`})(),children:[B>0?`+${B}`:B,ve&&(ve.up||ve.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[ve.up,"↑"]}),e.jsxs("span",{className:ve.down>0?"rv_down_hot":"rv_down",children:[ve.down,"↓"]})]}):null]})})(),v.map(B=>{var Ue;const ve=(Ue=T.breakdown)==null?void 0:Ue[B],Ie=Number((ve==null?void 0:ve.score)||0),Be=!!(ve&&(ve.up||ve.down||ve.raters));return e.jsx("span",{className:`team_lb_axis ${Ie>0?"pos":Ie<0?"neg":""}`,title:Be?`${kl(B)}: ${Ie>0?"+":""}${Ie} (▲${ve.up} ▼${ve.down} voices · ${ve.raters} engaged colleague${ve.raters===1?"":"s"}) — ${Ff[B]||"reputation category"}`:`${kl(B)}: no standing input`,children:Be?Ie>0?`+${Ie}`:Ie:"·"},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}),vi.map(B=>{var Be;const ve=(Be=T.axes)==null?void 0:Be[B.id],Ie=(ve==null?void 0:ve.score)||0;return e.jsx("span",{className:`team_lb_axis ${Ie>0?"pos":Ie<0?"neg":""}`,title:ve?`${B.label}: ${ve.up} up, ${ve.down} down`:`${B.label}: no votes`,children:ve?Ie>0?`+${Ie}`:Ie:"·"},B.id)}),(()=>{const B=T.messages,ve=B?B.up-B.down:0;return e.jsx("span",{className:`team_lb_axis ${ve>0?"pos":ve<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",":"]}),vi.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:!!Ci||T.target===Nt,onClick:ve=>{ve.stopPropagation(),Ii(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:!!Ci||T.target===Nt,onClick:ve=>{ve.stopPropagation(),Ii(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 ae(),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:[Z==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,Z===null&&de?e.jsx("div",{className:"muted team_note",children:de}):null,Z!==null&&Z!=="loading"?e.jsxs(e.Fragment,{children:[Z.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),Z.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)===M?sr():ye(String(u.channel)),Zt("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(u.id||u.key||v))}),Z.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:"}),Z.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:[m?e.jsx("button",{className:`team_drawer_tab ${St==="assistant"?"active":""}`,onClick:()=>xa("assistant"),disabled:!M,"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:!M,"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:!M,"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:!M,"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=Z!==null&&Z!=="loading"?Z: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(oy,{view:Or,onClose:()=>Ut(null)})]})}const qf=[{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"}],ed="abstractcontinuum_settings_v1";function ky(){try{const a=window.localStorage.getItem(ed)||"{}",s=JSON.parse(a);if(s&&(s.auth_token||s.gateway_url)){delete s.auth_token,delete s.gateway_url;try{window.localStorage.setItem(ed,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 Sy(){var R;const[a,s]=h.useState("board"),[r,l]=h.useState(null),[c,m]=h.useState(null),[f,p]=h.useState(()=>ky()),[_,y]=h.useState(!1),[b,x]=h.useState(!1),[N,C]=h.useState(0),[O,E]=h.useState(!1),[D,P]=h.useState(!1),[G,F]=u_("continuum"),[J,$]=h.useState(0),[ee,oe]=h.useState(null),[ce,pe]=h.useState("");h.useEffect(()=>{if(!ee)return;const U=setTimeout(()=>oe(null),8e3);return()=>clearTimeout(U)},[ee]);const[Ee,Ae]=h.useState(!1);h.useEffect(()=>{var xe;const U=((xe=document.querySelector('script[type="module"][src*="/assets/"]'))==null?void 0:xe.getAttribute("src"))||"";if(!U)return;let le=!1;async function ae(){try{const Oe=await fetch("/",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Oe.ok)return;const Ze=(await Oe.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),he=(Ze==null?void 0:Ze[1])||"";!le&&he&&U&&he!==U&&Ae(!0)}catch{}}const M=()=>void ae();window.addEventListener("focus",M);const ye=setInterval(()=>void ae(),300*1e3);return ae(),()=>{le=!0,window.removeEventListener("focus",M),clearInterval(ye)}},[]);function _e(U){pe(String(U||"")),s("executions")}h.useEffect(()=>{const U=le=>{var ae;Array.from(((ae=le.dataTransfer)==null?void 0:ae.types)||[]).includes("Files")&&le.preventDefault()};return window.addEventListener("dragover",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragover",U),window.removeEventListener("drop",U)}},[]);const[ue,q]=h.useState(!1);h.useEffect(()=>{a==="team"&&q(!0)},[a]);function L(U){var ye;const le=U.target,ae=(ye=le==null?void 0:le.closest)==null?void 0:ye.call(le,"a[href]");if(!ae||ae.target==="_blank"||ae.hasAttribute("download"))return;const M=ae.getAttribute("href")||"";M.startsWith("/")&&(U.preventDefault(),window.open(M,"_blank","noopener"))}h.useEffect(()=>{try{window.localStorage.setItem(ed,JSON.stringify(f))}catch{}},[f]);const W=h.useMemo(()=>new J_({base_url:""}),[]),Z=t_({appName:"AbstractContinuum",onStatusChange:()=>C(U=>U+1)}),z=Z.status,de=h.useRef(0);h.useEffect(()=>{let U=!1,le;return(async()=>{try{await W.list_processes(),U||(de.current=0,y(!0))}catch{if(U)return;de.current+=1,de.current>=2?y(!1):le=window.setTimeout(()=>{U||C(ae=>ae+1)},2e3)}})(),()=>{U=!0,le!==void 0&&window.clearTimeout(le)}},[W,a,N]);const V=h.useRef(_);h.useEffect(()=>{V.current&&!_&&(z!=null&&z.has_session)&&Z.refresh(),V.current=_},[_,z==null?void 0:z.has_session]);async function j(U,le){const ae=[...le.history.map(ye=>({role:ye.role,content:ye.content})),{role:"user",content:U}],M=await W.backlog_advisor({messages:ae,agent:f.backlog_advisor_agent||null});return String((M==null?void 0:M.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:qf.map(U=>e.jsxs("button",{className:`shell_nav_item ${a===U.id?"active":""}`,onClick:()=>s(U.id),title:U.label,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(at,{name:U.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:U.label})]},U.id))})]}),e.jsxs("div",{className:"shell_main",children:[e.jsxs("header",{className:"shell_header",children:[e.jsx("div",{className:"shell_header_title",children:((R=qf.find(U=>U.id===a))==null?void 0:R.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(l_,{assistant:{open:O,onToggle:()=>E(U=>!U)},appearance:{onOpen:()=>P(!0)},extraActions:e.jsx("button",{className:"btn primary",onClick:()=>x(!0),disabled:!_,children:"+ New task"}),connection:{phase:Z.phase,signingOut:Z.signingOut,onConnect:Z.openModal,onDisconnect:()=>void Z.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:Z.openModal,children:"Connect"})]}):null,Z.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",Z.signOutError," — the session may still be live."]})}):null,ee?e.jsxs("div",{className:`shell_banner ${ee.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:ee.text}),e.jsx("button",{className:"btn",onClick:()=>oe(null),children:"Dismiss"})]}):null,Ee?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(Gg,{gateway:W,gateway_connected:_,data_nonce:J,on_mutated:()=>$(U=>U+1),on_open_executions:_e,default_execution_mode:f.default_execution_mode,query_preset:r,on_query_preset_consumed:()=>l(null),on_open_team:U=>{m(U),s("team")},on_new_task:()=>x(!0)}):null,a==="executions"?e.jsx(ov,{gateway:W,gateway_connected:_,focus_request_id:ce,on_focus_consumed:()=>pe(""),on_open_settings:()=>s("settings")}):null,a==="backlog"?e.jsx(Mg,{gateway:W,gateway_connected:_,maintenance_ai_provider:f.maintenance_ai_provider,maintenance_ai_model:f.maintenance_ai_model,maintenance_ai_reasoning:f.maintenance_ai_reasoning,backlog_advisor_agent:f.backlog_advisor_agent,default_execution_mode:f.default_execution_mode,on_open_executions:_e}):null,a==="agents"?e.jsx(ug,{gateway:W,gateway_connected:_,backlog_advisor_agent:f.backlog_advisor_agent,on_open_assistant:()=>E(!0),on_open_team:()=>s("team"),on_open_executions:()=>_e()}):null,ue?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(xh,{fallback:U=>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(U.message||U)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(jy,{gateway:W,gateway_connected:_,advisor:_?async(U,le)=>{const ae=[...le.map(ye=>({role:ye.role,content:ye.content})),{role:"user",content:U}],M=await W.backlog_advisor({messages:ae,agent:f.backlog_advisor_agent||null});return String((M==null?void 0:M.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:f.backlog_advisor_agent,on_open_board:U=>{l(U||null),s("board")},focus:c,on_focus_consumed:()=>m(null)})})}):null,a==="inbox"?e.jsx(fv,{gateway:W,gateway_connected:_,enable_triage:!0}):null,a==="services"?e.jsx(dv,{gateway:W,gateway_connected:_}):null,a==="settings"?e.jsx(Nv,{gateway:W,gateway_connected:_,settings:f,set_settings:p,connection:z}):null]})]}),e.jsx(Zp,{...Z.modalProps}),e.jsx(i_,{open:O,onClose:()=>E(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(H_,{ask:j,assistantName:"Continuum advisor",blockedNotice:_?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(d_,{open:D,onClose:()=>P(!1),value:G,onChange:F}),e.jsx(zg,{open:b,gateway:W,can_use_gateway:_,maint_provider:f.maintenance_ai_provider,maint_model:f.maintenance_ai_model,maint_reasoning:f.maintenance_ai_reasoning,on_close:()=>x(!1),on_created:async(U,le,ae)=>{$(ye=>ye+1);const M=String(U||"");s(M==="recurrent"?"backlog":"board"),oe(ae?{text:`Task created (${le}), but attachments failed: ${ae}`,tone:"warn"}:{text:`Task created: ${le} (${M||"?"})${M==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}const Eh=document.getElementById("root");if(!Eh)throw new Error("root element missing");xp.createRoot(Eh).render(e.jsx(Kt.StrictMode,{children:e.jsx(Sy,{})}));export{Av as _,mp as g};
|
|
123
|
+
//# sourceMappingURL=index-DTn9k-3t.js.map
|