@abstractframework/continuum 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/assets/{abnfDiagram-VRR7QNED-5iUoDrHe.js → abnfDiagram-VRR7QNED-BxjhPlKw.js} +2 -2
  2. package/dist/assets/{arc-BvEfqAyx.js → arc-_FbN2P3P.js} +2 -2
  3. package/dist/assets/{architectureDiagram-ZJ3FMSHR-B43j4dfb.js → architectureDiagram-ZJ3FMSHR-BCV-dnM4.js} +2 -2
  4. package/dist/assets/{blockDiagram-677ZJIJ3-Bq3Z9Mh9.js → blockDiagram-677ZJIJ3-Dy6_Bfr-.js} +2 -2
  5. package/dist/assets/{c4Diagram-LMCZKHZV-DZjfheTc.js → c4Diagram-LMCZKHZV-CDCz0hvp.js} +2 -2
  6. package/dist/assets/channel-DZQms9UX.js +2 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-Dme1SPlP.js → chunk-2Q5K7J3B-CQXku2fA.js} +2 -2
  8. package/dist/assets/{chunk-32BRIVSS-CTA5mZ-k.js → chunk-32BRIVSS-DtKcX2Bi.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-CCVwLX_R.js → chunk-5VM5RSS4-Bzx01bb4.js} +2 -2
  10. package/dist/assets/{chunk-EX3LRPZG-Bal1eqt_.js → chunk-EX3LRPZG-DkLvwLXU.js} +2 -2
  11. package/dist/assets/{chunk-JWPE2WC7-BbKjFH1w.js → chunk-JWPE2WC7-BHJIdcoD.js} +2 -2
  12. package/dist/assets/{chunk-MOJQB5TN-D038fNef.js → chunk-MOJQB5TN-D9jiV5_z.js} +2 -2
  13. package/dist/assets/{chunk-RYQCIY6F-CgAglqIu.js → chunk-RYQCIY6F-DamDSI2y.js} +2 -2
  14. package/dist/assets/{chunk-V7JOEXUC-5wWJLnmt.js → chunk-V7JOEXUC-CxvPsUwk.js} +2 -2
  15. package/dist/assets/{chunk-VR4S4FIN-BJkK_if8.js → chunk-VR4S4FIN-DSppuzPr.js} +2 -2
  16. package/dist/assets/{chunk-XXDRQBXY-C7vfFfUF.js → chunk-XXDRQBXY-ZbuFYbo7.js} +2 -2
  17. package/dist/assets/classDiagram-OUVF2IWQ-CkT3O2cp.js +2 -0
  18. package/dist/assets/classDiagram-v2-EOCWNBFH-CkT3O2cp.js +2 -0
  19. package/dist/assets/{cose-bilkent-JH36ORCC-BvnjjIc4.js → cose-bilkent-JH36ORCC-UbbsWpVp.js} +2 -2
  20. package/dist/assets/{cynefin-VYW2F7L2-7G9xH-Wu.js → cynefin-VYW2F7L2-D9Abr-kX.js} +2 -2
  21. package/dist/assets/{cynefinDiagram-TSTJHNR4-BHAxT-q7.js → cynefinDiagram-TSTJHNR4-BnnJ9CTo.js} +2 -2
  22. package/dist/assets/{dagre-VKFMJZFB-apu5lhgF.js → dagre-VKFMJZFB-DFwcUGid.js} +2 -2
  23. package/dist/assets/{diagram-FQU43EPY-DXy2E45k.js → diagram-FQU43EPY-By4TQsrB.js} +2 -2
  24. package/dist/assets/{diagram-G47NLZAW-B6rFYMQ0.js → diagram-G47NLZAW-CXSnSJkj.js} +2 -2
  25. package/dist/assets/{diagram-NH7WQ7WH-BA28RJEr.js → diagram-NH7WQ7WH-BzQeJ-p1.js} +2 -2
  26. package/dist/assets/{diagram-OA4YK3LP-BZSiH_8S.js → diagram-OA4YK3LP-DvtP4108.js} +2 -2
  27. package/dist/assets/{diagram-WEI45ONY-D067sKLu.js → diagram-WEI45ONY-KvsZ3VNQ.js} +2 -2
  28. package/dist/assets/{ebnfDiagram-CCIWWBDH-DlNauRSp.js → ebnfDiagram-CCIWWBDH-CzLqZFsO.js} +2 -2
  29. package/dist/assets/{erDiagram-Q63AITRT-Btckz8lB.js → erDiagram-Q63AITRT-CQWyXKfX.js} +2 -2
  30. package/dist/assets/{flowDiagram-23GEKE2U-B2odP7nC.js → flowDiagram-23GEKE2U-s4L-sKWk.js} +2 -2
  31. package/dist/assets/{ganttDiagram-NO4QXBWP-u5hBDz7E.js → ganttDiagram-NO4QXBWP-BReDLFsU.js} +2 -2
  32. package/dist/assets/{gitGraphDiagram-IHSO6WYX-zv2JmANO.js → gitGraphDiagram-IHSO6WYX-CEzFOhrL.js} +2 -2
  33. package/dist/assets/{index-DGfdjscl.css → index-B-FERC-W.css} +1 -1
  34. package/dist/assets/index-mKJDH7Ot.js +135 -0
  35. package/dist/assets/{infoDiagram-FWYZ7A6U-DEcOkDAn.js → infoDiagram-FWYZ7A6U-MNtISf3v.js} +2 -2
  36. package/dist/assets/{ishikawaDiagram-FXEZZL3T-BJrgSmAk.js → ishikawaDiagram-FXEZZL3T-6O8VElo9.js} +2 -2
  37. package/dist/assets/{journeyDiagram-5HDEW3XC-C5jDM6aI.js → journeyDiagram-5HDEW3XC-CB-ZuAF1.js} +2 -2
  38. package/dist/assets/{kanban-definition-HUTT4EX6-C_SOTYB_.js → kanban-definition-HUTT4EX6-waS8GFlU.js} +2 -2
  39. package/dist/assets/{linear-B2_xcRzn.js → linear-BypRlxdJ.js} +2 -2
  40. package/dist/assets/{mermaid.core-DtYr0_Mo.js → mermaid.core-DFl7RhFX.js} +5 -5
  41. package/dist/assets/{mindmap-definition-LN4V7U3C-DZ-9-uOb.js → mindmap-definition-LN4V7U3C-BZN-zc9E.js} +2 -2
  42. package/dist/assets/{pegDiagram-2B236MQR-CYHLogK5.js → pegDiagram-2B236MQR-SchySTJf.js} +2 -2
  43. package/dist/assets/{pieDiagram-ENE6RG2P-1AsP7e93.js → pieDiagram-ENE6RG2P-CQ2pvh8Q.js} +2 -2
  44. package/dist/assets/{quadrantDiagram-ABIIQ3AL-Cyzx5buZ.js → quadrantDiagram-ABIIQ3AL-C6vQnfAs.js} +2 -2
  45. package/dist/assets/{railroadDiagram-RFXS5EU6-CZw5BDc8.js → railroadDiagram-RFXS5EU6-Cmb7FtAP.js} +2 -2
  46. package/dist/assets/{requirementDiagram-TGXJPOKE-vPSkyXKw.js → requirementDiagram-TGXJPOKE-DAXFIRCv.js} +2 -2
  47. package/dist/assets/{sankeyDiagram-HTMAVEWB-C2MB60Ae.js → sankeyDiagram-HTMAVEWB-BWr5ag-s.js} +2 -2
  48. package/dist/assets/{sequenceDiagram-DBY2YBRQ-Bl_kSlwY.js → sequenceDiagram-DBY2YBRQ-Dj_80TqD.js} +2 -2
  49. package/dist/assets/{sizeCapture-X5ZJPWSS-CeyXM3P6.js → sizeCapture-X5ZJPWSS-DAEm627l.js} +2 -2
  50. package/dist/assets/{stateDiagram-2N3HPSRC-DV9HzA_f.js → stateDiagram-2N3HPSRC-FgjCzeK0.js} +2 -2
  51. package/dist/assets/stateDiagram-v2-6OUMAXLB-D1LWa2Hy.js +2 -0
  52. package/dist/assets/{swimlanes-5IMT3BWC-Mvd3QXYZ.js → swimlanes-5IMT3BWC-BEQjgozZ.js} +3 -3
  53. package/dist/assets/swimlanesDiagram-G3AALYLV-CMtZqccP.js +9 -0
  54. package/dist/assets/{timeline-definition-FHXFAJF6-H3xIXxsh.js → timeline-definition-FHXFAJF6-CYTxFiHP.js} +2 -2
  55. package/dist/assets/{vennDiagram-L72KCM5P-DpH11NML.js → vennDiagram-L72KCM5P-DAdkafCo.js} +2 -2
  56. package/dist/assets/{wardleyDiagram-EHGQE667-gAEsOW4c.js → wardleyDiagram-EHGQE667-BkG_3-sh.js} +2 -2
  57. package/dist/assets/{xychartDiagram-FW5EYKEG-6MlU2vLG.js → xychartDiagram-FW5EYKEG-Db2wjkzJ.js} +2 -2
  58. package/dist/index.html +2 -2
  59. package/dist/llms.txt +1 -1
  60. package/package.json +3 -3
  61. package/dist/assets/channel-D0tojHCx.js +0 -2
  62. package/dist/assets/classDiagram-OUVF2IWQ-C_9lZaEm.js +0 -2
  63. package/dist/assets/classDiagram-v2-EOCWNBFH-C_9lZaEm.js +0 -2
  64. package/dist/assets/index-CBYVkpsN.js +0 -135
  65. package/dist/assets/stateDiagram-v2-6OUMAXLB-CWpTtXGx.js +0 -2
  66. package/dist/assets/swimlanesDiagram-G3AALYLV-CXMWoo1W.js +0 -9
@@ -1,135 +0,0 @@
1
- var J_=Object.defineProperty;var Q_=(s,n,r)=>n in s?J_(s,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[n]=r;var Ka=(s,n,r)=>Q_(s,typeof n!="symbol"?n+"":n,r);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function r(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=r(l);fetch(l.href,u)}})();function Y_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Vu={exports:{}},Lo={},Gu={exports:{}},pt={};/**
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 Af;function X_(){if(Af)return pt;Af=1;var s=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),m=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),g=Symbol.iterator;function w(k){return k===null||typeof k!="object"?null:(k=g&&k[g]||k["@@iterator"],typeof k=="function"?k:null)}var L={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},A=Object.assign,$={};function T(k,C,re){this.props=k,this.context=C,this.refs=$,this.updater=re||L}T.prototype.isReactComponent={},T.prototype.setState=function(k,C){if(typeof k!="object"&&typeof k!="function"&&k!=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,k,C,"setState")},T.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function B(){}B.prototype=T.prototype;function O(k,C,re){this.props=k,this.context=C,this.refs=$,this.updater=re||L}var M=O.prototype=new B;M.constructor=O,A(M,T.prototype),M.isPureReactComponent=!0;var P=Array.isArray,E=Object.prototype.hasOwnProperty,Q={current:null},oe={key:!0,ref:!0,__self:!0,__source:!0};function G(k,C,re){var he,le={},D=null,be=null;if(C!=null)for(he in C.ref!==void 0&&(be=C.ref),C.key!==void 0&&(D=""+C.key),C)E.call(C,he)&&!oe.hasOwnProperty(he)&&(le[he]=C[he]);var $e=arguments.length-2;if($e===1)le.children=re;else if(1<$e){for(var Oe=Array($e),Re=0;Re<$e;Re++)Oe[Re]=arguments[Re+2];le.children=Oe}if(k&&k.defaultProps)for(he in $e=k.defaultProps,$e)le[he]===void 0&&(le[he]=$e[he]);return{$$typeof:s,type:k,key:D,ref:be,props:le,_owner:Q.current}}function Ne(k,C){return{$$typeof:s,type:k.type,key:C,ref:k.ref,props:k.props,_owner:k._owner}}function je(k){return typeof k=="object"&&k!==null&&k.$$typeof===s}function we(k){var C={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(re){return C[re]})}var ve=/\/+/g;function H(k,C){return typeof k=="object"&&k!==null&&k.key!=null?we(""+k.key):C.toString(36)}function X(k,C,re,he,le){var D=typeof k;(D==="undefined"||D==="boolean")&&(k=null);var be=!1;if(k===null)be=!0;else switch(D){case"string":case"number":be=!0;break;case"object":switch(k.$$typeof){case s:case n:be=!0}}if(be)return be=k,le=le(be),k=he===""?"."+H(be,0):he,P(le)?(re="",k!=null&&(re=k.replace(ve,"$&/")+"/"),X(le,C,re,"",function(Re){return Re})):le!=null&&(je(le)&&(le=Ne(le,re+(!le.key||be&&be.key===le.key?"":(""+le.key).replace(ve,"$&/")+"/")+k)),C.push(le)),1;if(be=0,he=he===""?".":he+":",P(k))for(var $e=0;$e<k.length;$e++){D=k[$e];var Oe=he+H(D,$e);be+=X(D,C,re,Oe,le)}else if(Oe=w(k),typeof Oe=="function")for(k=Oe.call(k),$e=0;!(D=k.next()).done;)D=D.value,Oe=he+H(D,$e++),be+=X(D,C,re,Oe,le);else if(D==="object")throw C=String(k),Error("Objects are not valid as a React child (found: "+(C==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":C)+"). If you meant to render a collection of children, use an array instead.");return be}function Z(k,C,re){if(k==null)return k;var he=[],le=0;return X(k,he,"","",function(D){return C.call(re,D,le++)}),he}function U(k){if(k._status===-1){var C=k._result;C=C(),C.then(function(re){(k._status===0||k._status===-1)&&(k._status=1,k._result=re)},function(re){(k._status===0||k._status===-1)&&(k._status=2,k._result=re)}),k._status===-1&&(k._status=0,k._result=C)}if(k._status===1)return k._result.default;throw k._result}var Y={current:null},I={transition:null},te={ReactCurrentDispatcher:Y,ReactCurrentBatchConfig:I,ReactCurrentOwner:Q};function ae(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:Z,forEach:function(k,C,re){Z(k,function(){C.apply(this,arguments)},re)},count:function(k){var C=0;return Z(k,function(){C++}),C},toArray:function(k){return Z(k,function(C){return C})||[]},only:function(k){if(!je(k))throw Error("React.Children.only expected to receive a single React element child.");return k}},pt.Component=T,pt.Fragment=r,pt.Profiler=l,pt.PureComponent=O,pt.StrictMode=i,pt.Suspense=h,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=te,pt.act=ae,pt.cloneElement=function(k,C,re){if(k==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+k+".");var he=A({},k.props),le=k.key,D=k.ref,be=k._owner;if(C!=null){if(C.ref!==void 0&&(D=C.ref,be=Q.current),C.key!==void 0&&(le=""+C.key),k.type&&k.type.defaultProps)var $e=k.type.defaultProps;for(Oe in C)E.call(C,Oe)&&!oe.hasOwnProperty(Oe)&&(he[Oe]=C[Oe]===void 0&&$e!==void 0?$e[Oe]:C[Oe])}var Oe=arguments.length-2;if(Oe===1)he.children=re;else if(1<Oe){$e=Array(Oe);for(var Re=0;Re<Oe;Re++)$e[Re]=arguments[Re+2];he.children=$e}return{$$typeof:s,type:k.type,key:le,ref:D,props:he,_owner:be}},pt.createContext=function(k){return k={$$typeof:m,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},k.Provider={$$typeof:u,_context:k},k.Consumer=k},pt.createElement=G,pt.createFactory=function(k){var C=G.bind(null,k);return C.type=k,C},pt.createRef=function(){return{current:null}},pt.forwardRef=function(k){return{$$typeof:d,render:k}},pt.isValidElement=je,pt.lazy=function(k){return{$$typeof:v,_payload:{_status:-1,_result:k},_init:U}},pt.memo=function(k,C){return{$$typeof:x,type:k,compare:C===void 0?null:C}},pt.startTransition=function(k){var C=I.transition;I.transition={};try{k()}finally{I.transition=C}},pt.unstable_act=ae,pt.useCallback=function(k,C){return Y.current.useCallback(k,C)},pt.useContext=function(k){return Y.current.useContext(k)},pt.useDebugValue=function(){},pt.useDeferredValue=function(k){return Y.current.useDeferredValue(k)},pt.useEffect=function(k,C){return Y.current.useEffect(k,C)},pt.useId=function(){return Y.current.useId()},pt.useImperativeHandle=function(k,C,re){return Y.current.useImperativeHandle(k,C,re)},pt.useInsertionEffect=function(k,C){return Y.current.useInsertionEffect(k,C)},pt.useLayoutEffect=function(k,C){return Y.current.useLayoutEffect(k,C)},pt.useMemo=function(k,C){return Y.current.useMemo(k,C)},pt.useReducer=function(k,C,re){return Y.current.useReducer(k,C,re)},pt.useRef=function(k){return Y.current.useRef(k)},pt.useState=function(k){return Y.current.useState(k)},pt.useSyncExternalStore=function(k,C,re){return Y.current.useSyncExternalStore(k,C,re)},pt.useTransition=function(){return Y.current.useTransition()},pt.version="18.3.1",pt}var Lf;function Bd(){return Lf||(Lf=1,Gu.exports=X_()),Gu.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 Mf;function Z_(){if(Mf)return Lo;Mf=1;var s=Bd(),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function m(d,h,x){var v,g={},w=null,L=null;x!==void 0&&(w=""+x),h.key!==void 0&&(w=""+h.key),h.ref!==void 0&&(L=h.ref);for(v in h)i.call(h,v)&&!u.hasOwnProperty(v)&&(g[v]=h[v]);if(d&&d.defaultProps)for(v in h=d.defaultProps,h)g[v]===void 0&&(g[v]=h[v]);return{$$typeof:n,type:d,key:w,ref:L,props:g,_owner:l.current}}return Lo.Fragment=r,Lo.jsx=m,Lo.jsxs=m,Lo}var Rf;function eg(){return Rf||(Rf=1,Vu.exports=Z_()),Vu.exports}var e=eg(),f=Bd();const Bt=Y_(f);var mc={},Ku={exports:{}},Hn={},Ju={exports:{}},Qu={};/**
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 Pf;function tg(){return Pf||(Pf=1,(function(s){function n(I,te){var ae=I.length;I.push(te);e:for(;0<ae;){var k=ae-1>>>1,C=I[k];if(0<l(C,te))I[k]=te,I[ae]=C,ae=k;else break e}}function r(I){return I.length===0?null:I[0]}function i(I){if(I.length===0)return null;var te=I[0],ae=I.pop();if(ae!==te){I[0]=ae;e:for(var k=0,C=I.length,re=C>>>1;k<re;){var he=2*(k+1)-1,le=I[he],D=he+1,be=I[D];if(0>l(le,ae))D<C&&0>l(be,le)?(I[k]=be,I[D]=ae,k=D):(I[k]=le,I[he]=ae,k=he);else if(D<C&&0>l(be,ae))I[k]=be,I[D]=ae,k=D;else break e}}return te}function l(I,te){var ae=I.sortIndex-te.sortIndex;return ae!==0?ae:I.id-te.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;s.unstable_now=function(){return u.now()}}else{var m=Date,d=m.now();s.unstable_now=function(){return m.now()-d}}var h=[],x=[],v=1,g=null,w=3,L=!1,A=!1,$=!1,T=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(I){for(var te=r(x);te!==null;){if(te.callback===null)i(x);else if(te.startTime<=I)i(x),te.sortIndex=te.expirationTime,n(h,te);else break;te=r(x)}}function P(I){if($=!1,M(I),!A)if(r(h)!==null)A=!0,U(E);else{var te=r(x);te!==null&&Y(P,te.startTime-I)}}function E(I,te){A=!1,$&&($=!1,B(G),G=-1),L=!0;var ae=w;try{for(M(te),g=r(h);g!==null&&(!(g.expirationTime>te)||I&&!we());){var k=g.callback;if(typeof k=="function"){g.callback=null,w=g.priorityLevel;var C=k(g.expirationTime<=te);te=s.unstable_now(),typeof C=="function"?g.callback=C:g===r(h)&&i(h),M(te)}else i(h);g=r(h)}if(g!==null)var re=!0;else{var he=r(x);he!==null&&Y(P,he.startTime-te),re=!1}return re}finally{g=null,w=ae,L=!1}}var Q=!1,oe=null,G=-1,Ne=5,je=-1;function we(){return!(s.unstable_now()-je<Ne)}function ve(){if(oe!==null){var I=s.unstable_now();je=I;var te=!0;try{te=oe(!0,I)}finally{te?H():(Q=!1,oe=null)}}else Q=!1}var H;if(typeof O=="function")H=function(){O(ve)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,Z=X.port2;X.port1.onmessage=ve,H=function(){Z.postMessage(null)}}else H=function(){T(ve,0)};function U(I){oe=I,Q||(Q=!0,H())}function Y(I,te){G=T(function(){I(s.unstable_now())},te)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(I){I.callback=null},s.unstable_continueExecution=function(){A||L||(A=!0,U(E))},s.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Ne=0<I?Math.floor(1e3/I):5},s.unstable_getCurrentPriorityLevel=function(){return w},s.unstable_getFirstCallbackNode=function(){return r(h)},s.unstable_next=function(I){switch(w){case 1:case 2:case 3:var te=3;break;default:te=w}var ae=w;w=te;try{return I()}finally{w=ae}},s.unstable_pauseExecution=function(){},s.unstable_requestPaint=function(){},s.unstable_runWithPriority=function(I,te){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var ae=w;w=I;try{return te()}finally{w=ae}},s.unstable_scheduleCallback=function(I,te,ae){var k=s.unstable_now();switch(typeof ae=="object"&&ae!==null?(ae=ae.delay,ae=typeof ae=="number"&&0<ae?k+ae:k):ae=k,I){case 1:var C=-1;break;case 2:C=250;break;case 5:C=1073741823;break;case 4:C=1e4;break;default:C=5e3}return C=ae+C,I={id:v++,callback:te,priorityLevel:I,startTime:ae,expirationTime:C,sortIndex:-1},ae>k?(I.sortIndex=ae,n(x,I),r(h)===null&&I===r(x)&&($?(B(G),G=-1):$=!0,Y(P,ae-k))):(I.sortIndex=C,n(h,I),A||L||(A=!0,U(E))),I},s.unstable_shouldYield=we,s.unstable_wrapCallback=function(I){var te=w;return function(){var ae=w;w=te;try{return I.apply(this,arguments)}finally{w=ae}}}})(Qu)),Qu}var zf;function ng(){return zf||(zf=1,Ju.exports=tg()),Ju.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 If;function sg(){if(If)return Hn;If=1;var s=Bd(),n=ng();function r(t){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)a+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,l={};function u(t,a){m(t,a),m(t+"Capture",a)}function m(t,a){for(l[t]=a,t=0;t<a.length;t++)i.add(a[t])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,x=/^[: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]*$/,v={},g={};function w(t){return h.call(g,t)?!0:h.call(v,t)?!1:x.test(t)?g[t]=!0:(v[t]=!0,!1)}function L(t,a,o,c){if(o!==null&&o.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function A(t,a,o,c){if(a===null||typeof a>"u"||L(t,a,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function $(t,a,o,c,_,y,j){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=c,this.attributeNamespace=_,this.mustUseProperty=o,this.propertyName=t,this.type=a,this.sanitizeURL=y,this.removeEmptyString=j}var T={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){T[t]=new $(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var a=t[0];T[a]=new $(a,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){T[t]=new $(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){T[t]=new $(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){T[t]=new $(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){T[t]=new $(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){T[t]=new $(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){T[t]=new $(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){T[t]=new $(t,5,!1,t.toLowerCase(),null,!1,!1)});var B=/[\-:]([a-z])/g;function O(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 a=t.replace(B,O);T[a]=new $(a,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var a=t.replace(B,O);T[a]=new $(a,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var a=t.replace(B,O);T[a]=new $(a,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){T[t]=new $(t,1,!1,t.toLowerCase(),null,!1,!1)}),T.xlinkHref=new $("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){T[t]=new $(t,1,!1,t.toLowerCase(),null,!0,!0)});function M(t,a,o,c){var _=T.hasOwnProperty(a)?T[a]:null;(_!==null?_.type!==0:c||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(A(a,o,_,c)&&(o=null),c||_===null?w(a)&&(o===null?t.removeAttribute(a):t.setAttribute(a,""+o)):_.mustUseProperty?t[_.propertyName]=o===null?_.type===3?!1:"":o:(a=_.attributeName,c=_.attributeNamespace,o===null?t.removeAttribute(a):(_=_.type,o=_===3||_===4&&o===!0?"":""+o,c?t.setAttributeNS(c,a,o):t.setAttribute(a,o))))}var P=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),Q=Symbol.for("react.portal"),oe=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),Ne=Symbol.for("react.profiler"),je=Symbol.for("react.provider"),we=Symbol.for("react.context"),ve=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),I=Symbol.iterator;function te(t){return t===null||typeof t!="object"?null:(t=I&&t[I]||t["@@iterator"],typeof t=="function"?t:null)}var ae=Object.assign,k;function C(t){if(k===void 0)try{throw Error()}catch(o){var a=o.stack.trim().match(/\n( *(at )?)/);k=a&&a[1]||""}return`
34
- `+k+t}var re=!1;function he(t,a){if(!t||re)return"";re=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(_e){var c=_e}Reflect.construct(t,[],a)}else{try{a.call()}catch(_e){c=_e}t.call(a.prototype)}else{try{throw Error()}catch(_e){c=_e}t()}}catch(_e){if(_e&&c&&typeof _e.stack=="string"){for(var _=_e.stack.split(`
35
- `),y=c.stack.split(`
36
- `),j=_.length-1,q=y.length-1;1<=j&&0<=q&&_[j]!==y[q];)q--;for(;1<=j&&0<=q;j--,q--)if(_[j]!==y[q]){if(j!==1||q!==1)do if(j--,q--,0>q||_[j]!==y[q]){var K=`
37
- `+_[j].replace(" at new "," at ");return t.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",t.displayName)),K}while(1<=j&&0<=q);break}}}finally{re=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?C(t):""}function le(t){switch(t.tag){case 5:return C(t.type);case 16:return C("Lazy");case 13:return C("Suspense");case 19:return C("SuspenseList");case 0:case 2:case 15:return t=he(t.type,!1),t;case 11:return t=he(t.type.render,!1),t;case 1:return t=he(t.type,!0),t;default:return""}}function D(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 Q:return"Portal";case Ne:return"Profiler";case G:return"StrictMode";case H:return"Suspense";case X:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case we:return(t.displayName||"Context")+".Consumer";case je:return(t._context.displayName||"Context")+".Provider";case ve:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Z:return a=t.displayName||null,a!==null?a:D(t.type)||"Memo";case U:a=t._payload,t=t._init;try{return D(t(a))}catch{}}return null}function be(t){var a=t.type;switch(t.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=a.render,t=t.displayName||t.name||"",a.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return D(a);case 8:return a===G?"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 a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function $e(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Oe(t){var a=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Re(t){var a=Oe(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,a),c=""+t[a];if(!t.hasOwnProperty(a)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var _=o.get,y=o.set;return Object.defineProperty(t,a,{configurable:!0,get:function(){return _.call(this)},set:function(j){c=""+j,y.call(this,j)}}),Object.defineProperty(t,a,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(j){c=""+j},stopTracking:function(){t._valueTracker=null,delete t[a]}}}}function rt(t){t._valueTracker||(t._valueTracker=Re(t))}function qe(t){if(!t)return!1;var a=t._valueTracker;if(!a)return!0;var o=a.getValue(),c="";return t&&(c=Oe(t)?t.checked?"true":"false":t.value),t=c,t!==o?(a.setValue(t),!0):!1}function it(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 Ge(t,a){var o=a.checked;return ae({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function ct(t,a){var o=a.defaultValue==null?"":a.defaultValue,c=a.checked!=null?a.checked:a.defaultChecked;o=$e(a.value!=null?a.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function et(t,a){a=a.checked,a!=null&&M(t,"checked",a,!1)}function fe(t,a){et(t,a);var o=$e(a.value),c=a.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}a.hasOwnProperty("value")?Ee(t,a.type,o):a.hasOwnProperty("defaultValue")&&Ee(t,a.type,$e(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(t.defaultChecked=!!a.defaultChecked)}function ce(t,a,o){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var c=a.type;if(!(c!=="submit"&&c!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+t._wrapperState.initialValue,o||a===t.value||(t.value=a),t.defaultValue=a}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function Ee(t,a,o){(a!=="number"||it(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var se=Array.isArray;function W(t,a,o,c){if(t=t.options,a){a={};for(var _=0;_<o.length;_++)a["$"+o[_]]=!0;for(o=0;o<t.length;o++)_=a.hasOwnProperty("$"+t[o].value),t[o].selected!==_&&(t[o].selected=_),_&&c&&(t[o].defaultSelected=!0)}else{for(o=""+$e(o),a=null,_=0;_<t.length;_++){if(t[_].value===o){t[_].selected=!0,c&&(t[_].defaultSelected=!0);return}a!==null||t[_].disabled||(a=t[_])}a!==null&&(a.selected=!0)}}function ie(t,a){if(a.dangerouslySetInnerHTML!=null)throw Error(r(91));return ae({},a,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ce(t,a){var o=a.value;if(o==null){if(o=a.children,a=a.defaultValue,o!=null){if(a!=null)throw Error(r(92));if(se(o)){if(1<o.length)throw Error(r(93));o=o[0]}a=o}a==null&&(a=""),o=a}t._wrapperState={initialValue:$e(o)}}function Je(t,a){var o=$e(a.value),c=$e(a.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),a.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function F(t){var a=t.textContent;a===t._wrapperState.initialValue&&a!==""&&a!==null&&(t.value=a)}function ue(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 ye(t,a){return t==null||t==="http://www.w3.org/1999/xhtml"?ue(a):t==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var xe,ke=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,o,c,_){MSApp.execUnsafeLocalFunction(function(){return t(a,o,c,_)})}:t})(function(t,a){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=a;else{for(xe=xe||document.createElement("div"),xe.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=xe.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;a.firstChild;)t.appendChild(a.firstChild)}});function J(t,a){if(a){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=a;return}}t.textContent=a}var R={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},ee=["Webkit","ms","Moz","O"];Object.keys(R).forEach(function(t){ee.forEach(function(a){a=a+t.charAt(0).toUpperCase()+t.substring(1),R[a]=R[t]})});function Pe(t,a,o){return a==null||typeof a=="boolean"||a===""?"":o||typeof a!="number"||a===0||R.hasOwnProperty(t)&&R[t]?(""+a).trim():a+"px"}function Fe(t,a){t=t.style;for(var o in a)if(a.hasOwnProperty(o)){var c=o.indexOf("--")===0,_=Pe(o,a[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,_):t[o]=_}}var Xe=ae({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 ut(t,a){if(a){if(Xe[t]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(r(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(r(61))}if(a.style!=null&&typeof a.style!="object")throw Error(r(62))}}function mt(t,a){if(t.indexOf("-")===-1)return typeof a.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 Le=null;function nt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ht=null,Pt=null,wt=null;function tn(t){if(t=Cr(t)){if(typeof ht!="function")throw Error(r(280));var a=t.stateNode;a&&(a=hi(a),ht(t.stateNode,t.type,a))}}function ge(t){Pt?wt?wt.push(t):wt=[t]:Pt=t}function Te(){if(Pt){var t=Pt,a=wt;if(wt=Pt=null,tn(t),a)for(t=0;t<a.length;t++)tn(a[t])}}function Ye(t,a){return t(a)}function yt(){}var _t=!1;function jt(t,a,o){if(_t)return t(a,o);_t=!0;try{return Ye(t,a,o)}finally{_t=!1,(Pt!==null||wt!==null)&&(yt(),Te())}}function ot(t,a){var o=t.stateNode;if(o===null)return null;var c=hi(o);if(c===null)return null;o=c[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(r(231,a,typeof o));return o}var $n=!1;if(d)try{var $s={};Object.defineProperty($s,"passive",{get:function(){$n=!0}}),window.addEventListener("test",$s,$s),window.removeEventListener("test",$s,$s)}catch{$n=!1}function nr(t,a,o,c,_,y,j,q,K){var _e=Array.prototype.slice.call(arguments,3);try{a.apply(o,_e)}catch(Me){this.onError(Me)}}var Es=!1,ls=null,nn=!1,Gs=null,Ks={onError:function(t){Es=!0,ls=t}};function Ts(t,a,o,c,_,y,j,q,K){Es=!1,ls=null,nr.apply(Ks,arguments)}function Pi(t,a,o,c,_,y,j,q,K){if(Ts.apply(this,arguments),Es){if(Es){var _e=ls;Es=!1,ls=null}else throw Error(r(198));nn||(nn=!0,Gs=_e)}}function As(t){var a=t,o=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(o=a.return),t=a.return;while(t)}return a.tag===3?o:null}function Ur(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function ft(t){if(As(t)!==t)throw Error(r(188))}function Ht(t){var a=t.alternate;if(!a){if(a=As(t),a===null)throw Error(r(188));return a!==t?null:t}for(var o=t,c=a;;){var _=o.return;if(_===null)break;var y=_.alternate;if(y===null){if(c=_.return,c!==null){o=c;continue}break}if(_.child===y.child){for(y=_.child;y;){if(y===o)return ft(_),t;if(y===c)return ft(_),a;y=y.sibling}throw Error(r(188))}if(o.return!==c.return)o=_,c=y;else{for(var j=!1,q=_.child;q;){if(q===o){j=!0,o=_,c=y;break}if(q===c){j=!0,c=_,o=y;break}q=q.sibling}if(!j){for(q=y.child;q;){if(q===o){j=!0,o=y,c=_;break}if(q===c){j=!0,c=y,o=_;break}q=q.sibling}if(!j)throw Error(r(189))}}if(o.alternate!==c)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?t:a}function sr(t){return t=Ht(t),t!==null?Rt(t):null}function Rt(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var a=Rt(t);if(a!==null)return a;t=t.sibling}return null}var ar=n.unstable_scheduleCallback,zi=n.unstable_cancelCallback,ll=n.unstable_shouldYield,Ii=n.unstable_requestPaint,It=n.unstable_now,Wr=n.unstable_getCurrentPriorityLevel,Hr=n.unstable_ImmediatePriority,rr=n.unstable_UserBlockingPriority,Js=n.unstable_NormalPriority,cl=n.unstable_LowPriority,Vr=n.unstable_IdlePriority,cs=null,hn=null;function Gr(t){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot(cs,t,void 0,(t.current.flags&128)===128)}catch{}}var pn=Math.clz32?Math.clz32:dl,ul=Math.log,ga=Math.LN2;function dl(t){return t>>>=0,t===0?32:31-(ul(t)/ga|0)|0}var ya=64,Kr=4194304;function ir(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function bn(t,a){var o=t.pendingLanes;if(o===0)return 0;var c=0,_=t.suspendedLanes,y=t.pingedLanes,j=o&268435455;if(j!==0){var q=j&~_;q!==0?c=ir(q):(y&=j,y!==0&&(c=ir(y)))}else j=o&~_,j!==0?c=ir(j):y!==0&&(c=ir(y));if(c===0)return 0;if(a!==0&&a!==c&&(a&_)===0&&(_=c&-c,y=a&-a,_>=y||_===16&&(y&4194240)!==0))return a;if((c&4)!==0&&(c|=o&16),a=t.entangledLanes,a!==0)for(t=t.entanglements,a&=c;0<a;)o=31-pn(a),_=1<<o,c|=t[o],a&=~_;return c}function Qs(t,a){switch(t){case 1:case 2:case 4:return a+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 a+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 Jr(t,a){for(var o=t.suspendedLanes,c=t.pingedLanes,_=t.expirationTimes,y=t.pendingLanes;0<y;){var j=31-pn(y),q=1<<j,K=_[j];K===-1?((q&o)===0||(q&c)!==0)&&(_[j]=Qs(q,a)):K<=a&&(t.expiredLanes|=q),y&=~q}}function Ls(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Vt(){var t=ya;return ya<<=1,(ya&4194240)===0&&(ya=64),t}function Xt(t){for(var a=[],o=0;31>o;o++)a.push(t);return a}function Ms(t,a,o){t.pendingLanes|=a,a!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,a=31-pn(a),t[a]=o}function va(t,a){var o=t.pendingLanes&~a;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=a,t.mutableReadLanes&=a,t.entangledLanes&=a,a=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var _=31-pn(o),y=1<<_;a[_]=0,c[_]=-1,t[_]=-1,o&=~y}}function Rs(t,a){var o=t.entangledLanes|=a;for(t=t.entanglements;o;){var c=31-pn(o),_=1<<c;_&a|t[c]&a&&(t[c]|=a),o&=~_}}var kt=0;function Gt(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var us,Qr,zn,Yr,Di,or=!1,lr=[],ds=null,Kn=null,En=null,Ps=new Map,cn=new Map,_n=[],Pc="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 xa(t,a){switch(t){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":En=null;break;case"pointerover":case"pointerout":Ps.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":cn.delete(a.pointerId)}}function Et(t,a,o,c,_,y){return t===null||t.nativeEvent!==y?(t={blockedOn:a,domEventName:o,eventSystemFlags:c,nativeEvent:y,targetContainers:[_]},a!==null&&(a=Cr(a),a!==null&&Qr(a)),t):(t.eventSystemFlags|=c,a=t.targetContainers,_!==null&&a.indexOf(_)===-1&&a.push(_),t)}function Jn(t,a,o,c,_){switch(a){case"focusin":return ds=Et(ds,t,a,o,c,_),!0;case"dragenter":return Kn=Et(Kn,t,a,o,c,_),!0;case"mouseover":return En=Et(En,t,a,o,c,_),!0;case"pointerover":var y=_.pointerId;return Ps.set(y,Et(Ps.get(y)||null,t,a,o,c,_)),!0;case"gotpointercapture":return y=_.pointerId,cn.set(y,Et(cn.get(y)||null,t,a,o,c,_)),!0}return!1}function In(t){var a=vs(t.target);if(a!==null){var o=As(a);if(o!==null){if(a=o.tag,a===13){if(a=Ur(o),a!==null){t.blockedOn=a,Di(t.priority,function(){zn(o)});return}}else if(a===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ba(t){if(t.blockedOn!==null)return!1;for(var a=t.targetContainers;0<a.length;){var o=mr(t.domEventName,t.eventSystemFlags,a[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);Le=c,o.target.dispatchEvent(c),Le=null}else return a=Cr(o),a!==null&&Qr(a),t.blockedOn=o,!1;a.shift()}return!0}function Xr(t,a,o){ba(t)&&o.delete(a)}function ml(){or=!1,ds!==null&&ba(ds)&&(ds=null),Kn!==null&&ba(Kn)&&(Kn=null),En!==null&&ba(En)&&(En=null),Ps.forEach(Xr),cn.forEach(Xr)}function wn(t,a){t.blockedOn===a&&(t.blockedOn=null,or||(or=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ml)))}function wa(t){function a(_){return wn(_,t)}if(0<lr.length){wn(lr[0],t);for(var o=1;o<lr.length;o++){var c=lr[o];c.blockedOn===t&&(c.blockedOn=null)}}for(ds!==null&&wn(ds,t),Kn!==null&&wn(Kn,t),En!==null&&wn(En,t),Ps.forEach(a),cn.forEach(a),o=0;o<_n.length;o++)c=_n[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<_n.length&&(o=_n[0],o.blockedOn===null);)In(o),o.blockedOn===null&&_n.shift()}var ms=P.ReactCurrentBatchConfig,cr=!0;function Oi(t,a,o,c){var _=kt,y=ms.transition;ms.transition=null;try{kt=1,Zr(t,a,o,c)}finally{kt=_,ms.transition=y}}function ur(t,a,o,c){var _=kt,y=ms.transition;ms.transition=null;try{kt=4,Zr(t,a,o,c)}finally{kt=_,ms.transition=y}}function Zr(t,a,o,c){if(cr){var _=mr(t,a,o,c);if(_===null)jr(t,a,c,dr,o),xa(t,c);else if(Jn(_,t,a,o,c))c.stopPropagation();else if(xa(t,c),a&4&&-1<Pc.indexOf(t)){for(;_!==null;){var y=Cr(_);if(y!==null&&us(y),y=mr(t,a,o,c),y===null&&jr(t,a,c,dr,o),y===_)break;_=y}_!==null&&c.stopPropagation()}else jr(t,a,c,null,o)}}var dr=null;function mr(t,a,o,c){if(dr=null,t=nt(c),t=vs(t),t!==null)if(a=As(t),a===null)t=null;else if(o=a.tag,o===13){if(t=Ur(a),t!==null)return t;t=null}else if(o===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;t=null}else a!==t&&(t=null);return dr=t,null}function Fi(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(Wr()){case Hr:return 1;case rr:return 4;case Js:case cl:return 16;case Vr:return 536870912;default:return 16}default:return 16}}var Dn=null,fs=null,Ys=null;function ei(){if(Ys)return Ys;var t,a=fs,o=a.length,c,_="value"in Dn?Dn.value:Dn.textContent,y=_.length;for(t=0;t<o&&a[t]===_[t];t++);var j=o-t;for(c=1;c<=j&&a[o-c]===_[y-c];c++);return Ys=_.slice(t,1<c?1-c:void 0)}function ja(t){var a=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&a===13&&(t=13)):t=a,t===10&&(t=13),32<=t||t===13?t:0}function ka(){return!0}function Xs(){return!1}function sn(t){function a(o,c,_,y,j){this._reactName=o,this._targetInst=_,this.type=c,this.nativeEvent=y,this.target=j,this.currentTarget=null;for(var q in t)t.hasOwnProperty(q)&&(o=t[q],this[q]=o?o(y):y[q]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?ka:Xs,this.isPropagationStopped=Xs,this}return ae(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=ka)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=ka)},persist:function(){},isPersistent:ka}),a}var Sa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kt=sn(Sa),zs=ae({},Sa,{view:0,detail:0}),qi=sn(zs),ti,fr,Zs,Na=ae({},zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hr,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!==Zs&&(Zs&&t.type==="mousemove"?(ti=t.screenX-Zs.screenX,fr=t.screenY-Zs.screenY):fr=ti=0,Zs=t),ti)},movementY:function(t){return"movementY"in t?t.movementY:fr}}),Bi=sn(Na),Ui=ae({},Na,{dataTransfer:0}),fl=sn(Ui),hl=ae({},zs,{relatedTarget:0}),ni=sn(hl),pl=ae({},Sa,{animationName:0,elapsedTime:0,pseudoElement:0}),Wi=sn(pl),_l=ae({},Sa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Hi=sn(_l),Vi=ae({},Sa,{data:0}),Gi=sn(Vi),On={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Is={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"},Ds={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ki(t){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(t):(t=Ds[t])?!!a[t]:!1}function hr(){return Ki}var Ji=ae({},zs,{key:function(t){if(t.key){var a=On[t.key]||t.key;if(a!=="Unidentified")return a}return t.type==="keypress"?(t=ja(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Is[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hr,charCode:function(t){return t.type==="keypress"?ja(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ja(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),zc=sn(Ji),Ca=ae({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$a=sn(Ca),hs=ae({},zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hr}),ea=sn(hs),gl=ae({},Sa,{propertyName:0,elapsedTime:0,pseudoElement:0}),yl=sn(gl),vl=ae({},Na,{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}),Ic=sn(vl),Dc=[9,13,27,32],pr=d&&"CompositionEvent"in window,ss=null;d&&"documentMode"in document&&(ss=document.documentMode);var Qi=d&&"TextEvent"in window&&!ss,Yi=d&&(!pr||ss&&8<ss&&11>=ss),si=" ",Xi=!1;function ta(t,a){switch(t){case"keyup":return Dc.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ai(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ea=!1;function _r(t,a){switch(t){case"compositionend":return ai(a);case"keypress":return a.which!==32?null:(Xi=!0,si);case"textInput":return t=a.data,t===si&&Xi?null:t;default:return null}}function Zi(t,a){if(Ea)return t==="compositionend"||!pr&&ta(t,a)?(t=ei(),Ys=fs=Dn=null,Ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Yi&&a.locale!=="ko"?null:a.data;default:return null}}var xl={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 eo(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a==="input"?!!xl[t.type]:a==="textarea"}function to(t,a,o,c){ge(c),a=mi(a,"onChange"),0<a.length&&(o=new Kt("onChange","change",null,o,c),t.push({event:o,listeners:a}))}var gr=null,Qn=null;function yr(t){Aa(t,0)}function ri(t){var a=Da(t);if(qe(a))return t}function ii(t,a){if(t==="change")return a}var oi=!1;if(d){var no;if(d){var Ta="oninput"in document;if(!Ta){var vr=document.createElement("div");vr.setAttribute("oninput","return;"),Ta=typeof vr.oninput=="function"}no=Ta}else no=!1;oi=no&&(!document.documentMode||9<document.documentMode)}function bl(){gr&&(gr.detachEvent("onpropertychange",wl),Qn=gr=null)}function wl(t){if(t.propertyName==="value"&&ri(Qn)){var a=[];to(a,Qn,t,nt(t)),jt(yr,a)}}function Oc(t,a,o){t==="focusin"?(bl(),gr=a,Qn=o,gr.attachEvent("onpropertychange",wl)):t==="focusout"&&bl()}function jl(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ri(Qn)}function Fc(t,a){if(t==="click")return ri(a)}function kl(t,a){if(t==="input"||t==="change")return ri(a)}function qc(t,a){return t===a&&(t!==0||1/t===1/a)||t!==t&&a!==a}var Yn=typeof Object.is=="function"?Object.is:qc;function na(t,a){if(Yn(t,a))return!0;if(typeof t!="object"||t===null||typeof a!="object"||a===null)return!1;var o=Object.keys(t),c=Object.keys(a);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var _=o[c];if(!h.call(a,_)||!Yn(t[_],a[_]))return!1}return!0}function Sl(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function so(t,a){var o=Sl(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=a&&c>=a)return{node:o,offset:a-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Sl(o)}}function ao(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?ao(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function Nl(){for(var t=window,a=it();a instanceof t.HTMLIFrameElement;){try{var o=typeof a.contentWindow.location.href=="string"}catch{o=!1}if(o)t=a.contentWindow;else break;a=it(t.document)}return a}function li(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}function ci(t){var a=Nl(),o=t.focusedElem,c=t.selectionRange;if(a!==o&&o&&o.ownerDocument&&ao(o.ownerDocument.documentElement,o)){if(c!==null&&li(o)){if(a=c.start,t=c.end,t===void 0&&(t=a),"selectionStart"in o)o.selectionStart=a,o.selectionEnd=Math.min(t,o.value.length);else if(t=(a=o.ownerDocument||document)&&a.defaultView||window,t.getSelection){t=t.getSelection();var _=o.textContent.length,y=Math.min(c.start,_);c=c.end===void 0?y:Math.min(c.end,_),!t.extend&&y>c&&(_=c,c=y,y=_),_=so(o,y);var j=so(o,c);_&&j&&(t.rangeCount!==1||t.anchorNode!==_.node||t.anchorOffset!==_.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(a=a.createRange(),a.setStart(_.node,_.offset),t.removeAllRanges(),y>c?(t.addRange(a),t.extend(j.node,j.offset)):(a.setEnd(j.node,j.offset),t.addRange(a)))}}for(a=[],t=o;t=t.parentNode;)t.nodeType===1&&a.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<a.length;o++)t=a[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var Cl=d&&"documentMode"in document&&11>=document.documentMode,ps=null,ui=null,xr=null,ro=!1;function io(t,a,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ro||ps==null||ps!==it(c)||(c=ps,"selectionStart"in c&&li(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),xr&&na(xr,c)||(xr=c,c=mi(ui,"onSelect"),0<c.length&&(a=new Kt("onSelect","select",null,a,o),t.push({event:a,listeners:c}),a.target=ps)))}function di(t,a){var o={};return o[t.toLowerCase()]=a.toLowerCase(),o["Webkit"+t]="webkit"+a,o["Moz"+t]="moz"+a,o}var sa={animationend:di("Animation","AnimationEnd"),animationiteration:di("Animation","AnimationIteration"),animationstart:di("Animation","AnimationStart"),transitionend:di("Transition","TransitionEnd")},oo={},lo={};d&&(lo=document.createElement("div").style,"AnimationEvent"in window||(delete sa.animationend.animation,delete sa.animationiteration.animation,delete sa.animationstart.animation),"TransitionEvent"in window||delete sa.transitionend.transition);function br(t){if(oo[t])return oo[t];if(!sa[t])return t;var a=sa[t],o;for(o in a)if(a.hasOwnProperty(o)&&o in lo)return oo[t]=a[o];return t}var $l=br("animationend"),El=br("animationiteration"),co=br("animationstart"),uo=br("transitionend"),Tl=new Map,Tn="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 vt(t,a){Tl.set(t,a),u(a,[t])}for(var Jt=0;Jt<Tn.length;Jt++){var wr=Tn[Jt],Bc=wr.toLowerCase(),Os=wr[0].toUpperCase()+wr.slice(1);vt(Bc,"on"+Os)}vt($l,"onAnimationEnd"),vt(El,"onAnimationIteration"),vt(co,"onAnimationStart"),vt("dblclick","onDoubleClick"),vt("focusin","onFocus"),vt("focusout","onBlur"),vt(uo,"onTransitionEnd"),m("onMouseEnter",["mouseout","mouseover"]),m("onMouseLeave",["mouseout","mouseover"]),m("onPointerEnter",["pointerout","pointerover"]),m("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_s=new Set("cancel close invalid load scroll toggle".split(" ").concat(Fn));function aa(t,a,o){var c=t.type||"unknown-event";t.currentTarget=o,Pi(c,a,void 0,t),t.currentTarget=null}function Aa(t,a){a=(a&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],_=c.event;c=c.listeners;e:{var y=void 0;if(a)for(var j=c.length-1;0<=j;j--){var q=c[j],K=q.instance,_e=q.currentTarget;if(q=q.listener,K!==y&&_.isPropagationStopped())break e;aa(_,q,_e),y=K}else for(j=0;j<c.length;j++){if(q=c[j],K=q.instance,_e=q.currentTarget,q=q.listener,K!==y&&_.isPropagationStopped())break e;aa(_,q,_e),y=K}}}if(nn)throw t=Gs,nn=!1,Gs=null,t}function Ct(t,a){var o=a[_o];o===void 0&&(o=a[_o]=new Set);var c=t+"__bubble";o.has(c)||(mo(a,t,2,!1),o.add(c))}function ra(t,a,o){var c=0;a&&(c|=4),mo(o,t,c,a)}var La="_reactListening"+Math.random().toString(36).slice(2);function Ma(t){if(!t[La]){t[La]=!0,i.forEach(function(o){o!=="selectionchange"&&(_s.has(o)||ra(o,!1,t),ra(o,!0,t))});var a=t.nodeType===9?t:t.ownerDocument;a===null||a[La]||(a[La]=!0,ra("selectionchange",!1,a))}}function mo(t,a,o,c){switch(Fi(a)){case 1:var _=Oi;break;case 4:_=ur;break;default:_=Zr}o=_.bind(null,a,o,t),_=void 0,!$n||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(_=!0),c?_!==void 0?t.addEventListener(a,o,{capture:!0,passive:_}):t.addEventListener(a,o,!0):_!==void 0?t.addEventListener(a,o,{passive:_}):t.addEventListener(a,o,!1)}function jr(t,a,o,c,_){var y=c;if((a&1)===0&&(a&2)===0&&c!==null)e:for(;;){if(c===null)return;var j=c.tag;if(j===3||j===4){var q=c.stateNode.containerInfo;if(q===_||q.nodeType===8&&q.parentNode===_)break;if(j===4)for(j=c.return;j!==null;){var K=j.tag;if((K===3||K===4)&&(K=j.stateNode.containerInfo,K===_||K.nodeType===8&&K.parentNode===_))return;j=j.return}for(;q!==null;){if(j=vs(q),j===null)return;if(K=j.tag,K===5||K===6){c=y=j;continue e}q=q.parentNode}}c=c.return}jt(function(){var _e=y,Me=nt(o),ze=[];e:{var Ae=Tl.get(t);if(Ae!==void 0){var He=Kt,Qe=t;switch(t){case"keypress":if(ja(o)===0)break e;case"keydown":case"keyup":He=zc;break;case"focusin":Qe="focus",He=ni;break;case"focusout":Qe="blur",He=ni;break;case"beforeblur":case"afterblur":He=ni;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=Bi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=fl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=ea;break;case $l:case El:case co:He=Wi;break;case uo:He=yl;break;case"scroll":He=qi;break;case"wheel":He=Ic;break;case"copy":case"cut":case"paste":He=Hi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=$a}var Ze=(a&4)!==0,Yt=!Ze&&t==="scroll",me=Ze?Ae!==null?Ae+"Capture":null:Ae;Ze=[];for(var ne=_e,pe;ne!==null;){pe=ne;var De=pe.stateNode;if(pe.tag===5&&De!==null&&(pe=De,me!==null&&(De=ot(ne,me),De!=null&&Ze.push(kr(ne,De,pe)))),Yt)break;ne=ne.return}0<Ze.length&&(Ae=new He(Ae,Qe,null,o,Me),ze.push({event:Ae,listeners:Ze}))}}if((a&7)===0){e:{if(Ae=t==="mouseover"||t==="pointerover",He=t==="mouseout"||t==="pointerout",Ae&&o!==Le&&(Qe=o.relatedTarget||o.fromElement)&&(vs(Qe)||Qe[ys]))break e;if((He||Ae)&&(Ae=Me.window===Me?Me:(Ae=Me.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,He?(Qe=o.relatedTarget||o.toElement,He=_e,Qe=Qe?vs(Qe):null,Qe!==null&&(Yt=As(Qe),Qe!==Yt||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(He=null,Qe=_e),He!==Qe)){if(Ze=Bi,De="onMouseLeave",me="onMouseEnter",ne="mouse",(t==="pointerout"||t==="pointerover")&&(Ze=$a,De="onPointerLeave",me="onPointerEnter",ne="pointer"),Yt=He==null?Ae:Da(He),pe=Qe==null?Ae:Da(Qe),Ae=new Ze(De,ne+"leave",He,o,Me),Ae.target=Yt,Ae.relatedTarget=pe,De=null,vs(Me)===_e&&(Ze=new Ze(me,ne+"enter",Qe,o,Me),Ze.target=pe,Ze.relatedTarget=Yt,De=Ze),Yt=De,He&&Qe)t:{for(Ze=He,me=Qe,ne=0,pe=Ze;pe;pe=ia(pe))ne++;for(pe=0,De=me;De;De=ia(De))pe++;for(;0<ne-pe;)Ze=ia(Ze),ne--;for(;0<pe-ne;)me=ia(me),pe--;for(;ne--;){if(Ze===me||me!==null&&Ze===me.alternate)break t;Ze=ia(Ze),me=ia(me)}Ze=null}else Ze=null;He!==null&&fo(ze,Ae,He,Ze,!1),Qe!==null&&Yt!==null&&fo(ze,Yt,Qe,Ze,!0)}}e:{if(Ae=_e?Da(_e):window,He=Ae.nodeName&&Ae.nodeName.toLowerCase(),He==="select"||He==="input"&&Ae.type==="file")var tt=ii;else if(eo(Ae))if(oi)tt=kl;else{tt=jl;var st=Oc}else(He=Ae.nodeName)&&He.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(tt=Fc);if(tt&&(tt=tt(t,_e))){to(ze,tt,o,Me);break e}st&&st(t,Ae,_e),t==="focusout"&&(st=Ae._wrapperState)&&st.controlled&&Ae.type==="number"&&Ee(Ae,"number",Ae.value)}switch(st=_e?Da(_e):window,t){case"focusin":(eo(st)||st.contentEditable==="true")&&(ps=st,ui=_e,xr=null);break;case"focusout":xr=ui=ps=null;break;case"mousedown":ro=!0;break;case"contextmenu":case"mouseup":case"dragend":ro=!1,io(ze,o,Me);break;case"selectionchange":if(Cl)break;case"keydown":case"keyup":io(ze,o,Me)}var at;if(pr)e:{switch(t){case"compositionstart":var dt="onCompositionStart";break e;case"compositionend":dt="onCompositionEnd";break e;case"compositionupdate":dt="onCompositionUpdate";break e}dt=void 0}else Ea?ta(t,o)&&(dt="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(dt="onCompositionStart");dt&&(Yi&&o.locale!=="ko"&&(Ea||dt!=="onCompositionStart"?dt==="onCompositionEnd"&&Ea&&(at=ei()):(Dn=Me,fs="value"in Dn?Dn.value:Dn.textContent,Ea=!0)),st=mi(_e,dt),0<st.length&&(dt=new Gi(dt,t,null,o,Me),ze.push({event:dt,listeners:st}),at?dt.data=at:(at=ai(o),at!==null&&(dt.data=at)))),(at=Qi?_r(t,o):Zi(t,o))&&(_e=mi(_e,"onBeforeInput"),0<_e.length&&(Me=new Gi("onBeforeInput","beforeinput",null,o,Me),ze.push({event:Me,listeners:_e}),Me.data=at))}Aa(ze,a)})}function kr(t,a,o){return{instance:t,listener:a,currentTarget:o}}function mi(t,a){for(var o=a+"Capture",c=[];t!==null;){var _=t,y=_.stateNode;_.tag===5&&y!==null&&(_=y,y=ot(t,o),y!=null&&c.unshift(kr(t,y,_)),y=ot(t,a),y!=null&&c.push(kr(t,y,_))),t=t.return}return c}function ia(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function fo(t,a,o,c,_){for(var y=a._reactName,j=[];o!==null&&o!==c;){var q=o,K=q.alternate,_e=q.stateNode;if(K!==null&&K===c)break;q.tag===5&&_e!==null&&(q=_e,_?(K=ot(o,y),K!=null&&j.unshift(kr(o,K,q))):_||(K=ot(o,y),K!=null&&j.push(kr(o,K,q)))),o=o.return}j.length!==0&&t.push({event:a,listeners:j})}var Ra=/\r\n?/g,Uc=/\u0000|\uFFFD/g;function An(t){return(typeof t=="string"?t:""+t).replace(Ra,`
38
- `).replace(Uc,"")}function Pa(t,a,o){if(a=An(a),An(t)!==a&&o)throw Error(r(425))}function Ln(){}var za=null,Sr=null;function Xn(t,a){return t==="textarea"||t==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var qn=typeof setTimeout=="function"?setTimeout:void 0,fi=typeof clearTimeout=="function"?clearTimeout:void 0,Al=typeof Promise=="function"?Promise:void 0,ho=typeof queueMicrotask=="function"?queueMicrotask:typeof Al<"u"?function(t){return Al.resolve(null).then(t).catch(Wc)}:qn;function Wc(t){setTimeout(function(){throw t})}function po(t,a){var o=a,c=0;do{var _=o.nextSibling;if(t.removeChild(o),_&&_.nodeType===8)if(o=_.data,o==="/$"){if(c===0){t.removeChild(_),wa(a);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=_}while(o);wa(a)}function gs(t){for(;t!=null;t=t.nextSibling){var a=t.nodeType;if(a===1||a===3)break;if(a===8){if(a=t.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return t}function Ll(t){t=t.previousSibling;for(var a=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(a===0)return t;a--}else o==="/$"&&a++}t=t.previousSibling}return null}var Ia=Math.random().toString(36).slice(2),Zn="__reactFiber$"+Ia,Nr="__reactProps$"+Ia,ys="__reactContainer$"+Ia,_o="__reactEvents$"+Ia,Hc="__reactListeners$"+Ia,Vc="__reactHandles$"+Ia;function vs(t){var a=t[Zn];if(a)return a;for(var o=t.parentNode;o;){if(a=o[ys]||o[Zn]){if(o=a.alternate,a.child!==null||o!==null&&o.child!==null)for(t=Ll(t);t!==null;){if(o=t[Zn])return o;t=Ll(t)}return a}t=o,o=t.parentNode}return null}function Cr(t){return t=t[Zn]||t[ys],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Da(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function hi(t){return t[Nr]||null}var go=[],oa=-1;function xs(t){return{current:t}}function At(t){0>oa||(t.current=go[oa],go[oa]=null,oa--)}function Tt(t,a){oa++,go[oa]=t.current,t.current=a}var bs={},an=xs(bs),gn=xs(!1),Fs=bs;function la(t,a){var o=t.type.contextTypes;if(!o)return bs;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===a)return c.__reactInternalMemoizedMaskedChildContext;var _={},y;for(y in o)_[y]=a[y];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=a,t.__reactInternalMemoizedMaskedChildContext=_),_}function p(t){return t=t.childContextTypes,t!=null}function b(){At(gn),At(an)}function N(t,a,o){if(an.current!==bs)throw Error(r(168));Tt(an,a),Tt(gn,o)}function S(t,a,o){var c=t.stateNode;if(a=a.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var _ in c)if(!(_ in a))throw Error(r(108,be(t)||"Unknown",_));return ae({},o,c)}function z(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bs,Fs=an.current,Tt(an,t),Tt(gn,gn.current),!0}function de(t,a,o){var c=t.stateNode;if(!c)throw Error(r(169));o?(t=S(t,a,Fs),c.__reactInternalMemoizedMergedChildContext=t,At(gn),At(an),Tt(an,t)):At(gn),Tt(gn,o)}var V=null,Se=!1,Ie=!1;function Be(t){V===null?V=[t]:V.push(t)}function Ve(t){Se=!0,Be(t)}function $t(){if(!Ie&&V!==null){Ie=!0;var t=0,a=kt;try{var o=V;for(kt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}V=null,Se=!1}catch(_){throw V!==null&&(V=V.slice(t+1)),ar(Hr,$t),_}finally{kt=a,Ie=!1}}return null}var zt=[],jn=0,xt=null,lt=0,Lt=[],gt=0,We=null,St=1,Ot="";function Ut(t,a){zt[jn++]=lt,zt[jn++]=xt,xt=t,lt=a}function Zt(t,a,o){Lt[gt++]=St,Lt[gt++]=Ot,Lt[gt++]=We,We=t;var c=St;t=Ot;var _=32-pn(c)-1;c&=~(1<<_),o+=1;var y=32-pn(a)+_;if(30<y){var j=_-_%5;y=(c&(1<<j)-1).toString(32),c>>=j,_-=j,St=1<<32-pn(a)+_|o<<_|c,Ot=y+t}else St=1<<y|o<<_|c,Ot=t}function Mt(t){t.return!==null&&(Ut(t,1),Zt(t,1,0))}function Qt(t){for(;t===xt;)xt=zt[--jn],zt[jn]=null,lt=zt[--jn],zt[jn]=null;for(;t===We;)We=Lt[--gt],Lt[gt]=null,Ot=Lt[--gt],Lt[gt]=null,St=Lt[--gt],Lt[gt]=null}var un=null,es=null,Dt=!1,ws=null;function sm(t,a){var o=os(5,null,null,0);o.elementType="DELETED",o.stateNode=a,o.return=t,a=t.deletions,a===null?(t.deletions=[o],t.flags|=16):a.push(o)}function am(t,a){switch(t.tag){case 5:var o=t.type;return a=a.nodeType!==1||o.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(t.stateNode=a,un=t,es=gs(a.firstChild),!0):!1;case 6:return a=t.pendingProps===""||a.nodeType!==3?null:a,a!==null?(t.stateNode=a,un=t,es=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(o=We!==null?{id:St,overflow:Ot}:null,t.memoizedState={dehydrated:a,treeContext:o,retryLane:1073741824},o=os(18,null,null,0),o.stateNode=a,o.return=t,t.child=o,un=t,es=null,!0):!1;default:return!1}}function Gc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Kc(t){if(Dt){var a=es;if(a){var o=a;if(!am(t,a)){if(Gc(t))throw Error(r(418));a=gs(o.nextSibling);var c=un;a&&am(t,a)?sm(c,o):(t.flags=t.flags&-4097|2,Dt=!1,un=t)}}else{if(Gc(t))throw Error(r(418));t.flags=t.flags&-4097|2,Dt=!1,un=t}}}function rm(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;un=t}function Ml(t){if(t!==un)return!1;if(!Dt)return rm(t),Dt=!0,!1;var a;if((a=t.tag!==3)&&!(a=t.tag!==5)&&(a=t.type,a=a!=="head"&&a!=="body"&&!Xn(t.type,t.memoizedProps)),a&&(a=es)){if(Gc(t))throw im(),Error(r(418));for(;a;)sm(t,a),a=gs(a.nextSibling)}if(rm(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,a=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(a===0){es=gs(t.nextSibling);break e}a--}else o!=="$"&&o!=="$!"&&o!=="$?"||a++}t=t.nextSibling}es=null}}else es=un?gs(t.stateNode.nextSibling):null;return!0}function im(){for(var t=es;t;)t=gs(t.nextSibling)}function pi(){es=un=null,Dt=!1}function Jc(t){ws===null?ws=[t]:ws.push(t)}var p_=P.ReactCurrentBatchConfig;function yo(t,a,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(r(309));var c=o.stateNode}if(!c)throw Error(r(147,t));var _=c,y=""+t;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===y?a.ref:(a=function(j){var q=_.refs;j===null?delete q[y]:q[y]=j},a._stringRef=y,a)}if(typeof t!="string")throw Error(r(284));if(!o._owner)throw Error(r(290,t))}return t}function Rl(t,a){throw t=Object.prototype.toString.call(a),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":t))}function om(t){var a=t._init;return a(t._payload)}function lm(t){function a(me,ne){if(t){var pe=me.deletions;pe===null?(me.deletions=[ne],me.flags|=16):pe.push(ne)}}function o(me,ne){if(!t)return null;for(;ne!==null;)a(me,ne),ne=ne.sibling;return null}function c(me,ne){for(me=new Map;ne!==null;)ne.key!==null?me.set(ne.key,ne):me.set(ne.index,ne),ne=ne.sibling;return me}function _(me,ne){return me=Va(me,ne),me.index=0,me.sibling=null,me}function y(me,ne,pe){return me.index=pe,t?(pe=me.alternate,pe!==null?(pe=pe.index,pe<ne?(me.flags|=2,ne):pe):(me.flags|=2,ne)):(me.flags|=1048576,ne)}function j(me){return t&&me.alternate===null&&(me.flags|=2),me}function q(me,ne,pe,De){return ne===null||ne.tag!==6?(ne=Fu(pe,me.mode,De),ne.return=me,ne):(ne=_(ne,pe),ne.return=me,ne)}function K(me,ne,pe,De){var tt=pe.type;return tt===oe?Me(me,ne,pe.props.children,De,pe.key):ne!==null&&(ne.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===U&&om(tt)===ne.type)?(De=_(ne,pe.props),De.ref=yo(me,ne,pe),De.return=me,De):(De=ac(pe.type,pe.key,pe.props,null,me.mode,De),De.ref=yo(me,ne,pe),De.return=me,De)}function _e(me,ne,pe,De){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==pe.containerInfo||ne.stateNode.implementation!==pe.implementation?(ne=qu(pe,me.mode,De),ne.return=me,ne):(ne=_(ne,pe.children||[]),ne.return=me,ne)}function Me(me,ne,pe,De,tt){return ne===null||ne.tag!==7?(ne=Pr(pe,me.mode,De,tt),ne.return=me,ne):(ne=_(ne,pe),ne.return=me,ne)}function ze(me,ne,pe){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Fu(""+ne,me.mode,pe),ne.return=me,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case E:return pe=ac(ne.type,ne.key,ne.props,null,me.mode,pe),pe.ref=yo(me,null,ne),pe.return=me,pe;case Q:return ne=qu(ne,me.mode,pe),ne.return=me,ne;case U:var De=ne._init;return ze(me,De(ne._payload),pe)}if(se(ne)||te(ne))return ne=Pr(ne,me.mode,pe,null),ne.return=me,ne;Rl(me,ne)}return null}function Ae(me,ne,pe,De){var tt=ne!==null?ne.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return tt!==null?null:q(me,ne,""+pe,De);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case E:return pe.key===tt?K(me,ne,pe,De):null;case Q:return pe.key===tt?_e(me,ne,pe,De):null;case U:return tt=pe._init,Ae(me,ne,tt(pe._payload),De)}if(se(pe)||te(pe))return tt!==null?null:Me(me,ne,pe,De,null);Rl(me,pe)}return null}function He(me,ne,pe,De,tt){if(typeof De=="string"&&De!==""||typeof De=="number")return me=me.get(pe)||null,q(ne,me,""+De,tt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case E:return me=me.get(De.key===null?pe:De.key)||null,K(ne,me,De,tt);case Q:return me=me.get(De.key===null?pe:De.key)||null,_e(ne,me,De,tt);case U:var st=De._init;return He(me,ne,pe,st(De._payload),tt)}if(se(De)||te(De))return me=me.get(pe)||null,Me(ne,me,De,tt,null);Rl(ne,De)}return null}function Qe(me,ne,pe,De){for(var tt=null,st=null,at=ne,dt=ne=0,fn=null;at!==null&&dt<pe.length;dt++){at.index>dt?(fn=at,at=null):fn=at.sibling;var Nt=Ae(me,at,pe[dt],De);if(Nt===null){at===null&&(at=fn);break}t&&at&&Nt.alternate===null&&a(me,at),ne=y(Nt,ne,dt),st===null?tt=Nt:st.sibling=Nt,st=Nt,at=fn}if(dt===pe.length)return o(me,at),Dt&&Ut(me,dt),tt;if(at===null){for(;dt<pe.length;dt++)at=ze(me,pe[dt],De),at!==null&&(ne=y(at,ne,dt),st===null?tt=at:st.sibling=at,st=at);return Dt&&Ut(me,dt),tt}for(at=c(me,at);dt<pe.length;dt++)fn=He(at,me,dt,pe[dt],De),fn!==null&&(t&&fn.alternate!==null&&at.delete(fn.key===null?dt:fn.key),ne=y(fn,ne,dt),st===null?tt=fn:st.sibling=fn,st=fn);return t&&at.forEach(function(Ga){return a(me,Ga)}),Dt&&Ut(me,dt),tt}function Ze(me,ne,pe,De){var tt=te(pe);if(typeof tt!="function")throw Error(r(150));if(pe=tt.call(pe),pe==null)throw Error(r(151));for(var st=tt=null,at=ne,dt=ne=0,fn=null,Nt=pe.next();at!==null&&!Nt.done;dt++,Nt=pe.next()){at.index>dt?(fn=at,at=null):fn=at.sibling;var Ga=Ae(me,at,Nt.value,De);if(Ga===null){at===null&&(at=fn);break}t&&at&&Ga.alternate===null&&a(me,at),ne=y(Ga,ne,dt),st===null?tt=Ga:st.sibling=Ga,st=Ga,at=fn}if(Nt.done)return o(me,at),Dt&&Ut(me,dt),tt;if(at===null){for(;!Nt.done;dt++,Nt=pe.next())Nt=ze(me,Nt.value,De),Nt!==null&&(ne=y(Nt,ne,dt),st===null?tt=Nt:st.sibling=Nt,st=Nt);return Dt&&Ut(me,dt),tt}for(at=c(me,at);!Nt.done;dt++,Nt=pe.next())Nt=He(at,me,dt,Nt.value,De),Nt!==null&&(t&&Nt.alternate!==null&&at.delete(Nt.key===null?dt:Nt.key),ne=y(Nt,ne,dt),st===null?tt=Nt:st.sibling=Nt,st=Nt);return t&&at.forEach(function(K_){return a(me,K_)}),Dt&&Ut(me,dt),tt}function Yt(me,ne,pe,De){if(typeof pe=="object"&&pe!==null&&pe.type===oe&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case E:e:{for(var tt=pe.key,st=ne;st!==null;){if(st.key===tt){if(tt=pe.type,tt===oe){if(st.tag===7){o(me,st.sibling),ne=_(st,pe.props.children),ne.return=me,me=ne;break e}}else if(st.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===U&&om(tt)===st.type){o(me,st.sibling),ne=_(st,pe.props),ne.ref=yo(me,st,pe),ne.return=me,me=ne;break e}o(me,st);break}else a(me,st);st=st.sibling}pe.type===oe?(ne=Pr(pe.props.children,me.mode,De,pe.key),ne.return=me,me=ne):(De=ac(pe.type,pe.key,pe.props,null,me.mode,De),De.ref=yo(me,ne,pe),De.return=me,me=De)}return j(me);case Q:e:{for(st=pe.key;ne!==null;){if(ne.key===st)if(ne.tag===4&&ne.stateNode.containerInfo===pe.containerInfo&&ne.stateNode.implementation===pe.implementation){o(me,ne.sibling),ne=_(ne,pe.children||[]),ne.return=me,me=ne;break e}else{o(me,ne);break}else a(me,ne);ne=ne.sibling}ne=qu(pe,me.mode,De),ne.return=me,me=ne}return j(me);case U:return st=pe._init,Yt(me,ne,st(pe._payload),De)}if(se(pe))return Qe(me,ne,pe,De);if(te(pe))return Ze(me,ne,pe,De);Rl(me,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ne!==null&&ne.tag===6?(o(me,ne.sibling),ne=_(ne,pe),ne.return=me,me=ne):(o(me,ne),ne=Fu(pe,me.mode,De),ne.return=me,me=ne),j(me)):o(me,ne)}return Yt}var _i=lm(!0),cm=lm(!1),Pl=xs(null),zl=null,gi=null,Qc=null;function Yc(){Qc=gi=zl=null}function Xc(t){var a=Pl.current;At(Pl),t._currentValue=a}function Zc(t,a,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&a)!==a?(t.childLanes|=a,c!==null&&(c.childLanes|=a)):c!==null&&(c.childLanes&a)!==a&&(c.childLanes|=a),t===o)break;t=t.return}}function yi(t,a){zl=t,Qc=gi=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&a)!==0&&(Bn=!0),t.firstContext=null)}function as(t){var a=t._currentValue;if(Qc!==t)if(t={context:t,memoizedValue:a,next:null},gi===null){if(zl===null)throw Error(r(308));gi=t,zl.dependencies={lanes:0,firstContext:t}}else gi=gi.next=t;return a}var $r=null;function eu(t){$r===null?$r=[t]:$r.push(t)}function um(t,a,o,c){var _=a.interleaved;return _===null?(o.next=o,eu(a)):(o.next=_.next,_.next=o),a.interleaved=o,ca(t,c)}function ca(t,a){t.lanes|=a;var o=t.alternate;for(o!==null&&(o.lanes|=a),o=t,t=t.return;t!==null;)t.childLanes|=a,o=t.alternate,o!==null&&(o.childLanes|=a),o=t,t=t.return;return o.tag===3?o.stateNode:null}var Oa=!1;function tu(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dm(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ua(t,a){return{eventTime:t,lane:a,tag:0,payload:null,callback:null,next:null}}function Fa(t,a,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(bt&2)!==0){var _=c.pending;return _===null?a.next=a:(a.next=_.next,_.next=a),c.pending=a,ca(t,o)}return _=c.interleaved,_===null?(a.next=a,eu(c)):(a.next=_.next,_.next=a),c.interleaved=a,ca(t,o)}function Il(t,a,o){if(a=a.updateQueue,a!==null&&(a=a.shared,(o&4194240)!==0)){var c=a.lanes;c&=t.pendingLanes,o|=c,a.lanes=o,Rs(t,o)}}function mm(t,a){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var _=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var j={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};y===null?_=y=j:y=y.next=j,o=o.next}while(o!==null);y===null?_=y=a:y=y.next=a}else _=y=a;o={baseState:c.baseState,firstBaseUpdate:_,lastBaseUpdate:y,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=a:t.next=a,o.lastBaseUpdate=a}function Dl(t,a,o,c){var _=t.updateQueue;Oa=!1;var y=_.firstBaseUpdate,j=_.lastBaseUpdate,q=_.shared.pending;if(q!==null){_.shared.pending=null;var K=q,_e=K.next;K.next=null,j===null?y=_e:j.next=_e,j=K;var Me=t.alternate;Me!==null&&(Me=Me.updateQueue,q=Me.lastBaseUpdate,q!==j&&(q===null?Me.firstBaseUpdate=_e:q.next=_e,Me.lastBaseUpdate=K))}if(y!==null){var ze=_.baseState;j=0,Me=_e=K=null,q=y;do{var Ae=q.lane,He=q.eventTime;if((c&Ae)===Ae){Me!==null&&(Me=Me.next={eventTime:He,lane:0,tag:q.tag,payload:q.payload,callback:q.callback,next:null});e:{var Qe=t,Ze=q;switch(Ae=a,He=o,Ze.tag){case 1:if(Qe=Ze.payload,typeof Qe=="function"){ze=Qe.call(He,ze,Ae);break e}ze=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Ze.payload,Ae=typeof Qe=="function"?Qe.call(He,ze,Ae):Qe,Ae==null)break e;ze=ae({},ze,Ae);break e;case 2:Oa=!0}}q.callback!==null&&q.lane!==0&&(t.flags|=64,Ae=_.effects,Ae===null?_.effects=[q]:Ae.push(q))}else He={eventTime:He,lane:Ae,tag:q.tag,payload:q.payload,callback:q.callback,next:null},Me===null?(_e=Me=He,K=ze):Me=Me.next=He,j|=Ae;if(q=q.next,q===null){if(q=_.shared.pending,q===null)break;Ae=q,q=Ae.next,Ae.next=null,_.lastBaseUpdate=Ae,_.shared.pending=null}}while(!0);if(Me===null&&(K=ze),_.baseState=K,_.firstBaseUpdate=_e,_.lastBaseUpdate=Me,a=_.shared.interleaved,a!==null){_=a;do j|=_.lane,_=_.next;while(_!==a)}else y===null&&(_.shared.lanes=0);Ar|=j,t.lanes=j,t.memoizedState=ze}}function fm(t,a,o){if(t=a.effects,a.effects=null,t!==null)for(a=0;a<t.length;a++){var c=t[a],_=c.callback;if(_!==null){if(c.callback=null,c=o,typeof _!="function")throw Error(r(191,_));_.call(c)}}}var vo={},qs=xs(vo),xo=xs(vo),bo=xs(vo);function Er(t){if(t===vo)throw Error(r(174));return t}function nu(t,a){switch(Tt(bo,a),Tt(xo,t),Tt(qs,vo),t=a.nodeType,t){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:ye(null,"");break;default:t=t===8?a.parentNode:a,a=t.namespaceURI||null,t=t.tagName,a=ye(a,t)}At(qs),Tt(qs,a)}function vi(){At(qs),At(xo),At(bo)}function hm(t){Er(bo.current);var a=Er(qs.current),o=ye(a,t.type);a!==o&&(Tt(xo,t),Tt(qs,o))}function su(t){xo.current===t&&(At(qs),At(xo))}var Ft=xs(0);function Ol(t){for(var a=t;a!==null;){if(a.tag===13){var o=a.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var au=[];function ru(){for(var t=0;t<au.length;t++)au[t]._workInProgressVersionPrimary=null;au.length=0}var Fl=P.ReactCurrentDispatcher,iu=P.ReactCurrentBatchConfig,Tr=0,qt=null,rn=null,dn=null,ql=!1,wo=!1,jo=0,__=0;function kn(){throw Error(r(321))}function ou(t,a){if(a===null)return!1;for(var o=0;o<a.length&&o<t.length;o++)if(!Yn(t[o],a[o]))return!1;return!0}function lu(t,a,o,c,_,y){if(Tr=y,qt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Fl.current=t===null||t.memoizedState===null?x_:b_,t=o(c,_),wo){y=0;do{if(wo=!1,jo=0,25<=y)throw Error(r(301));y+=1,dn=rn=null,a.updateQueue=null,Fl.current=w_,t=o(c,_)}while(wo)}if(Fl.current=Wl,a=rn!==null&&rn.next!==null,Tr=0,dn=rn=qt=null,ql=!1,a)throw Error(r(300));return t}function cu(){var t=jo!==0;return jo=0,t}function Bs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dn===null?qt.memoizedState=dn=t:dn=dn.next=t,dn}function rs(){if(rn===null){var t=qt.alternate;t=t!==null?t.memoizedState:null}else t=rn.next;var a=dn===null?qt.memoizedState:dn.next;if(a!==null)dn=a,rn=t;else{if(t===null)throw Error(r(310));rn=t,t={memoizedState:rn.memoizedState,baseState:rn.baseState,baseQueue:rn.baseQueue,queue:rn.queue,next:null},dn===null?qt.memoizedState=dn=t:dn=dn.next=t}return dn}function ko(t,a){return typeof a=="function"?a(t):a}function uu(t){var a=rs(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=rn,_=c.baseQueue,y=o.pending;if(y!==null){if(_!==null){var j=_.next;_.next=y.next,y.next=j}c.baseQueue=_=y,o.pending=null}if(_!==null){y=_.next,c=c.baseState;var q=j=null,K=null,_e=y;do{var Me=_e.lane;if((Tr&Me)===Me)K!==null&&(K=K.next={lane:0,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null}),c=_e.hasEagerState?_e.eagerState:t(c,_e.action);else{var ze={lane:Me,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null};K===null?(q=K=ze,j=c):K=K.next=ze,qt.lanes|=Me,Ar|=Me}_e=_e.next}while(_e!==null&&_e!==y);K===null?j=c:K.next=q,Yn(c,a.memoizedState)||(Bn=!0),a.memoizedState=c,a.baseState=j,a.baseQueue=K,o.lastRenderedState=c}if(t=o.interleaved,t!==null){_=t;do y=_.lane,qt.lanes|=y,Ar|=y,_=_.next;while(_!==t)}else _===null&&(o.lanes=0);return[a.memoizedState,o.dispatch]}function du(t){var a=rs(),o=a.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=o.dispatch,_=o.pending,y=a.memoizedState;if(_!==null){o.pending=null;var j=_=_.next;do y=t(y,j.action),j=j.next;while(j!==_);Yn(y,a.memoizedState)||(Bn=!0),a.memoizedState=y,a.baseQueue===null&&(a.baseState=y),o.lastRenderedState=y}return[y,c]}function pm(){}function _m(t,a){var o=qt,c=rs(),_=a(),y=!Yn(c.memoizedState,_);if(y&&(c.memoizedState=_,Bn=!0),c=c.queue,mu(vm.bind(null,o,c,t),[t]),c.getSnapshot!==a||y||dn!==null&&dn.memoizedState.tag&1){if(o.flags|=2048,So(9,ym.bind(null,o,c,_,a),void 0,null),mn===null)throw Error(r(349));(Tr&30)!==0||gm(o,a,_)}return _}function gm(t,a,o){t.flags|=16384,t={getSnapshot:a,value:o},a=qt.updateQueue,a===null?(a={lastEffect:null,stores:null},qt.updateQueue=a,a.stores=[t]):(o=a.stores,o===null?a.stores=[t]:o.push(t))}function ym(t,a,o,c){a.value=o,a.getSnapshot=c,xm(a)&&bm(t)}function vm(t,a,o){return o(function(){xm(a)&&bm(t)})}function xm(t){var a=t.getSnapshot;t=t.value;try{var o=a();return!Yn(t,o)}catch{return!0}}function bm(t){var a=ca(t,1);a!==null&&Ns(a,t,1,-1)}function wm(t){var a=Bs();return typeof t=="function"&&(t=t()),a.memoizedState=a.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:t},a.queue=t,t=t.dispatch=v_.bind(null,qt,t),[a.memoizedState,t]}function So(t,a,o,c){return t={tag:t,create:a,destroy:o,deps:c,next:null},a=qt.updateQueue,a===null?(a={lastEffect:null,stores:null},qt.updateQueue=a,a.lastEffect=t.next=t):(o=a.lastEffect,o===null?a.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,a.lastEffect=t)),t}function jm(){return rs().memoizedState}function Bl(t,a,o,c){var _=Bs();qt.flags|=t,_.memoizedState=So(1|a,o,void 0,c===void 0?null:c)}function Ul(t,a,o,c){var _=rs();c=c===void 0?null:c;var y=void 0;if(rn!==null){var j=rn.memoizedState;if(y=j.destroy,c!==null&&ou(c,j.deps)){_.memoizedState=So(a,o,y,c);return}}qt.flags|=t,_.memoizedState=So(1|a,o,y,c)}function km(t,a){return Bl(8390656,8,t,a)}function mu(t,a){return Ul(2048,8,t,a)}function Sm(t,a){return Ul(4,2,t,a)}function Nm(t,a){return Ul(4,4,t,a)}function Cm(t,a){if(typeof a=="function")return t=t(),a(t),function(){a(null)};if(a!=null)return t=t(),a.current=t,function(){a.current=null}}function $m(t,a,o){return o=o!=null?o.concat([t]):null,Ul(4,4,Cm.bind(null,a,t),o)}function fu(){}function Em(t,a){var o=rs();a=a===void 0?null:a;var c=o.memoizedState;return c!==null&&a!==null&&ou(a,c[1])?c[0]:(o.memoizedState=[t,a],t)}function Tm(t,a){var o=rs();a=a===void 0?null:a;var c=o.memoizedState;return c!==null&&a!==null&&ou(a,c[1])?c[0]:(t=t(),o.memoizedState=[t,a],t)}function Am(t,a,o){return(Tr&21)===0?(t.baseState&&(t.baseState=!1,Bn=!0),t.memoizedState=o):(Yn(o,a)||(o=Vt(),qt.lanes|=o,Ar|=o,t.baseState=!0),a)}function g_(t,a){var o=kt;kt=o!==0&&4>o?o:4,t(!0);var c=iu.transition;iu.transition={};try{t(!1),a()}finally{kt=o,iu.transition=c}}function Lm(){return rs().memoizedState}function y_(t,a,o){var c=Wa(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},Mm(t))Rm(a,o);else if(o=um(t,a,o,c),o!==null){var _=Rn();Ns(o,t,c,_),Pm(o,a,c)}}function v_(t,a,o){var c=Wa(t),_={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(Mm(t))Rm(a,_);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=a.lastRenderedReducer,y!==null))try{var j=a.lastRenderedState,q=y(j,o);if(_.hasEagerState=!0,_.eagerState=q,Yn(q,j)){var K=a.interleaved;K===null?(_.next=_,eu(a)):(_.next=K.next,K.next=_),a.interleaved=_;return}}catch{}finally{}o=um(t,a,_,c),o!==null&&(_=Rn(),Ns(o,t,c,_),Pm(o,a,c))}}function Mm(t){var a=t.alternate;return t===qt||a!==null&&a===qt}function Rm(t,a){wo=ql=!0;var o=t.pending;o===null?a.next=a:(a.next=o.next,o.next=a),t.pending=a}function Pm(t,a,o){if((o&4194240)!==0){var c=a.lanes;c&=t.pendingLanes,o|=c,a.lanes=o,Rs(t,o)}}var Wl={readContext:as,useCallback:kn,useContext:kn,useEffect:kn,useImperativeHandle:kn,useInsertionEffect:kn,useLayoutEffect:kn,useMemo:kn,useReducer:kn,useRef:kn,useState:kn,useDebugValue:kn,useDeferredValue:kn,useTransition:kn,useMutableSource:kn,useSyncExternalStore:kn,useId:kn,unstable_isNewReconciler:!1},x_={readContext:as,useCallback:function(t,a){return Bs().memoizedState=[t,a===void 0?null:a],t},useContext:as,useEffect:km,useImperativeHandle:function(t,a,o){return o=o!=null?o.concat([t]):null,Bl(4194308,4,Cm.bind(null,a,t),o)},useLayoutEffect:function(t,a){return Bl(4194308,4,t,a)},useInsertionEffect:function(t,a){return Bl(4,2,t,a)},useMemo:function(t,a){var o=Bs();return a=a===void 0?null:a,t=t(),o.memoizedState=[t,a],t},useReducer:function(t,a,o){var c=Bs();return a=o!==void 0?o(a):a,c.memoizedState=c.baseState=a,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:a},c.queue=t,t=t.dispatch=y_.bind(null,qt,t),[c.memoizedState,t]},useRef:function(t){var a=Bs();return t={current:t},a.memoizedState=t},useState:wm,useDebugValue:fu,useDeferredValue:function(t){return Bs().memoizedState=t},useTransition:function(){var t=wm(!1),a=t[0];return t=g_.bind(null,t[1]),Bs().memoizedState=t,[a,t]},useMutableSource:function(){},useSyncExternalStore:function(t,a,o){var c=qt,_=Bs();if(Dt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=a(),mn===null)throw Error(r(349));(Tr&30)!==0||gm(c,a,o)}_.memoizedState=o;var y={value:o,getSnapshot:a};return _.queue=y,km(vm.bind(null,c,y,t),[t]),c.flags|=2048,So(9,ym.bind(null,c,y,o,a),void 0,null),o},useId:function(){var t=Bs(),a=mn.identifierPrefix;if(Dt){var o=Ot,c=St;o=(c&~(1<<32-pn(c)-1)).toString(32)+o,a=":"+a+"R"+o,o=jo++,0<o&&(a+="H"+o.toString(32)),a+=":"}else o=__++,a=":"+a+"r"+o.toString(32)+":";return t.memoizedState=a},unstable_isNewReconciler:!1},b_={readContext:as,useCallback:Em,useContext:as,useEffect:mu,useImperativeHandle:$m,useInsertionEffect:Sm,useLayoutEffect:Nm,useMemo:Tm,useReducer:uu,useRef:jm,useState:function(){return uu(ko)},useDebugValue:fu,useDeferredValue:function(t){var a=rs();return Am(a,rn.memoizedState,t)},useTransition:function(){var t=uu(ko)[0],a=rs().memoizedState;return[t,a]},useMutableSource:pm,useSyncExternalStore:_m,useId:Lm,unstable_isNewReconciler:!1},w_={readContext:as,useCallback:Em,useContext:as,useEffect:mu,useImperativeHandle:$m,useInsertionEffect:Sm,useLayoutEffect:Nm,useMemo:Tm,useReducer:du,useRef:jm,useState:function(){return du(ko)},useDebugValue:fu,useDeferredValue:function(t){var a=rs();return rn===null?a.memoizedState=t:Am(a,rn.memoizedState,t)},useTransition:function(){var t=du(ko)[0],a=rs().memoizedState;return[t,a]},useMutableSource:pm,useSyncExternalStore:_m,useId:Lm,unstable_isNewReconciler:!1};function js(t,a){if(t&&t.defaultProps){a=ae({},a),t=t.defaultProps;for(var o in t)a[o]===void 0&&(a[o]=t[o]);return a}return a}function hu(t,a,o,c){a=t.memoizedState,o=o(c,a),o=o==null?a:ae({},a,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var Hl={isMounted:function(t){return(t=t._reactInternals)?As(t)===t:!1},enqueueSetState:function(t,a,o){t=t._reactInternals;var c=Rn(),_=Wa(t),y=ua(c,_);y.payload=a,o!=null&&(y.callback=o),a=Fa(t,y,_),a!==null&&(Ns(a,t,_,c),Il(a,t,_))},enqueueReplaceState:function(t,a,o){t=t._reactInternals;var c=Rn(),_=Wa(t),y=ua(c,_);y.tag=1,y.payload=a,o!=null&&(y.callback=o),a=Fa(t,y,_),a!==null&&(Ns(a,t,_,c),Il(a,t,_))},enqueueForceUpdate:function(t,a){t=t._reactInternals;var o=Rn(),c=Wa(t),_=ua(o,c);_.tag=2,a!=null&&(_.callback=a),a=Fa(t,_,c),a!==null&&(Ns(a,t,c,o),Il(a,t,c))}};function zm(t,a,o,c,_,y,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,y,j):a.prototype&&a.prototype.isPureReactComponent?!na(o,c)||!na(_,y):!0}function Im(t,a,o){var c=!1,_=bs,y=a.contextType;return typeof y=="object"&&y!==null?y=as(y):(_=p(a)?Fs:an.current,c=a.contextTypes,y=(c=c!=null)?la(t,_):bs),a=new a(o,y),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Hl,t.stateNode=a,a._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=_,t.__reactInternalMemoizedMaskedChildContext=y),a}function Dm(t,a,o,c){t=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(o,c),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(o,c),a.state!==t&&Hl.enqueueReplaceState(a,a.state,null)}function pu(t,a,o,c){var _=t.stateNode;_.props=o,_.state=t.memoizedState,_.refs={},tu(t);var y=a.contextType;typeof y=="object"&&y!==null?_.context=as(y):(y=p(a)?Fs:an.current,_.context=la(t,y)),_.state=t.memoizedState,y=a.getDerivedStateFromProps,typeof y=="function"&&(hu(t,a,y,o),_.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(a=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),a!==_.state&&Hl.enqueueReplaceState(_,_.state,null),Dl(t,o,_,c),_.state=t.memoizedState),typeof _.componentDidMount=="function"&&(t.flags|=4194308)}function xi(t,a){try{var o="",c=a;do o+=le(c),c=c.return;while(c);var _=o}catch(y){_=`
39
- Error generating stack: `+y.message+`
40
- `+y.stack}return{value:t,source:a,stack:_,digest:null}}function _u(t,a,o){return{value:t,source:null,stack:o??null,digest:a??null}}function gu(t,a){try{console.error(a.value)}catch(o){setTimeout(function(){throw o})}}var j_=typeof WeakMap=="function"?WeakMap:Map;function Om(t,a,o){o=ua(-1,o),o.tag=3,o.payload={element:null};var c=a.value;return o.callback=function(){Xl||(Xl=!0,Lu=c),gu(t,a)},o}function Fm(t,a,o){o=ua(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var _=a.value;o.payload=function(){return c(_)},o.callback=function(){gu(t,a)}}var y=t.stateNode;return y!==null&&typeof y.componentDidCatch=="function"&&(o.callback=function(){gu(t,a),typeof c!="function"&&(Ba===null?Ba=new Set([this]):Ba.add(this));var j=a.stack;this.componentDidCatch(a.value,{componentStack:j!==null?j:""})}),o}function qm(t,a,o){var c=t.pingCache;if(c===null){c=t.pingCache=new j_;var _=new Set;c.set(a,_)}else _=c.get(a),_===void 0&&(_=new Set,c.set(a,_));_.has(o)||(_.add(o),t=I_.bind(null,t,a,o),a.then(t,t))}function Bm(t){do{var a;if((a=t.tag===13)&&(a=t.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return t;t=t.return}while(t!==null);return null}function Um(t,a,o,c,_){return(t.mode&1)===0?(t===a?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(a=ua(-1,1),a.tag=2,Fa(o,a,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=_,t)}var k_=P.ReactCurrentOwner,Bn=!1;function Mn(t,a,o,c){a.child=t===null?cm(a,null,o,c):_i(a,t.child,o,c)}function Wm(t,a,o,c,_){o=o.render;var y=a.ref;return yi(a,_),c=lu(t,a,o,c,y,_),o=cu(),t!==null&&!Bn?(a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~_,da(t,a,_)):(Dt&&o&&Mt(a),a.flags|=1,Mn(t,a,c,_),a.child)}function Hm(t,a,o,c,_){if(t===null){var y=o.type;return typeof y=="function"&&!Ou(y)&&y.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(a.tag=15,a.type=y,Vm(t,a,y,c,_)):(t=ac(o.type,null,c,a,a.mode,_),t.ref=a.ref,t.return=a,a.child=t)}if(y=t.child,(t.lanes&_)===0){var j=y.memoizedProps;if(o=o.compare,o=o!==null?o:na,o(j,c)&&t.ref===a.ref)return da(t,a,_)}return a.flags|=1,t=Va(y,c),t.ref=a.ref,t.return=a,a.child=t}function Vm(t,a,o,c,_){if(t!==null){var y=t.memoizedProps;if(na(y,c)&&t.ref===a.ref)if(Bn=!1,a.pendingProps=c=y,(t.lanes&_)!==0)(t.flags&131072)!==0&&(Bn=!0);else return a.lanes=t.lanes,da(t,a,_)}return yu(t,a,o,c,_)}function Gm(t,a,o){var c=a.pendingProps,_=c.children,y=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tt(wi,ts),ts|=o;else{if((o&1073741824)===0)return t=y!==null?y.baseLanes|o:o,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:t,cachePool:null,transitions:null},a.updateQueue=null,Tt(wi,ts),ts|=t,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=y!==null?y.baseLanes:o,Tt(wi,ts),ts|=c}else y!==null?(c=y.baseLanes|o,a.memoizedState=null):c=o,Tt(wi,ts),ts|=c;return Mn(t,a,_,o),a.child}function Km(t,a){var o=a.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(a.flags|=512,a.flags|=2097152)}function yu(t,a,o,c,_){var y=p(o)?Fs:an.current;return y=la(a,y),yi(a,_),o=lu(t,a,o,c,y,_),c=cu(),t!==null&&!Bn?(a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~_,da(t,a,_)):(Dt&&c&&Mt(a),a.flags|=1,Mn(t,a,o,_),a.child)}function Jm(t,a,o,c,_){if(p(o)){var y=!0;z(a)}else y=!1;if(yi(a,_),a.stateNode===null)Gl(t,a),Im(a,o,c),pu(a,o,c,_),c=!0;else if(t===null){var j=a.stateNode,q=a.memoizedProps;j.props=q;var K=j.context,_e=o.contextType;typeof _e=="object"&&_e!==null?_e=as(_e):(_e=p(o)?Fs:an.current,_e=la(a,_e));var Me=o.getDerivedStateFromProps,ze=typeof Me=="function"||typeof j.getSnapshotBeforeUpdate=="function";ze||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(q!==c||K!==_e)&&Dm(a,j,c,_e),Oa=!1;var Ae=a.memoizedState;j.state=Ae,Dl(a,c,j,_),K=a.memoizedState,q!==c||Ae!==K||gn.current||Oa?(typeof Me=="function"&&(hu(a,o,Me,c),K=a.memoizedState),(q=Oa||zm(a,o,q,c,Ae,K,_e))?(ze||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(a.flags|=4194308)):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=c,a.memoizedState=K),j.props=c,j.state=K,j.context=_e,c=q):(typeof j.componentDidMount=="function"&&(a.flags|=4194308),c=!1)}else{j=a.stateNode,dm(t,a),q=a.memoizedProps,_e=a.type===a.elementType?q:js(a.type,q),j.props=_e,ze=a.pendingProps,Ae=j.context,K=o.contextType,typeof K=="object"&&K!==null?K=as(K):(K=p(o)?Fs:an.current,K=la(a,K));var He=o.getDerivedStateFromProps;(Me=typeof He=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(q!==ze||Ae!==K)&&Dm(a,j,c,K),Oa=!1,Ae=a.memoizedState,j.state=Ae,Dl(a,c,j,_);var Qe=a.memoizedState;q!==ze||Ae!==Qe||gn.current||Oa?(typeof He=="function"&&(hu(a,o,He,c),Qe=a.memoizedState),(_e=Oa||zm(a,o,_e,c,Ae,Qe,K)||!1)?(Me||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(c,Qe,K),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(c,Qe,K)),typeof j.componentDidUpdate=="function"&&(a.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof j.componentDidUpdate!="function"||q===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||q===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=1024),a.memoizedProps=c,a.memoizedState=Qe),j.props=c,j.state=Qe,j.context=K,c=_e):(typeof j.componentDidUpdate!="function"||q===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||q===t.memoizedProps&&Ae===t.memoizedState||(a.flags|=1024),c=!1)}return vu(t,a,o,c,y,_)}function vu(t,a,o,c,_,y){Km(t,a);var j=(a.flags&128)!==0;if(!c&&!j)return _&&de(a,o,!1),da(t,a,y);c=a.stateNode,k_.current=a;var q=j&&typeof o.getDerivedStateFromError!="function"?null:c.render();return a.flags|=1,t!==null&&j?(a.child=_i(a,t.child,null,y),a.child=_i(a,null,q,y)):Mn(t,a,q,y),a.memoizedState=c.state,_&&de(a,o,!0),a.child}function Qm(t){var a=t.stateNode;a.pendingContext?N(t,a.pendingContext,a.pendingContext!==a.context):a.context&&N(t,a.context,!1),nu(t,a.containerInfo)}function Ym(t,a,o,c,_){return pi(),Jc(_),a.flags|=256,Mn(t,a,o,c),a.child}var xu={dehydrated:null,treeContext:null,retryLane:0};function bu(t){return{baseLanes:t,cachePool:null,transitions:null}}function Xm(t,a,o){var c=a.pendingProps,_=Ft.current,y=!1,j=(a.flags&128)!==0,q;if((q=j)||(q=t!==null&&t.memoizedState===null?!1:(_&2)!==0),q?(y=!0,a.flags&=-129):(t===null||t.memoizedState!==null)&&(_|=1),Tt(Ft,_&1),t===null)return Kc(a),t=a.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((a.mode&1)===0?a.lanes=1:t.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(j=c.children,t=c.fallback,y?(c=a.mode,y=a.child,j={mode:"hidden",children:j},(c&1)===0&&y!==null?(y.childLanes=0,y.pendingProps=j):y=rc(j,c,0,null),t=Pr(t,c,o,null),y.return=a,t.return=a,y.sibling=t,a.child=y,a.child.memoizedState=bu(o),a.memoizedState=xu,t):wu(a,j));if(_=t.memoizedState,_!==null&&(q=_.dehydrated,q!==null))return S_(t,a,j,c,q,_,o);if(y){y=c.fallback,j=a.mode,_=t.child,q=_.sibling;var K={mode:"hidden",children:c.children};return(j&1)===0&&a.child!==_?(c=a.child,c.childLanes=0,c.pendingProps=K,a.deletions=null):(c=Va(_,K),c.subtreeFlags=_.subtreeFlags&14680064),q!==null?y=Va(q,y):(y=Pr(y,j,o,null),y.flags|=2),y.return=a,c.return=a,c.sibling=y,a.child=c,c=y,y=a.child,j=t.child.memoizedState,j=j===null?bu(o):{baseLanes:j.baseLanes|o,cachePool:null,transitions:j.transitions},y.memoizedState=j,y.childLanes=t.childLanes&~o,a.memoizedState=xu,c}return y=t.child,t=y.sibling,c=Va(y,{mode:"visible",children:c.children}),(a.mode&1)===0&&(c.lanes=o),c.return=a,c.sibling=null,t!==null&&(o=a.deletions,o===null?(a.deletions=[t],a.flags|=16):o.push(t)),a.child=c,a.memoizedState=null,c}function wu(t,a){return a=rc({mode:"visible",children:a},t.mode,0,null),a.return=t,t.child=a}function Vl(t,a,o,c){return c!==null&&Jc(c),_i(a,t.child,null,o),t=wu(a,a.pendingProps.children),t.flags|=2,a.memoizedState=null,t}function S_(t,a,o,c,_,y,j){if(o)return a.flags&256?(a.flags&=-257,c=_u(Error(r(422))),Vl(t,a,j,c)):a.memoizedState!==null?(a.child=t.child,a.flags|=128,null):(y=c.fallback,_=a.mode,c=rc({mode:"visible",children:c.children},_,0,null),y=Pr(y,_,j,null),y.flags|=2,c.return=a,y.return=a,c.sibling=y,a.child=c,(a.mode&1)!==0&&_i(a,t.child,null,j),a.child.memoizedState=bu(j),a.memoizedState=xu,y);if((a.mode&1)===0)return Vl(t,a,j,null);if(_.data==="$!"){if(c=_.nextSibling&&_.nextSibling.dataset,c)var q=c.dgst;return c=q,y=Error(r(419)),c=_u(y,c,void 0),Vl(t,a,j,c)}if(q=(j&t.childLanes)!==0,Bn||q){if(c=mn,c!==null){switch(j&-j){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(c.suspendedLanes|j))!==0?0:_,_!==0&&_!==y.retryLane&&(y.retryLane=_,ca(t,_),Ns(c,t,_,-1))}return Du(),c=_u(Error(r(421))),Vl(t,a,j,c)}return _.data==="$?"?(a.flags|=128,a.child=t.child,a=D_.bind(null,t),_._reactRetry=a,null):(t=y.treeContext,es=gs(_.nextSibling),un=a,Dt=!0,ws=null,t!==null&&(Lt[gt++]=St,Lt[gt++]=Ot,Lt[gt++]=We,St=t.id,Ot=t.overflow,We=a),a=wu(a,c.children),a.flags|=4096,a)}function Zm(t,a,o){t.lanes|=a;var c=t.alternate;c!==null&&(c.lanes|=a),Zc(t.return,a,o)}function ju(t,a,o,c,_){var y=t.memoizedState;y===null?t.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:_}:(y.isBackwards=a,y.rendering=null,y.renderingStartTime=0,y.last=c,y.tail=o,y.tailMode=_)}function ef(t,a,o){var c=a.pendingProps,_=c.revealOrder,y=c.tail;if(Mn(t,a,c.children,o),c=Ft.current,(c&2)!==0)c=c&1|2,a.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=a.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Zm(t,o,a);else if(t.tag===19)Zm(t,o,a);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===a)break e;for(;t.sibling===null;){if(t.return===null||t.return===a)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(Tt(Ft,c),(a.mode&1)===0)a.memoizedState=null;else switch(_){case"forwards":for(o=a.child,_=null;o!==null;)t=o.alternate,t!==null&&Ol(t)===null&&(_=o),o=o.sibling;o=_,o===null?(_=a.child,a.child=null):(_=o.sibling,o.sibling=null),ju(a,!1,_,o,y);break;case"backwards":for(o=null,_=a.child,a.child=null;_!==null;){if(t=_.alternate,t!==null&&Ol(t)===null){a.child=_;break}t=_.sibling,_.sibling=o,o=_,_=t}ju(a,!0,o,null,y);break;case"together":ju(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Gl(t,a){(a.mode&1)===0&&t!==null&&(t.alternate=null,a.alternate=null,a.flags|=2)}function da(t,a,o){if(t!==null&&(a.dependencies=t.dependencies),Ar|=a.lanes,(o&a.childLanes)===0)return null;if(t!==null&&a.child!==t.child)throw Error(r(153));if(a.child!==null){for(t=a.child,o=Va(t,t.pendingProps),a.child=o,o.return=a;t.sibling!==null;)t=t.sibling,o=o.sibling=Va(t,t.pendingProps),o.return=a;o.sibling=null}return a.child}function N_(t,a,o){switch(a.tag){case 3:Qm(a),pi();break;case 5:hm(a);break;case 1:p(a.type)&&z(a);break;case 4:nu(a,a.stateNode.containerInfo);break;case 10:var c=a.type._context,_=a.memoizedProps.value;Tt(Pl,c._currentValue),c._currentValue=_;break;case 13:if(c=a.memoizedState,c!==null)return c.dehydrated!==null?(Tt(Ft,Ft.current&1),a.flags|=128,null):(o&a.child.childLanes)!==0?Xm(t,a,o):(Tt(Ft,Ft.current&1),t=da(t,a,o),t!==null?t.sibling:null);Tt(Ft,Ft.current&1);break;case 19:if(c=(o&a.childLanes)!==0,(t.flags&128)!==0){if(c)return ef(t,a,o);a.flags|=128}if(_=a.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Tt(Ft,Ft.current),c)break;return null;case 22:case 23:return a.lanes=0,Gm(t,a,o)}return da(t,a,o)}var tf,ku,nf,sf;tf=function(t,a){for(var o=a.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break;for(;o.sibling===null;){if(o.return===null||o.return===a)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},ku=function(){},nf=function(t,a,o,c){var _=t.memoizedProps;if(_!==c){t=a.stateNode,Er(qs.current);var y=null;switch(o){case"input":_=Ge(t,_),c=Ge(t,c),y=[];break;case"select":_=ae({},_,{value:void 0}),c=ae({},c,{value:void 0}),y=[];break;case"textarea":_=ie(t,_),c=ie(t,c),y=[];break;default:typeof _.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Ln)}ut(o,c);var j;o=null;for(_e in _)if(!c.hasOwnProperty(_e)&&_.hasOwnProperty(_e)&&_[_e]!=null)if(_e==="style"){var q=_[_e];for(j in q)q.hasOwnProperty(j)&&(o||(o={}),o[j]="")}else _e!=="dangerouslySetInnerHTML"&&_e!=="children"&&_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&_e!=="autoFocus"&&(l.hasOwnProperty(_e)?y||(y=[]):(y=y||[]).push(_e,null));for(_e in c){var K=c[_e];if(q=_!=null?_[_e]:void 0,c.hasOwnProperty(_e)&&K!==q&&(K!=null||q!=null))if(_e==="style")if(q){for(j in q)!q.hasOwnProperty(j)||K&&K.hasOwnProperty(j)||(o||(o={}),o[j]="");for(j in K)K.hasOwnProperty(j)&&q[j]!==K[j]&&(o||(o={}),o[j]=K[j])}else o||(y||(y=[]),y.push(_e,o)),o=K;else _e==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,q=q?q.__html:void 0,K!=null&&q!==K&&(y=y||[]).push(_e,K)):_e==="children"?typeof K!="string"&&typeof K!="number"||(y=y||[]).push(_e,""+K):_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&(l.hasOwnProperty(_e)?(K!=null&&_e==="onScroll"&&Ct("scroll",t),y||q===K||(y=[])):(y=y||[]).push(_e,K))}o&&(y=y||[]).push("style",o);var _e=y;(a.updateQueue=_e)&&(a.flags|=4)}},sf=function(t,a,o,c){o!==c&&(a.flags|=4)};function No(t,a){if(!Dt)switch(t.tailMode){case"hidden":a=t.tail;for(var o=null;a!==null;)a.alternate!==null&&(o=a),a=a.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?a||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Sn(t){var a=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(a)for(var _=t.child;_!==null;)o|=_.lanes|_.childLanes,c|=_.subtreeFlags&14680064,c|=_.flags&14680064,_.return=t,_=_.sibling;else for(_=t.child;_!==null;)o|=_.lanes|_.childLanes,c|=_.subtreeFlags,c|=_.flags,_.return=t,_=_.sibling;return t.subtreeFlags|=c,t.childLanes=o,a}function C_(t,a,o){var c=a.pendingProps;switch(Qt(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(a),null;case 1:return p(a.type)&&b(),Sn(a),null;case 3:return c=a.stateNode,vi(),At(gn),At(an),ru(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ml(a)?a.flags|=4:t===null||t.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,ws!==null&&(Pu(ws),ws=null))),ku(t,a),Sn(a),null;case 5:su(a);var _=Er(bo.current);if(o=a.type,t!==null&&a.stateNode!=null)nf(t,a,o,c,_),t.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!c){if(a.stateNode===null)throw Error(r(166));return Sn(a),null}if(t=Er(qs.current),Ml(a)){c=a.stateNode,o=a.type;var y=a.memoizedProps;switch(c[Zn]=a,c[Nr]=y,t=(a.mode&1)!==0,o){case"dialog":Ct("cancel",c),Ct("close",c);break;case"iframe":case"object":case"embed":Ct("load",c);break;case"video":case"audio":for(_=0;_<Fn.length;_++)Ct(Fn[_],c);break;case"source":Ct("error",c);break;case"img":case"image":case"link":Ct("error",c),Ct("load",c);break;case"details":Ct("toggle",c);break;case"input":ct(c,y),Ct("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!y.multiple},Ct("invalid",c);break;case"textarea":Ce(c,y),Ct("invalid",c)}ut(o,y),_=null;for(var j in y)if(y.hasOwnProperty(j)){var q=y[j];j==="children"?typeof q=="string"?c.textContent!==q&&(y.suppressHydrationWarning!==!0&&Pa(c.textContent,q,t),_=["children",q]):typeof q=="number"&&c.textContent!==""+q&&(y.suppressHydrationWarning!==!0&&Pa(c.textContent,q,t),_=["children",""+q]):l.hasOwnProperty(j)&&q!=null&&j==="onScroll"&&Ct("scroll",c)}switch(o){case"input":rt(c),ce(c,y,!0);break;case"textarea":rt(c),F(c);break;case"select":case"option":break;default:typeof y.onClick=="function"&&(c.onclick=Ln)}c=_,a.updateQueue=c,c!==null&&(a.flags|=4)}else{j=_.nodeType===9?_:_.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=ue(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=j.createElement(o,{is:c.is}):(t=j.createElement(o),o==="select"&&(j=t,c.multiple?j.multiple=!0:c.size&&(j.size=c.size))):t=j.createElementNS(t,o),t[Zn]=a,t[Nr]=c,tf(t,a,!1,!1),a.stateNode=t;e:{switch(j=mt(o,c),o){case"dialog":Ct("cancel",t),Ct("close",t),_=c;break;case"iframe":case"object":case"embed":Ct("load",t),_=c;break;case"video":case"audio":for(_=0;_<Fn.length;_++)Ct(Fn[_],t);_=c;break;case"source":Ct("error",t),_=c;break;case"img":case"image":case"link":Ct("error",t),Ct("load",t),_=c;break;case"details":Ct("toggle",t),_=c;break;case"input":ct(t,c),_=Ge(t,c),Ct("invalid",t);break;case"option":_=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},_=ae({},c,{value:void 0}),Ct("invalid",t);break;case"textarea":Ce(t,c),_=ie(t,c),Ct("invalid",t);break;default:_=c}ut(o,_),q=_;for(y in q)if(q.hasOwnProperty(y)){var K=q[y];y==="style"?Fe(t,K):y==="dangerouslySetInnerHTML"?(K=K?K.__html:void 0,K!=null&&ke(t,K)):y==="children"?typeof K=="string"?(o!=="textarea"||K!=="")&&J(t,K):typeof K=="number"&&J(t,""+K):y!=="suppressContentEditableWarning"&&y!=="suppressHydrationWarning"&&y!=="autoFocus"&&(l.hasOwnProperty(y)?K!=null&&y==="onScroll"&&Ct("scroll",t):K!=null&&M(t,y,K,j))}switch(o){case"input":rt(t),ce(t,c,!1);break;case"textarea":rt(t),F(t);break;case"option":c.value!=null&&t.setAttribute("value",""+$e(c.value));break;case"select":t.multiple=!!c.multiple,y=c.value,y!=null?W(t,!!c.multiple,y,!1):c.defaultValue!=null&&W(t,!!c.multiple,c.defaultValue,!0);break;default:typeof _.onClick=="function"&&(t.onclick=Ln)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Sn(a),null;case 6:if(t&&a.stateNode!=null)sf(t,a,t.memoizedProps,c);else{if(typeof c!="string"&&a.stateNode===null)throw Error(r(166));if(o=Er(bo.current),Er(qs.current),Ml(a)){if(c=a.stateNode,o=a.memoizedProps,c[Zn]=a,(y=c.nodeValue!==o)&&(t=un,t!==null))switch(t.tag){case 3:Pa(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Pa(c.nodeValue,o,(t.mode&1)!==0)}y&&(a.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[Zn]=a,a.stateNode=c}return Sn(a),null;case 13:if(At(Ft),c=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Dt&&es!==null&&(a.mode&1)!==0&&(a.flags&128)===0)im(),pi(),a.flags|=98560,y=!1;else if(y=Ml(a),c!==null&&c.dehydrated!==null){if(t===null){if(!y)throw Error(r(318));if(y=a.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(r(317));y[Zn]=a}else pi(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Sn(a),y=!1}else ws!==null&&(Pu(ws),ws=null),y=!0;if(!y)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=o,a):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(a.child.flags|=8192,(a.mode&1)!==0&&(t===null||(Ft.current&1)!==0?on===0&&(on=3):Du())),a.updateQueue!==null&&(a.flags|=4),Sn(a),null);case 4:return vi(),ku(t,a),t===null&&Ma(a.stateNode.containerInfo),Sn(a),null;case 10:return Xc(a.type._context),Sn(a),null;case 17:return p(a.type)&&b(),Sn(a),null;case 19:if(At(Ft),y=a.memoizedState,y===null)return Sn(a),null;if(c=(a.flags&128)!==0,j=y.rendering,j===null)if(c)No(y,!1);else{if(on!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(j=Ol(t),j!==null){for(a.flags|=128,No(y,!1),c=j.updateQueue,c!==null&&(a.updateQueue=c,a.flags|=4),a.subtreeFlags=0,c=o,o=a.child;o!==null;)y=o,t=c,y.flags&=14680066,j=y.alternate,j===null?(y.childLanes=0,y.lanes=t,y.child=null,y.subtreeFlags=0,y.memoizedProps=null,y.memoizedState=null,y.updateQueue=null,y.dependencies=null,y.stateNode=null):(y.childLanes=j.childLanes,y.lanes=j.lanes,y.child=j.child,y.subtreeFlags=0,y.deletions=null,y.memoizedProps=j.memoizedProps,y.memoizedState=j.memoizedState,y.updateQueue=j.updateQueue,y.type=j.type,t=j.dependencies,y.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),o=o.sibling;return Tt(Ft,Ft.current&1|2),a.child}t=t.sibling}y.tail!==null&&It()>ji&&(a.flags|=128,c=!0,No(y,!1),a.lanes=4194304)}else{if(!c)if(t=Ol(j),t!==null){if(a.flags|=128,c=!0,o=t.updateQueue,o!==null&&(a.updateQueue=o,a.flags|=4),No(y,!0),y.tail===null&&y.tailMode==="hidden"&&!j.alternate&&!Dt)return Sn(a),null}else 2*It()-y.renderingStartTime>ji&&o!==1073741824&&(a.flags|=128,c=!0,No(y,!1),a.lanes=4194304);y.isBackwards?(j.sibling=a.child,a.child=j):(o=y.last,o!==null?o.sibling=j:a.child=j,y.last=j)}return y.tail!==null?(a=y.tail,y.rendering=a,y.tail=a.sibling,y.renderingStartTime=It(),a.sibling=null,o=Ft.current,Tt(Ft,c?o&1|2:o&1),a):(Sn(a),null);case 22:case 23:return Iu(),c=a.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(a.flags|=8192),c&&(a.mode&1)!==0?(ts&1073741824)!==0&&(Sn(a),a.subtreeFlags&6&&(a.flags|=8192)):Sn(a),null;case 24:return null;case 25:return null}throw Error(r(156,a.tag))}function $_(t,a){switch(Qt(a),a.tag){case 1:return p(a.type)&&b(),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return vi(),At(gn),At(an),ru(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 5:return su(a),null;case 13:if(At(Ft),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(r(340));pi()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return At(Ft),null;case 4:return vi(),null;case 10:return Xc(a.type._context),null;case 22:case 23:return Iu(),null;case 24:return null;default:return null}}var Kl=!1,Nn=!1,E_=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function bi(t,a){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){Wt(t,a,c)}else o.current=null}function Su(t,a,o){try{o()}catch(c){Wt(t,a,c)}}var af=!1;function T_(t,a){if(za=cr,t=Nl(),li(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var _=c.anchorOffset,y=c.focusNode;c=c.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var j=0,q=-1,K=-1,_e=0,Me=0,ze=t,Ae=null;t:for(;;){for(var He;ze!==o||_!==0&&ze.nodeType!==3||(q=j+_),ze!==y||c!==0&&ze.nodeType!==3||(K=j+c),ze.nodeType===3&&(j+=ze.nodeValue.length),(He=ze.firstChild)!==null;)Ae=ze,ze=He;for(;;){if(ze===t)break t;if(Ae===o&&++_e===_&&(q=j),Ae===y&&++Me===c&&(K=j),(He=ze.nextSibling)!==null)break;ze=Ae,Ae=ze.parentNode}ze=He}o=q===-1||K===-1?null:{start:q,end:K}}else o=null}o=o||{start:0,end:0}}else o=null;for(Sr={focusedElem:t,selectionRange:o},cr=!1,Ke=a;Ke!==null;)if(a=Ke,t=a.child,(a.subtreeFlags&1028)!==0&&t!==null)t.return=a,Ke=t;else for(;Ke!==null;){a=Ke;try{var Qe=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Ze=Qe.memoizedProps,Yt=Qe.memoizedState,me=a.stateNode,ne=me.getSnapshotBeforeUpdate(a.elementType===a.type?Ze:js(a.type,Ze),Yt);me.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var pe=a.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(De){Wt(a,a.return,De)}if(t=a.sibling,t!==null){t.return=a.return,Ke=t;break}Ke=a.return}return Qe=af,af=!1,Qe}function Co(t,a,o){var c=a.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var _=c=c.next;do{if((_.tag&t)===t){var y=_.destroy;_.destroy=void 0,y!==void 0&&Su(a,o,y)}_=_.next}while(_!==c)}}function Jl(t,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var o=a=a.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==a)}}function Nu(t){var a=t.ref;if(a!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof a=="function"?a(t):a.current=t}}function rf(t){var a=t.alternate;a!==null&&(t.alternate=null,rf(a)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(a=t.stateNode,a!==null&&(delete a[Zn],delete a[Nr],delete a[_o],delete a[Hc],delete a[Vc])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function of(t){return t.tag===5||t.tag===3||t.tag===4}function lf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||of(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 Cu(t,a,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,a?o.nodeType===8?o.parentNode.insertBefore(t,a):o.insertBefore(t,a):(o.nodeType===8?(a=o.parentNode,a.insertBefore(t,o)):(a=o,a.appendChild(t)),o=o._reactRootContainer,o!=null||a.onclick!==null||(a.onclick=Ln));else if(c!==4&&(t=t.child,t!==null))for(Cu(t,a,o),t=t.sibling;t!==null;)Cu(t,a,o),t=t.sibling}function $u(t,a,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,a?o.insertBefore(t,a):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for($u(t,a,o),t=t.sibling;t!==null;)$u(t,a,o),t=t.sibling}var yn=null,ks=!1;function qa(t,a,o){for(o=o.child;o!==null;)cf(t,a,o),o=o.sibling}function cf(t,a,o){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(cs,o)}catch{}switch(o.tag){case 5:Nn||bi(o,a);case 6:var c=yn,_=ks;yn=null,qa(t,a,o),yn=c,ks=_,yn!==null&&(ks?(t=yn,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):yn.removeChild(o.stateNode));break;case 18:yn!==null&&(ks?(t=yn,o=o.stateNode,t.nodeType===8?po(t.parentNode,o):t.nodeType===1&&po(t,o),wa(t)):po(yn,o.stateNode));break;case 4:c=yn,_=ks,yn=o.stateNode.containerInfo,ks=!0,qa(t,a,o),yn=c,ks=_;break;case 0:case 11:case 14:case 15:if(!Nn&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){_=c=c.next;do{var y=_,j=y.destroy;y=y.tag,j!==void 0&&((y&2)!==0||(y&4)!==0)&&Su(o,a,j),_=_.next}while(_!==c)}qa(t,a,o);break;case 1:if(!Nn&&(bi(o,a),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(q){Wt(o,a,q)}qa(t,a,o);break;case 21:qa(t,a,o);break;case 22:o.mode&1?(Nn=(c=Nn)||o.memoizedState!==null,qa(t,a,o),Nn=c):qa(t,a,o);break;default:qa(t,a,o)}}function uf(t){var a=t.updateQueue;if(a!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new E_),a.forEach(function(c){var _=O_.bind(null,t,c);o.has(c)||(o.add(c),c.then(_,_))})}}function Ss(t,a){var o=a.deletions;if(o!==null)for(var c=0;c<o.length;c++){var _=o[c];try{var y=t,j=a,q=j;e:for(;q!==null;){switch(q.tag){case 5:yn=q.stateNode,ks=!1;break e;case 3:yn=q.stateNode.containerInfo,ks=!0;break e;case 4:yn=q.stateNode.containerInfo,ks=!0;break e}q=q.return}if(yn===null)throw Error(r(160));cf(y,j,_),yn=null,ks=!1;var K=_.alternate;K!==null&&(K.return=null),_.return=null}catch(_e){Wt(_,a,_e)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)df(a,t),a=a.sibling}function df(t,a){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Ss(a,t),Us(t),c&4){try{Co(3,t,t.return),Jl(3,t)}catch(Ze){Wt(t,t.return,Ze)}try{Co(5,t,t.return)}catch(Ze){Wt(t,t.return,Ze)}}break;case 1:Ss(a,t),Us(t),c&512&&o!==null&&bi(o,o.return);break;case 5:if(Ss(a,t),Us(t),c&512&&o!==null&&bi(o,o.return),t.flags&32){var _=t.stateNode;try{J(_,"")}catch(Ze){Wt(t,t.return,Ze)}}if(c&4&&(_=t.stateNode,_!=null)){var y=t.memoizedProps,j=o!==null?o.memoizedProps:y,q=t.type,K=t.updateQueue;if(t.updateQueue=null,K!==null)try{q==="input"&&y.type==="radio"&&y.name!=null&&et(_,y),mt(q,j);var _e=mt(q,y);for(j=0;j<K.length;j+=2){var Me=K[j],ze=K[j+1];Me==="style"?Fe(_,ze):Me==="dangerouslySetInnerHTML"?ke(_,ze):Me==="children"?J(_,ze):M(_,Me,ze,_e)}switch(q){case"input":fe(_,y);break;case"textarea":Je(_,y);break;case"select":var Ae=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!y.multiple;var He=y.value;He!=null?W(_,!!y.multiple,He,!1):Ae!==!!y.multiple&&(y.defaultValue!=null?W(_,!!y.multiple,y.defaultValue,!0):W(_,!!y.multiple,y.multiple?[]:"",!1))}_[Nr]=y}catch(Ze){Wt(t,t.return,Ze)}}break;case 6:if(Ss(a,t),Us(t),c&4){if(t.stateNode===null)throw Error(r(162));_=t.stateNode,y=t.memoizedProps;try{_.nodeValue=y}catch(Ze){Wt(t,t.return,Ze)}}break;case 3:if(Ss(a,t),Us(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{wa(a.containerInfo)}catch(Ze){Wt(t,t.return,Ze)}break;case 4:Ss(a,t),Us(t);break;case 13:Ss(a,t),Us(t),_=t.child,_.flags&8192&&(y=_.memoizedState!==null,_.stateNode.isHidden=y,!y||_.alternate!==null&&_.alternate.memoizedState!==null||(Au=It())),c&4&&uf(t);break;case 22:if(Me=o!==null&&o.memoizedState!==null,t.mode&1?(Nn=(_e=Nn)||Me,Ss(a,t),Nn=_e):Ss(a,t),Us(t),c&8192){if(_e=t.memoizedState!==null,(t.stateNode.isHidden=_e)&&!Me&&(t.mode&1)!==0)for(Ke=t,Me=t.child;Me!==null;){for(ze=Ke=Me;Ke!==null;){switch(Ae=Ke,He=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:Co(4,Ae,Ae.return);break;case 1:bi(Ae,Ae.return);var Qe=Ae.stateNode;if(typeof Qe.componentWillUnmount=="function"){c=Ae,o=Ae.return;try{a=c,Qe.props=a.memoizedProps,Qe.state=a.memoizedState,Qe.componentWillUnmount()}catch(Ze){Wt(c,o,Ze)}}break;case 5:bi(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){hf(ze);continue}}He!==null?(He.return=Ae,Ke=He):hf(ze)}Me=Me.sibling}e:for(Me=null,ze=t;;){if(ze.tag===5){if(Me===null){Me=ze;try{_=ze.stateNode,_e?(y=_.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none"):(q=ze.stateNode,K=ze.memoizedProps.style,j=K!=null&&K.hasOwnProperty("display")?K.display:null,q.style.display=Pe("display",j))}catch(Ze){Wt(t,t.return,Ze)}}}else if(ze.tag===6){if(Me===null)try{ze.stateNode.nodeValue=_e?"":ze.memoizedProps}catch(Ze){Wt(t,t.return,Ze)}}else if((ze.tag!==22&&ze.tag!==23||ze.memoizedState===null||ze===t)&&ze.child!==null){ze.child.return=ze,ze=ze.child;continue}if(ze===t)break e;for(;ze.sibling===null;){if(ze.return===null||ze.return===t)break e;Me===ze&&(Me=null),ze=ze.return}Me===ze&&(Me=null),ze.sibling.return=ze.return,ze=ze.sibling}}break;case 19:Ss(a,t),Us(t),c&4&&uf(t);break;case 21:break;default:Ss(a,t),Us(t)}}function Us(t){var a=t.flags;if(a&2){try{e:{for(var o=t.return;o!==null;){if(of(o)){var c=o;break e}o=o.return}throw Error(r(160))}switch(c.tag){case 5:var _=c.stateNode;c.flags&32&&(J(_,""),c.flags&=-33);var y=lf(t);$u(t,y,_);break;case 3:case 4:var j=c.stateNode.containerInfo,q=lf(t);Cu(t,q,j);break;default:throw Error(r(161))}}catch(K){Wt(t,t.return,K)}t.flags&=-3}a&4096&&(t.flags&=-4097)}function A_(t,a,o){Ke=t,mf(t)}function mf(t,a,o){for(var c=(t.mode&1)!==0;Ke!==null;){var _=Ke,y=_.child;if(_.tag===22&&c){var j=_.memoizedState!==null||Kl;if(!j){var q=_.alternate,K=q!==null&&q.memoizedState!==null||Nn;q=Kl;var _e=Nn;if(Kl=j,(Nn=K)&&!_e)for(Ke=_;Ke!==null;)j=Ke,K=j.child,j.tag===22&&j.memoizedState!==null?pf(_):K!==null?(K.return=j,Ke=K):pf(_);for(;y!==null;)Ke=y,mf(y),y=y.sibling;Ke=_,Kl=q,Nn=_e}ff(t)}else(_.subtreeFlags&8772)!==0&&y!==null?(y.return=_,Ke=y):ff(t)}}function ff(t){for(;Ke!==null;){var a=Ke;if((a.flags&8772)!==0){var o=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Nn||Jl(5,a);break;case 1:var c=a.stateNode;if(a.flags&4&&!Nn)if(o===null)c.componentDidMount();else{var _=a.elementType===a.type?o.memoizedProps:js(a.type,o.memoizedProps);c.componentDidUpdate(_,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var y=a.updateQueue;y!==null&&fm(a,y,c);break;case 3:var j=a.updateQueue;if(j!==null){if(o=null,a.child!==null)switch(a.child.tag){case 5:o=a.child.stateNode;break;case 1:o=a.child.stateNode}fm(a,j,o)}break;case 5:var q=a.stateNode;if(o===null&&a.flags&4){o=q;var K=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":K.autoFocus&&o.focus();break;case"img":K.src&&(o.src=K.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var _e=a.alternate;if(_e!==null){var Me=_e.memoizedState;if(Me!==null){var ze=Me.dehydrated;ze!==null&&wa(ze)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Nn||a.flags&512&&Nu(a)}catch(Ae){Wt(a,a.return,Ae)}}if(a===t){Ke=null;break}if(o=a.sibling,o!==null){o.return=a.return,Ke=o;break}Ke=a.return}}function hf(t){for(;Ke!==null;){var a=Ke;if(a===t){Ke=null;break}var o=a.sibling;if(o!==null){o.return=a.return,Ke=o;break}Ke=a.return}}function pf(t){for(;Ke!==null;){var a=Ke;try{switch(a.tag){case 0:case 11:case 15:var o=a.return;try{Jl(4,a)}catch(K){Wt(a,o,K)}break;case 1:var c=a.stateNode;if(typeof c.componentDidMount=="function"){var _=a.return;try{c.componentDidMount()}catch(K){Wt(a,_,K)}}var y=a.return;try{Nu(a)}catch(K){Wt(a,y,K)}break;case 5:var j=a.return;try{Nu(a)}catch(K){Wt(a,j,K)}}}catch(K){Wt(a,a.return,K)}if(a===t){Ke=null;break}var q=a.sibling;if(q!==null){q.return=a.return,Ke=q;break}Ke=a.return}}var L_=Math.ceil,Ql=P.ReactCurrentDispatcher,Eu=P.ReactCurrentOwner,is=P.ReactCurrentBatchConfig,bt=0,mn=null,en=null,vn=0,ts=0,wi=xs(0),on=0,$o=null,Ar=0,Yl=0,Tu=0,Eo=null,Un=null,Au=0,ji=1/0,ma=null,Xl=!1,Lu=null,Ba=null,Zl=!1,Ua=null,ec=0,To=0,Mu=null,tc=-1,nc=0;function Rn(){return(bt&6)!==0?It():tc!==-1?tc:tc=It()}function Wa(t){return(t.mode&1)===0?1:(bt&2)!==0&&vn!==0?vn&-vn:p_.transition!==null?(nc===0&&(nc=Vt()),nc):(t=kt,t!==0||(t=window.event,t=t===void 0?16:Fi(t.type)),t)}function Ns(t,a,o,c){if(50<To)throw To=0,Mu=null,Error(r(185));Ms(t,o,c),((bt&2)===0||t!==mn)&&(t===mn&&((bt&2)===0&&(Yl|=o),on===4&&Ha(t,vn)),Wn(t,c),o===1&&bt===0&&(a.mode&1)===0&&(ji=It()+500,Se&&$t()))}function Wn(t,a){var o=t.callbackNode;Jr(t,a);var c=bn(t,t===mn?vn:0);if(c===0)o!==null&&zi(o),t.callbackNode=null,t.callbackPriority=0;else if(a=c&-c,t.callbackPriority!==a){if(o!=null&&zi(o),a===1)t.tag===0?Ve(gf.bind(null,t)):Be(gf.bind(null,t)),ho(function(){(bt&6)===0&&$t()}),o=null;else{switch(Gt(c)){case 1:o=Hr;break;case 4:o=rr;break;case 16:o=Js;break;case 536870912:o=Vr;break;default:o=Js}o=Sf(o,_f.bind(null,t))}t.callbackPriority=a,t.callbackNode=o}}function _f(t,a){if(tc=-1,nc=0,(bt&6)!==0)throw Error(r(327));var o=t.callbackNode;if(ki()&&t.callbackNode!==o)return null;var c=bn(t,t===mn?vn:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||a)a=sc(t,c);else{a=c;var _=bt;bt|=2;var y=vf();(mn!==t||vn!==a)&&(ma=null,ji=It()+500,Mr(t,a));do try{P_();break}catch(q){yf(t,q)}while(!0);Yc(),Ql.current=y,bt=_,en!==null?a=0:(mn=null,vn=0,a=on)}if(a!==0){if(a===2&&(_=Ls(t),_!==0&&(c=_,a=Ru(t,_))),a===1)throw o=$o,Mr(t,0),Ha(t,c),Wn(t,It()),o;if(a===6)Ha(t,c);else{if(_=t.current.alternate,(c&30)===0&&!M_(_)&&(a=sc(t,c),a===2&&(y=Ls(t),y!==0&&(c=y,a=Ru(t,y))),a===1))throw o=$o,Mr(t,0),Ha(t,c),Wn(t,It()),o;switch(t.finishedWork=_,t.finishedLanes=c,a){case 0:case 1:throw Error(r(345));case 2:Rr(t,Un,ma);break;case 3:if(Ha(t,c),(c&130023424)===c&&(a=Au+500-It(),10<a)){if(bn(t,0)!==0)break;if(_=t.suspendedLanes,(_&c)!==c){Rn(),t.pingedLanes|=t.suspendedLanes&_;break}t.timeoutHandle=qn(Rr.bind(null,t,Un,ma),a);break}Rr(t,Un,ma);break;case 4:if(Ha(t,c),(c&4194240)===c)break;for(a=t.eventTimes,_=-1;0<c;){var j=31-pn(c);y=1<<j,j=a[j],j>_&&(_=j),c&=~y}if(c=_,c=It()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*L_(c/1960))-c,10<c){t.timeoutHandle=qn(Rr.bind(null,t,Un,ma),c);break}Rr(t,Un,ma);break;case 5:Rr(t,Un,ma);break;default:throw Error(r(329))}}}return Wn(t,It()),t.callbackNode===o?_f.bind(null,t):null}function Ru(t,a){var o=Eo;return t.current.memoizedState.isDehydrated&&(Mr(t,a).flags|=256),t=sc(t,a),t!==2&&(a=Un,Un=o,a!==null&&Pu(a)),t}function Pu(t){Un===null?Un=t:Un.push.apply(Un,t)}function M_(t){for(var a=t;;){if(a.flags&16384){var o=a.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var _=o[c],y=_.getSnapshot;_=_.value;try{if(!Yn(y(),_))return!1}catch{return!1}}}if(o=a.child,a.subtreeFlags&16384&&o!==null)o.return=a,a=o;else{if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ha(t,a){for(a&=~Tu,a&=~Yl,t.suspendedLanes|=a,t.pingedLanes&=~a,t=t.expirationTimes;0<a;){var o=31-pn(a),c=1<<o;t[o]=-1,a&=~c}}function gf(t){if((bt&6)!==0)throw Error(r(327));ki();var a=bn(t,0);if((a&1)===0)return Wn(t,It()),null;var o=sc(t,a);if(t.tag!==0&&o===2){var c=Ls(t);c!==0&&(a=c,o=Ru(t,c))}if(o===1)throw o=$o,Mr(t,0),Ha(t,a),Wn(t,It()),o;if(o===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=a,Rr(t,Un,ma),Wn(t,It()),null}function zu(t,a){var o=bt;bt|=1;try{return t(a)}finally{bt=o,bt===0&&(ji=It()+500,Se&&$t())}}function Lr(t){Ua!==null&&Ua.tag===0&&(bt&6)===0&&ki();var a=bt;bt|=1;var o=is.transition,c=kt;try{if(is.transition=null,kt=1,t)return t()}finally{kt=c,is.transition=o,bt=a,(bt&6)===0&&$t()}}function Iu(){ts=wi.current,At(wi)}function Mr(t,a){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,fi(o)),en!==null)for(o=en.return;o!==null;){var c=o;switch(Qt(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&b();break;case 3:vi(),At(gn),At(an),ru();break;case 5:su(c);break;case 4:vi();break;case 13:At(Ft);break;case 19:At(Ft);break;case 10:Xc(c.type._context);break;case 22:case 23:Iu()}o=o.return}if(mn=t,en=t=Va(t.current,null),vn=ts=a,on=0,$o=null,Tu=Yl=Ar=0,Un=Eo=null,$r!==null){for(a=0;a<$r.length;a++)if(o=$r[a],c=o.interleaved,c!==null){o.interleaved=null;var _=c.next,y=o.pending;if(y!==null){var j=y.next;y.next=_,c.next=j}o.pending=c}$r=null}return t}function yf(t,a){do{var o=en;try{if(Yc(),Fl.current=Wl,ql){for(var c=qt.memoizedState;c!==null;){var _=c.queue;_!==null&&(_.pending=null),c=c.next}ql=!1}if(Tr=0,dn=rn=qt=null,wo=!1,jo=0,Eu.current=null,o===null||o.return===null){on=1,$o=a,en=null;break}e:{var y=t,j=o.return,q=o,K=a;if(a=vn,q.flags|=32768,K!==null&&typeof K=="object"&&typeof K.then=="function"){var _e=K,Me=q,ze=Me.tag;if((Me.mode&1)===0&&(ze===0||ze===11||ze===15)){var Ae=Me.alternate;Ae?(Me.updateQueue=Ae.updateQueue,Me.memoizedState=Ae.memoizedState,Me.lanes=Ae.lanes):(Me.updateQueue=null,Me.memoizedState=null)}var He=Bm(j);if(He!==null){He.flags&=-257,Um(He,j,q,y,a),He.mode&1&&qm(y,_e,a),a=He,K=_e;var Qe=a.updateQueue;if(Qe===null){var Ze=new Set;Ze.add(K),a.updateQueue=Ze}else Qe.add(K);break e}else{if((a&1)===0){qm(y,_e,a),Du();break e}K=Error(r(426))}}else if(Dt&&q.mode&1){var Yt=Bm(j);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),Um(Yt,j,q,y,a),Jc(xi(K,q));break e}}y=K=xi(K,q),on!==4&&(on=2),Eo===null?Eo=[y]:Eo.push(y),y=j;do{switch(y.tag){case 3:y.flags|=65536,a&=-a,y.lanes|=a;var me=Om(y,K,a);mm(y,me);break e;case 1:q=K;var ne=y.type,pe=y.stateNode;if((y.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(Ba===null||!Ba.has(pe)))){y.flags|=65536,a&=-a,y.lanes|=a;var De=Fm(y,q,a);mm(y,De);break e}}y=y.return}while(y!==null)}bf(o)}catch(tt){a=tt,en===o&&o!==null&&(en=o=o.return);continue}break}while(!0)}function vf(){var t=Ql.current;return Ql.current=Wl,t===null?Wl:t}function Du(){(on===0||on===3||on===2)&&(on=4),mn===null||(Ar&268435455)===0&&(Yl&268435455)===0||Ha(mn,vn)}function sc(t,a){var o=bt;bt|=2;var c=vf();(mn!==t||vn!==a)&&(ma=null,Mr(t,a));do try{R_();break}catch(_){yf(t,_)}while(!0);if(Yc(),bt=o,Ql.current=c,en!==null)throw Error(r(261));return mn=null,vn=0,on}function R_(){for(;en!==null;)xf(en)}function P_(){for(;en!==null&&!ll();)xf(en)}function xf(t){var a=kf(t.alternate,t,ts);t.memoizedProps=t.pendingProps,a===null?bf(t):en=a,Eu.current=null}function bf(t){var a=t;do{var o=a.alternate;if(t=a.return,(a.flags&32768)===0){if(o=C_(o,a,ts),o!==null){en=o;return}}else{if(o=$_(o,a),o!==null){o.flags&=32767,en=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{on=6,en=null;return}}if(a=a.sibling,a!==null){en=a;return}en=a=t}while(a!==null);on===0&&(on=5)}function Rr(t,a,o){var c=kt,_=is.transition;try{is.transition=null,kt=1,z_(t,a,o,c)}finally{is.transition=_,kt=c}return null}function z_(t,a,o,c){do ki();while(Ua!==null);if((bt&6)!==0)throw Error(r(327));o=t.finishedWork;var _=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var y=o.lanes|o.childLanes;if(va(t,y),t===mn&&(en=mn=null,vn=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||Zl||(Zl=!0,Sf(Js,function(){return ki(),null})),y=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||y){y=is.transition,is.transition=null;var j=kt;kt=1;var q=bt;bt|=4,Eu.current=null,T_(t,o),df(o,t),ci(Sr),cr=!!za,Sr=za=null,t.current=o,A_(o),Ii(),bt=q,kt=j,is.transition=y}else t.current=o;if(Zl&&(Zl=!1,Ua=t,ec=_),y=t.pendingLanes,y===0&&(Ba=null),Gr(o.stateNode),Wn(t,It()),a!==null)for(c=t.onRecoverableError,o=0;o<a.length;o++)_=a[o],c(_.value,{componentStack:_.stack,digest:_.digest});if(Xl)throw Xl=!1,t=Lu,Lu=null,t;return(ec&1)!==0&&t.tag!==0&&ki(),y=t.pendingLanes,(y&1)!==0?t===Mu?To++:(To=0,Mu=t):To=0,$t(),null}function ki(){if(Ua!==null){var t=Gt(ec),a=is.transition,o=kt;try{if(is.transition=null,kt=16>t?16:t,Ua===null)var c=!1;else{if(t=Ua,Ua=null,ec=0,(bt&6)!==0)throw Error(r(331));var _=bt;for(bt|=4,Ke=t.current;Ke!==null;){var y=Ke,j=y.child;if((Ke.flags&16)!==0){var q=y.deletions;if(q!==null){for(var K=0;K<q.length;K++){var _e=q[K];for(Ke=_e;Ke!==null;){var Me=Ke;switch(Me.tag){case 0:case 11:case 15:Co(8,Me,y)}var ze=Me.child;if(ze!==null)ze.return=Me,Ke=ze;else for(;Ke!==null;){Me=Ke;var Ae=Me.sibling,He=Me.return;if(rf(Me),Me===_e){Ke=null;break}if(Ae!==null){Ae.return=He,Ke=Ae;break}Ke=He}}}var Qe=y.alternate;if(Qe!==null){var Ze=Qe.child;if(Ze!==null){Qe.child=null;do{var Yt=Ze.sibling;Ze.sibling=null,Ze=Yt}while(Ze!==null)}}Ke=y}}if((y.subtreeFlags&2064)!==0&&j!==null)j.return=y,Ke=j;else e:for(;Ke!==null;){if(y=Ke,(y.flags&2048)!==0)switch(y.tag){case 0:case 11:case 15:Co(9,y,y.return)}var me=y.sibling;if(me!==null){me.return=y.return,Ke=me;break e}Ke=y.return}}var ne=t.current;for(Ke=ne;Ke!==null;){j=Ke;var pe=j.child;if((j.subtreeFlags&2064)!==0&&pe!==null)pe.return=j,Ke=pe;else e:for(j=ne;Ke!==null;){if(q=Ke,(q.flags&2048)!==0)try{switch(q.tag){case 0:case 11:case 15:Jl(9,q)}}catch(tt){Wt(q,q.return,tt)}if(q===j){Ke=null;break e}var De=q.sibling;if(De!==null){De.return=q.return,Ke=De;break e}Ke=q.return}}if(bt=_,$t(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(cs,t)}catch{}c=!0}return c}finally{kt=o,is.transition=a}}return!1}function wf(t,a,o){a=xi(o,a),a=Om(t,a,1),t=Fa(t,a,1),a=Rn(),t!==null&&(Ms(t,1,a),Wn(t,a))}function Wt(t,a,o){if(t.tag===3)wf(t,t,o);else for(;a!==null;){if(a.tag===3){wf(a,t,o);break}else if(a.tag===1){var c=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ba===null||!Ba.has(c))){t=xi(o,t),t=Fm(a,t,1),a=Fa(a,t,1),t=Rn(),a!==null&&(Ms(a,1,t),Wn(a,t));break}}a=a.return}}function I_(t,a,o){var c=t.pingCache;c!==null&&c.delete(a),a=Rn(),t.pingedLanes|=t.suspendedLanes&o,mn===t&&(vn&o)===o&&(on===4||on===3&&(vn&130023424)===vn&&500>It()-Au?Mr(t,0):Tu|=o),Wn(t,a)}function jf(t,a){a===0&&((t.mode&1)===0?a=1:(a=Kr,Kr<<=1,(Kr&130023424)===0&&(Kr=4194304)));var o=Rn();t=ca(t,a),t!==null&&(Ms(t,a,o),Wn(t,o))}function D_(t){var a=t.memoizedState,o=0;a!==null&&(o=a.retryLane),jf(t,o)}function O_(t,a){var o=0;switch(t.tag){case 13:var c=t.stateNode,_=t.memoizedState;_!==null&&(o=_.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(r(314))}c!==null&&c.delete(a),jf(t,o)}var kf;kf=function(t,a,o){if(t!==null)if(t.memoizedProps!==a.pendingProps||gn.current)Bn=!0;else{if((t.lanes&o)===0&&(a.flags&128)===0)return Bn=!1,N_(t,a,o);Bn=(t.flags&131072)!==0}else Bn=!1,Dt&&(a.flags&1048576)!==0&&Zt(a,lt,a.index);switch(a.lanes=0,a.tag){case 2:var c=a.type;Gl(t,a),t=a.pendingProps;var _=la(a,an.current);yi(a,o),_=lu(null,a,c,t,_,o);var y=cu();return a.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,p(c)?(y=!0,z(a)):y=!1,a.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,tu(a),_.updater=Hl,a.stateNode=_,_._reactInternals=a,pu(a,c,t,o),a=vu(null,a,c,!0,y,o)):(a.tag=0,Dt&&y&&Mt(a),Mn(null,a,_,o),a=a.child),a;case 16:c=a.elementType;e:{switch(Gl(t,a),t=a.pendingProps,_=c._init,c=_(c._payload),a.type=c,_=a.tag=q_(c),t=js(c,t),_){case 0:a=yu(null,a,c,t,o);break e;case 1:a=Jm(null,a,c,t,o);break e;case 11:a=Wm(null,a,c,t,o);break e;case 14:a=Hm(null,a,c,js(c.type,t),o);break e}throw Error(r(306,c,""))}return a;case 0:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:js(c,_),yu(t,a,c,_,o);case 1:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:js(c,_),Jm(t,a,c,_,o);case 3:e:{if(Qm(a),t===null)throw Error(r(387));c=a.pendingProps,y=a.memoizedState,_=y.element,dm(t,a),Dl(a,c,null,o);var j=a.memoizedState;if(c=j.element,y.isDehydrated)if(y={element:c,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},a.updateQueue.baseState=y,a.memoizedState=y,a.flags&256){_=xi(Error(r(423)),a),a=Ym(t,a,c,o,_);break e}else if(c!==_){_=xi(Error(r(424)),a),a=Ym(t,a,c,o,_);break e}else for(es=gs(a.stateNode.containerInfo.firstChild),un=a,Dt=!0,ws=null,o=cm(a,null,c,o),a.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(pi(),c===_){a=da(t,a,o);break e}Mn(t,a,c,o)}a=a.child}return a;case 5:return hm(a),t===null&&Kc(a),c=a.type,_=a.pendingProps,y=t!==null?t.memoizedProps:null,j=_.children,Xn(c,_)?j=null:y!==null&&Xn(c,y)&&(a.flags|=32),Km(t,a),Mn(t,a,j,o),a.child;case 6:return t===null&&Kc(a),null;case 13:return Xm(t,a,o);case 4:return nu(a,a.stateNode.containerInfo),c=a.pendingProps,t===null?a.child=_i(a,null,c,o):Mn(t,a,c,o),a.child;case 11:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:js(c,_),Wm(t,a,c,_,o);case 7:return Mn(t,a,a.pendingProps,o),a.child;case 8:return Mn(t,a,a.pendingProps.children,o),a.child;case 12:return Mn(t,a,a.pendingProps.children,o),a.child;case 10:e:{if(c=a.type._context,_=a.pendingProps,y=a.memoizedProps,j=_.value,Tt(Pl,c._currentValue),c._currentValue=j,y!==null)if(Yn(y.value,j)){if(y.children===_.children&&!gn.current){a=da(t,a,o);break e}}else for(y=a.child,y!==null&&(y.return=a);y!==null;){var q=y.dependencies;if(q!==null){j=y.child;for(var K=q.firstContext;K!==null;){if(K.context===c){if(y.tag===1){K=ua(-1,o&-o),K.tag=2;var _e=y.updateQueue;if(_e!==null){_e=_e.shared;var Me=_e.pending;Me===null?K.next=K:(K.next=Me.next,Me.next=K),_e.pending=K}}y.lanes|=o,K=y.alternate,K!==null&&(K.lanes|=o),Zc(y.return,o,a),q.lanes|=o;break}K=K.next}}else if(y.tag===10)j=y.type===a.type?null:y.child;else if(y.tag===18){if(j=y.return,j===null)throw Error(r(341));j.lanes|=o,q=j.alternate,q!==null&&(q.lanes|=o),Zc(j,o,a),j=y.sibling}else j=y.child;if(j!==null)j.return=y;else for(j=y;j!==null;){if(j===a){j=null;break}if(y=j.sibling,y!==null){y.return=j.return,j=y;break}j=j.return}y=j}Mn(t,a,_.children,o),a=a.child}return a;case 9:return _=a.type,c=a.pendingProps.children,yi(a,o),_=as(_),c=c(_),a.flags|=1,Mn(t,a,c,o),a.child;case 14:return c=a.type,_=js(c,a.pendingProps),_=js(c.type,_),Hm(t,a,c,_,o);case 15:return Vm(t,a,a.type,a.pendingProps,o);case 17:return c=a.type,_=a.pendingProps,_=a.elementType===c?_:js(c,_),Gl(t,a),a.tag=1,p(c)?(t=!0,z(a)):t=!1,yi(a,o),Im(a,c,_),pu(a,c,_,o),vu(null,a,c,!0,t,o);case 19:return ef(t,a,o);case 22:return Gm(t,a,o)}throw Error(r(156,a.tag))};function Sf(t,a){return ar(t,a)}function F_(t,a,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function os(t,a,o,c){return new F_(t,a,o,c)}function Ou(t){return t=t.prototype,!(!t||!t.isReactComponent)}function q_(t){if(typeof t=="function")return Ou(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ve)return 11;if(t===Z)return 14}return 2}function Va(t,a){var o=t.alternate;return o===null?(o=os(t.tag,a,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=a,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,a=t.dependencies,o.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function ac(t,a,o,c,_,y){var j=2;if(c=t,typeof t=="function")Ou(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case oe:return Pr(o.children,_,y,a);case G:j=8,_|=8;break;case Ne:return t=os(12,o,a,_|2),t.elementType=Ne,t.lanes=y,t;case H:return t=os(13,o,a,_),t.elementType=H,t.lanes=y,t;case X:return t=os(19,o,a,_),t.elementType=X,t.lanes=y,t;case Y:return rc(o,_,y,a);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case je:j=10;break e;case we:j=9;break e;case ve:j=11;break e;case Z:j=14;break e;case U:j=16,c=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return a=os(j,o,a,_),a.elementType=t,a.type=c,a.lanes=y,a}function Pr(t,a,o,c){return t=os(7,t,c,a),t.lanes=o,t}function rc(t,a,o,c){return t=os(22,t,c,a),t.elementType=Y,t.lanes=o,t.stateNode={isHidden:!1},t}function Fu(t,a,o){return t=os(6,t,null,a),t.lanes=o,t}function qu(t,a,o){return a=os(4,t.children!==null?t.children:[],t.key,a),a.lanes=o,a.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},a}function B_(t,a,o,c,_){this.tag=a,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xt(0),this.expirationTimes=Xt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.identifierPrefix=c,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function Bu(t,a,o,c,_,y,j,q,K){return t=new B_(t,a,o,q,K),a===1?(a=1,y===!0&&(a|=8)):a=0,y=os(3,null,null,a),t.current=y,y.stateNode=t,y.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},tu(y),t}function U_(t,a,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:c==null?null:""+c,children:t,containerInfo:a,implementation:o}}function Nf(t){if(!t)return bs;t=t._reactInternals;e:{if(As(t)!==t||t.tag!==1)throw Error(r(170));var a=t;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(p(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(r(171))}if(t.tag===1){var o=t.type;if(p(o))return S(t,o,a)}return a}function Cf(t,a,o,c,_,y,j,q,K){return t=Bu(o,c,!0,t,_,y,j,q,K),t.context=Nf(null),o=t.current,c=Rn(),_=Wa(o),y=ua(c,_),y.callback=a??null,Fa(o,y,_),t.current.lanes=_,Ms(t,_,c),Wn(t,c),t}function ic(t,a,o,c){var _=a.current,y=Rn(),j=Wa(_);return o=Nf(o),a.context===null?a.context=o:a.pendingContext=o,a=ua(y,j),a.payload={element:t},c=c===void 0?null:c,c!==null&&(a.callback=c),t=Fa(_,a,j),t!==null&&(Ns(t,_,j,y),Il(t,_,j)),j}function oc(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 $f(t,a){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<a?o:a}}function Uu(t,a){$f(t,a),(t=t.alternate)&&$f(t,a)}function W_(){return null}var Ef=typeof reportError=="function"?reportError:function(t){console.error(t)};function Wu(t){this._internalRoot=t}lc.prototype.render=Wu.prototype.render=function(t){var a=this._internalRoot;if(a===null)throw Error(r(409));ic(t,a,null,null)},lc.prototype.unmount=Wu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var a=t.containerInfo;Lr(function(){ic(null,t,null,null)}),a[ys]=null}};function lc(t){this._internalRoot=t}lc.prototype.unstable_scheduleHydration=function(t){if(t){var a=Yr();t={blockedOn:null,target:t,priority:a};for(var o=0;o<_n.length&&a!==0&&a<_n[o].priority;o++);_n.splice(o,0,t),o===0&&In(t)}};function Hu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function cc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Tf(){}function H_(t,a,o,c,_){if(_){if(typeof c=="function"){var y=c;c=function(){var _e=oc(j);y.call(_e)}}var j=Cf(a,c,t,0,null,!1,!1,"",Tf);return t._reactRootContainer=j,t[ys]=j.current,Ma(t.nodeType===8?t.parentNode:t),Lr(),j}for(;_=t.lastChild;)t.removeChild(_);if(typeof c=="function"){var q=c;c=function(){var _e=oc(K);q.call(_e)}}var K=Bu(t,0,!1,null,null,!1,!1,"",Tf);return t._reactRootContainer=K,t[ys]=K.current,Ma(t.nodeType===8?t.parentNode:t),Lr(function(){ic(a,K,o,c)}),K}function uc(t,a,o,c,_){var y=o._reactRootContainer;if(y){var j=y;if(typeof _=="function"){var q=_;_=function(){var K=oc(j);q.call(K)}}ic(a,j,t,_)}else j=H_(o,a,t,_,c);return oc(j)}us=function(t){switch(t.tag){case 3:var a=t.stateNode;if(a.current.memoizedState.isDehydrated){var o=ir(a.pendingLanes);o!==0&&(Rs(a,o|1),Wn(a,It()),(bt&6)===0&&(ji=It()+500,$t()))}break;case 13:Lr(function(){var c=ca(t,1);if(c!==null){var _=Rn();Ns(c,t,1,_)}}),Uu(t,1)}},Qr=function(t){if(t.tag===13){var a=ca(t,134217728);if(a!==null){var o=Rn();Ns(a,t,134217728,o)}Uu(t,134217728)}},zn=function(t){if(t.tag===13){var a=Wa(t),o=ca(t,a);if(o!==null){var c=Rn();Ns(o,t,a,c)}Uu(t,a)}},Yr=function(){return kt},Di=function(t,a){var o=kt;try{return kt=t,a()}finally{kt=o}},ht=function(t,a,o){switch(a){case"input":if(fe(t,o),a=o.name,o.type==="radio"&&a!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<o.length;a++){var c=o[a];if(c!==t&&c.form===t.form){var _=hi(c);if(!_)throw Error(r(90));qe(c),fe(c,_)}}}break;case"textarea":Je(t,o);break;case"select":a=o.value,a!=null&&W(t,!!o.multiple,a,!1)}},Ye=zu,yt=Lr;var V_={usingClientEntryPoint:!1,Events:[Cr,Da,hi,ge,Te,zu]},Ao={findFiberByHostInstance:vs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},G_={bundleType:Ao.bundleType,version:Ao.version,rendererPackageName:Ao.rendererPackageName,rendererConfig:Ao.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:P.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=sr(t),t===null?null:t.stateNode},findFiberByHostInstance:Ao.findFiberByHostInstance||W_,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 dc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dc.isDisabled&&dc.supportsFiber)try{cs=dc.inject(G_),hn=dc}catch{}}return Hn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V_,Hn.createPortal=function(t,a){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hu(a))throw Error(r(200));return U_(t,a,null,o)},Hn.createRoot=function(t,a){if(!Hu(t))throw Error(r(299));var o=!1,c="",_=Ef;return a!=null&&(a.unstable_strictMode===!0&&(o=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onRecoverableError!==void 0&&(_=a.onRecoverableError)),a=Bu(t,1,!1,null,null,o,!1,c,_),t[ys]=a.current,Ma(t.nodeType===8?t.parentNode:t),new Wu(a)},Hn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var a=t._reactInternals;if(a===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=sr(a),t=t===null?null:t.stateNode,t},Hn.flushSync=function(t){return Lr(t)},Hn.hydrate=function(t,a,o){if(!cc(a))throw Error(r(200));return uc(null,t,a,!0,o)},Hn.hydrateRoot=function(t,a,o){if(!Hu(t))throw Error(r(405));var c=o!=null&&o.hydratedSources||null,_=!1,y="",j=Ef;if(o!=null&&(o.unstable_strictMode===!0&&(_=!0),o.identifierPrefix!==void 0&&(y=o.identifierPrefix),o.onRecoverableError!==void 0&&(j=o.onRecoverableError)),a=Cf(a,null,t,1,o??null,_,!1,y,j),t[ys]=a.current,Ma(t),c)for(t=0;t<c.length;t++)o=c[t],_=o._getVersion,_=_(o._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[o,_]:a.mutableSourceEagerHydrationData.push(o,_);return new lc(a)},Hn.render=function(t,a,o){if(!cc(a))throw Error(r(200));return uc(null,t,a,!1,o)},Hn.unmountComponentAtNode=function(t){if(!cc(t))throw Error(r(40));return t._reactRootContainer?(Lr(function(){uc(null,null,t,!1,function(){t._reactRootContainer=null,t[ys]=null})}),!0):!1},Hn.unstable_batchedUpdates=zu,Hn.unstable_renderSubtreeIntoContainer=function(t,a,o,c){if(!cc(o))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return uc(t,a,o,!1,c)},Hn.version="18.3.1-next-f1338f8080-20240426",Hn}var Df;function Qh(){if(Df)return Ku.exports;Df=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(n){console.error(n)}}return s(),Ku.exports=sg(),Ku.exports}var Of;function ag(){if(Of)return mc;Of=1;var s=Qh();return mc.createRoot=s.createRoot,mc.hydrateRoot=s.hydrateRoot,mc}var rg=ag();const Yh=[{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"]}];Yh.map(s=>({id:s.id,label:s.label}));function ig(s){return`theme-${String(s||"").trim()||"dark"}`}function Ff(s){try{const n=document.documentElement,r=Array.from(n.classList).filter(i=>i.startsWith("theme-"));for(const i of r)n.classList.remove(i);n.classList.add(ig(s))}catch{}}const wd=[{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}],jd=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function og(s){const n=String(s).trim();return wd.find(r=>r.id===n)||wd[1]}function lg(s){const n=String(s).trim();return jd.find(r=>r.id===n)||jd[1]}function qf(s){try{const n=document.documentElement,r=og(s.font_scale||"md"),i=lg(s.header_density||"standard");n.style.setProperty("--font-scale",String(r.scale)),n.style.setProperty("--header-density",String(i.density))}catch{}}function cg(s){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(s).matches}catch{return!1}}function ug(s){const[n,r]=f.useState(()=>cg(s));return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia(s),l=()=>r(i.matches);return l(),typeof i.addEventListener=="function"?i.addEventListener("change",l):i.addListener(l),()=>{typeof i.removeEventListener=="function"?i.removeEventListener("change",l):i.removeListener(l)}},[s]),n}let Mo=null;function dg(s,n){const r=Math.max(0,Math.round(s));if(!(n.scale<=1.01))return{vvHeight:r,keyboardInset:0};const i=Math.max(0,Math.min(r,Math.round(n.height))),l=Math.max(0,Math.round(s-n.height-Math.max(0,n.offsetTop)));return{vvHeight:i,keyboardInset:l}}function mg(){if(Mo)return Mo;if(typeof window>"u"||typeof document>"u")return()=>{};const s=window.visualViewport;if(!s)return()=>{};const n=document.documentElement;let r=0;const i=()=>{r=0;const{vvHeight:u,keyboardInset:m}=dg(window.innerHeight,{height:s.height,offsetTop:s.offsetTop,scale:s.scale||1});n.style.setProperty("--vv-height",`${u}px`),n.style.setProperty("--keyboard-inset",`${m}px`)},l=()=>{r||(r=window.requestAnimationFrame(i))};return i(),s.addEventListener("resize",l),s.addEventListener("scroll",l),window.addEventListener("orientationchange",l),Mo=()=>{s.removeEventListener("resize",l),s.removeEventListener("scroll",l),window.removeEventListener("orientationchange",l),r&&window.cancelAnimationFrame(r),n.style.removeProperty("--vv-height"),n.style.removeProperty("--keyboard-inset"),Mo=null},Mo}var Xh=Qh();function Si(...s){return s.filter(Boolean).join(" ")}function qr({value:s,options:n,placeholder:r="Select…",disabled:i=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:m="Search…",allowCustom:d=!1,clearable:h=!1,minPopoverWidth:x=240,variant:v="panel",className:g,triggerClassName:w,ariaLabel:L,id:A,includeValueOption:$=!1,onOpen:T,customOptionLabel:B,validateCustomValue:O,onChange:M,renderOption:P,renderValue:E}){const Q=f.useRef(null),oe=f.useRef(null),G=f.useRef(null),Ne=f.useRef(T),je=f.useId(),we=A||`af-select-${je.replace(/[^a-zA-Z0-9_-]/g,"")}`,ve=`${we}-listbox`,[H,X]=f.useState(!1),[Z,U]=f.useState(""),[Y,I]=f.useState(0),[te,ae]=f.useState("bottom"),[k,C]=f.useState({left:0,top:0,width:0});f.useEffect(()=>{Ne.current=T},[T]);const re=f.useMemo(()=>{if(!$)return n;const se=String(s??"").trim();return!se||n.some(W=>W.value===se)?n:[...n,{value:se,label:se}]},[$,n,s]),he=f.useMemo(()=>{const se=String(s??"");return re.find(W=>W.value===se)||null},[re,s]),le=f.useMemo(()=>(he==null?void 0:he.label)||String(s||"").trim()||"",[he,s]),D=f.useMemo(()=>{const se=Z.trim().toLowerCase();return se?re.filter(W=>W.label.toLowerCase().includes(se)||W.value.toLowerCase().includes(se)):re},[re,Z]),be=f.useMemo(()=>{if(!d)return null;const se=Z.trim();if(!se||re.some(Ce=>Ce.value===se))return null;const ie=(O==null?void 0:O(se,{options:re}))||"";return{value:se,label:B?B(se):`Use "${se}"`,disabled:!!ie,reason:ie}},[d,B,re,Z,O]),$e=f.useMemo(()=>{const se=be?[be,...D]:D;if(se.length>0)return se;const W=String(s??"").trim();return l&&W?[{value:W,label:le||W}]:se},[be,D,l,le,s]),Oe=f.useCallback(()=>{const se=Q.current;if(!se)return;const W=se.getBoundingClientRect(),ie=Math.max(W.width,x),Ce=Math.max(8,Math.min(W.left,window.innerWidth-ie-8)),Je=window.innerHeight-W.bottom,F=W.top,ue=Je>=220||Je>=F?"bottom":"top";ae(ue);const ye=ue==="bottom"?W.bottom+6:W.top-6;C({left:Ce,top:ye,width:ie})},[x]),Re=f.useCallback(()=>{X(!1),U("")},[]);f.useEffect(()=>{var se;H&&((se=Ne.current)==null||se.call(Ne))},[H]),f.useEffect(()=>{if(!H)return;Oe();const se=()=>Oe();return window.addEventListener("resize",se),window.addEventListener("scroll",se,!0),()=>{window.removeEventListener("resize",se),window.removeEventListener("scroll",se,!0)}},[H,Oe]),f.useEffect(()=>{if(!H)return;const se=W=>{var Ce,Je;const ie=W.target;ie&&((Ce=Q.current)!=null&&Ce.contains(ie)||(Je=oe.current)!=null&&Je.contains(ie)||Re())};return document.addEventListener("mousedown",se,!0),()=>document.removeEventListener("mousedown",se,!0)},[H,Re]),f.useEffect(()=>{if(!H)return;const se=Math.max(0,$e.findIndex(W=>W.value===s));I(se===-1?0:se),u&&setTimeout(()=>{var W;return(W=G.current)==null?void 0:W.focus()},0)},[H,u,s,$e]);const rt=se=>{var ie;const W=$e.find(Ce=>Ce.value===se);W!=null&&W.disabled||(M(se),Re(),(ie=Q.current)==null||ie.focus())},qe=se=>{var W,ie;if(se.key==="Escape")return se.preventDefault(),Re(),(W=Q.current)==null||W.focus(),!0;if(se.key==="Tab")return Re(),(ie=Q.current)==null||ie.focus(),!1;if(se.key==="ArrowDown")return se.preventDefault(),I(Ce=>Math.min(Ce+1,Math.max(0,$e.length-1))),!0;if(se.key==="ArrowUp")return se.preventDefault(),I(Ce=>Math.max(Ce-1,0)),!0;if(se.key==="Home")return se.preventDefault(),I(0),!0;if(se.key==="End")return se.preventDefault(),I(Math.max(0,$e.length-1)),!0;if(se.key==="Enter"){se.preventDefault();const Ce=$e[Y];return Ce&&rt(Ce.value),!0}return!1},it=se=>{if(!i){if(H){if(qe(se))return;if(se.key===" "&&!u){se.preventDefault();const W=$e[Y];W&&rt(W.value)}return}(se.key==="Enter"||se.key===" "||se.key==="ArrowDown"||se.key==="ArrowUp")&&(se.preventDefault(),X(!0))}},Ge=!!String(s||"").trim(),ct=Ge?le:r,et=be!=null&&be.disabled?be.reason||"Unavailable":"",fe=H&&$e.length>0?`${we}-opt-${Y}`:void 0,ce=e.jsx("span",{className:Si("af-select-value",!Ge&&"af-select-value--placeholder"),children:l&&!Ge?"Loading…":ct}),Ee=E?E(he,String(s||"")):ce;return e.jsxs("span",{className:Si("af-select",v==="pin"?"af-select--pin":"af-select--panel",g),children:[e.jsxs("button",{ref:Q,id:we,type:"button",className:Si("af-select-trigger",h&&Ge&&"af-select-trigger--clearable",w),disabled:i,onMouseDown:se=>se.stopPropagation(),onClick:se=>{se.stopPropagation(),!i&&X(W=>!W)},onKeyDown:it,role:u?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":H,"aria-controls":H?ve:void 0,"aria-activedescendant":u?void 0:fe,"aria-label":L,children:[Ee,e.jsx("span",{className:Si("af-select-caret",H&&"af-select-caret--open"),children:"▾"})]}),h&&Ge?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:i,onMouseDown:se=>{se.preventDefault(),se.stopPropagation()},onClick:se=>{var W;se.preventDefault(),se.stopPropagation(),M(""),Re(),(W=Q.current)==null||W.focus()},title:"Clear",children:"×"}):null,H?Xh.createPortal(e.jsxs("div",{ref:oe,className:Si("af-select-popover",te==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`},onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),onWheel:se=>se.stopPropagation(),onKeyDown:qe,tabIndex:-1,children:[u?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:G,className:"af-select-search-input",value:Z,onChange:se=>U(se.target.value),placeholder:m,onKeyDown:qe,role:"combobox","aria-expanded":!0,"aria-controls":ve,"aria-activedescendant":fe,"aria-invalid":!!et,"aria-describedby":et?`${we}-custom-error`:void 0}),et?e.jsx("div",{id:`${we}-custom-error`,className:"af-select-custom-error",role:"alert",children:et}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:ve,"aria-label":L,children:l&&$e.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):$e.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):$e.map((se,W)=>{var ye;const ie=se.value===s,Ce=W===Y,Je=String(se.group||"").trim(),F=W>0?String(((ye=$e[W-1])==null?void 0:ye.group)||"").trim():"",ue=!!Je&&Je!==F;return e.jsxs(Bt.Fragment,{children:[ue?e.jsx("div",{className:"af-select-group",role:"presentation",children:Je}):null,e.jsx("div",{id:`${we}-opt-${W}`,role:"option","aria-selected":ie,className:Si("af-select-option",ie&&"af-select-option--selected",Ce&&"af-select-option--highlighted",se.disabled&&"af-select-option--disabled"),title:se.disabled?se.reason||"Unavailable":void 0,onMouseEnter:()=>I(W),onMouseDown:xe=>{xe.preventDefault(),xe.stopPropagation()},onClick:()=>rt(se.value),"aria-disabled":se.disabled?!0:void 0,children:P?P(se,{selected:ie,highlighted:Ce}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:se.label}),se.reason?e.jsx("small",{className:"af-select-option-reason",children:se.reason}):null]}),ie?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},se.value)})})]}),document.body):null]})}function fg(s){const n=new Set,r=[];for(const i of s||[]){if(!i||typeof i!="object")continue;const l=String(i.name||"").trim();!l||n.has(l)||(n.add(l),r.push({name:l,display_name:typeof i.display_name=="string"?i.display_name:void 0}))}return r.sort((i,l)=>i.name.localeCompare(l.name)),r}function hg(s){const n=new Set,r=[];for(const i of s||[]){const l=String(i||"").trim();!l||n.has(l)||(n.add(l),r.push(l))}return r.sort(),r}const kd="Provided by connected pin";function pg(s){const n=s.disabled===!0,r=s.layout||"stack",i=s.allowGatewayDefault!==!1,l=String(s.gatewayDefaultLabel||"(gateway default)"),u=String(s.providerLabel||"Provider"),m=String(s.modelLabel||"Model"),d=String(s.providerPlaceholder||"(select)"),h=String(s.modelPlaceholder||"(select)"),x=String(s.provider||"").trim(),v=String(s.model||"").trim(),g=fg(s.providers),w=hg(s.models),L=typeof s.markSaved=="object"?s.markSaved:null,A=(P,E,Q,oe)=>s.markSaved&&!Q&&!oe&&(!L||L[E]===P)?`${P} (saved)`:P,$=n||!!s.loadingProviders,T=n||!!s.loadingModels,B=[...i?[{value:"",label:l}]:[],...g.map(P=>({value:P.name,label:P.display_name?`${P.display_name} (${P.name})`:P.name})),...s.markSaved&&x&&!g.some(P=>P.name===x)?[{value:x,label:A(x,"provider",s.loadingProviders,s.providerError)}]:[]],O=[...i?[{value:"",label:l}]:[],...w.map(P=>{var E;return{value:P,label:((E=s.modelDisplayNames)==null?void 0:E[P])||P}}),...s.markSaved&&v&&!w.includes(v)?[{value:v,label:A(v,"model",s.loadingModels,s.modelError)}]:[]],M=(P,E)=>e.jsxs("div",{className:"af-pmp__pinned","data-pinned":P,children:[e.jsx("span",{className:"af-pmp__pinned-text",children:kd}),E?e.jsxs("span",{className:"mono muted",children:[" · ",E]}):null]});return e.jsxs("div",{className:s.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:u}),s.providerPinned?M("provider",x):e.jsx(qr,{value:x,options:B,placeholder:i?l:d,disabled:$,loading:!!s.loadingProviders,searchable:!0,allowCustom:s.allowCustomProvider===!0,clearable:i,variant:"panel",triggerClassName:s.selectClassName,ariaLabel:u,onChange:P=>s.onChange({provider:String(P||"").trim(),model:""})}),s.loadingProviders?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,s.providerError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:s.providerError}):null]}),e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:m}),s.modelPinned?M("model",v):e.jsx(qr,{value:v,options:O,placeholder:i?l:h,disabled:T,loading:!!s.loadingModels,searchable:!0,allowCustom:s.allowCustomModel===!0,clearable:i,variant:"panel",triggerClassName:s.selectClassName,ariaLabel:m,onChange:P=>s.onChange({provider:x,model:String(P||"").trim()})}),s.loadingModels?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,s.modelError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:s.modelError}):null]})]})}function _g(s){if(s===!1||s&&typeof s=="object"&&s.mode==="off")return!1;if(!s||typeof s!="object")return;const n=s;if(!(n.mode!=="native_mtp"||!Number.isInteger(n.num_draft_tokens)||Number(n.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(n.num_draft_tokens),require_acceleration:!0}}function gg(s){var r;const n=(r=s==null?void 0:s.execution)==null?void 0:r.speculation;return!n||typeof n.supported!="boolean"?null:{supported:n.supported,ready:typeof n.ready=="boolean"?n.ready:null,reason:typeof n.reason=="string"?n.reason:null,supported_depths:n.supported&&Array.isArray(n.supported_depths)?[...new Set(n.supported_depths.filter(i=>typeof i=="number"&&Number.isInteger(i)&&i>0))]:[],default:Object.prototype.hasOwnProperty.call(n,"effective_default")?n.effective_default:n.default,requires_reload:typeof n.requires_reload=="boolean"?n.requires_reload:null}}function Bf(s){const n=_g(s);return n===!1?"off":n?String(n.num_draft_tokens):""}function yg(s){if(s==="off")return!1;if(!(!/^\d+$/.test(s)||Number(s)<1))return{mode:"native_mtp",num_draft_tokens:Number(s),require_acceleration:!0}}function vg(s){const n=gg(s.capabilities),r=Bf(s.value),i=(n==null?void 0:n.supported_depths.map(String))||[],l=Bf(n==null?void 0:n.default),u=s.inheritLabel||"Workflow / Gateway default",m=l?`${u} (${l==="off"?"Off":`depth ${l}`})`:u,d=s.error||(s.loading?"Checking MTP capability…":n?n.reason||(n.requires_reload?"Model reload required before MTP can run.":n.ready===!1?"MTP is supported but not ready on this instance.":n.ready===null&&n.supported?"MTP support verified; loaded-instance readiness is unknown.":n.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(qr,{ariaLabel:"MTP depth",value:r,placeholder:m,disabled:s.disabled||s.loading,options:[{value:"",label:m},{value:"off",label:"Off"},...i.map(h=>({value:h,label:`Depth ${h}`})),...r&&r!=="off"&&!i.includes(r)?[{value:r,label:`Depth ${r} (saved)`}]:[]],onChange:h=>s.onChange(yg(h))}),d&&!s.hideNote?e.jsx("div",{role:"status",className:"af-pmp__hint",children:d}):null]})}const Uf="api/gateway",Ri="api/connection/gateway";function Cs(s){const n=String(s||"");if(n.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(n)}.`);return n?`${Uf}/${n}`:Uf}function Yu(s,n){const r=String(n||"");if(r.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(r)}.`);let i=String(s??"");for(;i.endsWith("/");)i=i.slice(0,-1);return i?`${i}/${r}`:r}function xg(s){if(!s)return"";const n=[`${s.provider} / ${s.model}`];return s.reasoning&&n.push(`reasoning ${s.reasoning}`),s.speculation===!1?n.push("MTP off"):s.speculation&&n.push(`MTP depth ${s.speculation.num_draft_tokens}`),n.join(" · ")}function bg(s,n="Gateway default"){const r=xg(s);return r?`${n} · ${r}`:n}const wg="The gateway does not say which reasoning levels this model supports.",jg="Set anyway",kg="Reasoning and MTP choices appear when the gateway can describe the selected model.",Sg="Reasoning choices appear when the gateway can describe the selected model.";function Ng(s){const n=s.disabled===!0,r=s.value||{provider:"",model:""},i=!String(r.provider||"").trim()&&!String(r.model||"").trim(),l=s.layout==="compact",u=s.pinned||{},m=!!(u.provider||u.model),[d,h]=f.useState(!i),x=l||m||!(i&&!d),v=i&&(l||m||!d),g=f.useRef(i);f.useEffect(()=>{i&&!g.current&&h(!1),g.current=i},[i]);const[w,L]=f.useState([]),[A,$]=f.useState(!1),[T,B]=f.useState(""),[O,M]=f.useState([]),[P,E]=f.useState({}),[Q,oe]=f.useState(!1),[G,Ne]=f.useState(""),je=f.useRef(s);je.current=s;const[we,ve]=f.useState({status:"idle",value:null,message:""}),H=s.fetchGatewayDefault;f.useEffect(()=>{if(!H||n)return;let W=!0;const ie=Ce=>ve(Je=>JSON.stringify(Je)===JSON.stringify(Ce)?Je:Ce);return ve(Ce=>Ce.status==="idle"?{...Ce,status:"loading"}:Ce),H().then(Ce=>{var Je;W&&(Ce?(Je=Ce.warnings)!=null&&Je.length?ie({status:"unusable",value:Ce,message:Ce.warnings.join(" ")}):ie({status:"resolved",value:Ce,message:""}):ie({status:"none",value:null,message:""}))}).catch(Ce=>{W&&ie({status:"error",value:null,message:String((Ce==null?void 0:Ce.message)||Ce)})}),()=>{W=!1}},[H,n]);const X=we.status==="resolved"?we.value:null,Z=f.useRef({provider:String(r.provider||"").trim(),model:String(r.model||"").trim()});f.useEffect(()=>{if(!x||u.provider||n)return;let W=!0;return $(!0),(async()=>{try{const ie=await je.current.fetchProviders();if(!W)return;L(Array.isArray(ie)?ie:[]),B("")}catch(ie){if(!W)return;L([]),B(`#FALLBACK provider discovery failed: ${String((ie==null?void 0:ie.message)||ie)}`)}finally{W&&$(!1)}})(),()=>{W=!1}},[x,u.provider,n]);const U=String(r.provider||"").trim();f.useEffect(()=>{if(!U||n||u.model){M([]),Ne(""),oe(!1);return}let W=!0;return M([]),oe(!0),Ne(""),(async()=>{try{const ie=await je.current.fetchModels(U);if(!W)return;const Ce=[],Je={};for(const F of Array.isArray(ie)?ie:[]){const ue=typeof F=="string"?F:String((F==null?void 0:F.id)||"");ue&&(Ce.push(ue),typeof F!="string"&&(F!=null&&F.label)&&F.label!==ue&&(Je[ue]=String(F.label)))}M(Ce),E(Je)}catch(ie){if(!W)return;M([]),Ne(`#FALLBACK model discovery failed: ${String((ie==null?void 0:ie.message)||ie)}`)}finally{W&&oe(!1)}})(),()=>{W=!1}},[U,n,u.model]);const Y=String(r.model||"").trim(),I=s.defaultModeLabel||"Gateway default",te=we.status==="none"?`${I} · none configured`:bg(X,I),ae=s.customModeLabel||"Custom",k=s.effectiveDefault||(we.value?{provider:we.value.provider,model:we.value.model}:void 0),C=U||(k==null?void 0:k.provider)||"",re=Y||(U?"":k==null?void 0:k.model)||"",[he,le]=f.useState({levels:[],error:"",loading:!1}),[D,be]=f.useState(!1),$e=!!s.fetchModelCapabilities,[Oe,Re]=f.useState();f.useEffect(()=>{let W=!0;if(Re(void 0),le({levels:[],error:"",loading:$e&&!!re}),!(!$e||!re||n))return je.current.fetchModelCapabilities(re,C).then(ie=>{var ye;if(!W)return;if(ie!=null&&ie.error)throw new Error(String(ie.error));Re(ie);const Ce=(ie==null?void 0:ie.capabilities)||ie||{},Je=Ce.reasoning_levels||Ce.thinking_levels,F=Array.isArray(Je)?[...new Set(Je.filter(xe=>typeof xe=="string"&&!!xe.trim()))]:[];!F.length&&Ce.thinking_support===!0&&((ye=Ce.thinking_control)!=null&&ye.prompt_disable_token)&&F.push("off","auto");const ue=typeof Ce.thinking_support=="boolean"?Ce.thinking_support:void 0;le({levels:F,support:ue,error:"",loading:!1})}).catch(ie=>{W&&le({levels:[],error:String((ie==null?void 0:ie.message)||ie),loading:!1})}),()=>{W=!1}},[C,re,$e,n]),f.useEffect(()=>be(!1),[C,re]);const rt=s.inheritLabel||"Workflow / Gateway default",qe=v&&(X!=null&&X.reasoning)?`${rt} (${X.reasoning})`:rt,it=!v||s.optionsInDefaultMode!==!1,Ge=s.reasoningLadder?[...new Set(s.reasoningLadder.filter(W=>typeof W=="string"&&W.trim()))]:null,ct=he.loading?"loading":he.levels.length||he.support===!0?"supported":he.support===!1?"unsupported":"unknown",et=s.unknownReasoning==="allow-override"&&!!(Ge!=null&&Ge.length),fe=String(r.reasoning||"").trim();let ce=[],Ee=!1;if(!Ge)ce=he.levels.map(W=>({value:W,label:W}));else if(ct==="supported"||ct==="loading"){const W=he.levels;ce=[...Ge,...W.filter(Ce=>!Ge.includes(Ce))].map(Ce=>!W.length||W.includes(Ce)?{value:Ce,label:Ce}:{value:Ce,label:Ce,disabled:!0,reason:"This model does not advertise it"})}else ct==="unknown"&&et&&(Ee=!D,ce=Ge.map(W=>({value:W,label:W})));fe&&!ce.some(W=>W.value===fe)&&ce.push({value:fe,label:`${fe} (saved)`});const se=($e||et)&&(ce.length>0||ct==="unknown"&&et);return e.jsxs("div",{className:`af-pmp${l?" af-pmp--compact":""}${s.className?` ${s.className}`:""}`,"data-gateway-default":H?we.status:void 0,children:[l||m?null:e.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":v,className:`af-pmp__seg-btn${v?" is-active":""}`,onClick:()=>{h(!1),s.onChange({...r,provider:"",model:"",...$e?{reasoning:""}:{}})},disabled:n,title:te,"data-default-choice":"",children:te}),e.jsx("button",{type:"button",role:"tab","aria-selected":!v,className:`af-pmp__seg-btn${v?"":" is-active"}`,onClick:()=>{h(!0)},disabled:n,children:ae})]}),we.status==="error"||we.status==="unusable"?e.jsx("div",{role:"status",className:"af-pmp__hint","data-gateway-default-problem":we.status,children:we.status==="error"?`The gateway's default could not be read: ${we.message}`:`Gateway warning: ${we.message}`}):null,x?e.jsx(pg,{provider:U,model:Y,providers:w,models:O,modelDisplayNames:P,markSaved:Z.current,providerPinned:u.provider,modelPinned:u.model,disabled:n,loadingProviders:A,loadingModels:Q,providerError:T||void 0,modelError:G||void 0,providerLabel:s.providerLabel,modelLabel:s.modelLabel,allowGatewayDefault:l,gatewayDefaultLabel:l?te:void 0,allowCustomProvider:s.allowCustom!==!1,allowCustomModel:s.allowCustom!==!1,onChange:W=>s.onChange({...r,provider:W.provider,model:W.model,...$e?{reasoning:""}:{}})}):e.jsx("div",{className:"af-pmp__hint",children:s.defaultHint||"The gateway picks its configured default provider and model for this task."}),it&&u.reasoning?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:s.reasoningLabel||"Reasoning effort"}),e.jsx("div",{className:"af-pmp__pinned","data-pinned":"reasoning",children:kd})]}):it&&se?e.jsxs("div",{className:"af-pmp__reasoning","data-reasoning-state":ct,children:[e.jsx("label",{children:s.reasoningLabel||"Reasoning effort"}),e.jsx(qr,{ariaLabel:s.reasoningLabel||"Reasoning effort",placeholder:qe,value:r.reasoning||"",options:[{value:"",label:qe},...ce],disabled:n||he.loading||Ee,onChange:W=>s.onChange({...r,reasoning:W})}),ct==="unknown"&&et?e.jsxs("div",{className:"af-pmp__hint","data-reasoning-unknown":"",children:[wg," ",e.jsxs("label",{className:"af-pmp__override",children:[e.jsx("input",{type:"checkbox",checked:D,disabled:n,onChange:W=>{be(W.target.checked),!W.target.checked&&r.reasoning&&s.onChange({...r,reasoning:""})}})," ",jg]})]}):null]}):null,it&&s.enableSpeculation&&u.speculation?e.jsxs("div",{className:"af-pmp__speculation",children:[e.jsx("label",{children:"MTP depth"}),e.jsx("div",{className:"af-pmp__pinned","data-pinned":"speculation",children:kd})]}):it&&s.enableSpeculation?e.jsx(vg,{value:r.speculation,inheritLabel:rt,onChange:W=>s.onChange({...r,speculation:W}),capabilities:Oe,disabled:n,loading:he.loading,hideNote:!!he.error}):null,it&&he.error?e.jsxs("div",{role:"status",className:"af-pmp__hint","data-discovery":"unavailable",children:[s.enableSpeculation?kg:Sg,e.jsxs("details",{className:"af-pmp__details",children:[e.jsx("summary",{children:"Technical details"}),e.jsx("span",{children:he.error})]})]}):null]})}function Wf(...s){return s.filter(Boolean).join(" ")}function Cg({kicker:s="AbstractGateway connection",title:n="Connect to AbstractGateway",description:r="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:i="Not signed in",statusTone:l="neutral",showGatewayUrl:u=!1,gatewayUrl:m="",gatewayUrlPlaceholder:d="http://127.0.0.1:8080",onGatewayUrlChange:h,userId:x,userPlaceholder:v="admin",onUserIdChange:g,token:w,tokenPlaceholder:L="Paste Gateway user token",showToken:A=!1,onTokenChange:$,onShowTokenChange:T,remember:B=!1,rememberLabel:O="Remember this browser",onRememberChange:M,loading:P=!1,submitting:E=!1,submitDisabled:Q=!1,submitLabel:oe="Sign in",submittingLabel:G="Signing in...",closeLabel:Ne="Close",signOutLabel:je="Sign out",showClose:we=!1,showSignOut:ve=!1,error:H,message:X,className:Z,onSubmit:U,onClose:Y,onSignOut:I}){const te=P||E,ae=te||Q||!String(x||"").trim()||!String(w||"").trim(),k=C=>{C.preventDefault(),!ae&&U()};return e.jsxs("form",{className:Wf("af-gateway-signin",Z),onSubmit:k,children:[e.jsxs("div",{className:"af-gateway-signin__hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"af-gateway-signin__kicker",children:s}),e.jsx("h2",{children:n}),r?e.jsx("p",{children:r}):null]}),e.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),e.jsx("div",{className:"af-gateway-signin__status-row",children:e.jsx("span",{className:Wf("af-gateway-signin__status",`af-gateway-signin__status--${l}`),children:i})}),e.jsxs("div",{className:"af-gateway-signin__form",children:[u?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:m,onChange:C=>h==null?void 0:h(C.target.value),placeholder:d,autoComplete:"url",disabled:te})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:x,onChange:C=>g(C.target.value),placeholder:v,autoComplete:"username",disabled:te}),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:A?"text":"password",value:w,onChange:C=>$(C.target.value),placeholder:L,autoComplete:"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"",spellCheck:!1,disabled:te}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>T==null?void 0:T(!A),disabled:te,children:A?"Hide":"Show"})]}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!B,onChange:C=>M==null?void 0:M(C.target.checked),disabled:te}),O]})]}),H?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:H}):null,!H&&X?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:X}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[we?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:Y,disabled:te,children:Ne}):null,ve?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(I==null?void 0:I()),disabled:te,children:je}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:ae,children:E?G:oe})]})]})}function $g(s){return s==="light"?"Light":"Dark"}function Eg(s){const n=s.themes&&s.themes.length?s.themes:Yh,r=s.showSwatches!==!1,i=s.variant||"panel",l=f.useMemo(()=>{const m={};for(const d of n)m[d.id]=d;return m},[n]),u=f.useMemo(()=>n.map(m=>({value:m.id,label:m.label,group:$g(m.group)})),[n]);return e.jsx(qr,{value:s.value,options:u,placeholder:s.placeholder||"Select theme…",disabled:s.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:i,className:s.className,triggerClassName:s.triggerClassName,onChange:m=>s.onChange(String(m||"").trim()),renderValue:(m,d)=>{const h=String(d||"").trim(),x=l[h],v=(x==null?void 0:x.label)||h||s.placeholder||"Select theme…",g=(x==null?void 0:x.swatches)||null,w=!h;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${w?"af-theme-label--placeholder":""}`.trim(),children:v}),r&&g?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:g.map((L,A)=>e.jsx("span",{className:"af-theme-swatch",style:{background:L}},`${h}:${A}`))}):null]})},renderOption:(m,d)=>{const h=String(m.value||"").trim(),x=l[h],v=(x==null?void 0:x.swatches)||null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"af-theme-option-label",children:m.label}),e.jsxs("span",{className:"af-theme-option-right",children:[r&&v?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((g,w)=>e.jsx("span",{className:"af-theme-swatch",style:{background:g}},`${h}:${w}`))}):null,d.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function Tg(s){const n=s.scales&&s.scales.length?s.scales:wd,r=s.variant||"panel",i=f.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(qr,{value:s.value,options:i,placeholder:s.placeholder||"Font size…",disabled:s.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:s.className,triggerClassName:s.triggerClassName,onChange:l=>s.onChange(String(l||"").trim())})}function Ag(s){const n=s.densities&&s.densities.length?s.densities:jd,r=s.variant||"panel",i=f.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(qr,{value:s.value,options:i,placeholder:s.placeholder||"Header size…",disabled:s.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:s.className,triggerClassName:s.triggerClassName,onChange:l=>s.onChange(String(l||"").trim())})}const Lg=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function Mg(s){switch(s){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"cog":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"activity":return e.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"});case"settings":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("circle",{cx:"8",cy:"6",r:"2"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("circle",{cx:"16",cy:"12",r:"2"}),e.jsx("path",{d:"M4 18h16"}),e.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2v3"}),e.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),e.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M9 17h6"})]});case"paperclip":return e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a5.5 5.5 0 0 1-7.78-7.78l9.19-9.19a3.5 3.5 0 0 1 4.95 4.95l-9.2 9.19a1.5 1.5 0 0 1-2.12-2.12l8.49-8.48"});case"mic":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),e.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),e.jsx("path",{d:"M12 18v4"}),e.jsx("path",{d:"M8 22h8"})]});case"speaker":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),e.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),e.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 9l3 3-3 3"}),e.jsx("path",{d:"M12 15h5"})]});case"edit":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]});case"download":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("path",{d:"M7 10l5 5 5-5"}),e.jsx("path",{d:"M12 15V3"})]});case"loader":return e.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l10 18H2L12 3z"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M15 9l-6 6"}),e.jsx("path",{d:"M9 9l6 6"})]});case"copy":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return e.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return e.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return e.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M6 6l1 16h10l1-16"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"})]});case"send":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2L11 13"}),e.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7"})]});case"thumbsDown":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17"})]});case"thumbsUpFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7z",fill:"currentColor",stroke:"none"})]});case"thumbsDownFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17z",fill:"currentColor",stroke:"none"})]});case"board":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),e.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),e.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),e.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),e.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),e.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),e.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),e.jsx("path",{d:"M8 4.5V2.2"}),e.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),e.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2.5 4h11"}),e.jsx("path",{d:"M2.5 8h11"}),e.jsx("path",{d:"M2.5 12h7"})]});case"gear":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),e.jsx("path",{d:"M8 1.6v2"}),e.jsx("path",{d:"M8 12.4v2"}),e.jsx("path",{d:"M1.6 8h2"}),e.jsx("path",{d:"M12.4 8h2"}),e.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),e.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),e.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),e.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),e.jsx("path",{d:"M18.5 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"})]});case"contrast":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("path",{d:"M16 17l5-5-5-5"}),e.jsx("path",{d:"M21 12H9"})]});case"play":return e.jsx("path",{d:"M7 4.5v15a1 1 0 0 0 1.5.86l12-7.5a1 1 0 0 0 0-1.72l-12-7.5A1 1 0 0 0 7 4.5z",fill:"currentColor",stroke:"none"});case"stop":return e.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2",fill:"currentColor",stroke:"none"});case"folder":return e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"});case"file":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("path",{d:"M14 2v6h6"})]});case"archive":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),e.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),e.jsx("path",{d:"M10 12h4"})]});case"unarchive":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),e.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),e.jsx("path",{d:"M12 18v-6"}),e.jsx("path",{d:"m9 14 3-3 3 3"})]});case"clock":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6h4"})]});case"book":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z"})]});case"compose":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z"})]});case"image":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"M21 15l-3.1-3.1a2 2 0 0 0-2.8 0L6 21"})]});case"video":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}),e.jsx("path",{d:"M16 10.5l5.2-3.1a.5.5 0 0 1 .8.4v8.4a.5.5 0 0 1-.8.4L16 13.5"})]});case"camera":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z"}),e.jsx("circle",{cx:"12",cy:"13",r:"3"})]});case"music":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 18V5l12-2v13"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("circle",{cx:"18",cy:"16",r:"3"})]});case"database":return e.jsxs(e.Fragment,{children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),e.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]});case"branch":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 3v12"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]});case"loop":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 2l4 4-4 4"}),e.jsx("path",{d:"M3 11v-1a4 4 0 0 1 4-4h14"}),e.jsx("path",{d:"M7 22l-4-4 4-4"}),e.jsx("path",{d:"M21 13v1a4 4 0 0 1-4 4H3"})]});case"variable":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 21s-4-3-4-9 4-9 4-9"}),e.jsx("path",{d:"M16 3s4 3 4 9-4 9-4 9"}),e.jsx("path",{d:"M15 9l-6 6"}),e.jsx("path",{d:"M9 9l6 6"})]});case"minus":return e.jsx("path",{d:"M5 12h14"});case"divide":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"6",r:"1.25",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M5 12h14"}),e.jsx("circle",{cx:"12",cy:"18",r:"1.25",fill:"currentColor",stroke:"none"})]});case"function":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3"}),e.jsx("path",{d:"M9 11.2h5.7"})]});case"zoomIn":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"}),e.jsx("path",{d:"M11 8v6"}),e.jsx("path",{d:"M8 11h6"})]});case"zoomOut":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"}),e.jsx("path",{d:"M8 11h6"})]});case"fitView":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),e.jsx("path",{d:"M21 8V5a2 2 0 0 0-2-2h-3"}),e.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"}),e.jsx("path",{d:"M16 21h3a2 2 0 0 0 2-2v-3"})]});case"lock":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"4",y:"11",width:"16",height:"10",rx:"2"}),e.jsx("path",{d:"M8 11V7a4 4 0 0 1 8 0v4"})]});default:return null}}function Ue({name:s,size:n=16,className:r,title:i,...l}){const u=i?void 0:!0,m=Lg.has(s);return e.jsxs("svg",{width:n,height:n,viewBox:m?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:m?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":u,role:i?"img":"presentation",...l,children:[i?e.jsx("title",{children:i}):null,Mg(s)]})}function Rg(s){return!String(s.unavailableReason||"").trim()&&!s.busy}function Pg(s){return Rg(s)?!s.checked:null}let zg=0;function Li(s){const{label:n,checked:r,onChange:i,description:l,reasonVisible:u=!0,describedBy:m,hint:d,busy:h=!1,variant:x="inline",ariaLabel:v,className:g,id:w,action:L}=s,A=String(s.unavailableReason||"").trim(),$=!!A,T=m||(w?`${w}-reason`:$?`af-switch-reason-${++zg}`:void 0),B=["af-switch",x==="row"?"af-switch--row":x==="sm"?"af-switch--sm":"",$?"af-switch--unavailable":"",g||""].filter(Boolean).join(" "),O=P=>{const E=Pg({checked:r,unavailableReason:A,busy:h});if(E===null){P.preventDefault();return}i==null||i(E)},M=e.jsxs("button",{type:"button",role:"switch",id:w,className:B,"data-action":L,"aria-checked":r?"true":"false","aria-disabled":$?"true":void 0,"aria-describedby":$?T:void 0,"aria-busy":h?"true":void 0,"aria-label":v,"aria-description":l?void 0:d,title:$?d?`${A}
41
- ${d}`:A:d,onClick:O,children:[e.jsx("span",{className:"af-switch__track","aria-hidden":"true",children:e.jsx("span",{className:"af-switch__thumb"})}),e.jsxs("span",{className:"af-switch__text",children:[e.jsx("span",{className:"af-switch__label",children:n}),l?e.jsx("span",{className:"af-switch__desc",children:l}):null]})]});return!$||m?M:e.jsxs("span",{className:x==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[M,e.jsx("span",{id:T,className:u?"af-switch__reason":"af-switch__reason af-switch__reason--hidden",children:A})]})}const Ig=150,Zh="data-af-tip";function Dg(s,n,r,i=6,l=8){let u="top",m=s.top-i-n.height;if(m<l){const x=s.bottom+i;(x+n.height<=r.height-l||r.height-s.bottom>s.top)&&(m=x,u="bottom")}let h=(s.left+s.right)/2-n.width/2;return h=Math.max(l,Math.min(h,r.width-l-n.width)),m=Math.max(l,Math.min(m,r.height-l-n.height)),{top:Math.round(m),left:Math.round(h),side:u}}let Hf=0;function ep(s){return s?String(s.getAttribute(Zh)||"").trim():""}function Xu(s,n){const r=s;if(!r||typeof r.closest!="function")return null;const i=r.closest(`[${Zh}]`);return!i||!n.contains(i)||!ep(i)?null:i}function Og(s,n={}){if(!s)throw new Error("bindAfTooltips: a root (document or element) is required");const r=s.nodeType===9?s:s.ownerDocument,i=r.defaultView||globalThis,l=typeof n.delayMs=="number"&&n.delayMs>=0?n.delayMs:Ig;Hf+=1;const u=r.createElement("div");u.className="af-tooltip",u.setAttribute("role","tooltip");const m=`af-tooltip-${Hf}`;u.setAttribute("id",m),u.hidden=!0,(r.body||r.documentElement).appendChild(u);let d=null,h=null,x=null,v=null,g=!1,w=null;const L=()=>{x&&clearTimeout(x),x=null,h=null},A=()=>{v&&clearTimeout(v),v=null},$=()=>{if(!d)return;const Z=d.getBoundingClientRect(),U=u.getBoundingClientRect(),Y=Dg(Z,{width:U.width,height:U.height},{width:i.innerWidth,height:i.innerHeight});u.style.top=`${Y.top}px`,u.style.left=`${Y.left}px`,u.setAttribute("data-side",Y.side)},T=()=>{if(L(),A(),!d)return;String(d.getAttribute("aria-describedby")||"").split(/\s+/).includes(m)&&(w?d.setAttribute("aria-describedby",w):d.removeAttribute("aria-describedby")),w=null,d=null,u.hidden=!0,u.textContent=""},B=Z=>{L(),A(),d&&d!==Z&&T();const U=ep(Z);if(!U||Z.isConnected===!1)return;if(d=Z,u.textContent=U,u.hidden=!1,String(Z.getAttribute("aria-label")||"").trim()!==U){const I=Z.getAttribute("aria-describedby");w=I&&I!==m?I:null,Z.setAttribute("aria-describedby",w?`${w} ${m}`:m)}$()},O=Z=>{A(),d!==Z&&h!==Z&&(L(),h=Z,x=setTimeout(()=>{const U=h;x=null,h=null,U&&B(U)},l))},M=()=>{L(),d&&(A(),v=setTimeout(T,100))},P=Z=>{try{if(typeof Z.matches=="function")return Z.matches(":focus-visible")}catch{}return g},E=Z=>{if(Z.pointerType==="touch")return;if(u.contains(Z.target)){A();return}const Y=Xu(Z.target,s);Y&&O(Y)},Q=Z=>{const Y=Z.relatedTarget||null;if(!(Y&&(u.contains(Y)||d&&d.contains(Y)||h&&h.contains(Y)))){if(h&&!d){L();return}d&&M()}},oe=Z=>{const U=Z.relatedTarget||null;U&&(u.contains(U)||d&&d.contains(U))||M()},G=Z=>{const U=Xu(Z.target,s);U&&P(U)&&O(U)},Ne=Z=>{const U=Xu(Z.target,s);U&&(U===d||U===h)&&T()},je=()=>{g=!1,T()},we=Z=>{if(Z.key==="Escape"||Z.key==="Esc"){d?(Z.preventDefault(),T()):L();return}!Z.metaKey&&!Z.ctrlKey&&!Z.altKey&&(g=!0)},ve=()=>T(),H=s;H.addEventListener("pointerover",E),H.addEventListener("pointerout",Q),H.addEventListener("focusin",G),H.addEventListener("focusout",Ne),u.addEventListener("pointerover",E),u.addEventListener("pointerout",oe),r.addEventListener("pointerdown",je,!0),i.addEventListener("keydown",we,!0),i.addEventListener("scroll",ve,!0),i.addEventListener("resize",ve);let X=!1;return()=>{X||(X=!0,T(),H.removeEventListener("pointerover",E),H.removeEventListener("pointerout",Q),H.removeEventListener("focusin",G),H.removeEventListener("focusout",Ne),u.removeEventListener("pointerover",E),u.removeEventListener("pointerout",oe),r.removeEventListener("pointerdown",je,!0),i.removeEventListener("keydown",we,!0),i.removeEventListener("scroll",ve,!0),i.removeEventListener("resize",ve),u.parentNode&&u.parentNode.removeChild(u))}}const fc=new WeakMap;function Fg(s){let n=fc.get(s);n||(n={count:0,release:Og(s)},fc.set(s,n)),n.count+=1;let r=!1;return()=>{if(r)return;r=!0;const i=fc.get(s);i&&(i.count-=1,i.count<=0&&(i.release(),fc.delete(s)))}}function Ud(){f.useEffect(()=>{if(!(typeof document>"u"))return Fg(document)},[])}const Zu=1;function Ya(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}const qg=["granted","denied","structurally_unavailable","trust_gated"],Bg=["attachable","requires_review","blocked"],Ug=["default","operator","structural"],Wg=["grant","deny","clear"],Hg=new Set(["__proto__","constructor","prototype"]);function Vg(s,n){if(!Ya(s))return{ok:!1,reason:`${n}: cell is not an object`};const r=String(s.availability||"");if(!qg.includes(r))return{ok:!1,reason:`${n}: unknown availability "${r}"`};const i=String(s.provenance||"");if(!Ug.includes(i))return{ok:!1,reason:`${n}: unknown provenance "${i}"`};let l;if(r==="trust_gated"){const u=String(s.trust_state||"");if(!Bg.includes(u))return{ok:!1,reason:`${n}: trust_gated cell without a valid trust_state ("${u}")`};l=u}for(const u of["assigned","resolved_value","executable"]){const m=s[u];if(m!==void 0&&typeof m!="boolean")return{ok:!1,reason:`${n}: "${u}" is present but not a boolean`}}return{ok:!0,cell:{assigned:s.assigned===!0,resolved_value:s.resolved_value===!0,provenance:i,availability:r,executable:s.executable!==!1,reason:typeof s.reason=="string"?s.reason:void 0,trust_state:l}}}function tp(s){if(!Ya(s))return{ok:!1,reason:"payload is not an object"};const n=s.schema_version;if(typeof n!="number"||!Number.isFinite(n))return{ok:!1,reason:"payload has no numeric schema_version"};if(Math.floor(n)!==Zu)return{ok:!1,reason:`unsupported schema_version ${n} (this build understands ${Zu}); refusing to render grant state from an unknown schema`};if(!Array.isArray(s.phases)||s.phases.length===0)return{ok:!1,reason:"payload has no phases"};if(!Array.isArray(s.sections))return{ok:!1,reason:"payload has no sections"};const r=[],i=new Set;for(const m of s.phases){if(!Ya(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"phase without a string id"};const d=m.id.trim();if(Hg.has(d))return{ok:!1,reason:`reserved phase id "${d}"`};if(i.has(d))return{ok:!1,reason:`duplicate phase id "${d}"`};i.add(d),r.push({id:d,label:typeof m.label=="string"?m.label:void 0,hint:typeof m.hint=="string"?m.hint:void 0})}const l=[],u=new Set;for(const m of s.sections){if(!Ya(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"section without a string id"};const d=m.id.trim();if(u.has(d))return{ok:!1,reason:`duplicate section id "${d}"`};if(u.add(d),!Array.isArray(m.items))return{ok:!1,reason:`section "${d}" has no items array`};const h=[],x=new Set;for(const v of m.items){if(!Ya(v)||typeof v.id!="string"||!v.id.trim())return{ok:!1,reason:`section "${d}": item without a string id`};const g=v.id.trim();if(x.has(g))return{ok:!1,reason:`section "${d}": duplicate item id "${g}"`};if(x.add(g),v.cells!==void 0&&!Ya(v.cells))return{ok:!1,reason:`section "${d}" item "${g}": cells is not an object`};const w=Object.create(null),L=Ya(v.cells)?v.cells:{};for(const[A,$]of Object.entries(L)){if(!i.has(A))return{ok:!1,reason:`section "${d}" item "${g}": cell for undeclared phase "${A}"`};const T=Vg($,`section "${d}" item "${g}" phase "${A}"`);if(!T.ok)return T;w[A]=T.cell}h.push({id:g,label:typeof v.label=="string"?v.label:void 0,description:typeof v.description=="string"?v.description:void 0,cells:w})}l.push({id:d,label:typeof m.label=="string"?m.label:void 0,items:h})}return{ok:!0,payload:{schema_version:Zu,phases:r,sections:l}}}function Gg(s,n,r,i){for(const l of s)if(l.section===n&&l.item===r&&l.phase===i)return l.op;return null}function Wd(s,n,r,i,l){const u=s.sections.find(A=>A.id===r),m=u==null?void 0:u.items.find(A=>A.id===i),d=m&&m.cells[l]||null,h=Gg(n,r,i,l);if(!d)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 x=d.availability==="structurally_unavailable"||d.availability==="trust_gated"&&d.trust_state==="blocked";let v=d.resolved_value;h==="grant"?v=!0:h==="deny"?v=!1:h==="clear"&&(v=d.provenance==="operator"?null:d.resolved_value);const g=d.availability==="trust_gated"&&d.trust_state==="requires_review",w=x?!1:v;let L;return x?L={kind:"blocked",blocked_kind:d.availability==="trust_gated"?"trust":"structural"}:g&&w!==!0?L={kind:"approval"}:L={kind:"tristate",options:["grant","clear","deny"],active_op:h!==null?h:d.assigned?d.resolved_value?"grant":"deny":"clear"},{cell:d,pending:h,effective_value:w,interactive:!x,approval_required:g,standing_config:!x&&d.executable===!1,reason:d.reason||(x?d.availability:null),control:L}}function Kg(s,n,r){const i=Wd(s,n,r.section,r.item,r.phase);if(!i.cell||!i.interactive)return n;const l=n.filter(d=>!(d.section===r.section&&d.item===r.item&&d.phase===r.phase)),u=i.cell;return r.op==="clear"?u.assigned?[...l,r]:l:u.assigned&&u.provenance==="operator"&&u.resolved_value===(r.op==="grant")?l:[...l,r]}function Jg(s,n){const r=new Set,i=[];for(const l of n){if(!Ya(l)||!Wg.includes(l.op))continue;const u=`${l.section}\0${l.item}\0${l.phase}`;if(r.has(u))continue;r.add(u);const m=Wd(s,[],l.section,l.item,l.phase);!m.cell||!m.interactive||i.push(l)}return i}function Qg(s){return s==="grant"?"Grant":s==="deny"?"Deny":"Default"}function Yg(s){const{view:n,disabled:r}=s,i=n.control;if(i.kind==="absent")return e.jsx("div",{className:"af-matrix__cell is-absent",title:n.reason||void 0,children:e.jsx("span",{className:"af-matrix__cell-mark",children:"—"})});if(i.kind==="blocked")return e.jsxs("div",{className:`af-matrix__cell is-unavailable is-${i.blocked_kind}`,children:[e.jsx("span",{className:"af-matrix__cell-mark",children:"✕"}),e.jsx("span",{className:"af-matrix__cell-note",children:i.blocked_kind==="trust"?"blocked":"structural"}),n.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:n.reason}):null]});if(i.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:()=>s.onAct("grant"),"aria-label":`Approve and enable: ${s.cellLabel}`,children:"Approve & enable"}),n.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:n.reason}):null]});const l=n.cell,u=n.effective_value===null?"server default (unknown until saved)":n.effective_value?"on":"off";return e.jsxs("div",{className:`af-matrix__cell ${n.effective_value===null?"is-indeterminate":n.effective_value?"is-on":"is-off"} ${n.pending?"is-pending":""}`.trim(),title:n.reason||void 0,children:[e.jsx("div",{className:"af-matrix__tristate",role:"group","aria-label":s.cellLabel,children:i.options.map(m=>e.jsx("button",{type:"button","aria-pressed":i.active_op===m,className:`af-matrix__tri-btn is-${m} ${i.active_op===m?"is-active":""}`.trim(),disabled:r,onClick:()=>s.onAct(m),children:Qg(m)},m))}),e.jsxs("div",{className:"af-matrix__cell-meta",children:[e.jsx("span",{className:`af-matrix__prov is-${l.provenance}`,children:n.pending?"pending":l.provenance}),e.jsx("span",{className:"af-matrix__value-mark",children:u}),n.standing_config?e.jsx("span",{className:"af-matrix__standing",title:n.reason||"grant is stored; no executor consumes it yet",children:"standing config"}):null]})]})}function Xg(s){const n=s.disabled===!0,r=f.useMemo(()=>tp(s.payload),[s.payload]),i=f.useMemo(()=>r.ok?Jg(r.payload,s.patches):s.patches,[r,s.patches]);if(!r.ok)return e.jsxs("div",{className:`af-matrix af-matrix--refused ${s.className||""}`.trim(),children:[e.jsx("div",{className:"af-matrix__title",children:s.title||"Phase capabilities"}),e.jsxs("div",{className:"af-matrix__refusal",children:["Cannot render capability state: ",r.reason]})]});const l=r.payload,u=(m,d,h,x)=>{if(n)return;const v=Kg(l,i,{section:m,item:d,phase:h,op:x});s.onPatchesChange(v)};return e.jsxs("div",{className:`af-matrix ${s.className||""}`.trim(),children:[e.jsxs("div",{className:"af-matrix__header",children:[e.jsx("div",{className:"af-matrix__title",children:s.title||"Phase capabilities"}),s.subtitle?e.jsx("div",{className:"af-matrix__subtitle",children:s.subtitle}):null,i.length>0?e.jsxs("div",{className:"af-matrix__pending-note",children:[i.length," unsaved change",i.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"}),l.phases.map(m=>e.jsxs("th",{className:"af-matrix__phase",title:m.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:m.label||m.id}),m.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:m.hint}):null]},m.id))]})}),l.sections.map(m=>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:l.phases.length+1,children:m.label||m.id})}),m.items.map(d=>e.jsxs("tr",{className:"af-matrix__item-row",children:[e.jsx("th",{className:"af-matrix__item",title:d.description||void 0,children:e.jsx("span",{className:"af-matrix__item-name",children:d.label||d.id})}),l.phases.map(h=>{const x=Wd(l,i,m.id,d.id,h.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(Yg,{view:x,cellLabel:`${d.label||d.id} — ${h.label||h.id}`,disabled:n,onAct:v=>u(m.id,d.id,h.id,v)})},h.id)})]},d.id)),m.items.length===0?e.jsx("tr",{children:e.jsx("td",{className:"af-matrix__empty",colSpan:l.phases.length+1,children:"No entries in this section."})}):null]},m.id))]})})]})}function np(s){return!!(s&&s.ok===!0&&s.has_session===!0)}function Zg(s){const n=s||{},r=n.connectionPath||Ri,i=n.variant||"dismissable",l=f.useRef(n.onStatusChange);l.current=n.onStatusChange;const u=f.useRef(i);u.current=i;const m=f.useRef(!!n.autoOpenMidSession);m.current=!!n.autoOpenMidSession;const[d,h]=f.useState(null),[x,v]=f.useState("loading"),[g,w]=f.useState(!1),L=f.useRef(!1),A=f.useRef(!1),$=f.useRef("loading"),T=f.useRef("none"),B=f.useRef(!1),O=f.useRef(0),M=f.useCallback(X=>{var U;O.current+=1,h(X),(U=l.current)==null||U.call(l,X);const Z=np(X);if(Z)v("connected"),$.current="connected",L.current=!1,T.current="none",A.current||w(!1);else if(X!==null){const Y=$.current;v("disconnected"),$.current="disconnected",Y!=="disconnected"&&(T.current=B.current?"signout":Y==="connected"?"mid":"boot");const I=u.current==="blocking"||T.current!=="mid"||m.current;!L.current&&I&&w(!0)}X!==null&&(A.current=Z)},[]),P=f.useCallback(async()=>{const X=O.current;try{const Z=await Sd(r);if(O.current!==X)return;M(Z)}catch{if(O.current!==X)return;M(null)}},[r,M]),[E,Q]=f.useState(!1),[oe,G]=f.useState(null),Ne=f.useCallback(async()=>{Q(!0),G(null),O.current+=1;let X=null;try{await ap(r)}catch(Z){X=String((Z==null?void 0:Z.message)||Z||"Sign-out request failed")}B.current=!0;try{await P()}finally{B.current=!1}return G(X),Q(!1),X===null&&$.current!=="connected"},[r,P]),je=f.useRef(!1);f.useEffect(()=>{je.current||(je.current=!0,P())},[P]);const we=f.useCallback(()=>{w(!0)},[]),ve=f.useCallback(()=>{const X=$.current;i==="blocking"&&X==="disconnected"||(X==="disconnected"&&(L.current=!0),w(!1))},[i]),H=f.useMemo(()=>({isOpen:g,onClose:ve,blocking:i==="blocking"&&x!=="connected",appName:n.appName,connectionPath:r,defaultGatewayUrl:n.defaultGatewayUrl,initialStatus:d,onStatusChange:M}),[g,ve,i,x,n.appName,r,n.defaultGatewayUrl,d,M]);return{status:d,phase:x,connected:x==="connected",modalOpen:g,signingOut:E,signOutError:oe,openModal:we,refresh:P,signOut:Ne,modalProps:H}}const ey="default";function Xa(s){return typeof s=="string"?s.trim():""}function Vf(s){return Array.isArray(s)?s.filter(n=>typeof n=="string"):void 0}function ty(s){var x;if(!s||!np(s))return null;const n=(x=s.gateway)==null?void 0:x.principal;if(!n||typeof n!="object")return null;const r=Xa(n.user_id);if(!r)return null;const i={userId:r},l=Xa(n.tenant_id);l&&(i.tenantId=l);const u=Xa(n.runtime_id);u&&(i.runtimeId=u);const m=Vf(n.roles);m&&(i.roles=m);const d=Vf(n.scopes);d&&(i.scopes=d);const h=Xa(n.source);return h&&(i.source=h),typeof n.admin=="boolean"&&(i.admin=n.admin),i}function sp(s){const n=Xa(s.displayName)||Xa(s.userId),r=Xa(s.tenantId);return r&&r!==ey?`${r}/${n}`:n}function Hd(s){const n=Xa(s);if(!n)return"";try{return new URL(n).host||n}catch{return n}}async function Sd(s=Ri){const n=await fetch(s),r=await n.json().catch(()=>null);if(!n.ok){const i=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${n.status}`;throw new Error(i)}return r}async function ny(s,n=Ri){const r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),i=await r.json().catch(()=>null);if(!r.ok){const l=i&&typeof i=="object"&&i.detail?String(i.detail):`HTTP ${r.status}`;throw new Error(l)}return i}async function ap(s=Ri){const n=await fetch(s,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({})),i=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${n.status}`;throw new Error(i)}}function ed(s){let n=String(s||"").trim();for(let r=0;r<2&&n;r+=1){try{const u=JSON.parse(n);if(typeof u=="string"&&u!==n){n=u.trim();continue}}catch{}const i=n[0],l=n[n.length-1];if(i==='"'&&l==='"'||i==="'"&&l==="'"){n=n.slice(1,-1).trim();continue}break}return n.replace(/\/+$/,"")}function sy(s){var d,h;if(!s)return{label:"Signed out",tone:"warn"};if(!s.has_session)return{label:"Signed out",tone:"warn"};const n=s.gateway||{},r=(d=n.principal)==null?void 0:d.user_id,i=(h=n.principal)==null?void 0:h.runtime_id;if(n.ok&&r)return{label:`Signed in as ${r}${i?` · runtime ${i}`:""}`,tone:"ok"};if(n.ok)return{label:"Signed in",tone:"ok"};const l=typeof s.gateway_status=="number"?s.gateway_status:null,u=Hd(s.gateway_url);if(l===0)return{label:`Gateway${u?` at ${u}`:""} did not answer — is it running?`,tone:"err"};if(l===502||l===503||l===504)return{label:`Gateway unavailable (HTTP ${l}) — try again shortly`,tone:"err"};if(l!==null&&l>=500)return{label:`Gateway error (HTTP ${l}) — try again shortly`,tone:"err"};if(l!==null&&l>=400&&l!==401&&l!==403)return{label:`Gateway answered HTTP ${l} — check the gateway URL`,tone:"err"};const m=n.error||n.detail;return typeof m=="string"&&m.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function ay(s){const n=s.connectionPath||Ri,[r,i]=f.useState(!1),[l,u]=f.useState(!1),[m,d]=f.useState(null),[h,x]=f.useState(!1);f.useEffect(()=>{s.isOpen||x(!1)},[s.isOpen]);const[v,g]=f.useState(s.defaultGatewayUrl||"http://127.0.0.1:8080"),[w,L]=f.useState("admin"),[A,$]=f.useState(""),[T,B]=f.useState(!1),[O,M]=f.useState(!0),[P,E]=f.useState(""),[Q,oe]=f.useState(""),G=f.useMemo(()=>sy(m),[m]),Ne=H=>{var X;d(H),(X=s.onStatusChange)==null||X.call(s,H)},je=f.useRef(!1);if(f.useEffect(()=>{var X;if(!s.isOpen)return;const H=!je.current;if(je.current=!0,H&&s.initialStatus!==void 0&&s.initialStatus!==null){const Z=s.initialStatus;Ne(Z),typeof Z.gateway_url=="string"&&Z.gateway_url.trim()&&g(ed(Z.gateway_url));const U=(X=Z.gateway)==null?void 0:X.principal;U!=null&&U.user_id&&L(U.user_id);return}i(!0),E(""),Sd(n).then(Z=>{var Y;Ne(Z),typeof Z.gateway_url=="string"&&Z.gateway_url.trim()&&g(ed(Z.gateway_url));const U=(Y=Z.gateway)==null?void 0:Y.principal;U!=null&&U.user_id&&L(U.user_id)}).catch(Z=>E(`Failed to load connection status: ${String((Z==null?void 0:Z.message)||Z)}`)).finally(()=>i(!1))},[s.isOpen]),f.useEffect(()=>{if(!s.isOpen)return;const H=X=>{X.key==="Escape"&&!X.defaultPrevented&&!s.blocking&&(X.preventDefault(),s.onClose())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[s.isOpen,s.blocking,s.onClose]),!s.isOpen||h)return null;const we=async()=>{u(!0),E(""),oe("");try{const H=ed(v);g(H);const X=await ny({gateway_url:H,gateway_user_id:w,gateway_token:A,persist:O},n);Ne(X),$(""),x(!0),s.onClose()}catch(H){E(String((H==null?void 0:H.message)||H))}finally{u(!1)}},ve=async()=>{u(!0),E(""),oe("");try{await ap(n),$("");const H=await Sd(n).catch(()=>null);Ne(H),oe("Signed out. This browser no longer holds a gateway session.")}catch(H){E(String((H==null?void 0:H.message)||H))}finally{u(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:H=>{!s.blocking&&H.target===H.currentTarget&&s.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Cg,{kicker:`${s.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:G.label,statusTone:G.tone,showGatewayUrl:!0,gatewayUrl:v,onGatewayUrlChange:H=>g(H),userId:w,onUserIdChange:L,token:A,tokenPlaceholder:m!=null&&m.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:T,onTokenChange:$,onShowTokenChange:B,remember:O,rememberLabel:"Keep this browser signed in",onRememberChange:M,loading:r,submitting:l,submittingLabel:"Signing in...",showClose:!s.blocking,onClose:s.onClose,showSignOut:!s.blocking&&!!(m!=null&&m.has_session),onSignOut:ve,error:P,message:Q,onSubmit:we})})})}function ry(){return globalThis.crypto}function iy(s){if(s.length<16)throw new Error("uuidV4FromBytes: needs 16 bytes");const n=Array.from(s.subarray(0,16));n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=n.map(i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function Yo(){const s=ry();if(s&&typeof s.randomUUID=="function")try{return s.randomUUID()}catch{}if(s&&typeof s.getRandomValues=="function")return iy(s.getRandomValues(new Uint8Array(16)));throw new Error("randomId: Web Crypto (crypto.getRandomValues) is unavailable")}function Vd(s){return globalThis.isSecureContext!==!1?null:`This page is loaded over http, so ${s} is unavailable — open it over https (for example through tailscale serve; the gateway console's Network page explains how) or on the gateway's own computer.`}const td={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},oy=/^var\(--[a-z0-9-]+\)$/i;function ly(s,n){const r=s||"neutral";if(r==="custom"){const i=String(n||"").trim();return oy.test(i)?i:td.neutral}return td[r]||td.neutral}function cy(s,n,r){return[s,`${s}--${n.tone||"neutral"}`,n.size==="sm"?`${s}--sm`:"",r||"",n.className||""].filter(Boolean).join(" ")}function uy(s){return{"--af-chip-hue":ly(s.tone,s.hue)}}function Vn(s){return e.jsxs("span",{className:cy("af-chip",s,s.onRemove?"af-chip--removable":""),style:uy(s),title:s.title,children:[e.jsx("span",{className:"af-chip__label",children:s.children}),s.onRemove?e.jsx("button",{type:"button",className:"af-chip__remove","aria-label":s.removeLabel||"Remove",onClick:n=>{var r;n.stopPropagation(),(r=s.onRemove)==null||r.call(s)},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]})}const dy='button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function my(s,n=!1){if(!s)return null;const r=s.querySelector(".af-drawer__body")||s,i=r.querySelector("[data-autofocus]");return i||(n?s:r.querySelector("textarea:not(:disabled)")||r.querySelector(dy)||s)}function fy(){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}function Gf(s){return s==="auto"?"var(--af-topbar-h, 0px)":typeof s=="number"&&Number.isFinite(s)?s:0}function Nd(s){const n=s.closeOnEscape!==!1,r=f.useRef(null);f.useEffect(()=>{if(!s.open||!n)return;const m=d=>{d.key!=="Escape"||d.defaultPrevented||(d.preventDefault(),s.onClose())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s.open,n,s.onClose]);const i=f.useRef(null),l=s.manageFocus!==!1,u=f.useRef(!1);return f.useEffect(()=>{var x;if(!u.current){u.current=!0;return}if(!l||typeof document>"u")return;const m=r.current;if(s.open){if(i.current=document.activeElement,m&&m.contains(document.activeElement))return;const v=window.setTimeout(()=>{var g;(g=my(m,fy()))==null||g.focus({preventScroll:!0})},0);return()=>window.clearTimeout(v)}const d=i.current;i.current=null;const h=document.activeElement;d&&d.isConnected&&(!h||h===document.body||m&&m.contains(h))&&((x=d.focus)==null||x.call(d,{preventScroll:!0}))},[s.open,l]),f.useEffect(()=>{const m=r.current;m&&(s.open?m.removeAttribute("inert"):m.setAttribute("inert",""))},[s.open]),e.jsxs(e.Fragment,{children:[s.backdrop&&s.open?e.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:s.onClose,style:{top:Gf(s.topOffset)}}):null,e.jsxs("div",{ref:r,className:`af-drawer${s.side==="left"?" af-drawer--left":""}${s.topOffset?" af-drawer--offset":""}${s.open?" af-drawer--open":""}${s.className?` ${s.className}`:""}`,style:{width:s.width||420,top:Gf(s.topOffset),display:s.open?void 0:"none"},role:"complementary","aria-label":s.label,"aria-hidden":s.open?void 0:!0,tabIndex:-1,children:[s.title!==void 0?e.jsxs("div",{className:"af-drawer__header",children:[e.jsx("div",{className:"af-drawer__title",children:s.title}),e.jsxs("div",{className:"af-drawer__header-actions",children:[s.headerActions,e.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:s.onClose,children:"×"})]})]}):null,e.jsx("div",{className:"af-drawer__body",children:s.children})]})]})}function hy(s,n,r,i=4,l=8){let u=s.bottom+i,m=!1;if(u+n.height>r.height-l){const x=s.top-i-n.height;(x>=l||s.top>r.height-s.bottom)&&(u=x,m=!0)}let d=s.left,h=!1;return d+n.width>r.width-l&&(d=s.right-n.width,h=!0),d=Math.max(l,Math.min(d,r.width-l-n.width)),u=Math.max(l,u),{top:Math.round(u),left:Math.round(d),up:m,leftward:h}}let Kf=0;function py(s,n,r={}){if(!s||!n)throw new Error("bindAfMenu: button and menu are required");const i=r.document||s.ownerDocument,l=i.defaultView||globalThis;n.getAttribute("id")||(Kf+=1,n.setAttribute("id",`af-menu-${Kf}`)),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-controls",String(n.getAttribute("id"))),n.setAttribute("role","menu"),n.hidden=!0;const u=()=>{const M=Array.from(n.querySelectorAll(".af-menu__item")),P=M.filter(E=>!E.hidden&&!E.hasAttribute("disabled"));for(const E of M)E.setAttribute("role","menuitem"),E.setAttribute("tabindex","-1");return P};u();let m=!1;const d=()=>{if(!m)return;const M=s.getBoundingClientRect(),P=n.getBoundingClientRect(),E=hy(M,{width:P.width,height:P.height},{width:l.innerWidth,height:l.innerHeight});n.style.top=`${E.top}px`,n.style.left=`${E.left}px`,n.setAttribute("data-placement",`${E.up?"top":"bottom"}-${E.leftward?"end":"start"}`)},h=M=>{const P=u();if(!P.length)return;const E=(M%P.length+P.length)%P.length;P[E].focus({preventScroll:!0})},x=M=>{m||(m=!0,n.hidden=!1,s.setAttribute("aria-expanded","true"),d(),h(M),i.addEventListener("pointerdown",g,!0),i.addEventListener("mousedown",g,!0),l.addEventListener("scroll",d,!0),l.addEventListener("resize",w),l.addEventListener("keydown",$,!0),r.onOpen&&r.onOpen())},v=M=>{m&&(m=!1,n.hidden=!0,s.setAttribute("aria-expanded","false"),i.removeEventListener("pointerdown",g,!0),i.removeEventListener("mousedown",g,!0),l.removeEventListener("scroll",d,!0),l.removeEventListener("resize",w),l.removeEventListener("keydown",$,!0),M&&s.focus({preventScroll:!0}),r.onClose&&r.onClose())};function g(M){const P=M.target;P&&(n.contains(P)||s.contains(P))||v(!1)}function w(){v(!1)}const L=M=>{M.preventDefault(),m?v(!0):x(0)},A=M=>{M.key==="ArrowDown"||(M.key==="Enter"||M.key===" ")&&!m?(M.preventDefault(),x(0)):M.key==="ArrowUp"&&(M.preventDefault(),x(-1))},$=M=>{if(!m||M.key!=="Escape"&&M.key!=="Esc")return;const P=M.target;P&&P!==s&&!n.contains(P)&&P!==i.body||(M.preventDefault(),v(!0))},T=M=>{if(!m)return;const E=u().indexOf(i.activeElement);M.key==="ArrowDown"?(M.preventDefault(),h(E+1)):M.key==="ArrowUp"?(M.preventDefault(),h(E<0?-1:E-1)):M.key==="Home"?(M.preventDefault(),h(0)):M.key==="End"?(M.preventDefault(),h(-1)):M.key==="Tab"&&v(!1)},B=M=>{const P=M.target,E=P&&typeof P.closest=="function"?P.closest(".af-menu__item"):null;if(!E||!n.contains(E))return;const Q=i.activeElement,oe=!Q||Q===i.body||n.contains(Q);v(oe)};s.addEventListener("click",L),s.addEventListener("keydown",A),n.addEventListener("keydown",T),n.addEventListener("click",B);let O=!1;return()=>{O||(O=!0,v(!1),s.removeEventListener("click",L),s.removeEventListener("keydown",A),n.removeEventListener("keydown",T),n.removeEventListener("click",B))}}function _y(s){const n=f.useRef(null),r=f.useRef(null),i=s.items.filter(u=>u&&!u.hidden),l=i.length>0;return f.useEffect(()=>{if(!(!l||!n.current||!r.current))return py(n.current,r.current)},[l]),l?e.jsxs("div",{className:`af-menu${s.className?` ${s.className}`:""}`,children:[e.jsx("button",{type:"button",ref:n,className:`af-menu__button${s.buttonClassName?` ${s.buttonClassName}`:""}`,"aria-label":s.label,title:s.title,"data-af-tip":s.tip,"aria-haspopup":"menu","aria-expanded":"false",children:s.buttonContent!==void 0?s.buttonContent:e.jsx("span",{"aria-hidden":"true",children:"⋯"})}),e.jsxs("div",{className:"af-menu__list",role:"menu",ref:r,hidden:!0,children:[s.header!==void 0&&s.header!==null?e.jsx("div",{className:"af-menu__header",role:"presentation",children:s.header}):null,i.map(u=>e.jsx("button",{type:"button",role:"menuitem",tabIndex:-1,"data-menu-id":u.id,className:`af-menu__item${u.danger?" af-menu__item--danger":""}`,onClick:()=>u.onSelect(),children:u.label},u.id))]})]}):null}const gy={name:"AbstractFramework",website:"https://abstractframework.ai",github_org:"https://github.com/lpalbou",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",license:"MIT",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},yy={abstractframework:{name:"AbstractFramework",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractFramework",docs:"https://github.com/lpalbou/AbstractFramework/tree/main/docs",issues:"https://github.com/lpalbou/AbstractFramework/issues",feedback:"https://github.com/lpalbou/AbstractFramework/issues/new?labels=feedback"},abstractgateway:{name:"AbstractGateway",website:"https://abstractframework.ai/gateway",repo:"https://github.com/lpalbou/AbstractGateway",docs:"https://www.lpalbou.info/AbstractGateway/",issues:"https://github.com/lpalbou/AbstractGateway/issues",feedback:"https://github.com/lpalbou/AbstractGateway/issues/new?labels=feedback"},abstractcode:{name:"AbstractCode",website:"https://abstractframework.ai/code",repo:"https://github.com/lpalbou/AbstractCode",docs:"https://github.com/lpalbou/AbstractCode/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCode/issues",feedback:"https://github.com/lpalbou/AbstractCode/issues/new?labels=feedback"},abstractassistant:{name:"AbstractAssistant",website:"https://abstractframework.ai/assistant",repo:"https://github.com/lpalbou/AbstractAssistant",docs:"https://github.com/lpalbou/AbstractAssistant/blob/main/docs/README.md",issues:"https://github.com/lpalbou/AbstractAssistant/issues",feedback:"https://github.com/lpalbou/AbstractAssistant/issues/new?labels=feedback"},abstractflow:{name:"AbstractFlow",website:"https://abstractframework.ai/flow",repo:"https://github.com/lpalbou/AbstractFlow",docs:"https://github.com/lpalbou/AbstractFlow#readme",issues:"https://github.com/lpalbou/AbstractFlow/issues",feedback:"https://github.com/lpalbou/AbstractFlow/issues/new?labels=feedback"},abstractcontinuum:{name:"AbstractContinuum",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractContinuum",docs:"https://github.com/lpalbou/AbstractContinuum/tree/main/docs",issues:"https://github.com/lpalbou/AbstractContinuum/issues",feedback:"https://github.com/lpalbou/AbstractContinuum/issues/new?labels=feedback"},abstractentity:{name:"AbstractEntity",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractEntity",docs:"https://github.com/lpalbou/AbstractEntity/tree/main/docs",issues:"https://github.com/lpalbou/AbstractEntity/issues",feedback:"https://github.com/lpalbou/AbstractEntity/issues/new?labels=feedback"},abstractobserver:{name:"AbstractObserver",website:"https://abstractframework.ai/observer",repo:"https://github.com/lpalbou/AbstractObserver",docs:"https://github.com/lpalbou/AbstractObserver#readme",issues:"https://github.com/lpalbou/AbstractObserver/issues",feedback:"https://github.com/lpalbou/AbstractObserver/issues/new?labels=feedback"},abstractcore:{name:"AbstractCore",website:"https://www.abstractcore.ai",repo:"https://github.com/lpalbou/AbstractCore",docs:"https://github.com/lpalbou/AbstractCore/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCore/issues",feedback:"https://github.com/lpalbou/AbstractCore/issues/new?labels=feedback"},abstractuic:{name:"AbstractUIC",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractUIC",docs:"https://github.com/lpalbou/AbstractUIC/tree/main/docs",issues:"https://github.com/lpalbou/AbstractUIC/issues",feedback:"https://github.com/lpalbou/AbstractUIC/issues/new?labels=feedback"}},vy={framework:gy,apps:yy},Tc=vy;function rp(){return{...Tc.framework}}function xy(){return Object.keys(Tc.apps).sort()}function by(s,n){const r=Object.prototype.hasOwnProperty.call(Tc.apps,s)?Tc.apps[s]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${s}" (known: ${xy().join(", ")})`);return{id:s,name:r.name,version:n,website:r.website,repo:r.repo,docs:r.docs,issues:r.issues,feedback:r.feedback}}async function wy(s,n){try{const r=await s(Cs("about"),{method:"GET",headers:{Accept:"application/json"},signal:n});if(!r.ok)return Xo(null,`HTTP ${r.status}`);const i=await r.json().catch(()=>null);return Xo(i)}catch(r){return Xo(null,String((r==null?void 0:r.message)||r||"request failed"))}}const jy={framework:null,frameworkNote:"checking…",gateway:null,gatewayNote:"checking…"};function $i(s){return typeof s=="string"?s.trim():""}function Xo(s,n){if(n!=null)return{framework:null,gateway:null,gatewayNote:`unavailable (${String(n).trim()||"unknown error"})`};const r=s&&typeof s=="object"&&!Array.isArray(s)?s:{},i=$i(r.abstractgateway),l=$i(r.abstractframework);return{framework:l||null,gateway:i||null,...i&&!l?{frameworkNote:"not installed on the gateway host"}:{},...i?{}:{gatewayNote:"unavailable (the gateway did not report its version)"}}}function ky(s){const n=rp();return[{id:"website",label:"Website",href:s.website,title:s.website},{id:"source",label:"Source",href:s.repo,title:s.repo},{id:"docs",label:"Docs",href:s.docs,title:s.docs},{id:"issues",label:"Issues",href:s.issues,title:s.issues},{id:"feedback",label:"Feedback",href:s.feedback,title:s.feedback},{id:"contact",label:"Contact",href:`mailto:${n.contact_email}`,title:n.contact_email}]}function Sy(s){const n=s||{},r=$i(n.framework),i=$i(n.gateway);return[["AbstractFramework",r||$i(n.frameworkNote)||"not reported"],["AbstractGateway",i||$i(n.gatewayNote)||"not connected"]]}const Ny='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Cy(s,n,r){if(s.key!=="Tab"||!n)return;const i=Array.from(n.querySelectorAll(Ny));if(i.length===0){s.preventDefault();return}const l=i[0],u=i[i.length-1],m=!!r&&n.contains(r);s.shiftKey?(r===l||!m)&&(s.preventDefault(),u.focus()):(r===u||!m)&&(s.preventDefault(),l.focus())}function $y(s){const n=rp();return e.jsxs("div",{className:`af-about-card${s.className?` ${s.className}`:""}`,"data-app":s.identity.id,children:[e.jsxs("div",{className:"af-about-card__head",children:[e.jsxs("h2",{className:"af-about-card__name",id:s.titleId,children:[s.identity.name," ",e.jsx("span",{className:"af-about-card__version",children:s.identity.version})]}),s.action]}),e.jsx("dl",{className:"af-about-card__versions",children:Sy(s.versions).map(([r,i])=>e.jsxs("div",{className:"af-about-card__fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:i})]},r))}),e.jsx("nav",{className:"af-about-card__links","aria-label":`${s.identity.name} links`,children:ky(s.identity).map(r=>r.href.startsWith("mailto:")?e.jsx("a",{className:"af-about-card__link","data-link":r.id,href:r.href,title:r.title,children:r.label},r.id):e.jsx("a",{className:"af-about-card__link","data-link":r.id,href:r.href,title:r.title,target:"_blank",rel:"noopener noreferrer",children:r.label},r.id))}),s.extra!==void 0&&s.extra!==null?e.jsx("div",{className:"af-about-card__extra",children:s.extra}):null,e.jsx("p",{className:"af-about-card__legal",children:n.copyright})]})}function Ey(s){Ud();const n=f.useRef(null),r=f.useRef(null),i=f.useId(),l=f.useRef(s.onClose);return l.current=s.onClose,f.useEffect(()=>{var d;if(!s.open)return;const u=document.activeElement;(d=n.current)==null||d.focus();const m=h=>{if(!h.defaultPrevented){if(h.key==="Escape"){h.preventDefault(),l.current();return}Cy(h,r.current,document.activeElement)}};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m),u&&typeof u.focus=="function"&&u.focus()}},[s.open]),s.open?e.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:s.onClose,role:"presentation",children:e.jsx("div",{ref:r,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":i,onClick:u=>u.stopPropagation(),children:e.jsx($y,{identity:s.identity,versions:s.versions,extra:s.extra,titleId:i,action:e.jsx("button",{ref:n,type:"button",className:"af-about-card__close","data-action":"close-about",onClick:s.onClose,"aria-label":"Close","data-af-tip":"Close About",children:e.jsx(Ue,{name:"x",size:16})})})})}):null}const Cc={theme:"dark",font_scale:"md",header_density:"standard"};function Ty(s){const n=s&&typeof s=="object"?s:{};return{theme:typeof n.theme=="string"&&n.theme?n.theme:Cc.theme,font_scale:typeof n.font_scale=="string"&&n.font_scale?n.font_scale:Cc.font_scale,header_density:typeof n.header_density=="string"&&n.header_density?n.header_density:Cc.header_density}}function Ay(s){return`af_appearance_${s}_v1`}function Ly(s,n){const r=Ay(s),i=f.useMemo(()=>({...Cc}),[JSON.stringify({})]),[l,u]=f.useState(()=>{let m=i;try{const d=localStorage.getItem(r)??(n!=null&&n.legacyKey?localStorage.getItem(n.legacyKey):null);d&&(m=Ty({...i,...JSON.parse(d)}))}catch{}try{Ff(m.theme),qf({font_scale:m.font_scale,header_density:m.header_density})}catch{}return m});return f.useEffect(()=>{Ff(l.theme),qf({font_scale:l.font_scale,header_density:l.header_density});try{localStorage.setItem(r,JSON.stringify(l))}catch{}},[r,l]),[l,u]}function ip(s){return f.useEffect(()=>{if(!s.open)return;const n=r=>{r.key!=="Escape"||r.defaultPrevented||(r.preventDefault(),s.onClose())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s.open,s.onClose]),s.open?e.jsx("div",{className:"af-appearance-overlay",onClick:s.onClose,role:"presentation",children:e.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":s.title||"Appearance",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",children:s.title||"Appearance"}),e.jsx("div",{className:"af-appearance__note",children:s.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(Eg,{value:s.value.theme,onChange:n=>s.onChange({...s.value,theme:n})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(Tg,{value:s.value.font_scale,onChange:n=>s.onChange({...s.value,font_scale:n})}),e.jsx("label",{className:"af-appearance__label",children:"Header size"}),e.jsx(Ag,{value:s.value.header_density,onChange:n=>s.onChange({...s.value,header_density:n})})]}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{type:"button",className:"af-appearance__close",onClick:s.onClose,children:"Close"})})]})}):null}function My(s,n){return{label:n?"Disconnecting…":s==="connected"?"Disconnect":s==="loading"?"Connecting…":"Connect",title:s==="connected"?"Disconnect from gateway":s==="loading"?"Checking gateway session…":"Connect to gateway"}}function Ry(s){return typeof s.openModal=="function"&&typeof s.signOut=="function"}function Py(s,n){return Ry(s)?{phase:s.phase,signingOut:s.signingOut===!0,connect:s.openModal,disconnect:async()=>{await s.signOut()===!0&&(n==null||n())},status:s.status,signOutError:s.signOutError||null}:{phase:s.phase,signingOut:s.signingOut===!0,connect:s.onConnect,disconnect:async()=>{s.onDisconnect()},status:s.status??null,signOutError:s.signOutError||null}}function zy(s,n){const r=Hd(n);return`Signed in as ${sp(s)}${r?` · gateway ${r}`:""}`}const nd="--af-topbar-h";function Iy(s,n=!0){f.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const r=s.current;if(!r)return;const i=r.closest("[data-af-topbar], header")||r.parentElement||r,l=document.documentElement;let u="";const m=()=>{u=`${Math.max(0,Math.round(i.getBoundingClientRect().bottom))}px`,l.style.setProperty(nd,u)};m();const d=typeof ResizeObserver<"u"?new ResizeObserver(m):null;d==null||d.observe(i);const h={passive:!0,capture:!0};return window.addEventListener("resize",m),window.addEventListener("scroll",m,h),()=>{d==null||d.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("scroll",m,h),u&&l.style.getPropertyValue(nd)===u&&l.style.removeProperty(nd)}},[s,n])}function Dy(s){const n=typeof navigator<"u"?navigator.clipboard:void 0;return!n||typeof n.writeText!="function"?null:()=>{n.writeText(s).catch(()=>{})}}function Oy(s){var P,E;const n=Py(s.connection,s.onSignOut),{phase:r,signingOut:i}=n,[l,u]=f.useState(!1),[m,d]=f.useState(!1),[h,x]=f.useState(void 0),v=f.useRef(null);Ud(),Iy(v,s.publishHeight!==!1);const g=s.about,w=s.appearance,L=!!(w&&"value"in w),A=g&&!g.versions?g.fetch:void 0,$=f.useRef(A);$.current=A,f.useEffect(()=>{const Q=$.current;if(!l||!Q)return;const oe=typeof AbortController<"u"?new AbortController:null;let G=!0;return x(jy),wy(Q,oe==null?void 0:oe.signal).then(Ne=>{G&&x(Ne)}),()=>{G=!1,oe==null||oe.abort()}},[l]);const T=My(r,i),B=s.identity&&r==="connected"?ty(n.status):null,O=()=>void n.disconnect();let M=null;if(B&&s.identity){const Q=sp(B),oe=zy(B,(P=n.status)==null?void 0:P.gateway_url),G=e.jsxs(e.Fragment,{children:[e.jsx(Ue,{name:"user",size:14}),e.jsx("span",{className:"af-topbar__identity-label",children:Q})]});if(s.identity==="badge")M=e.jsx("span",{className:"af-topbar__identity af-topbar__identity--badge","data-af-identity":"badge","data-af-tip":oe,"aria-label":oe,children:G});else{const Ne=Dy(B.userId),je=Hd((E=n.status)==null?void 0:E.gateway_url);M=e.jsx(_y,{label:`Account: ${oe}`,tip:oe,className:"af-topbar__account",buttonClassName:"af-topbar__identity af-topbar__identity--menu",buttonContent:G,header:e.jsxs("span",{className:"af-topbar__account-head","data-af-identity":"menu",children:[e.jsxs("span",{className:"af-topbar__account-who",children:["Signed in as ",Q]}),je?e.jsxs("span",{className:"af-topbar__account-host",children:["Gateway ",je]}):null]}),items:[{id:"copy-user-id",label:"Copy user id",onSelect:Ne||(()=>{}),hidden:!Ne},{id:"disconnect",label:"Disconnect",onSelect:O,danger:!0,hidden:i}]})}}return e.jsxs("div",{ref:v,className:`af-topbar${s.className?` ${s.className}`:""}`,role:"group","aria-label":"App actions",children:[s.extraActions,s.docs?e.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--docs${s.docs.open?" is-active":""}`,"aria-pressed":s.docs.open,"aria-label":s.docs.label||"Docs assistant","data-af-tip":s.docs.label||"Docs assistant",onClick:s.docs.onToggle,children:e.jsx(Ue,{name:"book",size:16})}):null,s.assistant?e.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--assistant${s.assistant.open?" is-active":""}`,"aria-pressed":s.assistant.open,"aria-label":s.assistant.label||"Open assistant","data-af-tip":s.assistant.label||"Assistant",onClick:s.assistant.onToggle,children:e.jsx(Ue,{name:"sparkle",size:16})}):null,w?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--appearance","aria-label":w.label||"Appearance (theme and typography)","data-af-tip":w.label||"Appearance (theme and text size)","aria-haspopup":L?"dialog":void 0,onClick:()=>{"value"in w?d(!0):w.onOpen()},children:e.jsx(Ue,{name:"contrast",size:16})}):null,g?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":g.label||`About ${g.identity.name}`,"data-af-tip":g.label||`About ${g.identity.name}`,"aria-haspopup":"dialog",onClick:()=>{var Q;u(!0),(Q=g.onOpen)==null||Q.call(g)},children:e.jsx(Ue,{name:"info",size:16})}):null,M,n.signOutError?e.jsxs("span",{className:"af-topbar__signout-error",role:"alert","data-af-tip":`Disconnect failed: ${n.signOutError}`,"aria-label":`Disconnect failed: ${n.signOutError}`,children:[e.jsx(Ue,{name:"warning",size:14}),e.jsx("span",{className:"af-topbar__signout-error-label",children:"Disconnect failed"})]}):null,e.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${r}`,onClick:r==="connected"?O:n.connect,disabled:i,title:T.title,"aria-label":T.title,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:T.label})]}),g?e.jsx(Ey,{open:l,onClose:()=>u(!1),identity:g.identity,versions:g.versions||(g.fetch?h:void 0),extra:g.extra}):null,w&&"value"in w?e.jsx(ip,{open:m,onClose:()=>d(!1),value:w.value,onChange:w.onChange,title:w.title,note:w.note}):null]})}const op=()=>{var s;return(s=globalThis.navigator)==null?void 0:s.mediaDevices};function Fy(s){var l;const n=Vd("the microphone");if(n)return n;const r=String((s==null?void 0:s.name)||"");if(r==="NotAllowedError"||r==="SecurityError"||r==="PermissionDeniedError")return"The browser blocked the microphone. Allow it for this site (the icon left of the address), then try again.";if(r==="NotFoundError"||r==="DevicesNotFoundError")return"No microphone was found. Connect one, then try again.";if(r==="OverconstrainedError")return"The chosen microphone is not connected. Pick another one in Settings → Voice.";if(r==="NotReadableError"||r==="TrackStartError")return"Another app is using the microphone. Close it, then try again.";if(!((l=op())!=null&&l.getUserMedia))return"This browser cannot record audio.";const i=String((s==null?void 0:s.message)||s||"").trim();return i?`The microphone did not start: ${i.replace(/\.$/,"")}.`:"The microphone did not start."}async function qy(s){const n=op();if(!(n!=null&&n.getUserMedia))throw Object.assign(new Error("This browser cannot record audio."),{name:"NotSupportedError"});return n.getUserMedia({audio:s?{deviceId:{exact:s}}:!0})}function lp(){const s=globalThis;return s.AudioContext||s.webkitAudioContext||null}function By(){const s=lp();return!!(s&&s.prototype&&typeof s.prototype.createMediaStreamDestination=="function")}function Uy(s,n,r=1){const i=lp();if(!i)return()=>{};const l=new i,u=l.createMediaStreamSource(s),m=l.createAnalyser();m.fftSize=1024,u.connect(m);const d=new Float32Array(m.fftSize);let h=!0;const v=setInterval(()=>{if(!h)return;m.getFloatTimeDomainData(d);let g=0;for(let w=0;w<d.length;w+=1)g+=d[w]*d[w];n(Math.min(1,Math.sqrt(g/d.length)*4*r))},50);return()=>{var g;h=!1,clearInterval(v);try{u.disconnect()}catch{}(g=l.close)==null||g.call(l)}}function Jf(s){const n=Number(s);return s==null||s===""||!Number.isFinite(n)?1:Math.min(1,Math.max(0,n))}function Qf(s){return(s&&typeof s=="object"?s.capture_mode:s)==="toggle"?"toggle":"hold"}async function*Wy(s){var i,l,u;const n=new AbortController,r=()=>n.abort();(i=s.signal)!=null&&i.aborted?r():(l=s.signal)==null||l.addEventListener("abort",r,{once:!0});try{const m=await fetch(s.path,{method:"POST",headers:{"Content-Type":"application/json",...s.csrfToken?{"x-abstract-csrf":s.csrfToken}:{},...s.headers||{}},body:JSON.stringify(s.body),signal:n.signal});if(!m.ok){const v=await m.json().catch(()=>null),g=v&&typeof v=="object"&&v.detail?String(v.detail):`HTTP ${m.status}`;throw new Error(g)}if(!m.body)throw new Error("TTS stream has no body");const d=m.body.getReader(),h=new TextDecoder;let x="";for(;;){const{done:v,value:g}=await d.read();x+=v?h.decode():h.decode(g,{stream:!0}),v&&x.trim()&&(x+=`
42
- `);let w;for(;(w=x.indexOf(`
43
- `))>=0;){const L=x.slice(0,w).trim();if(x=x.slice(w+1),!L)continue;let A=null;try{A=JSON.parse(L)}catch{throw new Error("TTS stream returned invalid JSON.")}if(A&&A.type==="error")throw new Error(String(A.error||"TTS stream error"));const $=A&&typeof A.audio_b64=="string"?A.audio_b64:"";if($){const T=atob($),B=new Uint8Array(T.length);for(let O=0;O<T.length;O+=1)B[O]=T.charCodeAt(O);yield B.buffer}if(A&&(A.type==="done"||A.type==="cancelled"))return}if(v)throw new Error("TTS stream ended before synthesis completed.")}}finally{(u=s.signal)==null||u.removeEventListener("abort",r),n.abort()}}function Ro(s,n){const r=String((n==null?void 0:n.message)||n||"").trim().replace(/\.$/,"");return r?`${s}: ${r}.`:`${s}.`}const Hy=350;function Vy(){var n;if(typeof window>"u")return!1;const s=navigator;return!!((n=s==null?void 0:s.mediaDevices)!=null&&n.getUserMedia)&&typeof window.MediaRecorder=="function"}function Gy(){if(typeof window>"u")return!1;const s=window;return!!(s!=null&&s.AudioContext||s!=null&&s.webkitAudioContext)}function Ky(){const s=window.MediaRecorder,n=i=>{var l;try{return!!((l=s==null?void 0:s.isTypeSupported)!=null&&l.call(s,i))}catch{return!1}},r=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const i of r)if(n(i))return i;return""}async function sd(s,n){var l;const r=n.slice(0),i=(l=s.decodeAudioData)==null?void 0:l.bind(s);if(typeof i!="function")throw new Error("decodeAudioData not available");try{const u=i(r);if(u&&typeof u.then=="function")return await u}catch{}return await new Promise((u,m)=>{try{i(r,u,m)}catch(d){m(d)}})}function Jy(s){const n=new Uint8Array(s);if(n.length<44)return null;const r=u=>String.fromCharCode(n[u],n[u+1],n[u+2],n[u+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const i=new DataView(s);let l=12;for(;l+8<=n.length;){const u=r(l),m=i.getUint32(l+4,!0);if(u==="data")return n.slice(0,l+8);l+=8+m+m%2}return null}function Qy(s,n){const r=new Uint8Array(n),i=new Uint8Array(s.length+r.length);i.set(s,0),i.set(r,s.length);const l=new DataView(i.buffer);return l.setUint32(4,i.length-8,!0),l.setUint32(s.length-4,r.length,!0),i.buffer}const hc=new WeakMap;function Yy(s,n){const r=s;if(!(typeof r.setSinkId!="function"||hc.get(s)===n)){hc.set(s,n);try{Promise.resolve(r.setSinkId(n)).catch(()=>hc.delete(s))}catch{hc.delete(s)}}}function cp(s){const n=f.useRef(s);n.current=s;const r=F=>{var ue,ye;return(ye=(ue=n.current).on_error)==null?void 0:ye.call(ue,F)},i=f.useMemo(()=>Gy()&&(typeof s.tts=="function"||typeof s.tts_stream=="function"),[s.tts,s.tts_stream]),l=f.useMemo(()=>Vy()&&typeof s.transcribe=="function",[s.transcribe]),[u,m]=f.useState({key:"",status:"idle"}),d=f.useRef(u),h=f.useCallback(F=>{d.current=F,m(ue=>ue.key===F.key&&ue.status===F.status?ue:F)},[]),x=f.useRef(""),v=f.useRef(""),g=f.useRef(null),w=f.useRef(null),L=f.useRef(null),A=f.useRef(null),$=f.useRef(0),T=f.useRef(0),B=f.useRef(0),O=f.useRef(null),M=f.useRef([]),P=f.useRef(0),E=f.useRef(!0),Q=f.useRef(!1),oe=()=>{try{const F=globalThis,ue=(F==null?void 0:F.AudioContext)||(F==null?void 0:F.webkitAudioContext);if(!ue)return null;if(!g.current){const ke=new ue,J=ke.createGain();J.gain.value=1,J.connect(ke.destination),g.current=ke,w.current=J}const ye=g.current,xe=w.current;if(!ye||!xe)return null;Yy(ye,n.current.output_device_id||""),xe.gain.value=Jf(n.current.volume)*(n.current.muted?0:1);try{ye.state==="suspended"&&ye.resume()}catch{}return{ctx:ye,gain:xe}}catch{return null}};f.useEffect(()=>{const F=w.current;F&&(F.gain.value=Jf(s.volume)*(s.muted?0:1))},[s.volume,s.muted]);const G=f.useCallback(()=>{const F=L.current;if(L.current=null,!!F){try{F.onended=null}catch{}try{F.stop()}catch{}try{F.disconnect()}catch{}}},[]),Ne=f.useCallback(()=>{var F;G(),B.current+=1,(F=O.current)==null||F.abort(),O.current=null,M.current=[],P.current=0,E.current=!0,Q.current=!1,v.current="",x.current="",A.current=null,$.current=0,T.current=0,h({key:"",status:"idle"})},[G,h]);f.useEffect(()=>()=>{var F,ue;Ne();try{(F=w.current)==null||F.disconnect()}catch{}try{(ue=g.current)==null||ue.close()}catch{}g.current=null,w.current=null,A.current=null},[]);const je=async(F,ue,ye)=>{const xe=B.current,ke=oe();if(!ke)throw new Error("TTS playback is not supported in this browser");const{ctx:J,gain:R}=ke;try{J.state==="suspended"&&await J.resume()}catch{}if(xe!==B.current)return;G();const ee=J.createBufferSource();ee.buffer=ue,ee.connect(R);const Pe=Number.isFinite(Number(ue.duration))?Number(ue.duration):0,Fe=Math.max(0,Math.min(Number(ye||0),Pe>0?Math.max(0,Pe-.01):0));T.current=J.currentTime-Fe,$.current=Fe,L.current=ee,x.current=F,ee.onended=()=>{L.current===ee&&(L.current=null,$.current=0,T.current=0,x.current="",h({key:"",status:"idle"}))},ee.start(0,Fe),h({key:F,status:"playing"})},we=(F,ue)=>{if(ue!==B.current)return;const ye=oe();if(!ye)return;const xe=M.current,ke=P.current;if(ke>=xe.length){E.current&&(x.current="",$.current=0,T.current=0,h({key:"",status:"idle"}));return}const J=xe[ke],{ctx:R,gain:ee}=ye;G();const Pe=R.createBufferSource();Pe.buffer=J,Pe.connect(ee);const Fe=Number.isFinite(Number(J.duration))?Number(J.duration):0,Xe=Math.max(0,Math.min(Number($.current||0),Fe>0?Math.max(0,Fe-.01):0));T.current=R.currentTime-Xe,L.current=Pe,x.current=F,Pe.onended=()=>{ue===B.current&&L.current===Pe&&(L.current=null,P.current=ke+1,$.current=0,we(F,ue))};try{R.state==="suspended"&&R.resume()}catch{}Pe.start(0,Xe),h({key:F,status:"playing"})},ve=async(F,ue,ye)=>{var ee;const xe=oe();if(!xe){r==null||r("This browser cannot play spoken replies.");return}G();const ke=++B.current;(ee=O.current)==null||ee.abort();const J=new AbortController;O.current=J,M.current=[],P.current=0,E.current=!1,Q.current=!1,A.current=null,$.current=0,T.current=0,x.current=F,v.current=F,h({key:F,status:"loading"}),r==null||r("");let R=null;try{for await(const Pe of ye(ue,J.signal)){if(ke!==B.current)return;let Fe;try{Fe=await sd(xe.ctx,Pe),R||(R=Jy(Pe))}catch{if(!R)continue;try{Fe=await sd(xe.ctx,Qy(R,Pe))}catch{continue}}if(ke!==B.current)return;M.current.push(Fe),!L.current&&!Q.current&&(v.current="",we(F,ke))}if(ke!==B.current)return;if(E.current=!0,M.current.length===0){r==null||r("Reading aloud failed: the voice engine returned no audio."),Ne();return}!L.current&&!Q.current&&we(F,ke)}catch(Pe){if(ke!==B.current)return;r==null||r(Ro("Reading aloud failed",Pe)),Ne()}finally{O.current===J&&(O.current=null)}},H=f.useCallback(async(F,ue)=>{var Xe;const ye=String(F||"").trim(),xe=String(ue||"").trim();if(!ye||!xe)return;const ke=n.current.tts,J=n.current.tts_stream;if(typeof ke!="function"&&typeof J!="function"){r==null||r("Reading aloud is not available on this gateway.");return}const R=oe();if(!R){r==null||r("This browser cannot play spoken replies.");return}const ee=d.current,Pe=ee.key===ye;if(Pe&&ee.status==="playing"){if(L.current){const ut=Math.max(0,R.ctx.currentTime-Number(T.current||0));$.current=ut}else $.current=0;Q.current=!0,G(),h({key:ye,status:"paused"});return}if(Pe&&ee.status==="paused"){if(M.current.length>0){r==null||r(""),Q.current=!1,h({key:ye,status:"playing"}),we(ye,B.current);return}const ut=A.current;if(ut){r==null||r(""),Q.current=!1;try{await je(ye,ut,$.current)}catch(mt){r==null||r(Ro("Reading aloud failed",mt)),h({key:"",status:"idle"})}return}}if(Pe&&ee.status==="loading")return;if(typeof J=="function"){await ve(ye,xe,J);return}G(),B.current+=1,(Xe=O.current)==null||Xe.abort(),O.current=null;const Fe=B.current;M.current=[],P.current=0,E.current=!0,Q.current=!1,A.current=null,$.current=0,T.current=0,x.current=ye,v.current=ye,h({key:ye,status:"loading"}),r==null||r("");try{const ut=await ke(xe);if(v.current!==ye||B.current!==Fe)return;const mt=await sd(R.ctx,ut);if(v.current!==ye||B.current!==Fe)return;A.current=mt,$.current=0,await je(ye,mt,0)}catch(ut){if(B.current!==Fe)return;v.current===ye&&(v.current="",x.current="",h({key:"",status:"idle"})),r==null||r(Ro("Reading aloud failed",ut))}},[]),[X,Z]=f.useState(!1),[U,Y]=f.useState(!1),I=f.useRef(!1),te=f.useRef(l);te.current=l;const ae=f.useCallback(F=>{I.current=F,Z(ue=>ue===F?ue:F)},[]),k=f.useRef(!1),C=f.useRef(null),re=f.useRef(null),he=f.useRef([]),le=f.useRef(""),D=f.useRef(0),be=f.useRef(!1),$e=f.useRef(!1),[Oe,Re]=f.useState(0),rt=f.useRef(0),qe=f.useRef(null),it=f.useRef(0),Ge=f.useRef(new Set),ct=f.useRef(null),et=f.useCallback(F=>{const ue=Math.round(Math.min(1,Math.max(0,Number(F)||0))*20)/20;if(ue!==it.current){it.current=ue;for(const ye of Array.from(Ge.current))ye(ue)}},[]),fe=f.useCallback(F=>(Ge.current.add(F),F(it.current),()=>{Ge.current.delete(F)}),[]),ce=f.useRef(new Set),Ee=f.useCallback(F=>(ce.current.add(F),()=>{ce.current.delete(F)}),[]);function se(){var ye,xe;const F=ct.current;ct.current=null;try{F==null||F()}catch{}et(0);try{(xe=(ye=C.current)==null?void 0:ye.getTracks)==null||xe.call(ye).forEach(ke=>{try{ke.stop()}catch{}})}catch{}C.current=null;const ue=qe.current;qe.current=null;try{ue==null||ue.close()}catch{}}const W=f.useCallback(()=>{D.current+=1,be.current=!1;const F=re.current;if(F){F.onstop=null,F.ondataavailable=null,F.onerror=null;try{F.stop()}catch{}}re.current=null,se(),ae(!1),k.current=!1,Y(!1),Re(0),he.current=[]},[ae]);f.useEffect(()=>()=>W(),[W]);async function ie(F,ue){var J,R;if(r==null||r(""),k.current)return;const ye=rt.current?Date.now()-rt.current:1/0;if(!F||!F.size||ye<Hy){Re(0),r==null||r("The recording was too short. Hold the microphone button while you speak, or tap it once to start and again to stop.");return}const xe=n.current.transcribe;if(typeof xe!="function"){r==null||r("Speech to text is not available on this gateway.");return}k.current=!0;const ke=D.current;Y(!0),Re(Date.now());try{const ee=await xe(F,ue),Pe=typeof ee=="string"||!ee?{text:String(ee||"")}:ee,Fe=String(Pe.text||"").trim();if(ke!==D.current)return;if(Fe){(R=(J=n.current).on_transcript)==null||R.call(J,Fe,{...Pe,text:Fe});for(const Xe of Array.from(ce.current))Xe(Fe,{...Pe,text:Fe})}else r==null||r("Nothing was heard. Check the microphone in Settings → Voice (Test), then try again.")}catch(ee){if(ke===D.current){const Pe=String((ee==null?void 0:ee.message)||ee||"").trim().replace(/\.$/,"");r==null||r(Pe?`Transcription failed: ${Pe}.`:"Transcription failed.")}}finally{ke===D.current&&(k.current=!1,Y(!1),Re(0))}}const Ce=f.useCallback(async()=>{if(r==null||r(""),!te.current){r==null||r(Vd("the microphone")??"Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(k.current||be.current||I.current||re.current)return;he.current=[];const F=D.current;be.current=!0,$e.current=!1;try{const ue=await qy(n.current.input_device_id||"");if(F!==D.current){ue.getTracks().forEach(ee=>ee.stop());return}if($e.current){$e.current=!1,ue.getTracks().forEach(ee=>ee.stop()),Re(0);return}C.current=ue;const ye=Number(n.current.input_gain??1);try{ct.current=Uy(ue,et,Number.isFinite(ye)&&ye>0?ye:1)}catch{}const xe=Ky();le.current=xe;let ke=ue;const J=Number(n.current.input_gain??1);if(Number.isFinite(J)&&J>0&&J!==1&&By()){const ee=globalThis.AudioContext||globalThis.webkitAudioContext,Pe=new ee,Fe=Pe.createGain();Fe.gain.value=J;const Xe=Pe.createMediaStreamDestination();Pe.createMediaStreamSource(ue).connect(Fe),Fe.connect(Xe),qe.current=Pe,ke=Xe.stream}const R=xe?new MediaRecorder(ke,{mimeType:xe}):new MediaRecorder(ke);re.current=R,R.ondataavailable=ee=>{if(F===D.current)try{ee!=null&&ee.data&&he.current.push(ee.data)}catch{}},R.onerror=()=>{F===D.current&&(r==null||r("Recording failed. Try again, or pick another microphone in Settings → Voice."))},R.onstop=()=>{if(F===D.current){ae(!1),se(),re.current=null;try{const ee=new Blob(he.current,{type:le.current||""});ie(ee,le.current)}catch(ee){r==null||r(Ro("The recording could not be prepared",ee))}}},R.start(),rt.current=Date.now(),Re(rt.current),ae(!0)}catch(ue){if(F!==D.current)return;se(),re.current=null,ae(!1),Re(0),r==null||r(Fy(ue))}finally{F===D.current&&(be.current=!1)}},[]),Je=f.useCallback(()=>{const F=re.current;if(be.current&&!F){$e.current=!0;return}if(!(!I.current||!F)){ae(!1);try{F.stop()}catch(ue){r==null||r(Ro("The recording could not stop",ue))}}},[]);return f.useEffect(()=>{if(!X||n.current.stop_on_pointerup===!1||n.current.stop_on_pointerup===void 0&&Qf(n.current.capture_mode)==="toggle")return;const F=()=>Je();return window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F),()=>{window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F)}},[X]),{tts_supported:i,tts_playback:u,toggle_tts:H,stop_tts:Ne,voice_ptt_supported:l,voice_ptt_recording:X,voice_ptt_busy:U,start_voice_ptt_recording:Ce,stop_voice_ptt_recording:Je,cancel_voice_ptt_recording:W,voice_ptt_since:Oe,subscribe_level:fe,voice_capture_mode:Qf(s.capture_mode),add_transcript_listener:Ee}}const up=72;function Xy(s,n=up){const r=Math.max(1,Math.floor(n)),i=new Array(r).fill(0),l=s.length;if(!l)return i;const u=l/r;let m=0;for(let d=0;d<r;d+=1){const h=Math.floor(d*u),x=Math.max(h+1,Math.floor((d+1)*u));let v=0;for(let g=h;g<x&&g<l;g+=1){const w=Math.abs(Number(s[g])||0);w>v&&(v=w)}i[d]=v,v>m&&(m=v)}return m<=0?i:i.map(d=>d/m)}function pc(s){if(typeof s!="number"||!Number.isFinite(s)||s<0)return"--:--";const n=Math.floor(s),r=Math.floor(n/3600),i=Math.floor(n%3600/60),l=String(n%60).padStart(2,"0");return r>0?`${r}:${String(i).padStart(2,"0")}:${l}`:`${i}:${l}`}function Zy(s,n,r){return!(n>0)||!(r>0)?0:Math.min(r,Math.max(0,s/n*r))}function ev(s,n){const[r,i]=f.useState({peaks:n??null,note:""});return f.useEffect(()=>{if(n){i({peaks:n,note:""});return}let l=!0;i({peaks:null,note:""});const u=typeof window<"u"?window.AudioContext||window.webkitAudioContext:void 0;if(!s||!u||typeof fetch!="function"){i({peaks:null,note:"Waveform unavailable in this browser."});return}return(async()=>{let m=null;try{const d=await(await fetch(s)).arrayBuffer();m=new u;const h=await m.decodeAudioData(d);l&&i({peaks:Xy(h.getChannelData(0)),note:""})}catch(d){l&&i({peaks:null,note:`Waveform unavailable: ${d instanceof Error?d.message:String(d)}`})}finally{m&&m.close().catch(()=>{})}})(),()=>{l=!1}},[s,n]),r}function dp(s){const n=f.useRef(null),r=f.useRef(null),[i,l]=f.useState(!1),[u,m]=f.useState(0),[d,h]=f.useState(null),[x,v]=f.useState(""),{peaks:g,note:w}=ev(s.src,s.peaks),L=g??new Array(up).fill(0),A=d&&d>0?Math.min(1,u/d):0,$=s.name?`Audio ${s.name}`:"Audio",T=f.useCallback(()=>{const P=n.current;P&&(P.paused?P.play().catch(E=>v(E instanceof Error?E.message:String(E))):P.pause())},[]),B=f.useCallback(P=>{const E=n.current;!E||!Number.isFinite(P)||(E.currentTime=P,m(P))},[]),O=P=>{var Q;const E=(Q=r.current)==null?void 0:Q.getBoundingClientRect();!E||!d||B(Zy(P-E.left,E.width,d))},M=P=>{if(!d)return;const E=P.key==="ArrowRight"||P.key==="ArrowUp"?5:P.key==="ArrowLeft"||P.key==="ArrowDown"?-5:0;E?(P.preventDefault(),B(Math.min(d,Math.max(0,u+E)))):P.key==="Home"?(P.preventDefault(),B(0)):P.key==="End"?(P.preventDefault(),B(d)):(P.key===" "||P.key==="Enter")&&(P.preventDefault(),T())};return e.jsxs("div",{className:`af-audio${s.className?` ${s.className}`:""}`,"data-playing":i?"true":"false",children:[e.jsx("audio",{ref:n,src:s.src,preload:"metadata",onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>l(!1),onTimeUpdate:P=>m(P.currentTarget.currentTime),onLoadedMetadata:P=>h(Number.isFinite(P.currentTarget.duration)?P.currentTarget.duration:null),onDurationChange:P=>h(Number.isFinite(P.currentTarget.duration)?P.currentTarget.duration:null),onError:()=>v("This audio cannot be played in this browser. Use Download to open it.")}),e.jsx("button",{type:"button",className:"af-audio__play","data-action":i?"pause-audio":"play-audio","aria-label":i?`Pause ${$}`:`Play ${$}`,title:i?"Pause":"Play",onClick:T,children:e.jsx(Ue,{name:i?"pause":"play",size:16})}),e.jsx("div",{ref:r,className:"af-audio__wave",role:"slider",tabIndex:0,"aria-label":`Seek in ${$}`,"aria-valuemin":0,"aria-valuemax":Math.round(d??0),"aria-valuenow":Math.round(u),"aria-valuetext":`${pc(u)} of ${pc(d)}`,title:w||void 0,"data-waveform":g?"decoded":"flat",onKeyDown:M,onPointerDown:P=>{var E,Q;(Q=(E=P.currentTarget).setPointerCapture)==null||Q.call(E,P.pointerId),O(P.clientX)},onPointerMove:P=>{P.buttons&1&&O(P.clientX)},children:e.jsx("svg",{viewBox:`0 0 ${L.length*2} 32`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:L.map((P,E)=>{const Q=Math.max(1.5,P*30),oe=(E+.5)/L.length<=A;return e.jsx("rect",{className:oe?"af-audio__bar af-audio__bar--played":"af-audio__bar",x:E*2+.3,y:16-Q/2,width:1.4,height:Q,rx:.6},E)})})}),e.jsxs("span",{className:"af-audio__time","aria-hidden":"true",children:[pc(u)," / ",pc(d)]}),x?e.jsx("p",{className:"af-audio__error",role:"alert",children:x}):null]})}const Br=s=>new Set(s.split(/\s+/).filter(Boolean)),tv=Br("if else for while do switch case default break continue return function const let var class extends new this super import export from as async await try catch finally throw typeof instanceof in of void delete yield static public private protected interface type enum implements package struct fn impl trait pub use mod mut match loop where crate self Self func go defer chan map range select int long short char float double bool boolean string true false null nil undefined None True False namespace using template typename virtual override final abstract sealed record val object fun when is"),nv=Br("def class return if elif else for while in not and or is import from as with try except finally raise pass break continue lambda yield global nonlocal assert del async await None True False self match case"),sv=Br("if then else elif fi for while do done case esac in function return export local readonly set unset echo exit source"),av=Br("select from where insert into values update set delete create table index view drop alter add join left right inner outer on group by order having limit offset as and or not null is in like between union all distinct primary key foreign references default"),Yf=Br("true false null yes no on off"),rv={c:{line:["//"],block:["/*","*/"],strings:['"',"'","`"],keywords:tv},python:{line:["#"],strings:['"',"'"],triple:!0,keywords:nv},shell:{line:["#"],strings:['"',"'"],keywords:sv},sql:{line:["--"],block:["/*","*/"],strings:["'",'"'],keywords:av},data:{line:["#"],strings:['"',"'"],keywords:Yf},json:{line:[],strings:['"'],keywords:Yf},css:{line:[],block:["/*","*/"],strings:['"',"'"],keywords:Br("")},markup:{line:[],block:["<!--","-->"],strings:['"',"'"],keywords:Br("")}},iv={js:"c",mjs:"c",cjs:"c",jsx:"c",ts:"c",tsx:"c",java:"c",kt:"c",c:"c",h:"c",cc:"c",cpp:"c",hpp:"c",cs:"c",go:"c",rs:"c",swift:"c",scala:"c",dart:"c",php:"c",py:"python",pyi:"python",rb:"shell",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",ps1:"shell",sql:"sql",yaml:"data",yml:"data",toml:"data",ini:"data",cfg:"data",conf:"data",env:"data",json:"json",jsonl:"json",css:"css",scss:"css",less:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",vue:"markup",javascript:"c",typescript:"c",rust:"c",python:"python",shell:"shell"};function Gd(s){const n=String(s||"").trim().toLowerCase(),r=n.split("/").pop()||n;if(r==="dockerfile"||r==="makefile")return"shell";const i=r.lastIndexOf("."),l=i>=0?r.slice(i+1):r;return iv[l]||""}const ov=s=>s>="0"&&s<="9",lv=s=>/[A-Za-z_$]/.test(s),Xf=s=>/[A-Za-z0-9_$]/.test(s);function mp(s,n){const r=String(s??""),i=rv[n];if(!i)return r?[{kind:"plain",text:r}]:[];const l=[];let u="";const m=(h,x)=>{if(x){if(h==="plain"){u+=x;return}u&&l.push({kind:"plain",text:u}),u="",l.push({kind:h,text:x})}};let d=0;for(;d<r.length;){const h=r[d];if(i.line.find(v=>r.startsWith(v,d))){const v=r.indexOf(`
44
- `,d),g=v===-1?r.length:v;m("comment",r.slice(d,g)),d=g;continue}if(i.block&&r.startsWith(i.block[0],d)){const v=r.indexOf(i.block[1],d+i.block[0].length),g=v===-1?r.length:v+i.block[1].length;m("comment",r.slice(d,g)),d=g;continue}if(i.strings.includes(h)){const v=i.triple&&r.startsWith(h.repeat(3),d)?h.repeat(3):"";if(v){const L=r.indexOf(v,d+3),A=L===-1?r.length:L+3;m("string",r.slice(d,A)),d=A;continue}let g=d+1;for(;g<r.length&&r[g]!==h&&(h==="`"||r[g]!==`
45
- `);)g+=r[g]==="\\"?2:1;const w=Math.min(r.length,g+1);m("string",r.slice(d,w)),d=w;continue}if(ov(h)&&!(d>0&&Xf(r[d-1]))){let v=d+1;for(;v<r.length&&/[0-9a-fA-FxXoObB._]/.test(r[v]);)v+=1;m("number",r.slice(d,v)),d=v;continue}if(lv(h)){let v=d+1;for(;v<r.length&&Xf(r[v]);)v+=1;const g=r.slice(d,v),w=n==="sql"?i.keywords.has(g.toLowerCase()):i.keywords.has(g);m(w?"keyword":"plain",g),d=v;continue}m("plain",h),d+=1}return u&&l.push({kind:"plain",text:u}),l}function _c({text:s,language:n="",lineNumbers:r=!0,className:i,ariaLabel:l}){const u=Gd(n),m=mp(s,u),d=r?String(s??"").split(`
46
- `).length:0;return e.jsx("pre",{className:`af-code${r?" af-code--numbered":""}${i?` ${i}`:""}`,"data-language":u||"text","aria-label":l,style:r?{"--af-code-gutter":`${String(d).length+1}ch`}:void 0,children:e.jsx("code",{children:r?cv(m).map((h,x)=>e.jsxs("span",{className:"af-code__line","data-line":x+1,children:[h.map((v,g)=>Zf(v,g)),`
47
- `]},x)):m.map((h,x)=>Zf(h,x))})})}function Zf(s,n){return s.kind==="plain"?e.jsx(Bt.Fragment,{children:s.text},n):e.jsx("span",{className:`af-code__${s.kind}`,children:s.text},n)}function cv(s){const n=[[]];for(const r of s)r.text.split(`
48
- `).forEach((l,u)=>{u>0&&n.push([]),l&&n[n.length-1].push({kind:r.kind,text:l})});return n}const fp=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Go=6e4,Ko=60*Go,gc=24*Ko;function il(s){if(s==null||s==="")return NaN;if(s instanceof Date)return s.getTime();if(typeof s=="number")return Number.isFinite(s)?s<1e12?s*1e3:s:NaN;const n=String(s).trim();return/^\d+(\.\d+)?$/.test(n)?il(Number(n)):Date.parse(n)}function eh(s){return s<10?`0${s}`:String(s)}function th(s,n){const r=il(s);if(!Number.isFinite(r))return"";const i=new Date(r),l=i.getFullYear()===new Date(n).getFullYear();return`${fp[i.getMonth()]} ${i.getDate()}${l?"":`, ${i.getFullYear()}`}`}function hp(s){const n=il(s);if(!Number.isFinite(n))return"";const r=new Date(n);return`${fp[r.getMonth()]} ${r.getDate()}, ${r.getFullYear()}, ${eh(r.getHours())}:${eh(r.getMinutes())}`}function pp(s,n){const r=il(s);if(!Number.isFinite(r)||!Number.isFinite(n))return"";const i=n-r;if(i<0){const u=-i;if(u<Go)return"due now";if(u<Ko)return`in ${Math.round(u/Go)} min`;if(u<gc)return`in ${Math.round(u/Ko)} h`;const m=Math.round(u/gc);return m<7?`in ${m} ${m===1?"day":"days"}`:th(r,n)}if(i<Go)return"just now";if(i<Ko)return`${Math.floor(i/Go)} min ago`;if(i<gc)return`${Math.floor(i/Ko)} h ago`;const l=Math.floor(i/gc);return l===1?"yesterday":l<7?`${l} days ago`:th(r,n)}const uv=new Set("png jpg jpeg gif webp bmp ico avif".split(" ")),dv=new Set("mp3 wav ogg oga opus m4a aac flac weba".split(" ")),mv=new Set("mp4 m4v webm mov ogv mkv".split(" ")),fv=new Set("mts cts".split(" ")),hv=new Set(["video/mp2t"]),pv=new Set("txt log csv tsv rst adoc org tex diff patch lock".split(" "));function _v(s){const n=String(s||"").split("/").pop()||"",r=n.lastIndexOf(".");return r>0?n.slice(r+1).toLowerCase():n.toLowerCase()}function _p(s,n=""){const r=_v(s),i=String(n||"").split(";",1)[0].trim().toLowerCase();return r==="md"||r==="markdown"||i==="text/markdown"?"markdown":r==="json"||i==="application/json"||i.endsWith("+json")?"json":r==="pdf"||i==="application/pdf"?"pdf":uv.has(r)?"image":dv.has(r)?"audio":mv.has(r)?"video":Gd(s)||fv.has(r)?"code":pv.has(r)?"text":i.startsWith("image/")&&i!=="image/svg+xml"?"image":i.startsWith("audio/")?"audio":i.startsWith("video/")&&!hv.has(i)?"video":i.startsWith("text/")?"text":["application/javascript","application/xml","application/x-yaml","application/toml"].includes(i)?"code":"binary"}function gv(s){return s==="markdown"||s==="code"||s==="json"||s==="text"}function gp(s){if(typeof s!="number"||!Number.isFinite(s)||s<0)return"";if(s<1024)return`${s} B`;const n=["KiB","MiB","GiB","TiB"];let r=s/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r<10?r.toFixed(1):Math.round(r)} ${n[i]}`}function yv(s){const n=s.kind??_p(s.name,s.contentType),r=gp(s.sizeBytes),i=s.modified!==void 0?pp(s.modified,s.nowMs):"";return e.jsxs("section",{className:`af-file-viewer${s.className?` ${s.className}`:""}`,"aria-label":`Preview of ${s.name}`,"data-kind":n,children:[e.jsxs("header",{className:"af-file-viewer__head",children:[e.jsx(Ue,{name:"file",size:15}),e.jsxs("span",{className:"af-file-viewer__title",children:[e.jsx("strong",{className:"af-file-viewer__name",title:s.path||s.name,children:s.name}),r||i?e.jsxs("span",{className:"af-file-viewer__meta",children:[r?e.jsx("span",{"data-meta":"size",children:r}):null,r&&i?e.jsx("span",{"aria-hidden":"true",children:" · "}):null,i?e.jsx("time",{"data-meta":"modified",title:hp(s.modified),dateTime:new Date(il(s.modified)).toISOString(),children:i}):null]}):null]}),s.actions,s.onDownload?e.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"download-file",onClick:s.onDownload,title:"Download","aria-label":`Download ${s.name}`,children:e.jsx(Ue,{name:"download",size:15})}):null,s.onClose?e.jsx("button",{type:"button",className:"af-file-viewer__icon-btn","data-action":"close-preview",onClick:s.onClose,title:"Close","aria-label":"Close the preview",children:e.jsx(Ue,{name:"x",size:15})}):null]}),e.jsx("div",{className:"af-file-viewer__body",children:s.status==="loading"?e.jsx("p",{className:"af-file-viewer__muted",role:"status",children:"Loading preview…"}):s.status==="error"?e.jsx("p",{className:"af-file-viewer__error",role:"alert",children:s.error||"The preview could not be loaded."}):e.jsxs(e.Fragment,{children:[s.partialNote?e.jsx("p",{className:"af-file-viewer__muted",role:"status",children:s.partialNote}):null,e.jsx(vv,{kind:n,p:s})]})})]})}function vv({kind:s,p:n}){const r=n.text??"";switch(s){case"image":return n.url?e.jsx("img",{className:"af-file-viewer__image",src:n.url,alt:n.name}):e.jsx(Po,{});case"audio":return n.url?e.jsx(dp,{src:n.url,name:n.name}):e.jsx(Po,{});case"video":return n.url?e.jsx("video",{className:"af-file-viewer__image af-file-viewer__video",src:n.url,controls:!0,playsInline:!0,preload:"metadata","aria-label":n.name}):e.jsx(Po,{});case"pdf":return n.url?e.jsx("object",{className:"af-file-viewer__pdf",data:n.url,type:"application/pdf","aria-label":n.name,children:e.jsx("p",{className:"af-file-viewer__muted",children:"This browser cannot show PDFs inline. Use Download to open it."})}):e.jsx(Po,{});case"markdown":return n.renderMarkdown?e.jsx("div",{className:"af-file-viewer__markdown",children:n.renderMarkdown(r)}):e.jsx(_c,{text:r,language:""});case"json":{let i=r,l="";try{i=JSON.stringify(JSON.parse(r),null,2)}catch{l=n.partialNote?"":"Not valid JSON; shown as text."}return e.jsxs(e.Fragment,{children:[l?e.jsx("p",{className:"af-file-viewer__muted",children:l}):null,e.jsx(_c,{text:i,language:"json"})]})}case"code":return e.jsx(_c,{text:r,language:n.name});case"text":return e.jsx(_c,{text:r,language:"",lineNumbers:!1});default:return e.jsx(Po,{})}}function Po(){return e.jsx("p",{className:"af-file-viewer__muted",children:"No preview for this file type. Use Download to open it."})}function xv(s){const n=String(s??"").trim();if(!n||!(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]")))return null;try{return JSON.parse(n)}catch{return null}}async function ln(s){var r;const n=String(s||"");if(!n)return!1;try{if(typeof navigator<"u"&&typeof((r=navigator.clipboard)==null?void 0:r.writeText)=="function")return await navigator.clipboard.writeText(n),!0}catch{}try{const i=document.createElement("textarea");i.value=n,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select();const l=document.execCommand("copy")===!0;return document.body.removeChild(i),l}catch{return!1}}const bv=3,wv=Number.MAX_SAFE_INTEGER;function yp(s){return!!s&&typeof s=="object"&&!Array.isArray(s)}function vp(s){return Array.isArray(s)}function jv(s){if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)}catch{return String(s)}}function Ei({kind:s,children:n}){return e.jsx("span",{className:`pc-json-token ${s}`,children:n})}function kv(s){const n=JSON.stringify(s.value),r=n.length>96||n.includes("\\n")||n.includes("\\r")||n.includes("\\t"),[i,l]=f.useState(!r||s.expansionMode==="unfolded");return f.useEffect(()=>{r&&l(s.expansionMode==="unfolded")},[r,s.expansionMode,s.expansionVersion]),r?e.jsxs("span",{className:`pc-json-string ${i?"open":"collapsed"}`,children:[e.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>l(u=>!u),"aria-label":i?"Collapse string value":"Expand string value","aria-expanded":i,children:i?"▾":"▸"}),i?e.jsx("span",{className:"pc-json-token string pc-json-string__value",children:n}):e.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>l(!0),"aria-label":"Expand string value",children:[e.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:n}),e.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):e.jsx(Ei,{kind:"string",children:n})}function Sv(s,n,r){return s===null?e.jsx(Ei,{kind:"null",children:"null"}):typeof s=="string"?e.jsx(kv,{value:s,expansionMode:n,expansionVersion:r}):typeof s=="number"?e.jsx(Ei,{kind:"number",children:String(s)}):typeof s=="boolean"?e.jsx(Ei,{kind:"boolean",children:s?"true":"false"}):e.jsx(Ei,{kind:"string",children:JSON.stringify(String(s))})}function Nv(s){return vp(s)?s.length===1?"1 item":`${s.length} items`:yp(s)?Object.keys(s).length===1?"1 key":`${Object.keys(s).length} keys`:""}function xp(s){const{label:n,value:r,depth:i,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:d}=s,h=i*14,x=yp(r),v=vp(r),g=x||v,w=i<l,[L,A]=f.useState(w);f.useEffect(()=>{A(w)},[w,m]);const $=n?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{kind:"key",children:JSON.stringify(n)}),": "]}):null;if(!g)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[$,Sv(r,u,m),d?",":""]});const T=v?"[":"{",B=v?"]":"}",O=Nv(r),M=L?`${T}`:`${T}…${B}${O?` (${O})`:""}`,P=v?r.map((E,Q)=>({key:String(Q),label:void 0,value:E})):Object.entries(r).map(([E,Q])=>({key:E,label:E,value:Q}));return e.jsxs("details",{className:"pc-json-viewer__details",open:L,onToggle:E=>A(E.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:h},children:[$,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:L?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:M}),!L&&d?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),L?e.jsx("div",{className:"pc-json-viewer__children",children:P.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:B}),d?",":""]}):e.jsxs(e.Fragment,{children:[P.map((E,Q)=>{const oe=Q===P.length-1;return e.jsx(xp,{label:E.label,value:E.value,depth:i+1,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:!oe},`${i}:${n||"root"}:${E.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:h},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:B}),d?",":""]})]})}):null]})}function Cv(s){const n=s.trim();if(!n)return s;if(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]"))try{return JSON.parse(n)}catch{return s}return s}function $c(s){const{value:n,className:r,showCopy:i=!0}=s,[l,u]=f.useState({mode:"folded",version:0}),[m,d]=f.useState("idle"),h=typeof s.collapseAfterDepth=="number"&&(Number.isFinite(s.collapseAfterDepth)||s.collapseAfterDepth===1/0)&&s.collapseAfterDepth>=0?s.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(s.collapseAfterDepth):bv,x=l.mode==="unfolded"?wv:h,v=f.useMemo(()=>typeof n=="string"?Cv(n):n,[n]),g=f.useMemo(()=>jv(n),[n]),w=["pc-json-viewer",r].filter(Boolean).join(" ");f.useEffect(()=>{u(A=>({mode:"folded",version:A.version+1}))},[v]);const L=()=>{u(A=>({mode:A.mode==="unfolded"?"folded":"unfolded",version:A.version+1}))};return e.jsxs("div",{className:w,children:[e.jsxs("div",{className:"pc-json-viewer__toolbar",children:[e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:L,"aria-expanded":l.mode==="unfolded",children:l.mode==="unfolded"?"Fold all":"Unfold all"}),i?e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void ln(g).then(A=>{d(A?"copied":"failed"),window.setTimeout(()=>d("idle"),2e3)}),children:m==="copied"?"Copied":m==="failed"?"Copy failed — select and copy":"Copy JSON"}):null]}),e.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:e.jsx(xp,{value:v,depth:0,collapseAfterDepth:x,expansionMode:l.mode,expansionVersion:l.version,trailingComma:!1})})]})}function $v({code:s,lang:n}){const[r,i]=f.useState("idle"),l=f.useRef(null);f.useEffect(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]);const u=mp(s,Gd(n));return e.jsxs("div",{className:"pc-md_codeblock",children:[e.jsx("button",{type:"button",className:`pc-md_copy${r!=="idle"?` pc-md_copy--${r}`:""}`,"aria-label":"Copy code",title:r==="idle"?"Copy":r==="copied"?"Copied":"Copy failed",onClick:async()=>{const m=await ln(s);i(m?"copied":"failed"),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>i("idle"),900)},children:e.jsx(Ue,{name:r==="copied"?"check":"copy",size:14})}),e.jsx("pre",{className:"pc-md_pre",children:e.jsx("code",{className:n?`language-${n}`:void 0,children:u.map((m,d)=>m.kind==="plain"?e.jsx(Bt.Fragment,{children:m.text},d):e.jsx("span",{className:`af-code__${m.kind}`,children:m.text},d))})})]})}function zo(s,n){const r=String(s??"");if(!n||!n.needles.length)return[r];const i=[],l=r.toLowerCase();let u=0;for(;u<r.length;){let m=-1,d="";for(let v=0;v<n.needlesLower.length;v++){const g=n.needlesLower[v];if(!g)continue;const w=l.indexOf(g,u);if(w===-1)continue;const L=n.needles[v]||"";L&&(m===-1||w<m||w===m&&L.length>d.length)&&(m=w,d=L)}if(m===-1||!d){i.push(r.slice(u));break}m>u&&i.push(r.slice(u,m));const h=n.hits===0&&n.id?n.id:void 0,x=r.slice(m,m+d.length);i.push(e.jsx("span",{id:h,className:n.className,children:x},`hl:${n.hits}`)),n.hits+=1,u=m+d.length}return i}function bp(s){const n=String(s||"").trim();if(n&&/^(https?:|mailto:|tel:|#|\/)/i.test(n))return n}const Cd="http://same-origin.invalid/";function Ev(s){try{const n=new URL(s,Cd);return n.protocol==="http:"&&n.origin===new URL(Cd).origin}catch{return!1}}function wp(s){const n=String(s||"").trim();return bp(n)??(n&&Ev(n)?n:void 0)}let Or=null;function Tv(s){const n=String(s||"").trim();if(!n)return!1;const r=typeof document<"u"&&document.baseURI?document.baseURI:null;if(r===null&&/^[a-z][a-z0-9+.-]*:/i.test(n))return!1;const i=r??Cd;let l,u;try{l=new URL(i).origin,u=new URL(n,i)}catch{return!1}return u.protocol!=="http:"&&u.protocol!=="https:"?!1:u.origin===l}function jp(s,n,r){return e.jsx("a",{className:"pc-md_link pc-md_image_link",href:n,target:"_blank",rel:"noopener noreferrer",children:`image: ${r||n}`},s)}function nh(s){return!!s&&/[\p{L}\p{N}]/u.test(s)}function pa(s,n){const r=[],i=String(s??"");let l=0,u="";const m=()=>{if(u){for(const d of zo(u,n))r.push(d);u=""}};for(;l<i.length;){const d=i[l];if(d==="!"&&i[l+1]==="["){const h=i.indexOf("]",l+2);if(h!==-1&&i[h+1]==="("){const x=i.indexOf(")",h+2);if(x!==-1){const v=i.slice(l+2,h),g=wp(i.slice(h+2,x));if(g&&Or&&!Or(g)){m(),r.push(jp(`img:${l}`,g,v)),l=x+1;continue}if(g){m(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:g,alt:v,loading:"lazy"}),v?e.jsx("span",{className:"pc-md_img_caption",children:n?zo(v,n):v}):null]},`img:${l}`)),l=x+1;continue}}}}if(d==="["){const h=i.indexOf("]",l+1);if(h!==-1&&i[h+1]==="("){const x=i.indexOf(")",h+2);if(x!==-1){const v=i.slice(l+1,h),g=bp(i.slice(h+2,x));if(g){m(),r.push(e.jsx("a",{className:"pc-md_link",href:g,target:g.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:pa(v,n)},`link:${l}`)),l=x+1;continue}}}}if(d==="`"){const h=i.indexOf("`",l+1);if(h!==-1){m();const x=i.slice(l+1,h);r.push(e.jsx("code",{children:n?zo(x,n):x},`code:${l}`)),l=h+1;continue}}if(d==="_"&&!nh(i[l-1])){const h=i[l+1]==="_"?"__":"_",x=h.length;if(i[l+x]&&!/\s/.test(i[l+x])&&i[l+x]!=="_"){let v=i.indexOf(h,l+x);for(;v!==-1&&(/\s/.test(i[v-1]||" ")||nh(i[v+x])||x===1&&i[v+1]==="_");)v=i.indexOf(h,v+1);if(v!==-1&&v>l+x){m();const g=i.slice(l+x,v),w=pa(g,n);r.push(x===2?e.jsx("strong",{children:w},`ubold:${l}`):e.jsx("em",{children:w},`uem:${l}`)),l=v+x;continue}}}if(d==="*"&&i[l+1]==="*"){const h=i.indexOf("**",l+2);if(h!==-1){m();const x=i.slice(l+2,h);r.push(e.jsx("strong",{children:n?zo(x,n):x},`bold:${l}`)),l=h+2;continue}}if(d==="*"&&i[l+1]!=="*"){const h=i.indexOf("*",l+1);if(h!==-1){m();const x=i.slice(l+1,h);r.push(e.jsx("em",{children:n?zo(x,n):x},`em:${l}`)),l=h+1;continue}}u+=d,l+=1}return m(),r}function Av(s){return String(s??"").replace(/\r\n/g,`
49
- `).replace(/\r/g,`
50
- `).split(`
51
- `)}function Ec(s){const r=String(s??"").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 Lv(s){const n=[];for(const l of s){const u=Ec(l);u?n.push(u):n.length>0&&l.trim()&&(n[n.length-1].content+=` ${l.trim()}`)}const r=[],i=[];for(const l of n){for(;i.length>0&&l.indent<i[i.length-1].indent;)i.pop();let u=i.length>0?i[i.length-1]:null;if(u&&l.indent>u.indent){const m=u.node.items,d=m[m.length-1];if(d){const h={ordered:l.ordered,start:l.start,items:[]};d.children.push(h),i.push({indent:l.indent,node:h}),u=i[i.length-1]}}else if(u&&u.node.ordered!==l.ordered){i.pop();const m=i.length>0?i[i.length-1]:null,d={ordered:l.ordered,start:l.start,items:[]};if(m){const h=m.node.items,x=h[h.length-1];x?x.children.push(d):m.node.items.push({content:"",children:[d]})}else r.push(d);i.push({indent:l.indent,node:d}),u=i[i.length-1]}if(!u){const m={ordered:l.ordered,start:l.start,items:[]};r.push(m),i.push({indent:l.indent,node:m}),u=i[i.length-1]}u.node.items.push({content:l.content,children:[]})}return r}function kp(s,n,r){const i=s.items.map((l,u)=>e.jsxs("li",{children:[pa(l.content,n),l.children.map((m,d)=>kp(m,n,`${r}:${u}:${d}`))]},`${r}:li:${u}`));return s.ordered?e.jsx("ol",{className:"pc-md_ol",start:s.start!==1?s.start:void 0,children:i},r):e.jsx("ul",{className:"pc-md_ul",children:i},r)}function Mv(s,n,r){return Lv(s).map((i,l)=>kp(i,n,`${r}:${l}`))}function sh(s){let n=String(s??"").trim();return n?(n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(r=>String(r??"").trim())):[]}function ah(s){let n=String(s??"").trim();if(!n)return!1;n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1));const r=n.split("|").map(i=>String(i??"").trim());return r.length<2?!1:r.every(i=>/^:?-{3,}:?$/.test(i))}const rh=/^(#{1,5})\s+(.*)$/;function ih(s){return s.trim().startsWith("```")}function oh(s){return s.trimStart().startsWith(">")}function ns(s){const n=Or;Or=s.images==="link"?s.inlineImage||Tv:null;try{return Rv(s)}finally{Or=n}}function Rv({text:s,className:n,highlight:r,highlights:i,highlightClassName:l,highlightId:u}){const m=Av(s),d=[],h=[];Array.isArray(i)&&h.push(...i),typeof r=="string"&&r.trim()&&h.push(r);const x=Array.from(new Set(h.map(L=>String(L??"").trim()).filter(Boolean))).filter(L=>L.length>=4),v=x.length?{needles:x,needlesLower:x.map(L=>L.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let g=0;for(;g<m.length;){const L=String(m[g]??"");if(!L.trim()){g+=1;continue}const A=L.trim();if(/^([-_*])(\s*\1){2,}$/.test(A)){d.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${g}`)),g+=1;continue}const $=L.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if($){const O=wp($[2]||"");if(O&&Or&&!Or(O)){d.push(e.jsx("p",{className:"pc-md_p",children:jp(`img:${g}`,O,$[1]||"")},`p:${g}`)),g+=1;continue}if(O){const M=$[1]||"";d.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:O,alt:M,loading:"lazy"}),M?e.jsx("figcaption",{children:pa(M,v)}):null]},`figure:${g}`)),g+=1;continue}}if(ih(L)){const M=L.trim().replace(/```/g,"").trim(),P=[];for(g+=1;g<m.length&&!String(m[g]??"").trim().startsWith("```");)P.push(String(m[g]??"")),g+=1;g<m.length&&(g+=1);const E=P.join(`
52
- `);d.push(e.jsx($v,{code:E,lang:M},`pre:${g}`));continue}const T=L.match(rh);if(T){const O=T[1].length,M=T[2]||"",P=pa(M,v);O===1?d.push(e.jsx("h1",{children:P},`h1:${g}`)):O===2?d.push(e.jsx("h2",{children:P},`h2:${g}`)):O===3?d.push(e.jsx("h3",{children:P},`h3:${g}`)):O===4?d.push(e.jsx("h4",{children:P},`h4:${g}`)):d.push(e.jsx("h5",{children:P},`h5:${g}`)),g+=1;continue}if(oh(L)){const O=[];for(;g<m.length&&String(m[g]??"").trimStart().startsWith(">");){const P=String(m[g]??"").trimStart();O.push(P.replace(/^>\s?/,"")),g+=1}d.push(e.jsx("blockquote",{className:"pc-md_quote",children:O.map((M,P)=>e.jsxs(Bt.Fragment,{children:[pa(M,v),P<O.length-1?e.jsx("br",{}):null]},`q:${g}:${P}`))},`quote:${g}`));continue}if(L.includes("|")&&g+1<m.length&&ah(String(m[g+1]??""))){const O=sh(L),M=Math.max(1,O.length),P=[];for(g+=2;g<m.length;){const E=String(m[g]??"");if(!E.trim()||!E.includes("|"))break;const Q=sh(E),oe=[];for(let G=0;G<M;G++)oe.push(Q[G]??"");P.push(oe),g+=1}d.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:O.slice(0,M).map((E,Q)=>e.jsx("th",{children:pa(E,v)},`th:${g}:${Q}`))})}),e.jsx("tbody",{children:P.map((E,Q)=>e.jsx("tr",{children:E.map((oe,G)=>e.jsx("td",{children:pa(oe,v)},`td:${g}:${Q}:${G}`))},`tr:${g}:${Q}`))})]})},`table:${g}`));continue}if(Ec(L)){const O=[];for(;g<m.length;){const M=String(m[g]??"");if(!M.trim()||M.trimStart().startsWith("```"))break;if(Ec(M)||/^\s{2,}\S/.test(M)){O.push(M),g+=1;continue}break}d.push(e.jsx(Bt.Fragment,{children:Mv(O,v,`list:${g}`)},`list:${g}`));continue}const B=[];for(;g<m.length&&String(m[g]??"").trim()&&!(B.length>0&&Ec(String(m[g]??"")));){const O=String(m[g]??"");if(B.length>0&&(rh.test(O)||ih(O)||oh(O))||B.length>0&&O.includes("|")&&g+1<m.length&&ah(String(m[g+1]??"")))break;B.push(O),g+=1}d.push(e.jsx("p",{className:"pc-md_p",children:B.map((O,M)=>e.jsxs(Bt.Fragment,{children:[pa(O,v),M<B.length-1?e.jsx("br",{}):null]},`pl:${g}:${M}`))},`p:${g}`))}const w=["pc-md",n].filter(Boolean).join(" ");return e.jsx("div",{className:w,children:d})}function Pv(s){const n=String(s.text??""),r=f.useMemo(()=>xv(n),[n]),i=["pc-chat-content",s.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:i,children:e.jsx($c,{value:r,collapseAfterDepth:s.jsonCollapseAfterDepth})}):s.renderMarkdown?e.jsx("div",{className:i,children:s.renderMarkdown(n)}):e.jsx("div",{className:i,children:e.jsx(ns,{text:n,images:s.images,inlineImage:s.inlineImage})})}const zv=new Set("html htm xhtml xht shtml svg svgz xml xsl xslt mht mhtml".split(" ")),Iv=new Set(["application/pdf","application/json","text/plain","text/markdown","text/csv","text/tab-separated-values","text/x-python","text/javascript","application/javascript","text/css","text/x-c","text/x-shellscript","text/x-typescript","image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","video/mp4","video/webm","video/quicktime","audio/mpeg","audio/mp4","audio/aac","audio/wav","audio/x-wav","audio/ogg","audio/webm","audio/flac"]);function Sp(s){const n=String(s??"");if(!n.trim())return!1;try{const r=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/",i=new URL(n,r).protocol;return i==="blob:"||i==="data:"}catch{return!0}}function Dv(s,n){const r=String(n||"").split("/").pop()||"",i=r.lastIndexOf(".");if(i>0&&zv.has(r.slice(i+1).toLowerCase()))return!1;const l=String(s||"").split(";",1)[0].trim().toLowerCase();return!l||l==="text/html"||l.includes("xml")?!1:Iv.has(l)}function Ov(s){const n=r=>!!r&&(!Sp(r)||Dv(s.contentType,s.name));if(n(s.href))return s.href;if(n(s.src))return s.src}function Fv(s){const{markdownImages:n,inlineImage:r,renderMarkdown:i,...l}=s;return e.jsx(yv,{...l,nowMs:s.nowMs??Date.now(),renderMarkdown:i||(u=>e.jsx(ns,{text:u,...n?{images:n}:{},...r?{inlineImage:r}:{}}))})}function qv({sandbox:s,className:n}){return s?e.jsxs("div",{className:`pc-tool-sandbox is-${s.state}${n?` ${n}`:""}`,"data-sandbox-kind":s.kind,children:[e.jsx("div",{className:"pc-tool-sandbox__line",children:s.line}),s.rows.length?e.jsxs("ul",{className:"pc-tool-sandbox__rows","aria-label":"Workspaces the sandbox enforced",children:[s.rows.map((r,i)=>e.jsxs("li",{children:[e.jsx("code",{children:r.path}),e.jsx("span",{className:"pc-tool-sandbox__mode",children:r.private?`${r.mode} · this run's folder`:r.mode})]},`${r.mode}:${r.path}:${i}`)),s.builtinRefused?e.jsxs("li",{className:"pc-tool-sandbox__builtin",children:[s.builtinRefused," built-in protected ",s.builtinRefused===1?"folder":"folders"," refused"]}):null]}):null]}):null}function lh(s){if(s.decision==="denied")return"Denied by this chat's policy";const n=s.setAt?hp(s.setAt):"",i=[s.setBy?`set by ${s.setBy}`:"",n?`at ${n}`:""].filter(Boolean).join(" ");return`Allowed by this chat's policy${i?` (${i})`:""}`}const xn="not reported",Pn=s=>s===void 0?xn:Math.round(s).toLocaleString(),Cn=s=>{if(s===void 0)return xn;if(s<6e4)return`${(s/1e3).toFixed(1)}s`;const n=Math.round(s/1e3);return`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`},Np=s=>s===void 0?xn:`${Math.round(s).toLocaleString()} tok/s`,Bv=(s,n)=>n>0?`${Math.round(s/n*100)}%`:"",Fr=(s,n,r=`${n}s`)=>`${s.toLocaleString()} ${s===1?n:r}`,Uv=s=>{const n=s.split("#")[0].replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||s};function Wv(s){const n=new Map;for(const r of s)r&&n.set(r,(n.get(r)||0)+1);return[...n].map(([r,i])=>i>1?`${r} ×${i}`:r).join(" · ")}function Ac(s){const n=[],r=(s.models||[]).map(Uv),i=s.providers||[];return(r.length||i.length)&&n.push([r.join(", ")||"model not reported",i.join(", ")].filter(Boolean).join(" · ")),n.push("From the run ledger; summed across this turn and its child runs."),n}function Hv(s){const n=s.modelCalls||[],r=[],i=[{label:"Input",value:Pn(s.inputTokens)},{label:"Output",value:Pn(s.outputTokens)}];if(s.reasoningTokens!==void 0&&i.push({label:"Reasoning",value:Pn(s.reasoningTokens),hint:"part of output"}),i.push({label:"Total",value:Pn(s.totalTokens)}),r.push({heading:`Usage · ${Fr(s.llmCalls,"model call")}`,rows:i}),s.measuredCacheCalls){const u=s.cachedTokens||0,m=s.fedTokens||0,d=[{label:"Reused from cache",value:`${Pn(u)}${u+m?` (${Bv(u,u+m)})`:""}`},{label:"Newly processed",value:Pn(s.fedTokens)},{label:"Outcome",value:Wv(n.map(h=>h.cacheOutcome))||(s.cacheOutcomes||[]).join(" · ")||xn},{label:"Backend",value:(s.cacheBackends||[]).join(", ")||xn}];s.measuredCacheCalls!==s.llmCalls&&d.push({label:"Measured on",value:`${s.measuredCacheCalls} of ${s.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:d})}else s.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:xn}]});const l=n.filter(u=>u.inputTokens!==void 0);return l.length===1&&n.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${Pn(l[0].inputTokens)} tokens`}]}):l.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${Pn(l[0].inputTokens)} → ${Pn(l[l.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),n.length>1&&r.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:n.map((u,m)=>[String(m+1),Pn(u.inputTokens),u.cachedTokens===void 0?"—":Pn(u.cachedTokens),u.fedTokens===void 0?"—":Pn(u.fedTokens),Pn(u.outputTokens),u.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:s.totalTokens===void 0?xn:`${s.totalTokens.toLocaleString()} total`,sections:r,footer:Ac(s)}}function yc(s,n,r,i){if(s===void 0)return xn;const l=[Cn(s)];return n!==void 0&&l.push(`${n.toLocaleString()} ${i}${r!==void 0?` at ${Np(r)}`:""}`),l.join(" · ")}function Vv(s){var x,v,g;const n=s.modelCalls||[],r=[],i=s.durationMs,l=[{label:"Wall clock",value:Cn(i)}];if(l.push({label:"Model",value:s.genTimeMs===void 0?xn:`${Cn(s.genTimeMs)} · ${Fr(s.timedCalls||0,"call")}${s.timedCalls!==s.llmCalls?` (of ${s.llmCalls})`:""}`}),l.push({label:"Tools",value:s.toolTimeMs!==void 0?`${Cn(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`:s.toolCalls?xn:"none",hint:s.toolTimeIncludesApproval?"includes approval wait":void 0}),i!==void 0&&s.genTimeMs!==void 0){const w=i-s.genTimeMs-(s.toolTimeMs||0);l.push({label:"Orchestration",value:w>=0?Cn(w):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:l});const u=[],m=s.ttftCalls||0,d=s.promptPhaseCalls||0;s.promptPhaseMs!==void 0?u.push({label:m&&m===d?"Prefill (TTFT)":"Prefill",value:yc(s.promptPhaseMs,s.promptPhaseNewTokens,s.promptPhaseTokensPerSecond,"new tok"),hint:m===d?"measured time to first token":m?`TTFT measured on ${m} of ${d}; rest from provider rate`:"derived: prompt ÷ provider rate"}):s.prefillMs!==void 0&&s.prefillNewTokensPerSecond!==void 0?u.push({label:"Prefill",value:yc(s.prefillMs,s.prefillNewTokens,s.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):s.prefillMs!==void 0?u.push({label:"Prefill",value:`${Cn(s.prefillMs)}${s.promptTokensPerSecond!==void 0?` at ${Np(s.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):u.push({label:"Prefill",value:xn}),s.cachedTokens&&(s.promptPhaseMs??s.prefillMs)!==void 0&&u.push({label:"Restored",value:`${s.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),u.push({label:"Generation",value:s.generationPhaseMs!==void 0?yc(s.generationPhaseMs,s.generationPhaseTokens,s.generationPhaseTokensPerSecond,"tok"):yc(s.decodeMs,s.outputTokens,s.generationTokensPerSecond,"tok")}),s.measuredSpeedCalls&&s.measuredSpeedCalls!==s.llmCalls&&u.push({label:"Speeds from",value:`${s.measuredSpeedCalls} of ${s.llmCalls} calls`}),r.push({heading:"Model",rows:u});const h=s.speculation;if(h){const w=(h.draftKinds||[]).map(A=>A.toUpperCase()).join(", "),L=[{label:"Mode",value:`${h.used?"on":"off"}${w?` · ${w}`:""}${(x=h.modes)!=null&&x.length?` (${h.modes.join(", ")})`:""}`,hint:h.calls!==s.llmCalls||h.used!==h.calls?`used on ${h.used} of ${s.llmCalls} calls`:void 0},{label:"Acceptance",value:h.acceptanceRate===void 0?xn:`${Math.round(h.acceptanceRate*100)}% · ${Pn(h.acceptedTokens)} of ${Pn(h.draftedTokens)} drafted`}];((v=h.draftLengths)!=null&&v.length||h.rounds!==void 0)&&L.push({label:"Draft length",value:`${(g=h.draftLengths)!=null&&g.length?`${h.draftLengths.join("/")} tok/round`:xn}${h.rounds!==void 0?` · ${h.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:L})}return s.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Cn(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Cn(s.slowestToolBatch.ms)} · ${Cp(s.slowestToolBatch)}`}],note:s.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),n.length>1&&r.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:n.map((w,L)=>[String(L+1),w.promptMs===void 0?"—":`${Cn(w.promptMs)}${w.promptSource==="rate"?"*":""}`,w.promptNewTokensPerSecond===void 0?"—":Math.round(w.promptNewTokensPerSecond).toLocaleString(),w.generationMs===void 0?"—":Cn(w.generationMs),w.generationTokensPerSecond===void 0?"—":Math.round(w.generationTokensPerSecond).toLocaleString(),w.cacheOutcome||"—"])},note:n.some(w=>w.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:i===void 0?xn:`${Cn(i)} wall clock`,sections:r,footer:Ac(s)}}function Cp(s){return s.tools.length===1?`${s.tools[0]} ×${s.calls}`:`${Fr(s.calls,"call")} (${s.tools.join(", ")})`}function Gv(s){const n=[],r=(s.toolsWaiting||0)+(s.toolsRunning||0);if(!s.toolCalls&&!r)return n.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:n,footer:Ac(s)};const i=[{label:"Succeeded",value:(s.toolCalls-(s.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(s.toolsFailed||0).toLocaleString()}];s.toolsRunning&&i.push({label:"Running",value:s.toolsRunning.toLocaleString()}),s.toolsWaiting&&i.push({label:"Awaiting approval",value:s.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),n.push({heading:"Outcome",rows:i});const l=Object.entries(s.toolBreakdown||{}).sort((d,h)=>h[1].calls-d[1].calls||d[0].localeCompare(h[0]));l.length&&n.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:l.map(([d,h])=>[d,h.calls.toLocaleString(),h.failed.toLocaleString(),h.ms!==void 0?`${Cn(h.ms)}${h.sharedBatches?" +shared":""}`:h.sharedBatches?"shared":xn])},note:l.some(([,d])=>d.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const u=l.filter(([,d])=>d.errors&&Object.keys(d.errors).length);u.length&&n.push({heading:"Failures",rows:u.map(([d,h])=>({label:d,value:Object.entries(h.errors).sort((x,v)=>v[1]-x[1]).map(([x,v])=>v>1?`${x} ×${v}`:x).join(" · ")}))});const m=[{label:"Tool time",value:s.toolTimeMs===void 0?xn:`${Cn(s.toolTimeMs)} · ${Fr(s.toolBatches||0,"batch","batches")}`}];return s.slowestToolBatch&&m.push({label:"Slowest batch",value:`${Cn(s.slowestToolBatch.ms)} · ${Cp(s.slowestToolBatch)}`}),n.push({heading:"Timing",rows:m,note:s.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Fr(s.toolCalls,"call")}${s.toolsFailed?` · ${s.toolsFailed} failed`:""}`,sections:n,footer:Ac(s)}}function ad(s,n){return s==="tokens"?Hv(n):s==="time"?Vv(n):Gv(n)}function Kv(s){const n=s.detail;return e.jsxs("div",{ref:s.panelRef,id:s.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${n.kind}`,style:s.style,onMouseEnter:s.onMouseEnter,onMouseLeave:s.onMouseLeave,children:[e.jsxs("div",{className:"pc-stat-detail-head",children:[e.jsx("span",{className:"pc-stat-detail-title",children:n.title}),e.jsx("span",{className:"pc-stat-detail-headline",children:n.headline})]}),n.sections.map(r=>{var i;return e.jsxs("div",{className:"pc-stat-detail-section",children:[e.jsx("div",{className:"pc-stat-detail-heading",children:r.heading}),(i=r.rows)!=null&&i.length?e.jsx("dl",{className:"pc-stat-detail-rows",children:r.rows.map(l=>e.jsxs(Bt.Fragment,{children:[e.jsx("dt",{children:l.label}),e.jsxs("dd",{children:[e.jsx("span",{className:l.value===xn?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:l.value}),l.hint?e.jsx("span",{className:"pc-stat-detail-hint",children:l.hint}):null]})]},l.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(l=>e.jsx("th",{scope:"col",children:l},l))})}),e.jsx("tbody",{children:r.table.rows.map((l,u)=>e.jsx("tr",{children:l.map((m,d)=>e.jsx("td",{children:m},d))},u))})]}):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:n.footer.map(r=>e.jsx("div",{children:r},r))})]})}const fa=8;function Jv(s){const[n,r]=f.useState(!!s.defaultOpen),[i,l]=f.useState(null),u=f.useRef(null),m=f.useRef(null),d=f.useRef(null),h=`pc-stat-${f.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,x=f.useCallback(()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null},[]),v=f.useCallback(()=>{x(),r(!0)},[x]),g=f.useCallback(()=>{x(),d.current=window.setTimeout(()=>r(!1),120)},[x]);f.useEffect(()=>x,[x]),f.useLayoutEffect(()=>{if(!n){l(null);return}const $=()=>{const T=u.current,B=m.current;if(!T||!B)return;const O=T.getBoundingClientRect(),M=B.offsetWidth,P=B.offsetHeight,E=window.innerWidth,Q=window.innerHeight,oe=O.top-fa-P,G=O.bottom+fa,Ne=oe>=fa?oe:G+P<=Q-fa?G:Math.max(fa,Q-fa-P),je=Math.min(Math.max(fa,O.left),Math.max(fa,E-fa-M));l({top:Ne,left:je})};return $(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[n]),f.useEffect(()=>{if(!n)return;const $=T=>{T.key==="Escape"&&r(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[n]);const w=typeof s.onClick=="function",L=w?"button":"span",A=n?e.jsx(Kv,{detail:s.detail,id:h,panelRef:m,onMouseEnter:x,onMouseLeave:g,style:{position:"fixed",top:(i==null?void 0:i.top)??0,left:(i==null?void 0:i.left)??0,visibility:i?"visible":"hidden"}}):null;return e.jsxs(e.Fragment,{children:[e.jsxs(L,{ref:u,...w?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",w?"pc-chat-stat--clickable":"",s.className].filter(Boolean).join(" "),"aria-label":`${s.label} — ${s.detail.title.toLowerCase()} details`,"aria-describedby":n?h:void 0,"data-stat-kind":s.detail.kind,onMouseEnter:v,onMouseLeave:g,onFocus:v,onBlur:()=>r(!1),onKeyDown:$=>{$.key==="Escape"&&r(!1)},onClick:w?()=>{var $;return($=s.onClick)==null?void 0:$.call(s)}:void 0,children:[s.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:s.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:s.label})]}),A&&typeof document<"u"?Xh.createPortal(A,document.body):A]})}function $p(s){if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return s}}function Qv(s){const n=$p(s);if(!n||typeof n!="object"||Array.isArray(n))return{label:"input",value:n==null?"":String(n)};const r=Object.entries(n),l=["command","query","url","file_path","path","pattern","name"].map(u=>r.find(([m])=>m===u)).find(Boolean)||r[0];return l?{label:l[0].replace(/_/g," "),value:typeof l[1]=="string"?l[1]:JSON.stringify(l[1])??""}:{label:"",value:""}}function Ep({tool:s,showCopy:n=!0}){const[r,i]=f.useState(!1),l=$p(s.arguments),u=Qv(s.arguments),m=["file path","path"].includes(u.label)&&u.value.length>60?`${u.value.split(/[\\/]/).pop()} · ${u.value.slice(0,24)}…`:u.value,d=s.error&&/^File ['"].+['"] does not exist\.?$/.test(s.error)?"File not found. Expand for the exact path.":s.error&&s.error.length>180?`${s.error.slice(0,100)}…${s.error.slice(-70)}`:s.error,h={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},x=s.startedAt&&s.endedAt?Date.parse(s.endedAt)-Date.parse(s.startedAt):NaN,v=l&&typeof l=="object"&&!Array.isArray(l)?Object.entries(l):null;return e.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${s.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(Ue,{name:s.status==="completed"?"check":s.status==="failed"?"x":s.status==="waiting"?"warning":"loader",size:15})}),e.jsx("strong",{children:s.name}),e.jsx("span",{className:"pc-tool-activity__preview",title:u.value,children:u.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:u.label}),m]}):"No parameters"}),e.jsx("span",{className:"pc-tool-activity__status",children:h[s.status]}),s.policy?e.jsx("span",{className:"pc-tool-activity__policy","data-policy":s.policy.decision,title:lh(s.policy),children:s.policy.decision==="denied"?"Denied by this chat's policy":"Allowed by this chat's policy"}):null,Number.isFinite(x)&&x>=0?e.jsxs("span",{className:"pc-tool-activity__duration","data-approval-wait":s.approvalWait?"":void 0,title:s.approvalWait?"Timed from request to result: includes the wait for your decision.":void 0,children:[Cn(x),s.approvalWait?" incl. approval wait":""]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(Ue,{name:"chevronRight",size:13})}),s.error?e.jsx("span",{className:"pc-tool-activity__error",title:s.error,children:d}):null]}),e.jsxs("div",{className:"pc-tool-activity__detail",children:[s.policy?e.jsxs("p",{className:"pc-tool-activity__policy-line","data-policy":s.policy.decision,children:[lh(s.policy),s.policy.matched?` · matched ${s.policy.matched}`:""]}):null,e.jsx(qv,{sandbox:s.sandbox}),s.error?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Error"}),e.jsx("pre",{className:"pc-tool-activity__output",children:s.error})]}):null,e.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[e.jsx("h4",{children:"Parameters"}),n?e.jsxs("button",{type:"button",onClick:async()=>i(await ln(JSON.stringify(s,null,2))),children:[e.jsx(Ue,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),v?e.jsx("dl",{className:"pc-tool-activity__parameters",children:v.map(([g,w])=>e.jsxs(Bt.Fragment,{children:[e.jsx("dt",{children:g}),e.jsx("dd",{children:w&&typeof w=="object"?e.jsx($c,{value:w}):e.jsx("code",{children:typeof w=="string"?w:JSON.stringify(w)})})]},g))}):s.arguments===void 0?e.jsx("p",{children:"Arguments are unavailable in this ledger."}):e.jsx($c,{value:l}),s.output!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Result"}),typeof s.output=="string"?e.jsx("pre",{className:"pc-tool-activity__output",children:s.output}):e.jsx("div",{className:"pc-tool-activity__output",children:e.jsx($c,{value:s.output})})]}):null]})]})}function Yv({tools:s,showCopy:n}){const r=i=>s.filter(l=>l.status===i).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(Ue,{name:"terminal",size:14}),e.jsx("strong",{children:"Tools"}),e.jsxs("span",{children:[s.length," ",s.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]}),s.map(i=>e.jsx(Ep,{tool:i,showCopy:n},i.id))]})}function Xv(s){const n=s.totalTokens!==void 0?ad("tokens",s):null,r=ad("tools",s),i=s.durationMs!==void 0?ad("time",s):null;return[...n?[{label:`${s.totalTokens.toLocaleString()} tokens`,detail:n}]:[],{label:`${s.toolCalls} ${s.toolCalls===1?"tool":"tools"}`,detail:r},...s.changedFiles.length?[{label:`${s.changedFiles.length} ${s.changedFiles.length===1?"file":"files"} changed`,title:s.changedFiles.join(`
53
- `)}]:[],...i?[{label:Cn(s.durationMs),detail:i}]:[]]}function Zv(s){const n=String(s.role||"").trim().toLowerCase()||"system",r=String(s.kind||"").trim().toLowerCase(),i=String(s.level||"").trim().toLowerCase();return n==="system"&&r==="report_bug"?{label:String(s.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:n==="system"&&r==="report_feature"?{label:String(s.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:n==="user"?{label:String(s.title||"").trim()||"You",icon:"user",variant:"user"}:n==="assistant"?{label:String(s.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(s.title||"").trim()||(i==="error"?"Error":i==="warn"?"Warning":"System"),icon:i==="error"?"error":i==="warn"?"warning":"info",variant:i==="error"?"error":i==="warn"?"warn":"status"}}const ex=new Set(["blob:","data:","http:","https:"]);function Lc(s){const n=String(s||"").trim();if(n)try{const r=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/";return ex.has(new URL(n,r).protocol)?n:void 0}catch{return}}function Tp(s,n){return Sp(s)?{href:s,download:n||"file"}:{href:s,target:"_blank",rel:"noopener noreferrer"}}function tx({item:s,onOpen:n,markdown:r}){const[i,l]=f.useState(!1),u=Lc(s.src),m=String(s.name||s.label||"").trim()||"File",d=Ov({href:s.href?Lc(s.href):void 0,src:u,contentType:s.contentType,name:s.name||s.label}),h=_p(m,s.contentType),x=gv(h),v=typeof s.text=="string";if(!u&&!d&&!v)return null;const g=gp(s.size),w=String(s.label||"").trim()||m;return e.jsxs("figure",{className:"pc-chat-media__item pc-chat-media__item--file","data-file-kind":h,children:[e.jsxs("div",{className:"pc-chat-media__file-row",children:[e.jsx(Ue,{name:"file",size:14}),e.jsx("span",{className:"pc-chat-media__file-name",title:m,children:w}),g?e.jsx("span",{className:"pc-chat-media__file-size",children:g}):null,n?e.jsx("button",{type:"button",className:"pc-chat-media__file-open","data-action":"open-file",onClick:()=>n({...s,src:u||"",...d?{href:d}:{href:void 0}}),children:"Open"}):e.jsx("button",{type:"button",className:"pc-chat-media__file-open","data-action":"toggle-file","aria-expanded":i,onClick:()=>l(L=>!L),children:i?"Close":"Open"}),d?e.jsx("a",{className:"pc-chat-media__link",...Tp(d,String(s.name||"").trim()||w),children:"Raw file"}):null]}),i&&!n?e.jsx(Fv,{className:"pc-chat-media__viewer",name:m,kind:h,contentType:s.contentType,sizeBytes:s.size,status:x&&!v?"error":"ready",error:x&&!v?d?"No preview text was supplied for this file; open the raw file.":"No preview text was supplied for this file.":void 0,markdownImages:r.images||"link",...r.inlineImage?{inlineImage:r.inlineImage}:{},...r.renderMarkdown?{renderMarkdown:r.renderMarkdown}:{},...v?{text:s.text}:{},...u&&!x?{url:u}:{},onClose:()=>l(!1)}):null]})}function nx({item:s,onOpenFile:n,markdown:r}){const[i,l]=f.useState(!1);if(s.kind==="file")return e.jsx(tx,{item:s,onOpen:n,markdown:r||{}});const u=Lc(s.src),m=s.href?Lc(s.href):void 0,d=s.kind==="image"||s.kind==="audio"||s.kind==="video"?s.kind:null;if(!d||!u&&!m)return null;const h=d==="image"?"Image":d==="video"?"Video":"Audio",x=String(s.label||"").trim()||`Generated ${h.toLowerCase()}`,v=()=>l(!0);return e.jsxs("figure",{className:`pc-chat-media__item pc-chat-media__item--${d}`,children:[u&&d==="image"?e.jsx("img",{className:"pc-chat-media__image",src:u,alt:x,loading:"lazy",onError:v}):null,u&&d==="video"?e.jsx("video",{className:"pc-chat-media__video",src:u,controls:!0,playsInline:!0,preload:"metadata","aria-label":x,onError:v}):null,u&&d==="audio"?e.jsx(dp,{className:"pc-chat-media__audio",src:u,name:x}):null,d==="audio"&&String(s.transcript||"").trim()?e.jsxs("details",{className:"pc-chat-media__transcript",children:[e.jsx("summary",{children:"Transcript"}),e.jsx("p",{className:"pc-chat-media__transcript-text",children:String(s.transcript).trim()})]}):null,i?e.jsxs("div",{className:"pc-chat-media__error",role:"note",children:[h," could not be decoded by this browser",m?"; open the raw file with the link.":"."]}):null,m?e.jsx("figcaption",{className:"pc-chat-media__caption",children:e.jsx("a",{className:"pc-chat-media__link",...Tp(m,String(s.name||"").trim()||x),children:x})}):null]})}function sx(s){var Q,oe;const n=s.message,r=f.useMemo(()=>Zv(n),[n.kind,n.level,n.role,n.title]),i=String(n.ts||"").trim(),l=f.useMemo(()=>{if(!i)return"";const G=new Date(i);return Number.isFinite(G.getTime())?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[i]),[u,m]=f.useState("idle"),d=f.useRef(null);f.useEffect(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);const h=n.live,x=!h&&typeof s.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(n.content||"").trim(),v=x&&((Q=s.getSpeakState)==null?void 0:Q.call(s,n))||"idle",g=v==="loading"?"loader":v==="playing"?"pause":"speaker",w=v==="loading"?"Generating audio…":v==="playing"?"Pause":v==="paused"?"Resume":"Speak (TTS)",L=s.showCopy!==!1,A=Array.isArray(s.attachments)?s.attachments:Array.isArray(n.attachments)?n.attachments:[],$=n.statistics,T=n.stats,B=f.useMemo(()=>Array.isArray(s.stats)?s.stats:Array.isArray(T)?T:$?Xv($):[],[s.stats,T,$]),O=Array.isArray(n.media)?n.media:[],M=String(h?h.reasoning||"":n.reasoning||""),P=!!String(n.content||"").trim();if(n.toolActivity)return e.jsx(Ep,{tool:n.toolActivity,showCopy:s.showCopy});const E=s.renderFooter?s.renderFooter(n):null;if(((oe=s.variant)==null?void 0:oe.call(s,n))==="hint"||n.kind==="tool_policy_decision"){const G=String(n.level||"").trim().toLowerCase();return e.jsxs("div",{className:["pc-chat-hint",G==="warn"||G==="error"?`pc-chat-hint--${G}`:"",s.className].filter(Boolean).join(" "),role:"note","data-variant":"hint",children:[e.jsx("span",{className:"pc-chat-hint__text",children:String(n.content||"")}),E!=null&&E!==!1?e.jsx("div",{className:"pc-chat-footer",children:E}):null]})}return e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,h?"pc-chat-item--live":"",s.className].filter(Boolean).join(" "),...h?{"aria-busy":!0}:{},children:[e.jsxs("div",{className:"pc-chat-header",children:[e.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:e.jsx(Ue,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),h?e.jsxs("span",{className:"pc-chat-live-indicator",title:h.label?`Pending: ${h.label}`:"The reply is still being written",children:[e.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),h.label||"streaming"]}):null,h!=null&&h.caption?e.jsx("span",{className:"pc-chat-live-caption",children:h.caption}):null,e.jsx("span",{className:"pc-chat-header-spacer"}),l?e.jsx("span",{className:"pc-chat-time",children:l}):null,e.jsxs("div",{className:"pc-chat-header-actions",children:[x?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":w,title:w,onClick:()=>{var G;return(G=s.onSpeakToggle)==null?void 0:G.call(s,n)},children:e.jsx(Ue,{name:g,size:22,className:v==="loading"?"pc-chat-speak-spinner":void 0})}):null,L?e.jsx("button",{className:`pc-chat-icon-btn ${u!=="idle"?`pc-chat-icon-btn--${u}`:""}`.trim(),type:"button","aria-label":"Copy message",title:u==="idle"?"Copy":u==="copied"?"Copied":"Copy failed",onClick:async()=>{const G=await ln(String(n.content||""));m(G?"copied":"failed"),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>m("idle"),900)},children:e.jsx(Ue,{name:"copy",size:22})}):null]})]}),M.trim()?e.jsxs("details",{className:"pc-chat-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("div",{className:"pc-chat-thinking-body",children:M})]}):null,P||!h&&!O.length?e.jsx("div",{className:"pc-chat-body",children:e.jsx(Pv,{text:String(n.content||""),renderMarkdown:s.renderMarkdown,jsonCollapseAfterDepth:s.jsonCollapseAfterDepth,images:s.images||(r.variant==="user"?"inline":"link"),inlineImage:s.inlineImage})}):null,O.length?e.jsx("div",{className:"pc-chat-media",children:O.slice(0,24).map((G,Ne)=>e.jsx(nx,{item:G,onOpenFile:s.onOpenMedia,markdown:{renderMarkdown:s.renderMarkdown,images:s.images,inlineImage:s.inlineImage}},G.id||`${G.kind}:${G.src}:${Ne}`))}):null,A.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:A.slice(0,24).map((G,Ne)=>{const je=String(G.label||"").trim()||"attachment",we=String(G.target||"").trim(),ve=String(G.title||"").trim(),H=!!G.disabled||typeof G.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:ve||je,onClick:H?void 0:G.onClick,disabled:H,children:[e.jsx(Ue,{name:"paperclip",size:14}),we?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${we}`,children:we}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:je})]},G.id||`${je}:${Ne}`)})}):null,B.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:B.slice(0,12).map((G,Ne)=>{const je=String(G.label||"").trim();if(!je)return null;if(G.detail)return e.jsx(Jv,{label:je,detail:G.detail,icon:G.icon,onClick:G.onClick},G.id||`${je}:${Ne}`);const we=String(G.title||"").trim(),ve=typeof G.onClick=="function",H=ve?"button":"span";return e.jsxs(H,{...ve?{type:"button"}:{},className:["pc-chat-stat",ve?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:we||void 0,onClick:ve?()=>{var X;return(X=G.onClick)==null?void 0:X.call(G)}:void 0,children:[G.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:G.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:je})]},G.id||`${je}:${Ne}`)})}):null,E!=null&&E!==!1?e.jsx("div",{className:"pc-chat-footer",children:E}):null]})}function ax(s,n){const r=Math.max(0,Math.trunc(n));return s.scrollHeight-s.scrollTop-s.clientHeight<=r}function Rc(s){const n=typeof s.autoScrollThresholdPx=="number"&&Number.isFinite(s.autoScrollThresholdPx)?s.autoScrollThresholdPx:120,r=s.autoScroll!==!1,i=f.useRef(null),l=f.useRef(null),[u,m]=f.useState(!0),d=f.useMemo(()=>Array.isArray(s.messages)?s.messages:[],[s.messages]),h=f.useMemo(()=>{var g;const v=[];for(const w of d){const L=v[v.length-1];w.toolActivity&&((g=L==null?void 0:L[0])!=null&&g.toolActivity)&&L[0].runId===w.runId?L.push(w):v.push([w])}return v},[d]);f.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const g=()=>{m(ax(v,n))};return v.addEventListener("scroll",g,{passive:!0}),g(),()=>v.removeEventListener("scroll",g)},[r,n]);const x=f.useMemo(()=>{let v=0;for(const g of d)if(v+=String(g.content??"").length,Array.isArray(g.media))for(const w of g.media)v+=String((w==null?void 0:w.src)??"").length+1;return`${d.length}:${v}:${String(s.afterKey??"")}`},[d,s.afterKey]);return f.useEffect(()=>{if(!r||!u)return;const v=i.current;v&&(v.scrollTop=v.scrollHeight)},[r,u,x]),f.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const g=()=>{u&&(v.scrollTop=v.scrollHeight)};return v.addEventListener("load",g,!0),v.addEventListener("loadedmetadata",g,!0),()=>{v.removeEventListener("load",g,!0),v.removeEventListener("loadedmetadata",g,!0)}},[r,u]),e.jsxs("div",{ref:i,className:["pc-chat-thread",s.className].filter(Boolean).join(" "),children:[d.length?null:s.empty||null,h.map((v,g)=>{var A;const w=v[0],L=String(w.id||"")||String(w.ts||"")+":"+String(w.role||"")+":"+g;return w.toolActivity?e.jsx(Yv,{tools:v.map($=>$.toolActivity),showCopy:(A=s.messageProps)==null?void 0:A.showCopy},L):e.jsx(sx,{message:w,...s.messageProps||{}},L)}),s.after,e.jsx("div",{ref:l})]})}const ol=Bt.forwardRef(function(n,r){const i=typeof n.rows=="number"&&Number.isFinite(n.rows)?Math.max(1,Math.trunc(n.rows)):3,l=!!n.disabled,u=!!n.busy,m=!l&&!u&&!!String(n.value||"").trim();return e.jsxs("div",{className:["pc-composer",n.className].filter(Boolean).join(" "),children:[n.leading,e.jsx("textarea",{ref:r,className:["pc-composer__textarea",n.textareaClassName].filter(Boolean).join(" "),value:n.value,onChange:d=>n.onChange(d.target.value),rows:i,style:{"--pc-composer-rows":String(i)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:n.placeholder||"","aria-label":n.ariaLabel||n.placeholder||"Message",disabled:l,autoFocus:!!n.autoFocus,onPaste:n.onPaste,onKeyDown:d=>{d.key!=="Enter"||d.shiftKey||d.nativeEvent.isComposing||d.keyCode===229||(d.preventDefault(),m&&n.onSubmit())}}),e.jsxs("div",{className:"pc-composer__row",children:[e.jsx("div",{className:"pc-composer__actions",children:n.actions}),e.jsx("button",{type:"button",className:n.sendButtonClassName||"pc-btn",disabled:!m,onClick:()=>n.onSubmit(),children:u?n.busyLabel||"Thinking…":n.sendLabel||"Send"})]}),n.overlay]})});function rx(s){return!!(s&&typeof s[Symbol.asyncIterator]=="function")}function ix(s){const[n,r]=f.useState([]),i=s.messages??n,l=$=>{s.onMessagesChange&&s.onMessagesChange($),s.messages===void 0&&r($)},u=f.useRef(i);u.current=i;const[m,d]=f.useState(""),[h,x]=f.useState(!1),v=f.useRef(null),g=s.assistantName||"Assistant",w=!!s.blockedNotice,L=async $=>{const T=String($||"").trim();if(!T||h||w)return;d("");const B=u.current,O=[...B,{role:"user",content:T,ts:new Date().toISOString()}];l(O),x(!0);const M=new AbortController;v.current=M;try{const P=s.ask(T,{signal:M.signal,history:B});if(rx(P)){let E="";const Q=[...O,{role:"assistant",title:g,content:"",ts:new Date().toISOString()}];l(Q);for await(const oe of P){if(M.signal.aborted)break;E+=String(oe??""),l([...O,{role:"assistant",title:g,content:E,ts:new Date().toISOString()}])}!E.trim()&&!M.signal.aborted&&l([...O,{role:"assistant",title:g,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const E=String(await P??"").trim();l([...O,E?{role:"assistant",title:g,content:E,ts:new Date().toISOString()}:{role:"assistant",title:g,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(P){M.signal.aborted||l([...u.current,{role:"assistant",title:g,content:`#FALLBACK assistant request failed: ${String((P==null?void 0:P.message)||P||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{v.current===M&&(v.current=null),x(!1)}},A=f.useMemo(()=>i.length>0?null:e.jsxs("div",{className:"pc-assistant__empty",children:[e.jsx("div",{className:"pc-assistant__empty-text",children:s.emptyState||"Ask about this app — answers are grounded in its documentation."}),s.suggestions&&s.suggestions.length>0?e.jsx("div",{className:"pc-assistant__suggestions",children:s.suggestions.map($=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void L($),disabled:h||w,children:$},$))}):null]}),[i.length,s.emptyState,s.suggestions,h,w]);return e.jsxs("div",{className:`pc-assistant${s.className?` ${s.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[A,e.jsx(Rc,{messages:i,autoScroll:!0}),w?e.jsx("div",{className:"pc-assistant__blocked",children:s.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(ol,{value:m,onChange:d,onSubmit:()=>void L(m),placeholder:s.placeholder||"Ask about this app…",disabled:w,busy:h,rows:2,actions:h?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var $;($=v.current)==null||$.abort()},children:"Stop"}):null})})]})}function ox(s){if(!s)return!1;for(let n=0;n<s.length;n+=1)if(s[n]==="Files")return!0;return!1}function Ap(s){const n=[],r=[],i=s==null?void 0:s.items;if(i&&i.length){for(let u=0;u<i.length;u+=1){const m=i[u];if(!m||m.kind!=="file")continue;const d=typeof m.webkitGetAsEntry=="function"?m.webkitGetAsEntry():null,h=typeof m.getAsFile=="function"?m.getAsFile():null;d!=null&&d.isDirectory?r.push(d.name||(h==null?void 0:h.name)||"folder"):h&&n.push(h)}return{files:n,folders:r}}const l=s==null?void 0:s.files;if(l)for(let u=0;u<l.length;u+=1)l[u]&&n.push(l[u]);return{files:n,folders:r}}function lx(s){return s.length?s.length===1?`"${s[0]}" is a folder. Folders are not supported: drop the files inside it instead.`:`${s.length} folders were dropped. Folders are not supported: drop the files inside them instead.`:""}const cx={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function Io(s){return String(s).padStart(2,"0")}function ux(s,n,r){const i=String(s||"").trim();if(i&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(i))return i;const l=cx[String(n||"").toLowerCase()]||i.split(".").pop()||"bin",u=`${r.getFullYear()}-${Io(r.getMonth()+1)}-${Io(r.getDate())} at ${Io(r.getHours())}.${Io(r.getMinutes())}.${Io(r.getSeconds())}`;return`${String(n||"").startsWith("image/")||!i?"Pasted image":"Pasted file"} ${u}.${l}`}function dx(s,n=new Date){if(!s)return[];const r=s.types?Array.from(s.types):[];if(r.includes("text/plain")&&r.includes("text/html"))return[];const{files:i}=Ap(s);return i.map(l=>{const u=ux(l.name,l.type,n);return u===l.name?l:new File([l],u,{type:l.type,lastModified:l.lastModified})})}const Jo="llm.delta",Ci="llm.delta_end";function mx(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:null}function zr(s){return typeof s=="string"&&s.trim()!==""}function fx(s){return typeof s=="number"&&Number.isInteger(s)&&s>=0}function hx(s){return"reason"in s}function px(s,n){const r=mx(s),i=r==null?void 0:r.kind,l=n||(typeof i=="string"&&i?i:r&&"reason"in r?Ci:Jo),u=h=>{throw new Error(`Malformed ${l} event from the gateway: ${h}`)};if(n!==void 0&&n!==Jo&&n!==Ci&&u(`unknown event name ${JSON.stringify(n)}`),!r)return u("the payload is not an object");i!==void 0&&i!==Jo&&i!==Ci&&u(`unknown kind ${JSON.stringify(i)}`),i!==void 0&&n!==void 0&&i!==n&&u(`kind ${JSON.stringify(i)} does not match the event name`),zr(r.run_id)||u("run_id is missing"),zr(r.call_id)||u("call_id is missing"),fx(r.seq)||u("seq is not a non-negative integer");const m=n||i?(n||i)===Ci:"reason"in r;r.root_run_id!==void 0&&!zr(r.root_run_id)&&u("root_run_id is not a run id"),r.parent_run_id!==void 0&&r.parent_run_id!==null&&!zr(r.parent_run_id)&&u("parent_run_id is neither a run id nor null");const d={run_id:r.run_id,...zr(r.root_run_id)?{root_run_id:r.root_run_id}:{},...r.parent_run_id!==void 0?{parent_run_id:r.parent_run_id}:{},...zr(r.node_id)?{node_id:r.node_id}:{},call_id:r.call_id,seq:r.seq};return m?(["completed","failed","cancelled","unavailable"].includes(String(r.reason))||u(`unknown reason ${JSON.stringify(r.reason)}`),r.detail!==void 0&&r.detail!==null&&typeof r.detail!="string"&&u("detail is not a string"),{kind:Ci,...d,reason:r.reason,...zr(r.detail)?{detail:r.detail}:{}}):(typeof r.text!="string"&&u("text is not a string"),r.channel!=="content"&&r.channel!=="reasoning"&&u(`unknown channel ${JSON.stringify(r.channel)}`),typeof r.snapshot!="boolean"&&u("snapshot is not a boolean"),{kind:Jo,...d,text:r.text,channel:r.channel,snapshot:r.snapshot})}function _x(s,n){if(s!==Jo&&s!==Ci)return null;let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{throw new Error(`Malformed ${s} event from the gateway: data is not JSON`)}return px(r,s)}async function Lp(s,n){let r="";try{const i=await s.text();try{const l=JSON.parse(i),u=(l==null?void 0:l.detail)??(l==null?void 0:l.error)??(l==null?void 0:l.message);r=typeof u=="string"?u:u&&typeof u.message=="string"?u.message:i}catch{r=i}}catch{r=""}return new Error(`${n} (HTTP ${s.status}): ${r.trim()||s.statusText||"no reason given"}`)}const gx={registry_scope:"tenant_catalog",bundle_id:"docs-qa",bundle_version:"0.1.1",flow_id:"docsqa001"},Mp="docs";function yx(s){return Cs(`docs/corpus?${new URLSearchParams({app:String(s||"")})}`)}function rd(s){return`${String(s||"app")}-docs-assistant:${Yo()}`}function vx(s){const n={prompt:s.question,docs:s.docs,app:s.appName,use_session_history:!0};return s.attachments&&s.attachments.length&&(n.context={attachments:s.attachments}),{...gx,session_id:s.sessionId,kind:Mp,input_data:n}}function Rp(s){const n=s==null?void 0:s.output;if(typeof n=="string")return n.trim();const r=n==null?void 0:n.response;return typeof r=="string"?r.trim():""}function xx(s){const n=s&&typeof s=="object"?s:{},r=d=>typeof d=="number"&&Number.isFinite(d)&&d>0?Math.trunc(d):0,i=r(n.dropped_messages);if(!i)return"";const l=r(n.replayed_messages),u=r(n.dropped_tokens),m=r(n.max_tokens);return`Earlier messages not replayed: ${i.toLocaleString("en-US")}${u?` (~${u.toLocaleString("en-US")} tokens)`:""}. The model read the newest ${l.toLocaleString("en-US")} message${l===1?"":"s"}`+(m?` (history window: the most recent ${m.toLocaleString("en-US")} tokens of whole messages).`:".")}async function*bx(s,n){const r=s.getReader(),i=new TextDecoder;let l="";const u=()=>{r.cancel().catch(()=>{})};n==null||n.addEventListener("abort",u,{once:!0});try{for(;;){const{value:m,done:d}=await r.read();if(d)break;l+=i.decode(m,{stream:!0}).replace(/\r\n/g,`
54
- `);let h=l.indexOf(`
55
-
56
- `);for(;h>=0;){const x=l.slice(0,h);l=l.slice(h+2);let v="message";const g=[];for(const w of x.split(`
57
- `))w.startsWith("event:")?v=w.slice(6).trim():w.startsWith("data:")&&g.push(w.slice(5).replace(/^ /,""));g.length&&(yield{event:v,data:g.join(`
58
- `)}),h=l.indexOf(`
59
-
60
- `)}}}finally{n==null||n.removeEventListener("abort",u)}}function wx(s,n){return new Promise((r,i)=>{if(n.aborted)return i(new DOMException("Aborted","AbortError"));const l=setTimeout(()=>{n.removeEventListener("abort",u),r()},s),u=()=>{clearTimeout(l),i(new DOMException("Aborted","AbortError"))};n.addEventListener("abort",u,{once:!0})})}async function Za(s,n){if(!s.ok)throw await Lp(s,n);return s.json()}function jx(s){const n=s.pollMs??1e3,r=s.timeoutMs??18e4;let i=null;return async(l,u)=>{var A;const{fetchGateway:m,source:d}=s;if(i===null){const $=await m(yx(d.app),{signal:u.signal,headers:{Accept:"application/json"}}),T=await Za($,`The ${d.name} documentation could not be read, so nothing was asked`),B=typeof(T==null?void 0:T.text)=="string"?T.text:"";if(!B.trim())throw new Error(`The gateway returned an empty ${d.name} documentation corpus, so nothing was asked.`);i=B}const h=String(i),x=[];for(const $ of u.files||[]){const T=new FormData;T.append("session_id",u.sessionId),T.append("file",$,$.name||"upload.bin"),T.append("filename",$.name||"upload.bin"),$.type&&T.append("content_type",$.type);const B=await Za(await m(Cs("attachments/upload"),{method:"POST",body:T,signal:u.signal}),`"${$.name}" could not be attached`),O=B==null?void 0:B.attachment;if(!O||typeof O.$artifact!="string"||!O.$artifact)throw new Error(`"${$.name}" could not be attached: the gateway returned no attachment reference.`);x.push(O)}const v=await Za(await m(Cs("runs/start"),{method:"POST",signal:u.signal,headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(vx({question:l,docs:h,appName:d.name,sessionId:u.sessionId,attachments:x}))}),"The docs-qa workflow could not start"),g=String((v==null?void 0:v.run_id)||"");if(!g)throw new Error("The gateway did not return a run id for the docs-qa workflow.");const w=new AbortController,L=()=>w.abort();u.signal.addEventListener("abort",L,{once:!0}),u.onText&&(async()=>{var $;try{const T=await m(Cs(`runs/${encodeURIComponent(g)}/ledger/stream?after=0`),{signal:w.signal,headers:{Accept:"text/event-stream"}});if(!T.ok||!T.body)return;let B="",O="";for await(const M of bx(T.body,w.signal)){const P=_x(M.event,M.data);!P||hx(P)||P.channel!=="content"||P.run_id!==g||(P.call_id!==B&&(B=P.call_id,O=""),O=P.snapshot?P.text:O+P.text,($=u.onText)==null||$.call(u,O))}}catch{}})();try{const $=Date.now()+r;for(;;){await wx(n,u.signal);const T=await Za(await m(Cs(`runs/${encodeURIComponent(g)}`),{signal:u.signal}),"The docs-qa run could not be read"),B=String((T==null?void 0:T.status)||"").toLowerCase();if(B==="completed"){(A=u.onHistory)==null||A.call(u,(T==null?void 0:T.session_history)??null);const O=Rp(T);if(!O)throw new Error(`The docs-qa run ${g} completed without an answer.`);return O}if(B==="failed"||B==="cancelled"){const O=T==null?void 0:T.error,M=typeof O=="string"?O:typeof(O==null?void 0:O.message)=="string"?O.message:"";throw new Error(`The docs-qa run ${B}${M?`: ${M}`:""}.`)}if(B==="waiting")throw new Error(`The docs-qa run ${g} is waiting for input it should never need. Inspect it in Observer.`);if(Date.now()>=$)throw new Error(`The docs-qa run ${g} is still running after ${Math.round(r/1e3)} s. It stays in the gateway's history.`)}}finally{u.signal.removeEventListener("abort",L),w.abort()}}}async function kx(s,n,r={}){const i=new URLSearchParams({root_only:"true",kind:Mp,limit:"500",include_ledger_len:"false"}),l=await Za(await s(Cs(`runs?${i}`),{signal:r.signal}),"The docs assistant history could not be read"),u=`${String(n||"app")}-docs-assistant:`,m=new Map;for(const h of Array.isArray(l==null?void 0:l.items)?l.items:[]){const x=String((h==null?void 0:h.session_id)||"");if(!x.startsWith(u)||!(h!=null&&h.run_id))continue;const v=m.get(x)||{runs:[],updatedAt:""};v.runs.push({id:String(h.run_id),created:String(h.created_at||"")});const g=String(h.updated_at||h.created_at||"");g>v.updatedAt&&(v.updatedAt=g),m.set(x,v)}const d=[...m.entries()].sort((h,x)=>h[1].updatedAt<x[1].updatedAt?1:-1).slice(0,r.max??20);return Promise.all(d.map(async([h,x])=>{var w;const v=x.runs.sort((L,A)=>L.created<A.created?-1:1).map(L=>L.id);let g="";try{const L=await Za(await s(Cs(`runs/${encodeURIComponent(v[0])}/input_data`),{signal:r.signal}),"");g=String(((w=L==null?void 0:L.input_data)==null?void 0:w.prompt)||"").trim()}catch{g=""}return{sessionId:h,title:g||"Untitled question",updatedAt:x.updatedAt,runIds:v}}))}async function Sx(s,n,r,i){var u;const l=[];for(const m of n.runIds){const[d,h]=await Promise.all([Za(await s(Cs(`runs/${encodeURIComponent(m)}/input_data`),{signal:i}),"A past question could not be read"),Za(await s(Cs(`runs/${encodeURIComponent(m)}`),{signal:i}),"A past answer could not be read")]),x=String(((u=d==null?void 0:d.input_data)==null?void 0:u.prompt)||"").trim();x&&l.push({id:`u-${m}`,role:"user",content:x,ts:String((h==null?void 0:h.created_at)||"")||void 0});const v=Rp(h),g=String((h==null?void 0:h.status)||"").toLowerCase();l.push(v?{id:`a-${m}`,role:"assistant",title:r,content:v,ts:String((h==null?void 0:h.updated_at)||"")||void 0}:{id:`a-${m}`,role:"assistant",title:r,level:"warn",content:g==="completed"?"This answer was empty.":`No answer: the run is ${g||"unknown"}.`})}return l}function Nx(s){const[n,r]=f.useState(null);return s.state==="loading"?e.jsx("div",{className:"pc-docs-history__note",role:"status",children:"Loading past conversations…"}):s.state==="error"?e.jsx("div",{className:"pc-docs-history__note pc-docs-history__note--error",role:"alert",children:s.error||"The history could not be read."}):s.items.length?e.jsx("ul",{className:"pc-docs-history","aria-label":"Past conversations",children:s.items.map(i=>e.jsx("li",{className:`pc-docs-history__row${i.sessionId===s.activeSessionId?" is-active":""}`,children:n===i.sessionId?e.jsxs("div",{className:"pc-docs-history__confirm",children:[e.jsx("span",{children:"Archive this conversation? It stays in the gateway; it leaves this list."}),e.jsx("button",{type:"button",className:"pc-docs-history__btn pc-docs-history__btn--danger",onClick:()=>{r(null),s.onArchive(i)},children:"Archive"}),e.jsx("button",{type:"button",className:"pc-docs-history__btn",onClick:()=>r(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"pc-docs-history__open",onClick:()=>s.onOpen(i),title:i.title,children:[e.jsx("span",{className:"pc-docs-history__title",children:i.title}),e.jsxs("span",{className:"pc-docs-history__meta",children:[pp(i.updatedAt,s.nowMs),i.runIds.length>1?` · ${i.runIds.length} questions`:""]})]}),e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":`Archive "${i.title}"`,"data-af-tip":`Archive "${i.title}" (kept, hidden)`,onClick:()=>r(i.sessionId),children:e.jsx(Ue,{name:"archive",size:16})})]})},i.sessionId))}):e.jsx("div",{className:"pc-docs-history__note",children:"No past conversations yet."})}const Cx=/^image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)$/i;function $x(s){const n=f.useRef(null),[r,i]=f.useState(!1),l=!!s.blockedNotice,u=!!s.busy,m=s.files||[],d=typeof s.onAddFiles=="function"&&!l,h=e.jsxs("div",{className:"pc-docs-assistant__empty",children:[e.jsxs("p",{className:"pc-docs-assistant__empty-text",children:["Ask anything about ",s.source.name,"."]}),s.suggestions&&s.suggestions.length?e.jsx("div",{className:"pc-docs-assistant__suggestions",children:s.suggestions.map(x=>e.jsx("button",{type:"button",className:"pc-docs-assistant__suggestion",disabled:u||l,onClick:()=>{var v;return(v=s.onSuggestion)==null?void 0:v.call(s,x)},children:x},x))}):null]});return e.jsxs("div",{className:`pc-docs-assistant${r?" is-dragging":""}`,onDragOver:x=>{var v;!d||!ox((v=x.dataTransfer)==null?void 0:v.types)||(x.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:x=>{var g,w;if(!d)return;x.preventDefault(),i(!1);const v=Ap(x.dataTransfer);v.files.length&&((g=s.onAddFiles)==null||g.call(s,v.files)),v.folders.length&&((w=s.onNotice)==null||w.call(s,lx(v.folders)))},children:[e.jsx(Rc,{className:"pc-docs-assistant__thread",messages:s.messages,autoScroll:!0,empty:h,messageProps:{showCopy:!0}}),l?e.jsx("div",{className:"pc-docs-assistant__blocked",role:"status",children:s.blockedNotice}):null,s.notice?e.jsx("div",{className:"pc-docs-assistant__notice",role:"status",children:s.notice}):null,e.jsx("div",{className:"pc-docs-assistant__composer",children:e.jsx(ol,{value:s.draft,onChange:s.onDraftChange,onSubmit:s.onSend,placeholder:s.placeholder||`Ask about ${s.source.name}…`,ariaLabel:`Question about ${s.source.name}`,disabled:l,busy:u,rows:1,sendLabel:"Send",busyLabel:"Answering…",onPaste:x=>{var g;if(!d)return;const v=dx(x.clipboardData);v.length&&(x.preventDefault(),(g=s.onAddFiles)==null||g.call(s,v))},leading:m.length?e.jsx("div",{className:"pc-chat-attachments pc-docs-assistant__files",role:"list","aria-label":"Attached files",children:m.map(x=>e.jsxs("span",{role:"listitem",className:"pc-chat-attachment-chip",children:[e.jsx(Ue,{name:"paperclip",size:14}),e.jsx("span",{className:"pc-chat-attachment-name",children:x.name}),s.onRemoveFile&&!u?e.jsx("button",{type:"button",className:"pc-docs-assistant__file-remove","aria-label":`Remove ${x.name}`,"data-af-tip":`Remove ${x.name}`,onClick:()=>{var v;return(v=s.onRemoveFile)==null?void 0:v.call(s,x.id)},children:e.jsx(Ue,{name:"x",size:12})}):null]},x.id))}):null,actions:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Attach files","data-af-tip":"Attach files to your question",disabled:u,onClick:()=>{var x;return(x=n.current)==null?void 0:x.click()},children:e.jsx(Ue,{name:"paperclip",size:16})}),e.jsx("input",{ref:n,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:x=>{var g;const v=Array.from(x.currentTarget.files||[]);x.currentTarget.value="",v.length&&((g=s.onAddFiles)==null||g.call(s,v))}})]}):null,u&&s.onStop?e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Stop","data-af-tip":"Stop the answer",onClick:s.onStop,children:e.jsx(Ue,{name:"stop",size:14})}):null]})})}),e.jsxs("div",{className:"pc-docs-assistant__footer",title:`Answers come from ${s.source.name}'s documentation (llms.txt) through the gateway's docs-qa workflow.`,children:["Grounded on ",s.source.name,"’s documentation (llms.txt) · docs-qa"]})]})}function vc(){return new Date().toISOString()}function Ex(s){Ud();const{source:n}=s,r=f.useRef(s.fetchGateway);r.current=s.fetchGateway;const i=f.useMemo(()=>s.ask||jx({fetchGateway:(H,X)=>r.current(H,X),source:n}),[s.ask,n.app,n.name]),l=f.useRef(rd(n.app)),[u,m]=f.useState([]),d=f.useRef(u);d.current=u;const[h,x]=f.useState(""),[v,g]=f.useState([]),[w,L]=f.useState(!1),[A,$]=f.useState(""),T=f.useRef(null),[B,O]=f.useState(!1),[M,P]=f.useState({state:"loading",items:[]});f.useEffect(()=>()=>{var H;return(H=T.current)==null?void 0:H.abort()},[]);const E=f.useCallback(async()=>{P(H=>({...H,state:"loading"}));try{const H=await kx((X,Z)=>r.current(X,Z),n.app);P({state:"ready",items:H})}catch(H){P({state:"error",items:[],error:String((H==null?void 0:H.message)||H)})}},[n.app]),Q=f.useCallback(async H=>{var X;(X=T.current)==null||X.abort(),P(Z=>({...Z,state:"loading"}));try{const Z=await Sx((U,Y)=>r.current(U,Y),H,n.name);l.current=H.sessionId,m(Z),$(""),O(!1),P(U=>({...U,state:"ready"}))}catch(Z){P(U=>({...U,state:"error",error:String((Z==null?void 0:Z.message)||Z)}))}},[n.name]),oe=f.useCallback(async H=>{try{const X=await r.current(Cs(`sessions/${encodeURIComponent(H.sessionId)}/archive`),{method:"POST"});if(!X.ok)throw await Lp(X,"The conversation could not be archived");l.current===H.sessionId&&(l.current=rd(n.app),m([])),P(Z=>({...Z,items:Z.items.filter(U=>U.sessionId!==H.sessionId)}))}catch(X){P(Z=>({...Z,state:"error",error:String((X==null?void 0:X.message)||X)}))}},[n.app]);f.useEffect(()=>{var H;s.connected||(H=T.current)==null||H.abort()},[s.connected]),f.useEffect(()=>()=>{for(const H of v)H.preview&&URL.revokeObjectURL(H.preview)},[]);const G=f.useCallback(H=>{$(""),g(X=>[...X,...H.map(Z=>({id:Yo(),file:Z,preview:Cx.test(Z.type)&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(Z):void 0}))])},[]),Ne=f.useCallback(async H=>{const X=String(H||"").trim();if(!X||w||!s.connected)return;const Z=v;x(""),g([]),$("");const U=Z.filter(he=>he.preview).map(he=>({kind:"image",src:he.preview,label:he.file.name})),Y=Z.map(he=>({id:he.id,label:he.file.name,title:he.file.name,disabled:!0})),I={id:`u-${Yo()}`,role:"user",content:X,ts:vc(),...U.length?{media:U}:{},...Y.length?{attachments:Y}:{}},te=`a-${Yo()}`,ae=[...d.current,I],k={id:te,role:"assistant",title:n.name,content:"",ts:vc(),live:{callId:te,reasoning:"",label:"answering"}};m([...ae,k]),L(!0);const C=new AbortController;T.current=C;const re=he=>m([...ae,he]);try{const he=await i(X,{signal:C.signal,sessionId:l.current,files:Z.map(le=>le.file),onText:le=>{C.signal.aborted||re({...k,content:le,live:{callId:te,reasoning:"",label:"streaming"}})},onHistory:le=>$(xx(le))});C.signal.aborted||re({id:te,role:"assistant",title:n.name,content:he,ts:vc()})}catch(he){const le=C.signal.aborted;re({id:te,role:"assistant",title:n.name,level:le?"warn":"error",content:le?"Stopped. Nothing more will be shown for this question.":String((he==null?void 0:he.message)||he||"The docs assistant failed."),ts:vc()})}finally{T.current===C&&(T.current=null),L(!1)}},[i,w,v,s.connected,n.name]),je=()=>{var H;(H=T.current)==null||H.abort(),l.current=rd(n.app),m([]),g([]),x(""),$("")},we=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`pc-docs-assistant__icon-btn${B?" is-active":""}`,"aria-label":"Past conversations","data-af-tip":"Past conversations","aria-pressed":B,disabled:!s.connected||w,onClick:()=>{const H=!B;O(H),H&&E()},children:e.jsx(Ue,{name:"history",size:16})}),e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"New conversation","data-af-tip":"Start a new conversation",disabled:!u.length&&!h&&!v.length&&!B,onClick:()=>{je(),O(!1)},children:e.jsx(Ue,{name:"compose",size:16})})]}),ve=e.jsxs(e.Fragment,{children:[B?e.jsx("div",{className:"pc-docs-assistant pc-docs-assistant--history",children:e.jsx(Nx,{items:M.items,state:M.state,error:M.error,nowMs:Date.now(),activeSessionId:l.current,onOpen:H=>void Q(H),onArchive:H=>void oe(H)})}):null,e.jsx("div",{hidden:B,style:{display:B?"none":"contents"},children:e.jsx($x,{source:n,messages:u,draft:h,onDraftChange:x,onSend:()=>void Ne(h),onStop:()=>{var H;return(H=T.current)==null?void 0:H.abort()},busy:w,blockedNotice:s.connected?void 0:"Connect to the gateway to use the docs assistant.",files:v.map(H=>({id:H.id,name:H.file.name})),onAddFiles:G,onNotice:$,onRemoveFile:H=>g(X=>{const Z=X.find(U=>U.id===H);return Z!=null&&Z.preview&&URL.revokeObjectURL(Z.preview),X.filter(U=>U.id!==H)}),notice:A,suggestions:s.suggestions,onSuggestion:H=>void Ne(H),placeholder:s.placeholder})})]});return{headerActions:we,body:ve}}function Tx(s){const{headerActions:n,body:r}=Ex(s);return e.jsx(Nd,{open:s.open,onClose:s.onClose,label:"Docs assistant",title:e.jsxs("span",{className:"pc-docs-assistant__title",children:[e.jsx(Ue,{name:"book",size:16}),"Docs assistant"]}),width:s.width||420,topOffset:s.topOffset,manageFocus:s.manageFocus===!0,className:`pc-docs-assistant-drawer${s.className?` ${s.className}`:""}`,headerActions:n,children:r})}function Ax(s){const n=s.trim();if(!n)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return n}const Lx=Ax("0.7.3");function xc(s){return s?s.value!==void 0&&s.value!==null?!!s.value:s.enabled!==void 0?!!s.enabled:s.configured!==void 0?!!s.configured:s.path!==void 0?!!s.path:null:null}function Do(s){if(!s)return"";const n=s.value!==void 0&&s.value!==null?s.value:s.id??s.path??"";return typeof n=="string"?n.trim():""}const ch="abstractcontinuum_gateway_csrf",Mx="x-abstractcontinuum-csrf",Rx="x-abstract-csrf";function id(s){var i;const n=(s||"").trim(),r={};n&&(r.Authorization=`Bearer ${n}`);try{const l=(i=document.cookie.split(";").map(u=>u.trim()).find(u=>u.startsWith(`${ch}=`)))==null?void 0:i.slice(`${ch}=`.length);if(l){const u=decodeURIComponent(l);r[Mx]=u,r[Rx]=u}}catch{}return r}function uh(s){const n={},r=(i,l)=>{const u=String(l||"").trim();u&&(n[i]=u)};return r("provider",s==null?void 0:s.provider),r("model",s==null?void 0:s.model),r("profile",s==null?void 0:s.profile),r("voice",s==null?void 0:s.voice),r("quality_preset",s==null?void 0:s.quality_preset),n}async function Px(s){try{const n=await s.text();return n!=null&&n.trim()?n.trim():`${s.status}`}catch{return`${s.status}`}}class Pp extends Error{constructor(r,i,l){super(r);Ka(this,"status");Ka(this,"body");this.name="GatewayRequestError",this.status=i,this.body=l}}const od=[15,30,60,120];class zx{constructor(n){Ka(this,"_cfg");Ka(this,"_backoff_until",0);Ka(this,"_backoff_step",0);Ka(this,"fetch_gateway",(n,r)=>{const i=new Headers((r==null?void 0:r.headers)||{});for(const[l,u]of Object.entries(id(this._cfg.auth_token)))i.set(l,u);return fetch(Yu(this._cfg.base_url,n),{...r,headers:i})});this._cfg={...n,base_url:(n.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(n,r,i){const l=await fetch(Yu(this._cfg.base_url,r),{...i,headers:{...i==null?void 0:i.headers,...id(this._cfg.auth_token)}});if(l.ok)return this._backoff_step=0,this._backoff_until=0,l;const u=await Px(l);let m=null;try{m=JSON.parse(u)}catch{}let d=u;if(m&&typeof m=="object"&&m.detail!==void 0&&(d=typeof m.detail=="string"?m.detail:JSON.stringify(m.detail)),l.status===429||/too many requests|auth lockout|locked/i.test(d)){const x=od[Math.min(this._backoff_step,od.length-1)];this._backoff_until=Date.now()+x*1e3,this._backoff_step<od.length-1&&(this._backoff_step+=1)}throw new Pp(`${n} failed: ${d}`,l.status,m)}async _get_json(n,r){return await(await this._fetch(n,r)).json()}async _post_json(n,r,i){return await(await this._fetch(n,r,{method:"POST",headers:i===void 0?void 0:{"Content-Type":"application/json"},body:i===void 0?void 0:JSON.stringify(i)})).json()}async _post_form(n,r,i){return await(await this._fetch(n,r,{method:"POST",body:i})).json()}async list_runs(n){const r=new URLSearchParams;r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"?n.limit:50));const i=String((n==null?void 0:n.status)||"").trim();i&&r.set("status",i);const l=String((n==null?void 0:n.session_id)||"").trim();return l&&r.set("session_id",l),(n==null?void 0:n.root_only)===!0&&r.set("root_only","true"),await this._get_json("list_runs",`api/gateway/runs?${r.toString()}`)}async download_run_artifact_content(n,r,i){const l=String(n||"").trim(),u=String(r||"").trim();if(!l)throw new Error("download_run_artifact_content: run_id is required");if(!u)throw new Error("download_run_artifact_content: artifact_id is required");const m=String((i==null?void 0:i.access)||"").trim(),d=m?`?access=${encodeURIComponent(m)}`:"";return await(await this._fetch("download_run_artifact_content",`api/gateway/runs/${encodeURIComponent(l)}/artifacts/${encodeURIComponent(u)}/content${d}`)).blob()}async attachments_upload(n,r,i){const l=String(n||"").trim();if(!l)throw new Error("attachments_upload: session_id is required");if(!r)throw new Error("attachments_upload: file is required");const u=String((i==null?void 0:i.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",m=String((i==null?void 0:i.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),d=new FormData;d.append("session_id",l),d.append("file",r,u),d.append("filename",u),m&&d.append("content_type",m);const h=await this._post_form("attachments_upload","api/gateway/attachments/upload",d),x=h==null?void 0:h.attachment;if(!x||typeof x!="object")throw new Error("attachments_upload: missing attachment");if(!String(x.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return x}async audio_transcribe(n,r){const i=String(n||"").trim();if(!i)throw new Error("audio_transcribe: run_id is required");const l=r==null?void 0:r.audio_artifact;if(!l||typeof l!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(l.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const m={audio_artifact:l},d=String((r==null?void 0:r.language)||"").trim();d&&(m.language=d);const h=String((r==null?void 0:r.request_id)||"").trim();h&&(m.request_id=h);const x=await this._post_json("audio_transcribe",`api/gateway/runs/${encodeURIComponent(i)}/audio/transcribe`,m);return{ok:!!(x!=null&&x.ok),run_id:String((x==null?void 0:x.run_id)||""),request_id:String((x==null?void 0:x.request_id)||""),text:String((x==null?void 0:x.text)||""),transcript_artifact:x==null?void 0:x.transcript_artifact}}async voice_tts(n,r){const i=String(n||"").trim();if(!i)throw new Error("voice_tts: run_id is required");const l=String((r==null?void 0:r.text)||"").trim();if(!l)throw new Error("voice_tts: text is required");const u={text:l,...uh(r)},m=String((r==null?void 0:r.format)||"").trim();m&&(u.format=m),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(u.timeout_s=r.timeout_s);const d=String((r==null?void 0:r.request_id)||"").trim();d&&(u.request_id=d);const h=await this._post_json("voice_tts",`api/gateway/runs/${encodeURIComponent(i)}/voice/tts`,u);return{ok:!!(h!=null&&h.ok),run_id:String((h==null?void 0:h.run_id)||""),request_id:String((h==null?void 0:h.request_id)||""),audio_artifact:h==null?void 0:h.audio_artifact}}async capability_defaults(){return await this._get_json("capability_defaults","api/gateway/config/capability-defaults")}async voice_voices(n){const r=new URLSearchParams({compact:"true"}),i=String((n==null?void 0:n.provider)||"").trim(),l=String((n==null?void 0:n.model)||"").trim();return i&&r.set("provider",i),l&&r.set("model",l),n!=null&&n.providers_only&&r.set("providers_only","true"),await this._get_json("voice_voices",`api/gateway/voice/voices?${r.toString()}`)}voice_stream_transport(n,r){const i=String(n||"").trim();if(!i)throw new Error("voice_stream_transport: run_id is required");return{path:Yu(this._cfg.base_url,`api/gateway/runs/${encodeURIComponent(i)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...uh(r)},headers:id(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(n){const r=String(n||"").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(n){const r=String(n||"").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(n){return await this._post_json("bug_report_create","api/gateway/bugs/report",dh(n,"bug_report_create"))}async feature_report_create(n){return await this._post_json("feature_report_create","api/gateway/features/report",dh(n,"feature_report_create"))}async email_list_accounts(){return await this._get_json("email_list_accounts","api/gateway/email/accounts")}async email_list_messages(n){const r=new URLSearchParams,i=String((n==null?void 0:n.account)||"").trim();i&&r.set("account",i);const l=String((n==null?void 0:n.mailbox)||"").trim();l&&r.set("mailbox",l);const u=String((n==null?void 0:n.since)||"").trim();u&&r.set("since",u);const m=String((n==null?void 0:n.status)||"").trim();return m&&r.set("status",m),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):20)),await this._get_json("email_list_messages",`api/gateway/email/messages?${r.toString()}`)}async email_read_message(n,r){const i=String(n||"").trim();if(!i)throw new Error("email_read_message: uid is required");const l=new URLSearchParams,u=String((r==null?void 0:r.account)||"").trim();u&&l.set("account",u);const m=String((r==null?void 0:r.mailbox)||"").trim();m&&l.set("mailbox",m);const d=typeof(r==null?void 0:r.max_body_chars)=="number"&&Number.isFinite(r.max_body_chars)?Number(r.max_body_chars):2e4;return l.set("max_body_chars",String(d)),await this._get_json("email_read_message",`api/gateway/email/messages/${encodeURIComponent(i)}?${l.toString()}`)}async email_send(n){if(!String((n==null?void 0:n.subject)||"").trim())throw new Error("email_send: subject is required");return await this._post_json("email_send","api/gateway/email/send",n||{})}async triage_run(n){const r={};return typeof(n==null?void 0:n.write_drafts)=="boolean"&&(r.write_drafts=!!n.write_drafts),typeof(n==null?void 0:n.enable_llm)=="boolean"&&(r.enable_llm=!!n.enable_llm),await this._post_json("triage_run","api/gateway/triage/run",r)}async list_triage_decisions(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):200)),await this._get_json("list_triage_decisions",`api/gateway/triage/decisions?${r.toString()}`)}async apply_triage_decision(n,r){const i=String(n||"").trim();if(!i)throw new Error("apply_triage_decision: decision_id is required");const l=String((r==null?void 0:r.action)||"").trim();if(!l)throw new Error("apply_triage_decision: action is required");const u={action:l};if(l==="defer"){const m=r==null?void 0:r.defer_days;typeof m=="number"&&Number.isFinite(m)&&m>0&&(u.defer_days=Number(m))}return await this._post_json("apply_triage_decision",`api/gateway/triage/decisions/${encodeURIComponent(i)}/apply`,u)}async backlog_list(n){const r=String(n||"").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(n,r){const i=String(n||"").trim(),l=String(r||"").trim();if(!i)throw new Error("backlog_content: kind is required");if(!l)throw new Error("backlog_content: filename is required");return await this._get_json("backlog_content",`api/gateway/backlog/${encodeURIComponent(i)}/${encodeURIComponent(l)}/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(n){const r=String((n==null?void 0:n.from_kind)||"").trim(),i=String((n==null?void 0:n.to_kind)||"").trim(),l=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_move: from_kind is required");if(!i)throw new Error("backlog_move: to_kind is required");if(!l)throw new Error("backlog_move: filename is required");return await this._post_json("backlog_move","api/gateway/backlog/move",{from_kind:r,to_kind:i,filename:l})}async backlog_update(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_update: kind is required");if(!i)throw new Error("backlog_update: filename is required");const l={content:String((n==null?void 0:n.content)??"")},u=String((n==null?void 0:n.expected_sha256)||"").trim();return u&&(l.expected_sha256=u),await this._post_json("backlog_update",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/update`,l)}async backlog_create(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_create: kind is required");if(!i)throw new Error("backlog_create: package is required");if(!l)throw new Error("backlog_create: title is required");const u={kind:r,package:i,title:l},m=String((n==null?void 0:n.task_type)||"").trim();m&&(u.task_type=m);const d=String((n==null?void 0:n.summary)||"").trim();d&&(u.summary=d);const h=(n==null?void 0:n.content)==null?"":String((n==null?void 0:n.content)??"");return h.trim()&&(u.content=h),await this._post_json("backlog_create","api/gateway/backlog/create",u)}async backlog_merge(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim(),u=Array.isArray(n==null?void 0:n.items)?n.items:[];if(!r)throw new Error("backlog_merge: kind is required");if(!i)throw new Error("backlog_merge: package is required");if(!l)throw new Error("backlog_merge: title is required");if(u.length<2)throw new Error("backlog_merge: at least 2 items are required");const m={kind:r,package:i,title:l,items:u.map(x=>({kind:String((x==null?void 0:x.kind)||"").trim(),filename:String((x==null?void 0:x.filename)||"").trim()}))},d=String((n==null?void 0:n.task_type)||"").trim();d&&(m.task_type=d);const h=String((n==null?void 0:n.summary)||"").trim();return h&&(m.summary=h),await this._post_json("backlog_merge","api/gateway/backlog/merge",m)}async backlog_upload_attachment(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim(),l=n==null?void 0:n.file;if(!r)throw new Error("backlog_upload_attachment: kind is required");if(!i)throw new Error("backlog_upload_attachment: filename is required");if(!l)throw new Error("backlog_upload_attachment: file is required");const u=new FormData;return u.set("overwrite",(n==null?void 0:n.overwrite)===!0?"true":"false"),u.set("file",l,l.name||"attachment"),await this._post_form("backlog_upload_attachment",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/attachments/upload`,u)}async backlog_assist(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_assist: kind is required");if(!i)throw new Error("backlog_assist: package is required");if(!l)throw new Error("backlog_assist: title is required");const u={kind:r,package:i,title:l,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},m=String((n==null?void 0:n.summary)||"").trim();m&&(u.summary=m);const d=(n==null?void 0:n.draft_markdown)==null?"":String(n.draft_markdown??"");d.trim()&&(u.draft_markdown=d);const h=String((n==null?void 0:n.provider)||"").trim();h&&(u.provider=h);const x=String((n==null?void 0:n.model)||"").trim();x&&(u.model=x);const v=String((n==null?void 0:n.thinking)||"").trim();return v&&(u.thinking=v),await this._post_json("backlog_assist","api/gateway/backlog/assist",u)}async backlog_maintain(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim(),l=String((n==null?void 0:n.package)||"").trim(),u=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_maintain: kind is required");if(!i)throw new Error("backlog_maintain: filename is required");if(!l)throw new Error("backlog_maintain: package is required");if(!u)throw new Error("backlog_maintain: title is required");const m={kind:r,filename:i,package:l,title:u,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},d=String((n==null?void 0:n.summary)||"").trim();d&&(m.summary=d);const h=(n==null?void 0:n.draft_markdown)==null?"":String(n.draft_markdown??"");h.trim()&&(m.draft_markdown=h);const x=String((n==null?void 0:n.provider)||"").trim();x&&(m.provider=x);const v=String((n==null?void 0:n.model)||"").trim();return v&&(m.model=v),await this._post_json("backlog_maintain","api/gateway/backlog/maintain",m)}async backlog_advisor(n){const r={messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},i=String((n==null?void 0:n.provider)||"").trim();i&&(r.provider=i);const l=String((n==null?void 0:n.model)||"").trim();l&&(r.model=l);const u=String((n==null?void 0:n.thinking)||"").trim();u&&(r.thinking=u);const m=String((n==null?void 0:n.agent)||"").trim();m&&(r.agent=m),(n==null?void 0:n.include_trace)===!0&&(r.include_trace=!0);const d=String((n==null?void 0:n.focus_kind)||"").trim();d&&(r.focus_kind=d);const h=String((n==null?void 0:n.focus_type)||"").trim();return h&&(r.focus_type=h),await this._post_json("backlog_advisor","api/gateway/backlog/advisor",r)}async backlog_execute(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_execute: kind is required");if(!i)throw new Error("backlog_execute: filename is required");const l=new URLSearchParams,u=String((n==null?void 0:n.execution_mode)||"").trim();u&&l.set("execution_mode",u);const m=String((n==null?void 0:n.executor)||"").trim();m&&l.set("executor",m);const d=String((n==null?void 0:n.target_model)||"").trim();d&&l.set("target_model",d);const h=String((n==null?void 0:n.target_reasoning_effort)||"").trim();return h&&l.set("target_reasoning_effort",h),(n==null?void 0:n.dor)==="check"&&l.set("dor","check"),(n==null?void 0:n.override)===!0&&l.set("override","true"),await(await this._fetch("backlog_execute",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/execute${l.toString()?`?${l.toString()}`:""}`,{method:"POST"})).json()}async backlog_execute_batch(n){const r=Array.isArray(n==null?void 0:n.items)?n.items:[];if(!r.length)throw new Error("backlog_execute_batch: items are required");const i={items:r.map(h=>({kind:String((h==null?void 0:h.kind)||"").trim(),filename:String((h==null?void 0:h.filename)||"").trim()}))},l=String((n==null?void 0:n.execution_mode)||"").trim();l&&(i.execution_mode=l);const u=String((n==null?void 0:n.executor)||"").trim();u&&(i.executor=u);const m=String((n==null?void 0:n.target_model)||"").trim();m&&(i.target_model=m);const d=String((n==null?void 0:n.target_reasoning_effort)||"").trim();return d&&(i.target_reasoning_effort=d),(n==null?void 0:n.dor)==="check"&&(i.dor="check"),(n==null?void 0:n.override)===!0&&(i.override=!0),await this._post_json("backlog_execute_batch","api/gateway/backlog/execute_batch",i)}async backlog_exec_config(){return await this._get_json("backlog_exec_config","api/gateway/backlog/exec/config")}async backlog_exec_requests(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):200)),await this._get_json("backlog_exec_requests",`api/gateway/backlog/exec/requests?${r.toString()}`)}async backlog_exec_request(n,r){const i=String(n||"").trim();if(!i)throw new Error("backlog_exec_request: request_id is required");const l=new URLSearchParams;return(r==null?void 0:r.include_prompt)===!0&&l.set("include_prompt","true"),await this._get_json("backlog_exec_request",`api/gateway/backlog/exec/requests/${encodeURIComponent(i)}?${l.toString()}`)}async backlog_exec_feedback(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_feedback: request_id is required");const i=String((n==null?void 0:n.feedback)??"");if(!i.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:i})}async backlog_exec_promote(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_promote: request_id is required");const i={};return(n==null?void 0:n.redeploy)===!0&&(i.redeploy=!0),await this._post_json("backlog_exec_promote",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/promote`,i)}async backlog_exec_deploy_uat(n){const r=String((n==null?void 0:n.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(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_log_tail: request_id is required");const i=new URLSearchParams,l=String((n==null?void 0:n.name)||"").trim();l&&i.set("name",l);const u=typeof(n==null?void 0:n.max_bytes)=="number"&&Number.isFinite(n.max_bytes)?Number(n.max_bytes):0;u>0&&i.set("max_bytes",String(Math.floor(u)));const m=typeof(n==null?void 0:n.after_bytes)=="number"&&Number.isFinite(n.after_bytes)?Math.max(0,Math.floor(n.after_bytes)):null;return m!==null&&i.set("after_bytes",String(m)),await this._get_json("backlog_exec_log_tail",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/logs/tail?${i.toString()}`)}async backlog_exec_active_items(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.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(n){const r=String(n||"").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(n){const r=String(n||"").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(n){return await(await this._fetch("admin_runtime_config_update","api/gateway/admin/runtime-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n||{})})).json()}async entity_state(n,r){return await(await this._fetch("entity_state",`api/gateway/entities/${encodeURIComponent(n)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()}async entity_skills(n){return await(await this._fetch("entity_skills",`api/gateway/entities/${encodeURIComponent(n)}/skills`)).json()}async put_entity_skills(n,r){return await(await this._fetch("put_entity_skills",`api/gateway/entities/${encodeURIComponent(n)}/skills`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({skills:r})})).json()}async list_bundles(){return await(await this._fetch("list_bundles","api/gateway/bundles")).json()}async admin_data_homes(){return await(await this._fetch("admin_data_homes","api/gateway/admin/data-homes")).json()}async gateway_about(){return await this._get_json("gateway_about","api/gateway/about")}async list_processes(){return await this._get_json("list_processes","api/gateway/processes")}async list_process_env_vars(){return await this._get_json("list_process_env_vars","api/gateway/processes/env")}async update_process_env_vars(n){const r={},i=n!=null&&n.set&&typeof n.set=="object"?n.set:{},l=Array.isArray(n==null?void 0:n.unset)?n==null?void 0:n.unset:[];return i&&Object.keys(i).length&&(r.set=i),l&&l.length&&(r.unset=l),await this._post_json("update_process_env_vars","api/gateway/processes/env",r)}async start_process(n){const r=String(n||"").trim();return await this._post_json("start_process",`api/gateway/processes/${encodeURIComponent(r)}/start`)}async stop_process(n){const r=String(n||"").trim();return await this._post_json("stop_process",`api/gateway/processes/${encodeURIComponent(r)}/stop`)}async restart_process(n){const r=String(n||"").trim();return await this._post_json("restart_process",`api/gateway/processes/${encodeURIComponent(r)}/restart`)}async redeploy_process(n){const r=String(n||"").trim();return await this._post_json("redeploy_process",`api/gateway/processes/${encodeURIComponent(r)}/redeploy`)}async process_log_tail(n,r){const i=String(n||"").trim(),l=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(i)}/logs/tail?max_bytes=${encodeURIComponent(String(l))}`)}}function dh(s,n){const r=String((s==null?void 0:s.session_id)||"").trim();if(!r)throw new Error(`${n}: session_id is required`);const i=String((s==null?void 0:s.description)||"").trim();if(!i)throw new Error(`${n}: description is required`);const l={session_id:r,description:i};for(const m of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const d=String((s==null?void 0:s[m])||"").trim();d&&(l[m]=d)}const u=s==null?void 0:s.context;return u&&typeof u=="object"&&(l.context=u),l}const mh={framework:null,gateway:null,gatewayNote:"checking…"};function Ix(s){if(s instanceof Pp){const r=s.message.replace(/^gateway_about failed:\s*/,"").trim();return`HTTP ${s.status}${r&&r!==String(s.status)?`: ${r}`:""}`}return(s instanceof Error?s.message:String(s))||"request failed"}async function Dx(s){let n;try{n=await s.gateway_about()}catch(r){return Xo(null,Ix(r))}return Xo(n)}const fh=Vd("voice and camera")??"Voice and camera are not supported in this browser (getUserMedia unavailable).",Ox="Copy failed — select and copy";function hh(){var n;const s=globalThis.navigator;return typeof((n=s==null?void 0:s.mediaDevices)==null?void 0:n.getUserMedia)=="function"}function Fx(s){var l;const n=globalThis.document;if(!n||!n.body||typeof n.execCommand!="function")return!1;const r=n.createElement("textarea");r.value=s,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="0",r.style.left="-9999px",r.style.opacity="0";const i=n.activeElement;n.body.appendChild(r);try{return r.select(),r.setSelectionRange(0,s.length),n.execCommand("copy")===!0}catch{return!1}finally{n.body.removeChild(r);try{(l=i==null?void 0:i.focus)==null||l.call(i)}catch{}}}async function qx(s){var i;const n=String(s??""),r=globalThis.navigator;if(typeof((i=r==null?void 0:r.clipboard)==null?void 0:i.writeText)=="function")try{return await r.clipboard.writeText(n),!0}catch{}return Fx(n)}const Bx=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ux(s){const n=s.length,r=new Uint8Array(n+9+63>>6<<6);r.set(s),r[n]=128;const i=new DataView(r.buffer);i.setUint32(r.length-8,Math.floor(n/536870912),!1),i.setUint32(r.length-4,n<<3>>>0,!1);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),m=(d,h)=>d>>>h|d<<32-h;for(let d=0;d<r.length;d+=64){for(let T=0;T<16;T++)u[T]=i.getUint32(d+T*4,!1);for(let T=16;T<64;T++){const B=m(u[T-15],7)^m(u[T-15],18)^u[T-15]>>>3,O=m(u[T-2],17)^m(u[T-2],19)^u[T-2]>>>10;u[T]=u[T-16]+B+u[T-7]+O>>>0}let[h,x,v,g,w,L,A,$]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let T=0;T<64;T++){const B=m(w,6)^m(w,11)^m(w,25),O=w&L^~w&A,M=$+B+O+Bx[T]+u[T]>>>0,P=m(h,2)^m(h,13)^m(h,22),E=h&x^h&v^x&v,Q=P+E>>>0;$=A,A=L,L=w,w=g+M>>>0,g=v,v=x,x=h,h=M+Q>>>0}l[0]=l[0]+h>>>0,l[1]=l[1]+x>>>0,l[2]=l[2]+v>>>0,l[3]=l[3]+g>>>0,l[4]=l[4]+w>>>0,l[5]=l[5]+L>>>0,l[6]=l[6]+A>>>0,l[7]=l[7]+$>>>0}return Array.from(l,d=>d.toString(16).padStart(8,"0")).join("")}async function zp(s){var i;const n=new TextEncoder().encode(String(s??"")),r=(i=globalThis.crypto)==null?void 0:i.subtle;if(r&&typeof r.digest=="function"){const l=await r.digest("SHA-256",n);return Array.from(new Uint8Array(l),u=>u.toString(16).padStart(2,"0")).join("")}return Ux(n)}const Wx=/^[a-zA-Z0-9_-]+$/;function ph(s){return Wx.test(String(s||"").trim())}async function Hx(s){const n=String(s||""),r=new TextEncoder().encode(n),i=globalThis.crypto;if(!i||!i.subtle||typeof i.subtle.digest!="function")return"";const l=await i.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}async function Kd(s){const n=String(s||"").trim();if(!n)throw new Error("session_id is required");if(ph(n)){const i=`session_memory_${n}`;if(ph(i))return i}return`session_memory_sha_${(await Hx(n)).slice(0,32)}`}const er=["bug","feature","improvement","task"];function tl(s){return String(s||"").trim().toLowerCase()}function Ip(s){return er.includes(tl(s))}function Dp(s){const n=tl(s);return Ip(n)?n:"task"}function Op(s){return s.toUpperCase()}function Fp(s){return s==="bug"?"danger":s==="feature"?"ok":s==="improvement"?"info":s==="task"?"task":"muted"}function qp(s){return Ip(s)?void 0:`"${s}" is not in the ruled type vocabulary (${er.join(" / ")})`}function Bp(s){const n=String(s||"").trim();return n.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||n}function _a(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function $d(s=new Date){const n=d=>String(d).padStart(2,"0"),r=-s.getTimezoneOffset(),i=r>=0?"+":"-",l=Math.abs(r),u=n(Math.floor(l/60)),m=n(l%60);return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())} ${i}${u}${m}`}function Vx(s){try{return JSON.parse(s)}catch{return null}}function _h(s,n){return s.scrollHeight-s.scrollTop-s.clientHeight<=n}function ld(s){const n=typeof s=="string"?s.trim():"";if(!n)return null;const r=n.replace(/(\.\d{3})\d+/,"$1"),i=Date.parse(r);return Number.isFinite(i)?i:null}function Hs(s){if(!Number.isFinite(s))return"";const n=Math.max(0,Math.floor(s/1e3)),r=n%60,i=Math.floor(n/60),l=i%60,u=Math.floor(i/60),m=u%24,d=Math.floor(u/24);return d>0?`${d}d ${m}h`:u>0?`${u}h ${l}m`:i>0?`${i}m ${r}s`:`${n}s`}async function Ed(s){return zp(String(s||""))}function Zo(s){const n=String(s||"").trim().toLowerCase();return n==="completed"||n==="promoted"?"ok":n==="failed"?"danger":n==="running"?"info":n==="queued"||n==="awaiting_qa"?"warn":"muted"}function Gx(s,n){return s==="processing"?"queued,running,awaiting_qa":s==="failed"?"failed":s==="completed"&&n==="runs"?"completed,promoted":""}function Oo(s,n){const r=s&&typeof s=="object"?s:{},i=r.backlog&&typeof r.backlog=="object"?r.backlog:{},l=r.result&&typeof r.result=="object"?r.result:{},u=r.executor&&typeof r.executor=="object"?r.executor:{},m=String(l.last_message||"").trim(),d=String(r.target_model||u.model||"").trim(),h=String(r.target_reasoning_effort||u.reasoning_effort||"").trim();return{request_id:n,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:i.relpath??null,backlog_kind:i.kind??null,backlog_filename:i.filename??null,target_agent:r.target_agent??null,target_model:d||null,target_reasoning_effort:h||null,executor_type:u.type??null,ok:typeof l.ok=="boolean"?l.ok:null,exit_code:typeof l.exit_code=="number"?l.exit_code:l.exit_code??null,error:typeof l.error=="string"?l.error:l.error??null,run_dir_relpath:r.run_dir_relpath??null,last_message:Kx(m)}}const cd=1200;function Kx(s){const n=String(s||"");return n?n.length<=cd?n:`${n.slice(0,cd)}
61
- … [#TRUNCATION: ${cd} of ${n.length} chars; the full last_message is in the run directory]`:null}function Jx(s){const n=String(s||""),r=n.split(/\r?\n/).filter(u=>String(u||"").trim().length>0),i=[];let l=0;for(let u=0;u<r.length;u+=1){const m=String(r[u]||"").trim(),d=Vx(m);if(!d||typeof d!="object"){l+=1,i.push({idx:u,type:"raw",payload:null,raw:m});continue}const h=String(d.type||d.event||"event");i.push({idx:u,type:h,payload:d,raw:m})}return{total:r.length,bad:l,events:i,raw:n}}function Qx(s){if(!s)return null;let n=0,r=0,i=0,l=0,u=0;for(const d of s.events){const h=d.payload,x=h&&typeof h.usage=="object"?h.usage:null;x&&(Number.isFinite(Number(x.input_tokens))&&(n+=Number(x.input_tokens)),Number.isFinite(Number(x.cached_input_tokens))&&(r+=Number(x.cached_input_tokens)),Number.isFinite(Number(x.output_tokens))&&(i+=Number(x.output_tokens)));const v=h&&typeof h.item=="object"?h.item:null;v&&String(v.type||"").trim()==="command_execution"&&(l+=1,String(v.status||"").trim().toLowerCase()==="failed"&&(u+=1))}return{has_tokens:n>0||i>0||r>0,input_tokens:n,cached_input_tokens:r,output_tokens:i,total_tokens:n+i,command_count:l,command_fail_count:u}}function nl(s,n=Date.now()){const r=ld(s==null?void 0:s.created_at),i=ld(s==null?void 0:s.started_at),l=ld(s==null?void 0:s.finished_at),u=String((s==null?void 0:s.status)||"").trim().toLowerCase(),m=l??(u==="running"?n:null),d=l!=null,h=r!=null&&i!=null?Math.max(0,i-r):null,x=i!=null&&m!=null?Math.max(0,m-i):null,v=r!=null&&m!=null?Math.max(0,m-r):null,g=!d&&r!=null?Math.max(0,n-r):null;return{is_done:d,queue_delay_ms:h,run_ms:x,total_ms:v,age_ms:g}}function Yx(s,n){const r=String(n.package_name).trim()||"{Package}",i=Bp(String(n.title||"").trim()||"{Title}"),l=String(n.summary||"").trim(),u=Dp(n.task_type),m=`# {ID}-${r}: [${Op(u)}] ${i}`.trim();let d=String(s||"");d=d.split("{Package}").join(r).split("{Title}").join(i);const h=d.split(/\r?\n/);let x=!1;for(let A=0;A<h.length;A+=1){const $=String(h[A]||"");if($.trim().startsWith("# ")){h[A]=m,x=!0;break}if($.trim())break}x||(h.unshift("",m),h.shift());const v=`> Created: ${String(n.created_at||"").trim()}`.trim();let g=!1;for(let A=0;A<Math.min(h.length,40);A+=1)if(String(h[A]||"").trim().toLowerCase().startsWith("> created:")){h[A]=v,g=!0;break}if(!g){const A=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice(A,0,v,"")}const w=`> Type: ${u}`.trim();let L=!1;for(let A=0;A<Math.min(h.length,60);A+=1)if(String(h[A]||"").trim().toLowerCase().startsWith("> type:")){h[A]=w,L=!0;break}if(!L){let A=-1;for(let $=0;$<Math.min(h.length,60);$+=1)if(String(h[$]||"").trim().toLowerCase().startsWith("> created:")){A=$;break}if(A>=0){const $=A+1;$<h.length&&!String(h[$]||"").trim()?h.splice($,0,w):h.splice($,0,w,"")}else{const $=h.length>1&&!String(h[1]||"").trim()?2:1;h.splice($,0,w,"")}}if(l){for(let A=0;A<h.length;A+=1)if(String(h[A]||"").trim().toLowerCase()==="## summary"){let $=A+1;for(;$<h.length&&!String(h[$]||"").trim();)$+=1;($<h.length?String(h[$]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?h[$]=l:h.splice(A+1,0,l,"");break}}return d=h.join(`
62
- `),d.endsWith(`
63
- `)||(d+=`
64
- `),d}function Ja(s){return String(s||"").split(/\r?\n/).map(n=>n.trim()).filter(Boolean)}function Xx(s){const n=String(s.package_name||"").trim()||"{Package}",r=Bp(String(s.title||"").trim()||"{Title}"),i=Dp(s.task_type),l=String(s.created_at||"").trim()||$d(),u=String(s.diagram||"").trim(),m=String(s.context||"").trim(),d=[];return d.push(`# {ID}-${n}: [${Op(i)}] ${r}`),d.push(""),d.push(`> Created: ${l}`),d.push(`> Type: ${i}`),d.push(""),d.push("## Summary"),d.push(s.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),d.push(""),d.push("## Diagram"),d.push("```"),d.push(u||`ASCII diagram of the system change.
65
- Show inputs/outputs and where code lives.`),d.push("```"),d.push(""),d.push("## Context"),d.push(m||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),d.push(""),d.push("## Scope"),d.push("### Included"),s.included.length?d.push(...s.included.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("### Excluded"),s.excluded.length?d.push(...s.excluded.map(h=>`- ${h}`)):d.push("- "),d.push(""),d.push("## Implementation Plan"),s.plan.length?d.push(...s.plan.map((h,x)=>`${x+1}. ${h}`)):d.push("1. "),d.push(""),d.push("## Dependencies"),s.dependencies.length?d.push(...s.dependencies.map(h=>`- ${h}`)):d.push("- Related backlog items / ADRs"),d.push(""),d.push("## Acceptance Criteria"),s.acceptance.length?d.push(...s.acceptance.map(h=>`- [ ] ${h}`)):d.push("- [ ] Criterion 1 (clear, testable)"),d.push(""),d.push("## Testing (ADR-0019)"),d.push("- Level A:"),s.tests_a.length?d.push(...s.tests_a.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level B:"),s.tests_b.length?d.push(...s.tests_b.map(h=>` - \`${h}\``)):d.push(" - `...`"),d.push("- Level C (optional / opt-in):"),s.tests_c.length?d.push(...s.tests_c.map(h=>` - \`${h}\``)):d.push(" - n/a"),d.push(""),d.push("## Related"),d.push("- ADRs:"),d.push("- Code:"),d.push("- Reports:"),s.attachments.length&&(d.push("- Attachments:"),d.push(...s.attachments.map(h=>` - ${h}`))),d.push(""),d.push("---"),d.push("## Report (added when completed)"),d.push(""),d.push("> Completed: YYYY-MM-DD"),d.push(""),d.push("### What changed"),d.push("- "),d.push(""),d.push("### Security / hardening"),d.push("- "),d.push(""),d.push("### Testing (ADR-0019)"),d.push("Levels executed:"),d.push("- A:"),d.push("- B:"),d.push("- C (if any):"),d.push(""),d.push("Commands run:"),d.push("- `...`"),d.push(""),d.push("### Follow-ups"),d.push("- "),d.push(""),d.join(`
66
- `)}function Zx(s,n){const r=n.map(h=>String(h||"").trim()).filter(Boolean);if(!r.length)return s;const i=String(s||"").split(/\r?\n/),l=i.map(h=>h.toLowerCase()),u=l.findIndex(h=>h.trim()==="## related");if(u<0)return`${String(s||"").trimEnd()}
67
-
68
- ## Related
69
- - Attachments:
70
- ${r.map(x=>` - ${x}`).join(`
71
- `)}
72
- `;let m=-1;for(let h=u+1;h<i.length;h+=1){const x=l[h].trim();if(x.startsWith("## ")||x.startsWith("---"))break;if(x.startsWith("- attachments:")){m=h;break}}const d=["- Attachments:",...r.map(h=>` - ${h}`)];if(m>=0){let h=m+1;for(;h<i.length&&/^\s+-\s/.test(i[h]);)h+=1;i.splice(h,0,...r.map(x=>` - ${x}`))}else{let h=u+1;for(let x=u+1;x<i.length;x+=1){const v=l[x].trim();if(v.startsWith("## ")||v.startsWith("---")){h=x;break}h=x+1}i.splice(h,0,...d,"")}return i.join(`
73
- `)}function eb(s,n){const r=tp(s);if(!r.ok)return null;const i=r.payload.phases.map(m=>m.id),l=new Map;for(const m of n)l.set(`${m.section}\0${m.item}\0${m.phase}`,m.op);const u=[];for(const m of r.payload.sections)for(const d of m.items){const h=[];for(const x of i){const v=d.cells[x];if(!v)continue;const g=l.get(`${m.id}\0${d.id}\0${x}`);(g?g==="grant":!!v.assigned)&&h.push(x)}h.length&&(h.length===i.length?u.push({name:d.id}):u.push({name:d.id,phases:h}))}return u}function tb(s){var E,Q;const{gateway:n,entity_name:r}=s,[i,l]=f.useState(null),[u,m]=f.useState(""),[d,h]=f.useState(!1),[x,v]=f.useState([]),[g,w]=f.useState(!1),[L,A]=f.useState(""),[$,T]=f.useState(""),B=f.useCallback(async()=>{h(!0),m("");try{l(await n.entity_skills(r))}catch(oe){l(null),m(String((oe==null?void 0:oe.message)||oe))}finally{h(!1)}},[n,r]);f.useEffect(()=>{v([]),T(""),A(""),B()},[B]);async function O(){if(!(i!=null&&i.matrix))return;const oe=eb(i.matrix,x);if(oe===null){A("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}w(!0),A("");try{const G=await n.put_entity_skills(r,oe);l(G),v([]),T("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>T(""),5e3)}catch(G){A(String((G==null?void 0:G.message)||G))}finally{w(!1)}}const M=Array.isArray((E=i==null?void 0:i.selection)==null?void 0:E.warnings)?i.selection.warnings.map(String):[],P=Array.isArray((Q=i==null?void 0:i.resolved)==null?void 0:Q.skills)?i.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 B(),disabled:d||g,title:"Reload the resolved view (discards pending edits)",children:d?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:s.on_close,children:"Close"})]})]}),u?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",u]}):null,M.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:M.join(" · ")}):null,P.length?e.jsx("div",{className:"entity_skills_resolved",children:P.map(oe=>{const G=String((oe==null?void 0:oe.name)||""),Ne=!!(oe!=null&&oe.active),je=!!(oe!=null&&oe.blocked),we=!!(oe!=null&&oe.requires_review),ve=oe==null?void 0:oe.requires_unmet,H=Array.isArray(ve)?ve.map(String):ve&&typeof ve=="object"?Object.entries(ve).map(([Y,I])=>`${Y}: ${String(I)}`):[],X=Ne?"ok":je?"danger":H.length||we?"warn":"muted",Z=Ne?"active":je?"blocked":H.length?"requires unmet":we?"requires review":"inactive",U=[...Array.isArray(oe==null?void 0:oe.reasons)?oe.reasons.map(String):[],...H].join("; ");return e.jsxs("span",{className:`chip mono ${X}`,title:U||void 0,children:[G," · ",Z]},G)})}):null,e.jsx(Xg,{payload:i==null?void 0:i.matrix,patches:x,onPatchesChange:v,disabled:g||d,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 O(),disabled:g||!x.length,title:x.length?`Save ${x.length} pending change(s)`:"No pending changes",children:g?"Saving…":x.length?`Save ${x.length} change${x.length>1?"s":""}`:"Save"}),x.length?e.jsx("button",{className:"btn",onClick:()=>v([]),disabled:g,children:"Discard edits"}):null,L?e.jsx("span",{className:"page_error",style:{margin:0},children:L}):null,$?e.jsx("span",{className:"chip mono ok",children:$}):null]})]})}function nb(s){const n=new Map;for(const r of s){const i=String(r.target_agent||(r.target_model?`${String(r.executor_type||"agent").trim()||"agent"}:${r.target_model}`:"")||"(unattributed)").trim();let l=n.get(i);l||(l={agent:i,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:""},n.set(i,l)),l.runs+=1;const u=String(r.status||"").toLowerCase();u==="queued"||u==="running"?l.active+=1:u==="promoted"?l.promoted+=1:u==="completed"?l.completed+=1:u==="failed"?l.failed+=1:u==="awaiting_qa"&&(l.awaiting_qa+=1);const m=nl(r);m.run_ms!=null&&(l.total_run_ms+=m.run_ms,l.timed_runs+=1);const d=String(r.finished_at||r.started_at||r.created_at||"");d>l.last_active&&(l.last_active=d)}return[...n.values()].sort((r,i)=>i.runs-r.runs)}function sb(s){const{gateway:n,gateway_connected:r}=s,i=String(s.backlog_advisor_agent||"").trim()||"basic-agent",[l,u]=f.useState(null),[m,d]=f.useState([]),[h,x]=f.useState([]),[v,g]=f.useState(""),[w,L]=f.useState(null),[A,$]=f.useState(!1),[T,B]=f.useState(""),[O,M]=f.useState(!1),[P,E]=f.useState(""),[Q,oe]=f.useState(null),G=f.useRef(0);async function Ne(){if(!r||A)return;const k=++G.current;$(!0),B("");try{const[C,re,he]=await Promise.all([n.backlog_exec_config(),n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]);if(k!==G.current)return;u(C),d([...Array.isArray(re==null?void 0:re.requests)?re.requests:[],...Array.isArray(he==null?void 0:he.requests)?he.requests:[]])}catch(C){k===G.current&&B(String((C==null?void 0:C.message)||C||"Failed to load agents"))}finally{G.current,$(!1)}try{const C=await n.list_entities();if(k!==G.current)return;x(Array.isArray(C==null?void 0:C.entities)?C.entities:[]),g("")}catch(C){if(k!==G.current)return;x([]),g(`#FALLBACK entity registry unavailable: ${String((C==null?void 0:C.message)||C)}`)}try{const C=await n.admin_executors();if(k!==G.current)return;const re=Array.isArray(C)?C:Array.isArray(C==null?void 0:C.executors)?C.executors:[];L(re)}catch{k===G.current&&L(C=>C===null?null:C)}try{const C=await n.admin_runtime_config();k===G.current&&M((C==null?void 0:C.writable)===!0)}catch{k===G.current&&M(!1)}}async function je(){G.current+=1;try{const k=await n.list_entities();x(Array.isArray(k==null?void 0:k.entities)?k.entities:[]),g("")}catch(k){g(`#FALLBACK entity registry unavailable: ${String((k==null?void 0:k.message)||k)}`)}}async function we(){G.current+=1;try{const k=await n.admin_executors(),C=Array.isArray(k)?k:Array.isArray(k==null?void 0:k.executors)?k.executors:[];L(C)}catch{}try{u(await n.backlog_exec_config())}catch{}}async function ve(k){if(P)return;const C=`executor:${k}`;E(C),oe(null);try{await n.admin_runtime_config_update({executor:k}),await we()}catch(re){oe({key:C,text:String((re==null?void 0:re.message)||re||"Executor change refused")})}finally{E("")}}const[H,X]=f.useState(null);async function Z(k,C){if(P)return;const re=String(k.slug||k.name||"").trim();if(!re)return;const he=`entity:${re}`;E(he),oe(null);try{await n.entity_state(re,{state:C,reason:"by the operator via Continuum (Agents & Entities)"}),await je()}catch(le){oe({key:he,text:String((le==null?void 0:le.message)||le||"State change refused")})}finally{E("")}}f.useEffect(()=>{Ne()},[r]);const U=f.useMemo(()=>nb(m),[m]),Y=!!(l!=null&&l.runner_alive),I=String((l==null?void 0:l.executor)||"").trim(),te=!I||I==="none",ae=te?"No execution agent":I;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."}),T?e.jsx("span",{className:"page_error mono",children:T}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${A?"is_loading":""}`,onClick:()=>void Ne(),disabled:!r||A,title:"Refresh","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[w!==null&&w.length?w.map(k=>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(Ue,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.display||k.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",k.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${k.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:k.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(k.models)&&k.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:k.default?e.jsx("span",{className:"chip mono ok",title:"New executions run under this agent unless the request overrides it.",children:"gateway default"}):O?e.jsx("button",{className:"btn",disabled:!!P||k.available===!1,title:k.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":P&&P!==`executor:${k.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void ve(k.id),children:P===`executor:${k.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"})}),(Q==null?void 0:Q.key)===`executor:${k.id}`?e.jsx("div",{className:"detail_warn",children:Q.text}):null]},k.id)):l?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(Ue,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:ae}),e.jsx("div",{className:"entity_card_sub",children:te?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${Y?"ok":te?"warn":"danger"}`,style:{marginLeft:"auto"},children:Y?"available":te?"not configured":"offline"})]}),e.jsxs("div",{className:"agent_facts",children:[l.codex_model?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model:"})," ",l.codex_model]}):null,l.codex_reasoning_effort?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"reasoning:"})," ",l.codex_reasoning_effort]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"can execute:"})," ",l.can_execute?"yes":"no"]}),l.runner_error?e.jsx("div",{className:"page_error",children:l.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(Ue,{name:"edit",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:i}),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 k;return(k=s.on_open_assistant)==null?void 0:k.call(s)},disabled:!s.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:[h.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:[v?e.jsx("div",{className:"page_error",style:{fontSize:"var(--font-size-sm)"},children:v}):null,!v&&!h.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,h.length?e.jsx("div",{className:"agents_grid",style:{marginTop:0},children:h.map(k=>{var D,be,$e,Oe,Re,rt;if(k.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(Ue,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.name||k.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:k.entity_id||k.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:k.error})]},k.entity_id||k.slug||k.name);const C=String(((D=k.state)==null?void 0:D.state)||"unknown").toLowerCase(),re=C==="awake"?"ok":C==="asleep"?"info":C==="paused"?"warn":"muted",le=String(k.liveness||((be=k.state)==null?void 0:be.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(Ue,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.name||k.slug}),e.jsx("div",{className:"entity_card_sub mono",children:k.entity_id})]}),le?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${C}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${re}`,style:{marginLeft:"auto"},children:C})]}),e.jsxs("div",{className:"agent_facts",children:[k.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(k.created_at).toLocaleDateString()]}):null,($e=k.state)!=null&&$e.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",k.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(Oe=k.files)!=null&&Oe.spark?"✓":"—"," · memory ",(Re=k.files)!=null&&Re.memory?"✓":"—"," · book ",(rt=k.files)!=null&&rt.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!le&&(C==="asleep"||C==="paused")?e.jsx("button",{className:"btn",disabled:!!P,title:P&&P!==`entity:${k.slug||k.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void Z(k,"awake"),children:P===`entity:${k.slug||k.name}`?"Waking…":"Wake"}):null,!le&&C==="awake"?e.jsx("button",{className:"btn",disabled:!!P,title:P&&P!==`entity:${k.slug||k.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void Z(k,"asleep"),children:P===`entity:${k.slug||k.name}`?"Sending…":"Sleep"}):null,le?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:()=>X(qe=>qe===(k.name||k.slug)?null:k.name||k.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:H===(k.name||k.slug)?"Hide skills":"Skills"})]}),(Q==null?void 0:Q.key)===`entity:${k.slug||k.name}`?e.jsx("div",{className:"detail_warn",children:Q.text}):null]},k.entity_id||k.slug)})}):null,H?e.jsx(tb,{gateway:n,entity_name:H,on_close:()=>X(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"}),s.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:s.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"}),s.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:s.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"}),s.on_open_team?e.jsx("button",{className:"btn cap_row_action",onClick:s.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:[U.length," agent",U.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:U.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:U.map(k=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:k.agent}),e.jsx("td",{children:k.runs}),e.jsx("td",{className:"col_aux",children:k.active||""}),e.jsx("td",{className:"col_aux",children:k.promoted||""}),e.jsx("td",{className:"col_aux",children:k.completed||""}),e.jsx("td",{className:"col_aux",children:k.awaiting_qa||""}),e.jsx("td",{className:k.failed?"page_error":"",children:k.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:k.timed_runs?Hs(k.total_run_ms/k.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:k.last_active?new Date(k.last_active).toLocaleString():""})]},k.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Vs(s){const n=String(s||"").trim(),r=n.lastIndexOf("-");if(r<=0||r===n.length-1)return null;const i=n.slice(0,r),l=n.slice(r+1);return!/^[0-9]+$/.test(l)||!/^[a-z0-9][a-z0-9_.-]*$/.test(i)?null:{package:i,num:l}}function gh(s,n){const r=String(n||"").match(/^(\d{1,4})[-_]/);return!r||!s?null:`${s.toLowerCase()}-${r[1].padStart(4,"0")}`}function ab(s){return String(s||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function rb(s){const r=String(s||"").replace(/\\/g,"/").match(/(?:^|\/)(proposed|planned|completed|deprecated|recurrent)\/([^/]+\.md)$/i);return r?{kind:r[1].toLowerCase(),filename:r[2]}:null}const ib=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,ob=6;function lb(s){const n=[];for(const r of String(s||"").matchAll(ib)){const i=r[1];if(Vs(i)&&(n.includes(i)||n.push(i),n.length>=ob))break}return n}function Up(s,n,r=24){const i=s.started_at;if(i==null||i==="")return null;let l;if(typeof i=="number")l=i>1e12?i:i*1e3;else{const d=Date.parse(String(i));if(Number.isNaN(d))return null;l=d}const u=Math.max(0,(n-l)/36e5);return{label:u<1?`claimed ${Math.max(1,Math.round(u*60))}m`:u<48?`claimed ${Math.round(u)}h`:`claimed ${Math.round(u/24)}d`,stale:u>=r}}const sl=["P0","P1","P2","P3"],Wp={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},Hp=/^>\s*priority:\s*(p[0-3])\b/i,Vp=/^>\s*labels:\s*(.+)$/i;function Jd(s){return String(s||"").split(",").map(n=>n.trim().toLowerCase().replace(/\s+/g,"-")).filter(n=>!!n&&n.length<=40).slice(0,12)}function ud(s,n){const r=[];let i=!1;for(const l of s){const u=l.trim();if(/^#{1,6}\s/.test(u)){i=n.test(u);continue}i&&r.push(l)}return r}const cb=["one paragraph describing","criterion 1 (clear, testable)"];function yh(s){const n=s.trim().toLowerCase();return n?cb.some(r=>n.startsWith(r)):!0}function Mi(s){const n=String(s||"").split(/\r?\n/);let r=null,i=[];for(const h of n.slice(0,60)){const x=h.trim();if(/^##+\s/.test(x))break;const v=Hp.exec(x);v&&!r&&(r=v[1].toUpperCase());const g=Vp.exec(x);g&&!i.length&&(i=Jd(g[1]))}const l=[];for(const h of ud(n,/acceptance criteria/i)){const x=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(h);if(!x)continue;const v=x[2].trim();yh(v)||l.push({text:v,checked:x[1].toLowerCase()==="x"})}const u=[];for(const h of ud(n,/testing/i))for(const x of h.matchAll(/`([^`]+)`/g)){const v=x[1].trim();!v||v==="..."||v.toLowerCase()==="n/a"||u.push(v)}const m=ud(n,/^#{1,6}\s*summary\b/i).map(h=>h.trim()).filter(Boolean),d=m.length>0&&!m.every(yh);return{priority:r,labels:i,acceptance:l,test_commands:u,has_summary:d}}function Qd(s,n){const r=String(s.task_type||"").trim().toLowerCase(),i=[{id:"type",label:`Work type is set (${er.join(" / ")})`,ok:er.includes(r),evidence:r?`type: ${r}`:"no type"},{id:"summary",label:"Summary describes the outcome (not the template placeholder)",ok:n.has_summary,evidence:n.has_summary?"summary present":"empty or template placeholder"},{id:"acceptance",label:"At least one acceptance criterion",ok:n.acceptance.length>0,evidence:n.acceptance.length?`found ${n.acceptance.length}: "${vh(n.acceptance[0].text,60)}"${n.acceptance.length>1?", …":""}`:"none found under ## Acceptance Criteria"},{id:"tests",label:"At least one concrete test command (Testing A/B)",ok:n.test_commands.length>0,evidence:n.test_commands.length?`found ${n.test_commands.length}: \`${vh(n.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:i.every(l=>l.ok),checks:i}}function vh(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function Td(s){const n=s;if(!n||n.status!==409)return null;const r=n.body,i=r&&typeof r=="object"&&r.detail&&typeof r.detail=="object"?r.detail:r;if(!i||i.error!=="definition_of_ready_failed")return null;const u=(Array.isArray(i.checks)?i.checks:Array.isArray(i.members)?i.members.flatMap(m=>(Array.isArray(m==null?void 0:m.checks)?m.checks:[]).map(d=>({...d,label:m!=null&&m.relpath?`${m.relpath}: ${String((d==null?void 0:d.label)||"")}`:d==null?void 0:d.label}))):[]).map(m=>({id:String((m==null?void 0:m.id)||""),label:String((m==null?void 0:m.label)||""),ok:(m==null?void 0:m.ok)===!0,evidence:m!=null&&m.evidence?String(m.evidence):void 0}));return u.length?{ok:u.every(m=>m.ok),checks:u}:null}function Ad(s,n){const i=[...String(s||"").split(/\r?\n/)];function l(u,m){const d=[];for(let x=0;x<Math.min(i.length,60);x+=1){const v=i[x].trim();if(/^##+\s/.test(v))break;u.test(v)&&d.push(x)}if(d.length){for(let x=d.length-1;x>=1;x-=1)i.splice(d[x],1);m?i[d[0]]=m:i.splice(d[0],1);return}if(!m)return;let h=-1;for(let x=0;x<Math.min(i.length,60);x+=1){const v=i[x].trim();if(v.startsWith("> ")&&(h=x),/^##\s/.test(v))break}if(h<0){const x=i.findIndex(v=>v.trim().startsWith("# "));if(x>=0)h=x;else{i.unshift(m);return}}i.splice(h+1,0,m)}return l(Hp,n.priority?`> Priority: ${n.priority}`:null),l(Vp,n.labels.length?`> Labels: ${n.labels.join(", ")}`:null),i.join(`
74
- `)}const xh=[{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 Ld(s){const n=String(s||"").trim().toUpperCase();return sl.includes(n)?n:null}function Md(s){return s.priority!==void 0||s.labels!==void 0}const ub="decision-gate";function db(s){return Array.isArray(s)&&s.some(n=>String(n||"").trim().toLowerCase()===ub)}function Gp(s,n){return db(s.labels!==void 0?s.labels:n==null?void 0:n.labels)}function Kp(s){return s.priority!==void 0||s.labels!==void 0}function Rd(s,n){return s.priority!==void 0?s.priority:(n==null?void 0:n.priority)??null}function Pd(s,n){return s.labels!==void 0?s.labels:(n==null?void 0:n.labels)??[]}const mb=new Set(["queued","running"]);function fb(s){const n=String(s||"").split("/").filter(Boolean);return n.length?n[n.length-1]:""}const hb=/^batch\((\d+)\)$/i;function bh(s){const n=hb.exec(String(s||"").trim());return n?Number(n[1]):null}function pb(s){const n=s.recent_limit??12,r=[],i=new Set;for(const v of s.active_items){const g=String(v.filename||"").trim();g&&i.add(g)}const l=(v,g,w)=>{const L=String(v.backlog_filename||"").trim()||fb(String(v.backlog_relpath||"")),A=bh(L),$=A!==null?"":L;return $&&w&&i.add($),{key:$&&w?`file:${$}`:`req:${v.request_id}`,column:g,title:A!==null?`Batch execution (${A} items)`:$||`Execution ${v.request_id.slice(0,8)}…`,filename:$||void 0,request_id:v.request_id,exec_status:String(v.status||"").trim().toLowerCase(),created_at:v.created_at??null,started_at:v.started_at??null,finished_at:v.finished_at??null,target_agent:v.target_agent??(v.target_model?`${String(v.executor_type||"agent").trim()||"agent"}:${v.target_model}`:null),batch_size:A!==null?A:void 0}};for(const v of s.active_requests){const g=String(v.status||"").trim().toLowerCase();mb.has(g)?r.push(l(v,"in_progress",!0)):g==="awaiting_qa"&&r.push(l(v,"in_review",!0))}const u=[...s.terminal_requests].sort((v,g)=>{const w=String(v.finished_at||v.started_at||v.created_at||"");return String(g.finished_at||g.started_at||g.created_at||"").localeCompare(w)}),m=new Map;let d=0,h=0;for(const v of u){const g=String(v.status||"").trim().toLowerCase();if(g==="failed"){const w=String(v.backlog_filename||"").trim();w&&bh(w)===null&&m.set(w,(m.get(w)||0)+1),h<n&&(r.push(l(v,"failed",!1)),h+=1)}else(g==="promoted"||g==="completed")&&d<n&&(r.push(l(v,"done",!1)),d+=1)}for(const v of s.planned){const g=String(v.filename||"").trim();!g||i.has(g)||r.push({key:`file:${g}`,column:"ready",title:v.title||g,kind:"planned",filename:g,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,recent_failures:m.get(g)||void 0,priority:Md(v)?Ld(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}for(const v of s.proposed){const g=String(v.filename||"").trim();!g||i.has(g)||r.push({key:`file:${g}`,column:"triage",title:v.title||g,kind:"proposed",filename:g,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,priority:Md(v)?Ld(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}const x=new Map;for(const v of[...s.planned,...s.proposed])x.set(String(v.filename||"").trim(),v);for(const v of r){if(!v.filename||v.kind)continue;const g=x.get(v.filename);g&&(v.title=g.title||v.title,v.item_id=g.item_id,v.package=g.package,v.task_type=g.task_type,v.summary=g.summary)}return r}const _b=200;function gb(s,n){var v;const{live:r,done:i}=n,l=n.work||new Map;if(!r.size&&!i.length&&!l.size)return s;const u=new Set,m=new Set;for(const g of s){if(!g.filename||!g.package)continue;const w=gh(g.package,g.filename);w&&m.add(w)}const d=s.map(g=>{if(g.column!=="ready"||g.kind!=="planned"||!g.filename||!g.package)return g;const w=gh(g.package,g.filename);if(!w)return g;const L=r.get(w);return!L||!L.owner?g:(u.add(w),{...g,column:"in_progress",work_id:w,claim_owner:L.owner,claim_started_at:L.started_at})}),h=new Map;d.forEach((g,w)=>{g.filename&&h.set(g.filename,w)});for(const[g,w]of l){const L=w.card?h.get(ab(w.card)):void 0;if(m.has(g)||L!==void 0){if(L!==void 0){const T=d[L],B={...T,work_id:T.work_id||g,card_path:T.card_path||w.card},O=r.get(g);O!=null&&O.owner&&(u.add(g),B.claim_owner||(B.claim_owner=O.owner,B.claim_started_at=O.started_at)),d[L]=B}continue}if(w.status==="deprecated")continue;const A=r.get(g),$=w.status==="completed"?"done":w.status==="planned"?A!=null&&A.owner?"in_progress":"ready":"triage";A!=null&&A.owner&&u.add(g),d.push({key:`work:${g}`,column:$,title:w.title||g,work_id:g,package:(v=Vs(g))==null?void 0:v.package,summary:w.receipt,card_path:w.card,claim_owner:(A==null?void 0:A.owner)||(w.status==="completed"?w.owner:void 0),claim_started_at:A==null?void 0:A.started_at})}for(const[g,w]of r){if(u.has(g)||!w.owner)continue;const L=Vs(g);d.push({key:`claim:${g}`,column:"in_progress",title:typeof w.task=="string"&&w.task?w.task:g,work_id:L?g:void 0,package:L==null?void 0:L.package,claim_owner:w.owner,claim_started_at:w.started_at})}const x=new Set(d.filter(g=>g.column==="done").map(g=>g.work_id).filter(Boolean));for(const g of i.slice(0,_b)){if(x.has(g.item))continue;const w=Vs(g.item);d.push({key:`claim-done:${g.item}`,column:"done",title:g.item,work_id:w?g.item:void 0,package:w==null?void 0:w.package,claim_owner:g.owner,summary:g.receipt})}return d}function Ai(s){const n=String((s==null?void 0:s.message)??s??"");return/backlog folder not available|backlog browsing not configured/i.test(n)}function wh(s){return String((s==null?void 0:s.message)??s??"").trim().replace(/^[a-z_]+ failed: /,"")}function Yd(s,n,r){const[i,l]=f.useState({status:null,legacy:!1});return f.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{try{const m=await s.backlog_status();u||l({status:m,legacy:!1})}catch(m){u||l({status:null,legacy:Number(m==null?void 0:m.status)===404})}})(),()=>{u=!0}},[s,n,r]),i}function yb(){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 Xd(s){const{gateway:n,surface:r,status:i,legacy:l,on_changed:u}=s,[m,d]=f.useState(!1),[h,x]=f.useState(""),[v,g]=f.useState(!1),[w,L]=f.useState(""),[A,$]=f.useState((i==null?void 0:i.writable)??null);f.useEffect(()=>{if((i==null?void 0:i.writable)!==void 0){$(!!i.writable);return}if(!l)return;let M=!1;return n.admin_runtime_config().then(P=>{M||$((P==null?void 0:P.writable)===!0)}).catch(()=>{M||$(!1)}),()=>{M=!0}},[n,i==null?void 0:i.writable,l]);async function T(M){if(!v){g(!0),L("");try{await n.admin_runtime_config_update({triage_repo_root:M}),d(!1),u==null||u()}catch(P){L(wh(P))}finally{g(!1)}}}const B=String((i==null?void 0:i.reason)||"").trim()||(s.error?wh(s.error):""),O=String((i==null?void 0:i.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:[i!=null&&i.path?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"mono",children:i.path})," —"," "]}):null,B||"the gateway did not say why."]}),A===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[O?e.jsx("button",{className:"btn primary",disabled:v,onClick:()=>void T(O),title:O,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:v,onClick:()=>d(M=>!M),children:"Choose a folder…"})]}),O?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:O}),"; it is created with a starter overview and item template."]}):null,m?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:M=>{M.preventDefault(),h.trim()&&T(h.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:h,onChange:M=>x(String(M.target.value||"")),placeholder:"/path/to/your/project",autoFocus:!0}),e.jsx("button",{className:"btn primary",type:"submit",disabled:v||!h.trim(),children:v?"Saving…":"Use this folder"})]})]}):null,w?e.jsx("div",{className:"page_error mono",role:"alert",style:{marginTop:"8px"},children:w}):null]}):A===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(yb,{})}):null]})]})}function vb(s){const{status:n,on_create:r}=s,[i,l]=f.useState(!1),u=String((n==null?void 0:n.path)||"").trim(),m=u?`${u.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",d=u?`${u.replace(/\/+$/,"")}/${(n==null?void 0:n.template_relpath)||"docs/backlog/template.md"}`:(n==null?void 0:n.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"}),n!=null&&n.is_default?e.jsx("span",{className:"chip mono muted",children:"the gateway's own folder"}):null]}),e.jsxs("div",{className:"pane_body",children:[u?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:u}),e.jsx("button",{className:"btn",onClick:()=>{ln(u),l(!0)},children:i?"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:m})," (Triage), accepted ones move to"," ",e.jsx("code",{className:"mono",children:"planned/"})," (Ready). Start from the template ",e.jsx("code",{className:"mono",children:d}),", 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 xb(s){return s.kind?[s.kind]:["completed","planned","proposed"]}function Jp(s){const{gateway:n,can_use_gateway:r,target:i,on_close:l,on_mutated:u,on_open_executions:m}=s,d=!!i,[h,x]=f.useState("spec"),[v,g]=f.useState(""),[w,L]=f.useState(""),[A,$]=f.useState(null),[T,B]=f.useState(!1),[O,M]=f.useState(""),[P,E]=f.useState(!1),[Q,oe]=f.useState(""),[G,Ne]=f.useState(!1),[je,we]=f.useState(""),[ve,H]=f.useState(""),[X,Z]=f.useState(!1),[U,Y]=f.useState([]),[I,te]=f.useState(!1),[ae,k]=f.useState(null),[C,re]=f.useState(null),[he,le]=f.useState(""),[D,be]=f.useState(!1),[$e,Oe]=f.useState(""),[Re,rt]=f.useState({}),qe=f.useMemo(()=>Mi(v),[v]);f.useEffect(()=>{if(!d||!i)return;const W=ie=>{ie.key!=="Escape"||ie.defaultPrevented||bb(ie.target)||P||document.querySelector(".modal_backdrop")||(ie.preventDefault(),l())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[d,i,l,P]),f.useEffect(()=>{!d||!i||(x(i.initial_tab||"spec"),E(!1),M(""),Oe(""),le(""),rt({}),ce(!1),k(null),re(null),$(null),it(i),Ge(i))},[d,i==null?void 0:i.filename,i==null?void 0:i.kind,i==null?void 0:i.request_id]);async function it(W){if(!W.filename){g(""),L("");return}B(!0);try{let ie=null,Ce=null;for(const F of xb(W))try{const ue=await n.backlog_content(F,W.filename);ie={kind:F,text:String((ue==null?void 0:ue.content)||"")};break}catch(ue){Ce=ue}if(!ie)throw Ce||new Error("Spec not found in any backlog kind");$(ie.kind),g(ie.text),L(await Ed(ie.text));const Je=Mi(ie.text);we(Je.priority||""),H(Je.labels.join(", "))}catch(ie){M(String((ie==null?void 0:ie.message)||ie||"Failed to load the spec"))}finally{B(!1)}}async function Ge(W){te(!0);try{const[ie,Ce]=await Promise.all([n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),F=[...Array.isArray(ie==null?void 0:ie.requests)?ie.requests:[],...Array.isArray(Ce==null?void 0:Ce.requests)?Ce.requests:[]].filter(ye=>W.filename&&String(ye.backlog_filename||"").trim()===W.filename||ye.request_id===W.request_id);F.sort((ye,xe)=>String(xe.created_at||"").localeCompare(String(ye.created_at||""))),Y(F);const ue=F.find(ye=>String(ye.status||"").toLowerCase()==="awaiting_qa")||null;if(k(ue),ue)try{const ye=await n.backlog_exec_request(ue.request_id);re((ye==null?void 0:ye.payload)??null)}catch{re(null)}}catch{Y([])}finally{te(!1)}}async function ct(){if(!i||G)return;const W=A||i.kind;if(W){Ne(!0),M("");try{const ie=await n.backlog_update({kind:W,filename:i.filename,content:Q,expected_sha256:w||null}),Ce=Q.endsWith(`
75
- `)?Q:`${Q}
76
- `;g(Ce),L(String((ie==null?void 0:ie.sha256)||"")),E(!1),await u()}catch(ie){M(String((ie==null?void 0:ie.message)||ie||"Save failed"))}finally{Ne(!1)}}}async function et(){if(!i||X)return;const W=A||i.kind;if(W){Z(!0),M("");try{const ie=Ad(v,{priority:je||null,labels:Jd(ve)}),Ce=await n.backlog_update({kind:W,filename:i.filename,content:ie,expected_sha256:w||null});g(ie.endsWith(`
77
- `)?ie:`${ie}
78
- `),L(String((Ce==null?void 0:Ce.sha256)||"")),await u()}catch(ie){M(String((ie==null?void 0:ie.message)||ie||"Metadata save failed"))}finally{Z(!1)}}}const[fe,ce]=f.useState(!1);async function Ee(W){if(!(!ae||D)){if(W==="feedback"&&!he.trim()){Oe("Feedback is required.");return}be(!0),Oe("");try{W==="feedback"?await n.backlog_exec_feedback({request_id:ae.request_id,feedback:he}):W==="promote"?await n.backlog_exec_promote({request_id:ae.request_id,redeploy:!0}):await n.backlog_exec_deploy_uat({request_id:ae.request_id}),le(""),ce(!1),i&&await Ge(i),await u()}catch(ie){Oe(String((ie==null?void 0:ie.message)||ie||"QA action failed"));try{const Ce=await n.backlog_exec_request(ae.request_id);re((Ce==null?void 0:Ce.payload)??null)}catch{}}finally{be(!1)}}}if(!d||!i)return null;const se=qe.acceptance.filter((W,ie)=>!Re[`${ie}:${W.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:W=>{W.target===W.currentTarget&&l()},children:e.jsxs("div",{className:"drawer_panel work_drawer",role:"dialog","aria-modal":"true","aria-label":i.title||"Work item",children:[e.jsxs("div",{className:"drawer_header",children:[e.jsxs("div",{className:"col",style:{gap:2,minWidth:0},children:[e.jsx("div",{className:"drawer_title",title:i.filename,children:i.title}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:[A||i.kind||"locating…",i.filename?` • ${i.filename}`:""]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[i.filename?e.jsx("button",{className:"btn",onClick:()=>ln(`docs/backlog/${A||i.kind||"planned"}/${i.filename}`),title:"Copy repo path",children:"Copy path"}):null,e.jsx("button",{className:"btn",onClick:l,children:"Close"})]})]}),e.jsxs("div",{className:"tab_bar work_drawer_tabs",children:[e.jsx("button",{className:`tab ${h==="spec"?"active":""}`,onClick:()=>x("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${h==="runs"?"active":""}`,onClick:()=>x("runs"),children:["Runs ",U.length?`(${U.length})`:""]}),e.jsxs("button",{className:`tab ${h==="review"?"active":""}`,onClick:()=>x("review"),children:["Review",ae?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[O?e.jsx("div",{className:"mono board_error",children:O}):null,h==="spec"?e.jsxs(e.Fragment,{children:[i.has_live_request?e.jsx("div",{className:"mono work_drawer_warn",style:{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,i.filename?e.jsxs("div",{className:"work_meta_editor",children:[e.jsxs("select",{value:je,onChange:W=>we(W.target.value),disabled:X,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),sl.map(W=>e.jsx("option",{value:W,children:Wp[W]},W))]}),e.jsx("input",{value:ve,onChange:W=>H(W.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:X}),e.jsx("button",{className:"btn",onClick:()=>void et(),disabled:X||!r||T,children:X?"Saving…":"Save metadata"}),P?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>E(!1),disabled:G,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ct(),disabled:G,children:G?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{oe(v),E(!0)},disabled:T,children:"Edit spec"})]}):null,T?e.jsx("div",{className:"mono muted",children:"Loading…"}):P?e.jsx("textarea",{className:"mono work_spec_editor",value:Q,onChange:W=>oe(W.target.value),rows:24}):v?e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"md_doc",text:v}),e.jsx("div",{className:"mono muted work_drawer_hint",style:{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,h==="runs"?e.jsxs(e.Fragment,{children:[I?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!I&&!U.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,U.map(W=>{const ie=String(W.status||"").toLowerCase(),Ce=nl(W);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Zo(ie)}`,children:ie}),e.jsx("span",{className:"mono muted",children:_a(W.request_id,18)}),e.jsx("span",{className:"mono muted",children:W.created_at?new Date(W.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:Ce.run_ms!=null?`ran ${Hs(Ce.run_ms)}`:""}),W.target_agent?e.jsx("span",{className:"chip mono muted",children:W.target_agent}):null,ie==="running"||ie==="queued"||ie==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>m(W.request_id),children:ie==="awaiting_qa"?"View logs":"Follow live"}):null]},W.request_id)})]}):null,h==="review"?ae?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 work_drawer_hint",style:{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."}),qe.acceptance.length?e.jsx("div",{className:"work_dod_list",children:qe.acceptance.map((W,ie)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Re[`${ie}:${W.text}`],onChange:Ce=>rt(Je=>({...Je,[`${ie}:${W.text}`]:Ce.target.checked}))}),e.jsx("span",{children:W.text})]},`dod:${ie}:${W.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const W=String((C==null?void 0:C.execution_mode)||"uat").toLowerCase(),ie=String((C==null?void 0:C.candidate_relpath)||"").trim(),Ce=C==null?void 0:C.promotion_report,Je=!!(Ce!=null&&Ce.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 work_review_meta",children:["mode: ",W,ie?` • candidate: ${ie}`:""]}),e.jsx("button",{className:"btn",onClick:()=>m(ae.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),Je?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((Ce==null?void 0:Ce.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),qe.acceptance.length&&se>0?e.jsxs("div",{className:"mono work_drawer_warn",style:{marginTop:"8px"},children:[se," acceptance criteri",se===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:he,onChange:W=>le(W.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:D}),$e?e.jsx("div",{className:"mono board_error",children:$e}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ee("deploy_uat"),disabled:D,children:"Restart UAT"}),fe?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void Ee("promote"),disabled:D,children:["Confirm: promote to prod",se>0?` (${se} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>ce(!1),disabled:D,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>ce(!0),disabled:D,children:qe.acceptance.length&&se>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void Ee("feedback"),disabled:D,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function bb(s){const n=s;return!n||typeof n.closest!="function"?!1:!!n.closest("input, textarea, select, [contenteditable=''], [contenteditable='true']")}function Dr(){return Yo()}async function wb(s){const n=[],r=[];for(const i of s){const l=String((i==null?void 0:i.name)||"").trim()||"attachment";r.push(l);try{const u=await i.text();n.push(`[attached file: ${l}]
79
-
80
- \`\`\`
81
- ${u}
82
- \`\`\``)}catch{n.push(`[attached file: ${l}] (unreadable in browser)`)}}return{picked:r,text:n.join(`
83
-
84
- `)}}function jb(s){const{gateway:n,can_use_gateway:r,is_compact_layout:i,maint_provider:l,maint_model:u,maint_reasoning:m,advisor_agent:d,focus_kind:h,focus_type:x}=s,[v,g]=f.useState(!1),[w,L]=f.useState([]),[A,$]=f.useState(""),[T,B]=f.useState(!1),[O,M]=f.useState(""),[P,E]=f.useState(!1),[Q,oe]=f.useState([]),G=f.useRef(null),Ne=f.useRef(null),je=String(s.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[we,ve]=f.useState(""),[H,X]=f.useState("");f.useEffect(()=>{(async()=>{try{const C=await Kd(je);ve(C)}catch{ve("")}})()},[je]);const Z=f.useMemo(()=>{if(!r)return{};const C=String(we||"").trim(),re=je;return{tts:async he=>{if(!C)throw new Error("Voice store not available (missing run_id).");const le=await n.voice_tts(C,{text:he,request_id:Dr()}),D=le==null?void 0:le.audio_artifact,be=D&&typeof D=="object"&&!Array.isArray(D)?String(D.$artifact||"").trim():"";if(!be)throw new Error("TTS failed: missing audio artifact");return await(await n.download_run_artifact_content(C,be)).arrayBuffer()},transcribe:async(he,le)=>{if(!C)throw new Error("Voice input unavailable (missing run_id).");const D=String(le||he.type||"").toLowerCase(),be=D.includes("mp4")?"m4a":D.includes("ogg")?"ogg":D.includes("wav")?"wav":"webm",$e=new File([he],`recording.${be}`,{type:D||"audio/webm"}),Oe=await n.attachments_upload(re,$e,{filename:$e.name,content_type:$e.type}),Re=await n.audio_transcribe(C,{audio_artifact:Oe,request_id:Dr()});return String((Re==null?void 0:Re.text)||"").trim()}}},[r,n,we,je]),U=cp({...Z,on_error:X,on_transcript:C=>{const re=String(C||"").trim();re&&($(he=>{const le=String(he||"");return le.trim()?`${le.trimEnd()}
85
- ${re}`:re}),window.setTimeout(()=>{var he;return(he=G.current)==null?void 0:he.focus()},0))}});f.useEffect(()=>{if(!v)return;const C=re=>{re.key==="Escape"&&(k(),g(!1))};return window.addEventListener("keydown",C),setTimeout(()=>{var re;return(re=G.current)==null?void 0:re.focus()},0),()=>window.removeEventListener("keydown",C)},[v]);async function Y(){if(T||!r)return;if(U.voice_ptt_busy){X("Wait for transcription to finish.");return}M(""),X("");const C=A.trim();if(!C)return;const re={id:Dr(),role:"user",content:C,ts:new Date().toISOString()},he=[...w,re];L(he),$(""),B(!0);try{const le=await n.backlog_advisor({messages:he.map(Oe=>({role:Oe.role,content:Oe.content})),provider:l||null,model:u||null,thinking:m||null,agent:d||null,include_trace:P,focus_kind:h,focus_type:x}),D=P&&Array.isArray(le==null?void 0:le.tool_trace)?le.tool_trace:[],be=String((le==null?void 0:le.run_id)||"").trim(),$e=String((le==null?void 0:le.reply)||"").trim();if(P&&D.length){const Oe={id:Dr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:be||null,tool_trace:D},null,2)};L(Re=>[...Re,Oe])}$e&&L(Oe=>[...Oe,{id:Dr(),role:"assistant",content:$e,ts:new Date().toISOString()}])}catch(le){M(String((le==null?void 0:le.message)||le||"Backlog advisor failed"))}finally{B(!1)}}async function I(C){var D;const re=Array.from(C||[]);if(!re.length)return;const{picked:he,text:le}=await wb(re);oe(be=>[...he,...be].slice(0,12)),$(be=>{const $e=String(be||"").trim();return $e?`${$e}
86
-
87
- ${le}`:le});try{(D=G.current)==null||D.focus()}catch{}}function te(C){const re=String(C.id||C.ts||"").trim(),he=String(C.content||"").trim();!re||!he||(X(""),U.toggle_tts(re,he))}function ae(C){const re=String(C.id||C.ts||"").trim(),he=U.tts_playback;return!re||!he.key||he.key!==re?"idle":he.status}function k(){U.stop_voice_ptt_recording(),U.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${v?"open":""}`,onClick:()=>{g(C=>{const re=!C;return re||k(),re})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:e.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),v?e.jsx("div",{className:"drawer_backdrop",onMouseDown:C=>{C.target===C.currentTarget&&(k(),g(!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: ",d||"basic-agent"," • Using: ",l||"(gateway default)"," / ",u||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${P?"primary":""}`,onClick:()=>E(C=>!C),disabled:T,title:P?"Hide tool execution":"Show tool execution","aria-label":P?"Hide tool execution":"Show tool execution",children:[e.jsx(Ue,{name:"terminal",size:16}),i?null:P?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>L([]),disabled:T||!w.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{k(),g(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(Rc,{messages:w,className:"drawer_chat_thread",messageProps:U.tts_supported&&r&&we.trim()?{onSpeakToggle:te,getSpeakState:ae,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Ask about the backlog, e.g. “What are the top 5 planned items to focus on next and why?”"})}),e.jsxs("div",{className:"drawer_footer",children:[e.jsx("input",{ref:Ne,type:"file",multiple:!0,style:{display:"none"},onChange:C=>{const re=Array.from(C.currentTarget.files||[]);C.currentTarget.value="",re.length&&I(re)}}),e.jsx(ol,{ref:G,value:A,onChange:$,onSubmit:()=>void Y(),placeholder:"Message to backlog advisor…",disabled:!r,busy:T||U.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:U.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${U.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!we.trim()||T||U.voice_ptt_busy||!U.voice_ptt_supported,title:U.voice_ptt_supported?U.voice_ptt_busy?"Transcribing…":U.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":hh()?"Voice recording is not supported in this browser":fh,"aria-label":"Voice input",onPointerDown:C=>{var re,he;if(!(!r||!we.trim()||T||U.voice_ptt_busy||!U.voice_ptt_supported)){C.preventDefault();try{(he=(re=C.currentTarget)==null?void 0:re.setPointerCapture)==null||he.call(re,C.pointerId)}catch{}U.start_voice_ptt_recording()}},onPointerUp:C=>{C.preventDefault(),U.stop_voice_ptt_recording()},onPointerCancel:C=>{C.preventDefault(),U.stop_voice_ptt_recording()},children:[e.jsx(Ue,{name:U.voice_ptt_recording?"x":"mic",size:16}),i?null:U.voice_ptt_busy?"Transcribing…":U.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var C;return(C=Ne.current)==null?void 0:C.click()},disabled:T,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(Ue,{name:"paperclip",size:16}),i?null:"Attach"]})]})}),Q.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",Q[0]]}):null,O?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:O}):null,H?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:H}):null,hh()?null:e.jsx("div",{className:"muted","data-testid":"voice-https-hint",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:fh}),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 tr({open:s,title:n,children:r,actions:i,variant:l="default",onClose:u}){if(f.useEffect(()=>{if(!s)return;const d=h=>{h.key!=="Escape"||h.defaultPrevented||(h.preventDefault(),u())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,u]),!s)return null;const m=l==="fullscreen";return e.jsx("div",{className:`modal_backdrop${m?" fullscreen":""}`,onMouseDown:d=>{d.target===d.currentTarget&&u()},children:e.jsxs("div",{className:`modal_panel${m?" fullscreen":""}`,role:"dialog","aria-modal":"true","aria-label":n,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:n}),e.jsx("button",{className:"btn",onClick:u,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),i?e.jsx("div",{className:"modal_footer",children:i}):null]})})}function kb(s){const{readiness:n,server_refused:r,on_open_spec:i}=s;return n?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)"})]}),n.checks.map(l=>e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",color:l.ok?"rgb(74, 222, 128)":"rgb(250, 204, 21)"},children:[l.ok?"✓":"○"," ",l.label,l.evidence?e.jsxs("span",{style:{opacity:.75},children:[" — ",l.evidence]}):null]},l.id)),n.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."}),i?e.jsx("button",{className:"btn",type:"button",onClick:i,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 Qp(s){const{exec_cfg:n,with_setup:r}=s,i=["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:(n==null?void 0:n.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway — admins can enable it live from Settings → Gateway administration.":(n==null?void 0:n.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(n==null?void 0:n.codex_available)===!1?`The configured executor is not available on the gateway host (${String((n==null?void 0:n.codex_bin)||(n==null?void 0:n.executor)||"binary")} not found).`:"Backlog exec is not available on this gateway."}),n!=null&&n.runner_error?e.jsx("div",{className:"detail_hint",children:n.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:i.join(`
88
- `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>ln(i.join(`
89
- `)),children:"Copy setup"})]})]}):null]})}function Yp(s){const{value:n,onChange:r,disabled:i,inplace_warning:l,uat_note:u}=s;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:n,onChange:m=>r(m.target.value),disabled:i,style:{width:"100%"},children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),n==="inplace"?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:l}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:u})]})}const Sb=["minimal","low","medium","high"];function Xp(s){const{executors:n,value:r,onChange:i,disabled:l}=s;if(!n||!n.length)return null;const u=n.find(m=>m.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:m=>i(m.target.value),disabled:l,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",u?` (${u.display||u.id})`:""]}),n.map(m=>e.jsxs("option",{value:m.id,disabled:m.available===!1,children:[m.display||m.id,m.available===!1?" (unavailable on the gateway host)":""]},m.id))]})]})}function Nb(s){const{exec_cfg:n,model:r,set_model:i,effort:l,set_effort:u,disabled:m}=s;return e.jsxs("details",{style:{marginTop:"8px"},open:!!(r||l),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:d=>i(d.target.value),placeholder:String((n==null?void 0:n.codex_model)||"gateway default"),disabled:m})]})}),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:l,onChange:d=>u(d.target.value),disabled:m,children:[e.jsx("option",{value:"",children:"gateway default"}),Sb.map(d=>e.jsx("option",{value:d,children:d},d))]})]})})]}),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 Zp(s){const{open:n,target:r,execute_mode:i,set_execute_mode:l,action_loading:u,action_error:m,exec_cfg:d,exec_cfg_loading:h,exec_cfg_error:x,on_confirm:v,on_close:g}=s,w=s.readiness??null,L=s.show_readiness===!0,[A,$]=Bt.useState(""),[T,B]=Bt.useState(""),[O,M]=Bt.useState(""),P=(r==null?void 0:r.filename)||"";Bt.useEffect(()=>{$(""),B(""),M("")},[P]);const E=A.trim()||T||O?{executor:O||void 0,target_model:A.trim()||void 0,target_reasoning_effort:T||void 0}:void 0;return e.jsxs(tr,{open:n,title:"Execute backlog item?",onClose:g,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:g,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(E),disabled:u||h||!r||(d==null?void 0:d.can_execute)!==!0,children:u?"Executing…":L&&!w?"Execute (readiness unknown)":w&&!w.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)"})]}),d?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Agent: ",String(d.executor||"executor"),d.codex_model?` · ${d.codex_model}`:"",d.codex_reasoning_effort?` (reasoning ${d.codex_reasoning_effort})`:""]}):null,e.jsx(Xp,{executors:s.executors??null,value:O,onChange:M,disabled:u}),e.jsx(Nb,{exec_cfg:d,model:A,set_model:$,effort:T,set_effort:B,disabled:u}),L?e.jsx(kb,{readiness:w,server_refused:s.server_refused,on_open_spec:s.on_open_spec}):null,e.jsx(Yp,{value:i,onChange:l,disabled:u,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."}),h?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!h&&(d==null?void 0:d.can_execute)!==!0?e.jsx(Qp,{exec_cfg:d,with_setup:!0}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function Cb(s){const{open:n,batch_selected_items:r,batch_execute_mode:i,set_batch_execute_mode:l,batch_execute_loading:u,batch_execute_error:m,exec_cfg:d,exec_cfg_loading:h,exec_cfg_error:x,on_confirm:v,on_close:g}=s,[w,L]=Bt.useState("");return Bt.useEffect(()=>{n||L("")},[n]),e.jsxs(tr,{open:n,title:"Execute batch (single context)?",onClose:g,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:g,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(w||void 0),disabled:u||h||r.length<2||(d==null?void 0:d.can_execute)!==!0,children:u?"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(Xp,{executors:s.executors??null,value:w,onChange:L,disabled:u}),e.jsx(Yp,{value:i,onChange:l,disabled:u,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(A=>e.jsxs("div",{children:["- docs/backlog/planned/",A.filename]},`batchitem:${A.filename}`))}):null,h?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!h&&(d==null?void 0:d.can_execute)!==!0?e.jsx(Qp,{exec_cfg:d}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function $b(s){const{open:n,batch_selected_items:r,merge_package:i,set_merge_package:l,merge_task_type:u,set_merge_task_type:m,merge_title:d,set_merge_title:h,merge_summary:x,set_merge_summary:v,merge_loading:g,merge_error:w,on_confirm:L,on_close:A}=s;return e.jsxs(tr,{open:n,title:"Merge planned items into master backlog?",onClose:A,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:A,disabled:g,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:L,disabled:g||r.length<2||!d.trim()||!i.trim(),children:g?"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:i,onChange:$=>l($.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:u,onChange:$=>m($.target.value),children:er.map($=>e.jsx("option",{value:$,children:$},$))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:d,onChange:$=>h($.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:x,onChange:$=>v($.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.jsxs("div",{children:["- docs/backlog/planned/",$.filename]},`mergeitem:${$.filename}`))})]}):null,w?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:w}):null]})}function Zd(s){const n=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(s).matches,[r,i]=f.useState(n);return f.useEffect(()=>{var m;if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(s),u=()=>i(l.matches);return u(),typeof l.addEventListener=="function"?l.addEventListener("change",u):(m=l.addListener)==null||m.call(l,u),()=>{var d;typeof l.removeEventListener=="function"?l.removeEventListener("change",u):(d=l.removeListener)==null||d.call(l,u)}},[s]),r}function e_(s,n){const[r,i]=f.useState(null);return f.useEffect(()=>{if(!n){i(null);return}let l=!1;return(async()=>{try{const u=await s.admin_executors(),m=Array.isArray(u)?u:Array.isArray(u==null?void 0:u.executors)?u.executors:[];l||i(m)}catch{l||i(null)}})(),()=>{l=!0}},[n]),r}function em(s){const{gateway:n,can_use_gateway:r,kind:i,completed_view:l,is_exec_view:u,is_compact_layout:m,set_compact_pane:d,on_status_transfer:h}=s,[x,v]=f.useState(null),[g,w]=f.useState(!1),[L,A]=f.useState(""),[$,T]=f.useState([]),[B,O]=f.useState(!1),[M,P]=f.useState(""),[E,Q]=f.useState(null),[oe,G]=f.useState(null),[Ne,je]=f.useState(!1),[we,ve]=f.useState(""),[H,X]=f.useState(""),[Z,U]=f.useState(!1),[Y,I]=f.useState(""),[te,ae]=f.useState("events"),[k,C]=f.useState(""),[re,he]=f.useState(!1),[le,D]=f.useState(""),[be,$e]=f.useState(!1),[Oe,Re]=f.useState(!0),rt=f.useRef(null),qe=f.useRef(!0),it=f.useRef(null),Ge=f.useRef(!1),ct=f.useRef(!1),et=1e6,fe=f.useMemo(()=>te!=="events"?null:Jx(k),[k,te]),ce=f.useMemo(()=>Qx(fe),[fe]),Ee=nl(E);function se(){Q(null),G(null),ve(""),C(""),D(""),$e(!1),it.current=null}async function W(){if(!r)return null;if(g)return x;A(""),w(!0);try{const xe=await n.backlog_exec_config();return v(xe),xe}catch(xe){const ke=String((xe==null?void 0:xe.message)||xe||"Failed to load backlog exec config");return A(ke),v(null),null}finally{w(!1)}}async function ie(xe,ke,J){if(ct.current)return $;ct.current=!0,J!=null&&J.background||O(!0);const R=xe||i;try{const ee=Gx(R,ke||l),Pe=await n.backlog_exec_requests({status:ee,limit:200}),Fe=Array.isArray(Pe==null?void 0:Pe.requests)?Pe.requests:[];P(""),T(Fe);const Xe=String((E==null?void 0:E.status)||"").trim().toLowerCase(),ut=Xe==="failed"||Xe==="completed"||Xe==="promoted";if(R==="processing"&&(E!=null&&E.request_id)&&!ut&&!Fe.some(mt=>mt.request_id===E.request_id))try{const mt=await n.backlog_exec_request(E.request_id),Le=mt==null?void 0:mt.payload,nt=String((Le==null?void 0:Le.status)||"").trim().toLowerCase();(nt==="failed"||nt==="completed"||nt==="promoted")&&(h(nt),G(Le),Q(Oo(Le,E.request_id)))}catch{}if(E!=null&&E.request_id){const mt=Fe.find(Le=>Le.request_id===E.request_id)||null;mt&&Q(mt)}return Fe}catch(ee){return P(String((ee==null?void 0:ee.message)||ee||"Failed to load backlog exec requests")),[]}finally{ct.current=!1,J!=null&&J.background||O(!1)}}async function Ce(xe){if(r){Q(xe),m&&d("detail"),G(null),ve(""),je(!0),I(""),X(""),C(""),D(""),$e(!1),it.current=null;try{const ke=await n.backlog_exec_request(xe.request_id);G((ke==null?void 0:ke.payload)??null)}catch(ke){ve(String((ke==null?void 0:ke.message)||ke||"Failed to load request"))}finally{je(!1)}}}async function Je(xe){if(!r)return;const ke=String((E==null?void 0:E.request_id)||"").trim();if(!ke||Z)return;const J=String(H||"");if(!J.trim()){I("Feedback is required.");return}I(""),U(!0);try{const R=await n.backlog_exec_feedback({request_id:ke,feedback:J}),ee=(R==null?void 0:R.payload)??null;G(ee),ee&&Q(Oo(ee,ke)),X(""),await xe()}catch(R){I(String((R==null?void 0:R.message)||R||"Failed to send feedback"))}finally{U(!1)}}async function F(xe){if(!r)return;const ke=String((E==null?void 0:E.request_id)||"").trim();if(ke&&!Z){I(""),U(!0);try{const J=await n.backlog_exec_promote({request_id:ke,redeploy:!0}),R=(J==null?void 0:J.payload)??null;G(R),R&&Q(Oo(R,ke)),X(""),await xe()}catch(J){I(String((J==null?void 0:J.message)||J||"Failed to promote to prod"));try{const R=await n.backlog_exec_request(ke),ee=(R==null?void 0:R.payload)??null;G(ee),ee&&Q(Oo(ee,ke))}catch{}}finally{U(!1)}}}async function ue(xe){if(!r)return;const ke=String((E==null?void 0:E.request_id)||"").trim();if(ke&&!Z){I(""),U(!0);try{const J=await n.backlog_exec_deploy_uat({request_id:ke}),R=(J==null?void 0:J.payload)??null;G(R),R&&Q(Oo(R,ke)),await xe()}catch(J){I(String((J==null?void 0:J.message)||J||"Failed to deploy to UAT"))}finally{U(!1)}}}async function ye(xe){if(!r)return;const ke=String((xe==null?void 0:xe.request_id)||(E==null?void 0:E.request_id)||"").trim();if(!ke)return;const J=(xe==null?void 0:xe.name)||te,R=typeof(xe==null?void 0:xe.max_bytes)=="number"&&Number.isFinite(xe.max_bytes)?Number(xe.max_bytes):16e4;if(!Ge.current){Ge.current=!0,D(""),he(!0);try{const ee=`${ke}::${String(J)}`,Pe=it.current,Fe=Pe!==null&&Pe.key===ee,Xe=await n.backlog_exec_log_tail({request_id:ke,name:String(J),max_bytes:R,...Fe?{after_bytes:Pe.offset}:{}}),ut=typeof(Xe==null?void 0:Xe.next_offset)=="number"&&Number.isFinite(Xe.next_offset),mt=String((Xe==null?void 0:Xe.content)||"");Fe&&ut&&(Xe==null?void 0:Xe.reset)!==!0?(mt&&C(Le=>{let nt=Le+mt;if(nt.length>et){const ht=nt.length-et,Pt=nt.indexOf(`
90
- `,ht);nt=Pt>=0?nt.slice(Pt+1):nt.slice(ht),$e(!0)}return nt}),it.current={key:ee,offset:Number(Xe.next_offset)}):(C(mt),$e(!!(Xe!=null&&Xe.truncated)),it.current=ut?{key:ee,offset:Number(Xe.next_offset)}:null)}catch(ee){D(String((ee==null?void 0:ee.message)||ee||"Failed to load logs"))}finally{Ge.current=!1,he(!1)}}}return f.useEffect(()=>{r&&u&&W()},[u,r]),f.useEffect(()=>{if(!r||!u)return;const ke=setInterval(()=>{n.is_backing_off()||ie(i,void 0,{background:!0})},i==="processing"?2e3:5e3);return()=>clearInterval(ke)},[i,l,r,u,E==null?void 0:E.request_id]),f.useEffect(()=>{r&&u&&E!=null&&E.request_id&&ye({request_id:E.request_id,name:te})},[E==null?void 0:E.request_id,te,u,r]),f.useEffect(()=>{qe.current=!0},[E==null?void 0:E.request_id,te]),f.useEffect(()=>{if(!rt.current||!qe.current)return;const ke=window.requestAnimationFrame(()=>{const J=rt.current;J&&(J.scrollTop=J.scrollHeight)});return()=>window.cancelAnimationFrame(ke)},[k,te,E==null?void 0:E.request_id]),f.useEffect(()=>{if(!r||!u||!(E!=null&&E.request_id))return;const xe=String(E.status||"").trim().toLowerCase();if(xe==="completed"||xe==="promoted"||xe==="failed"||xe!=="running"&&Oe!==!0)return;const J=setInterval(()=>{n.is_backing_off()||ye({request_id:E.request_id,name:te})},xe==="running"?1500:2500);return()=>clearInterval(J)},[E==null?void 0:E.request_id,E==null?void 0:E.status,te,u,r,Oe]),{exec_cfg:x,exec_cfg_loading:g,exec_cfg_error:L,exec_requests:$,exec_loading:B,exec_error:M,exec_selected:E,set_exec_selected:Q,exec_detail:oe,set_exec_detail:G,exec_detail_loading:Ne,exec_detail_error:we,set_exec_detail_error:ve,exec_qa_feedback:H,set_exec_qa_feedback:X,exec_qa_loading:Z,exec_qa_error:Y,exec_log_name:te,set_exec_log_name:ae,exec_log_text:k,exec_log_loading:re,exec_log_error:le,exec_log_truncated:be,exec_log_auto:Oe,set_exec_log_auto:Re,exec_log_scroll_el_ref:rt,exec_log_follow_ref:qe,parsed_exec_events:fe,event_stats:ce,time_stats:Ee,clear_exec_selection:se,load_exec_config:W,refresh_exec_list:ie,load_exec_request:Ce,exec_send_feedback:Je,exec_promote_to_prod:F,exec_deploy_uat_now:ue,load_exec_log_tail:ye}}const jh=[{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 Eb(s){var tn;const n=s.gateway,r=s.gateway_connected,i=String(s.maintenance_ai_provider||"").trim(),l=String(s.maintenance_ai_model||"").trim(),u=String(s.maintenance_ai_reasoning||"").trim(),m=String(s.backlog_advisor_agent||"").trim()||"basic-agent",d=s.default_execution_mode==="inplace"?"inplace":"uat",h=Zd("(max-width: 767.98px)"),[x,v]=f.useState("planned"),[g,w]=f.useState([]),[L,A]=f.useState(!1),[$,T]=f.useState(""),[B,O]=f.useState(""),[M,P]=f.useState("all"),[E,Q]=f.useState(""),[oe,G]=f.useState(new Set),Ne=f.useRef(0),[je,we]=f.useState(null),[ve,H]=f.useState([]),[X,Z]=f.useState(null),[U,Y]=f.useState(d),[I,te]=f.useState(!1),ae=e_(n,r),[k,C]=f.useState(""),[re,he]=f.useState(!1),[le,D]=f.useState(d),[be,$e]=f.useState(!1),[Oe,Re]=f.useState(""),[rt,qe]=f.useState(!1),[it,Ge]=f.useState(!1),[ct,et]=f.useState("framework"),[fe,ce]=f.useState("task"),[Ee,se]=f.useState(""),[W,ie]=f.useState(""),[Ce,Je]=f.useState(!1),[F,ue]=f.useState(""),ye=em({gateway:n,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:h,set_compact_pane:()=>{},on_status_transfer:()=>{}});async function xe(){if(!r)return;const ge=++Ne.current;A(!0),T("");try{const Te=await n.backlog_list(x);if(ge!==Ne.current)return;w(Array.isArray(Te==null?void 0:Te.items)?Te.items:[])}catch(Te){if(ge!==Ne.current)return;w([]),T(String((Te==null?void 0:Te.message)||Te||"Failed to load backlog"))}finally{ge===Ne.current&&A(!1)}if(x==="planned")try{const Te=await n.backlog_exec_active_items();if(ge!==Ne.current)return;const Ye=new Set;for(const yt of Array.isArray(Te==null?void 0:Te.items)?Te.items:[]){const _t=String((yt==null?void 0:yt.filename)||"").trim();_t&&Ye.add(_t)}G(Ye)}catch{ge===Ne.current&&G(new Set)}else G(new Set)}f.useEffect(()=>{H([]),Q(""),xe()},[x,r]),f.useEffect(()=>{H(ge=>{const Te=new Set(g.map(yt=>String(yt.filename||"").trim())),Ye=ge.filter(yt=>Te.has(yt));return Ye.length===ge.length?ge:Ye})},[g]);const ke=f.useMemo(()=>{const ge=B.trim().toLowerCase(),Te=M.trim().toLowerCase();return g.filter(Ye=>{if(Te&&Te!=="all"&&tl(Ye.task_type)!==Te)return!1;if(!ge)return!0;const yt=Array.isArray(Ye.labels)?Ye.labels.join(" "):"";return`${Ye.item_id||""} ${Ye.package||""} ${Ye.title||""} ${Ye.task_type||""} ${Ye.summary||""} ${Ye.filename||""} ${yt} ${Ye.priority||""}`.toLowerCase().includes(ge)})},[g,B,M]),J=f.useMemo(()=>g.filter(ge=>ve.includes(String(ge.filename||"").trim())),[g,ve]),R=Ai($),[ee,Pe]=f.useState(0),Fe=Yd(n,r&&R,ee);function Xe(ge){we({filename:String(ge.filename||""),kind:x,title:ge.title||ge.filename,initial_tab:"spec"})}async function ut(ge,Te){Q("");try{await n.backlog_move({from_kind:x,to_kind:Te,filename:String(ge.filename||"")}),await xe()}catch(Ye){Q(String((Ye==null?void 0:Ye.message)||Ye||"Move failed"))}}async function mt(ge){const Te=String(ge.filename||"").trim();if(!Te)return;let Ye=null;try{const yt=await n.backlog_content("planned",Te);Ye=Qd({task_type:ge.task_type},Mi(String((yt==null?void 0:yt.content)||"")))}catch{Ye=null}C(""),Y(d),Z({filename:Te,title:ge.title||Te,readiness:Ye}),ye.load_exec_config()}async function Le(ge){if(!(!X||I)){te(!0),C("");try{const Te=ye.exec_cfg||await ye.load_exec_config();if(!Te||Te.can_execute!==!0){C((Te==null?void 0:Te.runner_error)||"Backlog exec is not available on this gateway.");return}const Ye=!!(X.readiness&&!X.readiness.ok);await n.backlog_execute({kind:"planned",filename:X.filename,execution_mode:U,executor:ge==null?void 0:ge.executor,target_model:ge==null?void 0:ge.target_model,target_reasoning_effort:ge==null?void 0:ge.target_reasoning_effort,dor:"check",override:Ye}),Z(null),await xe()}catch(Te){const Ye=Td(Te);Ye?(Z(yt=>yt&&{...yt,readiness:Ye,server_refused:!0}),C("")):C(String((Te==null?void 0:Te.message)||Te||"Execute failed"))}finally{te(!1)}}}async function nt(ge){if(!(be||J.length<2)){Re(""),$e(!0);try{const Te=ye.exec_cfg||await ye.load_exec_config();if(!Te||Te.can_execute!==!0){Re((Te==null?void 0:Te.runner_error)||"Backlog exec is not available on this gateway.");return}await n.backlog_execute_batch({items:J.map(Ye=>({kind:"planned",filename:String(Ye.filename||"")})),execution_mode:le,executor:ge,dor:"check",override:rt}),he(!1),H([]),qe(!1),await xe()}catch(Te){const Ye=Td(Te);if(Ye){const yt=Ye.checks.filter(_t=>!_t.ok);qe(!0),Re(`Definition of Ready refused by the gateway:
91
- ${yt.map(_t=>`○ ${_t.label}${_t.evidence?` — ${_t.evidence}`:""}`).join(`
92
- `)}
93
- Execute batch again to override (recorded as dor_overridden).`)}else Re(String((Te==null?void 0:Te.message)||Te||"Execute batch failed"))}finally{$e(!1)}}}async function ht(){if(Ce||J.length<2)return;const ge=Ee.trim();if(!ge){ue("Title is required.");return}ue(""),Je(!0);try{await n.backlog_merge({kind:"planned",items:J.map(Te=>({kind:"planned",filename:String(Te.filename||"")})),package:ct.trim()||"framework",task_type:fe,title:ge,summary:W.trim()||void 0}),Ge(!1),H([]),await xe()}catch(Te){ue(String((Te==null?void 0:Te.message)||Te||"Merge failed"))}finally{Je(!1)}}function Pt(ge){const Te=String(ge||"").trim();H(Ye=>Ye.includes(Te)?Ye.filter(yt=>yt!==Te):[...Ye,Te])}function wt(ge){if(x==="planned"){const Te=oe.has(String(ge.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void mt(ge),disabled:!r||Te,title:Te?"A live execution request already exists for this item":void 0,children:Te?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void ut(ge,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ut(ge,"trash"),disabled:!r,children:"Trash"})]})}return x==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void ut(ge,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void ut(ge,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ut(ge,"trash"),disabled:!r,children:"Trash"})]}):x==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ut(ge,"trash"),disabled:!r,children:"Trash"}):x==="deprecated"||x==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void ut(ge,"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:jh.map(ge=>e.jsx("button",{"aria-pressed":x===ge.id,className:`seg_btn ${x===ge.id?"active":""}`,onClick:()=>v(ge.id),children:ge.label},ge.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 ${L?"is_loading":""}`,onClick:()=>void xe(),disabled:!r||L,title:"Refresh","aria-label":"Refresh",children:[e.jsx(Ue,{name:"refresh",size:16}),L?"Refreshing":"Refresh"]})]}),R?e.jsx(Xd,{gateway:n,surface:"the backlog archive",status:Fe.status,legacy:Fe.legacy,error:$,on_changed:()=>{Pe(ge=>ge+1),xe()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:B,onChange:ge=>O(ge.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:M,onChange:ge=>P(ge.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),er.map(ge=>e.jsx("option",{value:ge,children:ge},ge))]}),e.jsx("div",{className:"page_toolbar_spacer"}),x==="planned"&&ve.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[ve.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:ve.length<2,onClick:()=>{Re(""),D(d),qe(!1),he(!0),ye.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:ve.length<2,onClick:()=>{const ge=J.map(Te=>String(Te.package||"").trim()).filter(Boolean);et(ge.length&&ge.every(Te=>Te===ge[0])?ge[0]:"framework"),ce("task"),se(`Master backlog (${J.length} items)`),ie(""),ue(""),Ge(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[ke.length,"/",g.length]})]}),$&&!R?e.jsx("div",{className:"page_error mono",children:$}):null,E?e.jsx("div",{className:"page_error mono",children:E}):null,e.jsxs("div",{className:"pane backlog_table_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:(tn=jh.find(ge=>ge.id===x))==null?void 0:tn.label}),e.jsxs("span",{className:"pane_count",children:[ke.length," item",ke.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:ke.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[x==="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"}),x!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:ke.map(ge=>{const Te=String(ge.filename||"").trim(),Ye=tl(ge.task_type),yt=Md(ge)?Ld(ge.priority):null,_t=Array.isArray(ge.labels)?ge.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>Xe(ge),children:[x==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:jt=>jt.stopPropagation(),children:e.jsx("label",{className:"backlog_sel_hit",children:e.jsx("input",{type:"checkbox",checked:ve.includes(Te),onChange:()=>Pt(Te),"aria-label":`Select ${Te}`})})}):null,e.jsx("td",{className:"mono muted col_id",children:ge.item_id||""}),e.jsx("td",{className:"col_type",children:Ye?e.jsx("span",{className:`chip mono ${Fp(Ye)}`,title:qp(Ye),children:Ye}):null}),e.jsx("td",{className:"mono muted col_package",title:ge.package||"",children:ge.package||""}),e.jsx("td",{className:"backlog_table_title",title:Te,children:ge.title||Te}),e.jsx("td",{className:"col_priority",children:yt?e.jsx("span",{className:`chip mono board_prio_${yt.toLowerCase()}`,children:yt}):null}),e.jsxs("td",{className:"col_labels",title:_t.join(", "),children:[_t.slice(0,2).map(jt=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:jt},jt)),_t.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",_t.length-2]}):null]}),x!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:jt=>jt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:wt(ge)})}):null]},`${x}:${Te}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:L?"Loading…":"No items."})})]})]}),e.jsx(Zp,{open:!!X,target:X?{kind:"planned",filename:X.filename,title:X.title}:null,execute_mode:U,set_execute_mode:Y,action_loading:I,action_error:k,exec_cfg:ye.exec_cfg,exec_cfg_loading:ye.exec_cfg_loading,exec_cfg_error:ye.exec_cfg_error,executors:ae,readiness:(X==null?void 0:X.readiness)??null,server_refused:(X==null?void 0:X.server_refused)===!0,show_readiness:!0,on_open_spec:X?()=>{const ge=X;Z(null),we({filename:ge.filename,kind:"planned",title:ge.title,initial_tab:"spec"})}:void 0,on_confirm:ge=>void Le(ge),on_close:()=>Z(null)}),e.jsx(Cb,{open:re,batch_selected_items:J,batch_execute_mode:le,set_batch_execute_mode:D,batch_execute_loading:be,batch_execute_error:Oe,executors:ae,exec_cfg:ye.exec_cfg,exec_cfg_loading:ye.exec_cfg_loading,exec_cfg_error:ye.exec_cfg_error,on_confirm:ge=>void nt(ge),on_close:()=>{he(!1),Re(""),qe(!1)}}),e.jsx($b,{open:it,batch_selected_items:J,merge_package:ct,set_merge_package:et,merge_task_type:fe,set_merge_task_type:ce,merge_title:Ee,set_merge_title:se,merge_summary:W,set_merge_summary:ie,merge_loading:Ce,merge_error:F,on_confirm:()=>void ht(),on_close:()=>{Ge(!1),ue("")}}),e.jsx(Jp,{gateway:n,can_use_gateway:r,target:je,on_close:()=>we(null),on_mutated:async()=>{await xe()},on_open_executions:ge=>{var Te;return(Te=s.on_open_executions)==null?void 0:Te.call(s,ge)}}),e.jsx(jb,{gateway:n,can_use_gateway:r,is_compact_layout:h,maint_provider:i,maint_model:l,maint_reasoning:u,advisor_agent:m,focus_kind:x,focus_type:M,voice_session_id:s.voice_session_id})]})}function Tb(s){const{open:n,gateway:r,can_use_gateway:i,maint_provider:l,maint_model:u,maint_reasoning:m,on_close:d,on_created:h}=s,[x,v]=f.useState(""),[g,w]=f.useState(!1),[L,A]=f.useState(""),[$,T]=f.useState("proposed"),[B,O]=f.useState("feature"),[M,P]=f.useState("framework"),[E,Q]=f.useState(""),[oe,G]=f.useState(""),[Ne,je]=f.useState(""),[we,ve]=f.useState(""),[H,X]=f.useState(""),[Z,U]=f.useState(""),[Y,I]=f.useState(!1),[te,ae]=f.useState(""),[k,C]=f.useState(""),[re,he]=f.useState(""),[le,D]=f.useState(""),[be,$e]=f.useState(""),[Oe,Re]=f.useState(""),[rt,qe]=f.useState(""),[it,Ge]=f.useState(""),[ct,et]=f.useState(""),[fe,ce]=f.useState(""),[Ee,se]=f.useState([]),[W,ie]=f.useState(!1),[Ce,Je]=f.useState(""),[F,ue]=f.useState([]),[ye,xe]=f.useState(""),[ke,J]=f.useState(!1);function R(){T("proposed"),O("feature"),P("framework"),Q(""),G(""),je(""),ve(""),X(""),U(""),I(!1),ae(""),C(""),he(""),D(""),$e(""),Re(""),qe(""),Ge(""),et(""),ce(""),se([]),ie(!1),Je(""),ue([]),xe(""),J(!1)}function ee(){d(),R()}async function Pe(){const Le=String(x||"").trim();if(Le)return Le;if(g)return"";A(""),w(!0);try{const nt=await r.backlog_template(),ht=String((nt==null?void 0:nt.content)||"");return v(ht),ht}catch(nt){return A(String((nt==null?void 0:nt.message)||nt||"Failed to load backlog template")),""}finally{w(!1)}}async function Fe(Le){if(!i)return;const nt=(Le==null?void 0:Le.force)===!0;if(!nt&&H.trim())return;const ht=await Pe();if(!ht.trim())return;const Pt=String(M||"").trim().toLowerCase()||"{Package}",wt=$d(),tn=Yx(ht,{package_name:Pt,title:E,task_type:B,summary:oe,created_at:wt});X(ge=>nt||!String(ge||"").trim()?tn:ge)}f.useEffect(()=>{n&&i&&Fe()},[n,i]);function Xe(Le){if(H.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const nt=String(M||"").trim().toLowerCase()||"{Package}",ht=$d(),Pt=Xx({package_name:nt,title:E,task_type:B,summary:oe,diagram:te,context:k,included:Ja(re),excluded:Ja(le),plan:Ja(be),dependencies:Ja(Oe),acceptance:Ja(rt),tests_a:Ja(it),tests_b:Ja(ct),tests_c:Ja(fe),created_at:ht,attachments:[]});X(Pt)}async function ut(){var nt;if(Y)return;U(""),I(!0),Je("");let Le="";try{const ht=String(M||"").trim().toLowerCase(),Pt=Jd(we),wt=!!(Ne||Pt.length);let tn=H||"";wt&&tn.trim()&&(tn=Ad(tn,{priority:Ne||null,labels:Pt}));const ge=await r.backlog_create({kind:$,package:ht,title:E,task_type:B,summary:oe||null,content:tn||null}),Te=String((ge==null?void 0:ge.kind)||"").trim(),Ye=String((ge==null?void 0:ge.filename)||"").trim();if(wt&&!tn.trim()&&Te&&Ye)try{const _t=await r.backlog_content(Te,Ye),jt=String((_t==null?void 0:_t.content)||""),ot=await Ed(jt),$n=Ad(jt,{priority:Ne||null,labels:Pt});await r.backlog_update({kind:Te,filename:Ye,content:$n,expected_sha256:ot||null})}catch(_t){Le=[Le,`metadata lines not written: ${String((_t==null?void 0:_t.message)||_t)}`].filter(Boolean).join("; ")}const yt=[...Ee||[]];if(Te&&Ye&&yt.length){ie(!0);const _t=[];try{for(const jt of yt){const ot=await r.backlog_upload_attachment({kind:Te,filename:Ye,file:jt,overwrite:!1}),$n=String(((nt=ot==null?void 0:ot.stored)==null?void 0:nt.relpath)||"").trim();$n&&_t.push($n)}}catch(jt){Le=[Le,String((jt==null?void 0:jt.message)||jt||"Attachment upload failed")].filter(Boolean).join("; "),Je(Le)}finally{if(_t.length)try{const jt=await r.backlog_content(Te,Ye),ot=String((jt==null?void 0:jt.content)||""),$n=await Ed(ot),$s=Zx(ot,_t);await r.backlog_update({kind:Te,filename:Ye,content:$s,expected_sha256:$n||null})}catch(jt){Le=[Le,`uploaded files not linked: ${String((jt==null?void 0:jt.message)||jt)}`].filter(Boolean).join("; ")}ie(!1)}}d(),R();try{await h(Te,Ye,Le)}catch{}}catch(ht){U(String((ht==null?void 0:ht.message)||ht||"Create failed"))}finally{I(!1)}}async function mt(){if(ke)return;U("");const Le=ye.trim();if(!Le)return;if(!E.trim()){U("Title is required before using AI assist.");return}const nt=String(M||"").trim().toLowerCase();if(!nt){U("Package is required before using AI assist.");return}const ht={id:Dr(),role:"user",content:Le,ts:new Date().toISOString()},Pt=[...F,ht];ue(Pt),xe(""),J(!0);try{const wt=await r.backlog_assist({kind:$,package:nt,title:E,summary:oe||null,draft_markdown:H||null,messages:Pt.map(Te=>({role:Te.role,content:Te.content})),provider:l||null,model:u||null,thinking:m||null}),tn=String((wt==null?void 0:wt.reply)||"").trim(),ge=String((wt==null?void 0:wt.draft_markdown)||"").trim();tn&&ue(Te=>[...Te,{id:Dr(),role:"assistant",content:tn,ts:new Date().toISOString()}]),ge&&X(ge)}catch(wt){U(String((wt==null?void 0:wt.message)||wt||"AI assist failed"))}finally{J(!1)}}return e.jsxs(tr,{open:n,title:"New backlog task",onClose:ee,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:ee,disabled:Y||ke,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ut(),disabled:Y||!E.trim()||!M.trim(),children:Y?"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:$,onChange:Le=>T(Le.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:B,onChange:Le=>O(Le.target.value),children:er.map(Le=>e.jsx("option",{value:Le,children:Le},Le))})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:M,onChange:Le=>P(Le.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:E,onChange:Le=>Q(Le.target.value),placeholder:"Short descriptive title"})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Priority"}),e.jsxs("select",{value:Ne,onChange:Le=>je(Le.target.value),children:[e.jsx("option",{value:"",children:"unset"}),sl.map(Le=>e.jsx("option",{value:Le,children:Wp[Le]},Le))]})]})}),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:we,onChange:Le=>ve(Le.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:Le=>G(Le.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:te,onChange:Le=>ae(Le.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:k,onChange:Le=>C(Le.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:re,onChange:Le=>he(Le.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:le,onChange:Le=>D(Le.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:be,onChange:Le=>$e(Le.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:Le=>Re(Le.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:rt,onChange:Le=>qe(Le.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:it,onChange:Le=>Ge(Le.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:ct,onChange:Le=>et(Le.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:fe,onChange:Le=>ce(Le.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:()=>Xe(),disabled:Y||ke,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:Le=>{const nt=Array.from(Le.target.files||[]);nt.length&&(se(ht=>[...ht,...nt]),Le.currentTarget.value="")}})}),Ee.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:Ee.map((Le,nt)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Le.name," (",Math.round(Le.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>se(ht=>ht.filter((Pt,wt)=>wt!==nt)),disabled:Y||W,children:"Remove"})]},`${Le.name}_${Le.size}_${nt}`))}):null,W?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,Ce?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ce}):null,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."}),g?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Loading template…"}):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.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{H.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||Fe({force:!0})},disabled:Y||ke||g||!i,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:H,onChange:Le=>X(Le.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(Rc,{messages:F,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(ol,{value:ye,onChange:xe,onSubmit:()=>void mt(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!i||!E.trim(),busy:ke,rows:3,sendButtonClassName:"btn primary"})}),Z?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Z}):null]})}class t_ extends Bt.Component{constructor(){super(...arguments);Ka(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,i){return i.error&&i.for_key!==void 0&&r.resetKey!==i.for_key?{error:null,for_key:r.resetKey}:i.for_key!==r.resetKey&&!i.error?{for_key:r.resetKey}:null}componentDidCatch(r,i){var l,u;try{(u=(l=this.props).onError)==null||u.call(l,r,i)}catch{}}render(){const{error:r}=this.state;if(r){const{fallback:i}=this.props;return typeof i=="function"?i(r):i}return this.props.children}}function n_(s){return`abstractcontinuum_list_open_${s}`}function s_(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function zd(s,n=s_()){try{return(n==null?void 0:n.getItem(n_(s)))!=="0"}catch{return!0}}function a_(s,n,r=s_()){try{r==null||r.setItem(n_(s),n?"1":"0")}catch{}}function Mc(s){const[n,r]=f.useState(()=>zd(s)),i=f.useCallback(()=>{r(l=>{const u=!l;return a_(s,u),u})},[s]);return[n,i]}function Ab(s){const[n,r]=f.useState({}),i=f.useCallback(u=>u in n?n[u]:zd(`${s}_${u}`),[n,s]),l=f.useCallback(u=>{r(m=>{const d=!(u in m?m[u]:zd(`${s}_${u}`));return a_(`${s}_${u}`,d),{...m,[u]:d}})},[s]);return[i,l]}function al(s){return e.jsxs("button",{type:"button",className:"list_disclosure","aria-expanded":s.open,"aria-controls":s.controls,onClick:s.on_toggle,title:s.open?`Hide ${s.title.toLowerCase()}`:`Show ${s.title.toLowerCase()}`,children:[e.jsx(Ue,{name:s.open?"chevronDown":"chevronRight",size:14}),e.jsx("span",{className:s.title_class||"pane_title",children:s.title}),s.count!==void 0?e.jsx("span",{className:s.count_class||"pane_count",children:s.count}):null]})}function rl(s){var n,r;try{if(!s||typeof window>"u"||!((n=window.matchMedia)!=null&&n.call(window,"(max-width: 767.98px)").matches))return;(r=s.scrollIntoView)==null||r.call(s,{block:"start",behavior:"smooth"})}catch{}}class tm{async _fetch(n,r,i){const l=await fetch(`api/hub${r}`,{...i,signal:(i==null?void 0:i.signal)??AbortSignal.timeout(2e4),headers:{...i!=null&&i.body?{"Content-Type":"application/json"}:{}}}),u=await l.text();let m=null;try{m=JSON.parse(u)}catch{}if(!l.ok){const d=m&&typeof m=="object"&&(m.detail||m.error)||u,h=new Error(`${n} failed: ${d}`);throw h.status=l.status,h}return m}async meta(){return await this._fetch("hub_meta","/meta")}async healthz(){return await this._fetch("hub_healthz","/healthz")}async ledger(n){return await this._fetch("hub_ledger",`/channels/${encodeURIComponent(n)}/ledger`)}async channel_info(n){return await this._fetch("hub_channel_info",`/channels/${encodeURIComponent(n)}/info`)}async digest(n){return await this._fetch("hub_digest",`/channels/${encodeURIComponent(n)}/digest`)}async fs_list(n,r=""){const i=r?`?prefix=${encodeURIComponent(r)}`:"",l=await this._fetch("hub_fs_list",`/channels/${encodeURIComponent(n)}/fs${i}`);return Array.isArray(l)?l:[]}async fs_read(n,r){const i=r.split("/").map(encodeURIComponent).join("/");return await this._fetch("hub_fs_read",`/channels/${encodeURIComponent(n)}/fs/${i}`)}async inbox(){const n=await this._fetch("hub_inbox","/inbox");return Array.isArray(n)?n:[]}async channels(){const n=await this._fetch("hub_channels","/channels");return Array.isArray(n)?n:[]}async messages(n,r){const i=new URLSearchParams;(r==null?void 0:r.since)!==void 0&&i.set("since",String(r.since)),r!=null&&r.limit&&i.set("limit",String(r.limit)),r!=null&&r.sort&&i.set("sort",r.sort);const l=await this._fetch("hub_messages",`/channels/${encodeURIComponent(n)}/messages?${i.toString()}`);return Array.isArray(l)?l:[]}async search(n){const r=new URLSearchParams;r.set("q",n.q);for(const i of n.channel??[])r.append("channel",i);return n.sender&&r.set("sender",n.sender),n.kind&&r.set("kind",n.kind),n.since!==void 0&&r.set("since",String(n.since)),n.until!==void 0&&r.set("until",String(n.until)),n.ref&&r.set("ref",n.ref),n.rated&&r.set("rated",n.rated),n.min_votes&&r.set("min_votes",String(n.min_votes)),n.sort&&r.set("sort",n.sort),n.limit&&r.set("limit",String(n.limit)),n.cursor&&r.set("cursor",n.cursor),await this._fetch("hub_search",`/search?${r.toString()}`)}async read_message(n,r){const i=await this._fetch("hub_read_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}`);return(Array.isArray(i)?i[0]:i)??null}async post_message(n,r){return await this._fetch("hub_post",`/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(r)})}async upload_attachment(n,r){const i=`api/hub/channels/${encodeURIComponent(n)}/attachments?filename=${encodeURIComponent(r.name)}`,l=await fetch(i,{method:"POST",headers:{"Content-Type":r.type||"application/octet-stream"},body:r,signal:AbortSignal.timeout(6e4)}),u=await l.text();let m=null;try{m=JSON.parse(u)}catch{}if(!l.ok){const d=m&&typeof m=="object"&&(m.detail||m.error)||u,h=new Error(`upload failed: ${d}`);throw h.status=l.status,h}if(!m||typeof m!="object"||!m.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return m}attachment_url(n,r){return`api/hub/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(r)}`}async ack(n,r){return await this._fetch("hub_ack","/inbox/ack",{method:"POST",body:JSON.stringify({cursors:{[n]:r}})})}async members(n){const r=await this._fetch("hub_members",`/channels/${encodeURIComponent(n)}/members`);return Array.isArray(r)?r:[]}async create_channel(n,r){return await this._fetch("hub_create_channel","/channels",{method:"POST",body:JSON.stringify({name:n,private:r})})}async put_channel_meta(n,r,i){const l={value:r};return typeof i=="number"&&(l.expect_version=i),await this._fetch("hub_channel_meta_put",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent("channel:meta")}`,{method:"PUT",body:JSON.stringify(l)})}async channel_meta(n){return await this._fetch("hub_channel_meta",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent("channel:meta")}`)}async block(n,r,i){return await this._fetch("hub_block",`/channels/${encodeURIComponent(n)}/blocks`,{method:"POST",body:JSON.stringify({agent:r,seconds:i==null?void 0:i.seconds,reason:i==null?void 0:i.reason})})}async unblock(n,r){return await this._fetch("hub_unblock",`/channels/${encodeURIComponent(n)}/blocks/${encodeURIComponent(r)}`,{method:"DELETE"})}async hub_block(n,r){return await this._fetch("hub_hub_block","/hub/blocks",{method:"POST",body:JSON.stringify({agent:n,seconds:r==null?void 0:r.seconds,reason:r==null?void 0:r.reason})})}async hub_unblock(n){return await this._fetch("hub_hub_unblock",`/hub/blocks/${encodeURIComponent(n)}`,{method:"DELETE"})}async leave(n){return await this._fetch("hub_leave",`/channels/${encodeURIComponent(n)}/leave`,{method:"POST"})}async archive(n){return await this._fetch("hub_archive",`/channels/${encodeURIComponent(n)}/archive`,{method:"POST"})}async unarchive(n){return await this._fetch("hub_unarchive",`/channels/${encodeURIComponent(n)}/archive`,{method:"DELETE"})}async retire_agent(n,r){return await this._fetch("hub_retire",`/agents/${encodeURIComponent(n)}/retire`,{method:"POST",body:JSON.stringify(r?{reason:r}:{})})}async unretire_agent(n){return await this._fetch("hub_unretire",`/agents/${encodeURIComponent(n)}/retire`,{method:"DELETE"})}async retired_agents(){const n=await this._fetch("hub_retired","/agents/retired");return Array.isArray(n)?n:[]}async delete_agent(n){return await this._fetch("hub_delete_agent",`/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async list_blocks(n){const r=n?`?scope=${encodeURIComponent(n)}`:"",i=await this._fetch("hub_blocks",`/blocks${r}`);return Array.isArray(i)?i:[]}async send_dm(n,r){return await this._fetch("hub_send_dm",`/dms/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify({body:r.body,title:r.title||void 0,status:r.status||"open"})})}async store_keys(n){const r=await this._fetch("hub_store_keys",`/channels/${encodeURIComponent(n)}/store`);return Array.isArray(r)?r:[]}async store_get(n,r){return await this._fetch("hub_store_get",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent(r)}`)}async delegations(){const n=await this._fetch("hub_delegations","/delegations");return Array.isArray(n)?n:[]}async set_delegation(n,r,i){return await this._fetch("hub_set_delegation","/admin/delegation",{method:"PUT",body:JSON.stringify({agent_id:n,powers:r,ttl_seconds:(i==null?void 0:i.ttl_seconds)??null,note:(i==null?void 0:i.note)??""})})}async revoke_delegation(n){return await this._fetch("hub_revoke_delegation",`/admin/delegation/${encodeURIComponent(n)}`,{method:"DELETE"})}async retract_message(n,r){return await this._fetch("hub_retract",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/retract`,{method:"POST",body:JSON.stringify({})})}async desk(){const n=await this._fetch("hub_desk","/desk");return Array.isArray(n)?{rows:n,satisfied:[]}:{...n,rows:Array.isArray(n==null?void 0:n.rows)?n.rows:[],satisfied:Array.isArray(n==null?void 0:n.satisfied)?n.satisfied:[]}}async owed(){const n=await this._fetch("hub_owed","/owed"),r=n&&typeof n=="object"?n:{};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(n){return await this._fetch("hub_create_group","/groups",{method:"POST",body:JSON.stringify({name:n.name,members:n.members,purpose:n.purpose,opening_post:n.opening_post||n.purpose,private:n.private!==!1})})}async work_rows(n){const r=await this._fetch("hub_work_rows",`/channels/${encodeURIComponent(n)}/work`);return Array.isArray(r)?r:[]}async work(n){return await this._fetch("hub_work",`/work/${encodeURIComponent(n)}`)}async create_invite(n,r){const i=await this._fetch("hub_create_invite",`/channels/${encodeURIComponent(n)}/invites`,{method:"POST",body:JSON.stringify({agent_id:r})}),l=i&&typeof i=="object"?String(i.invite_token||""):"";if(!l)throw new Error("invite mint returned no token (unexpected hub response shape)");return l}async presence(){const n=await this._fetch("hub_presence","/presence");return Array.isArray(n)?n:[]}async reputation(n){return await this._fetch("hub_reputation",`/channels/${encodeURIComponent(n)}/reputation`)}async reputation_hub(){return await this._fetch("hub_reputation_hub","/reputation")}async reputation_votes(n,r){const i=await this._fetch("hub_reputation_votes",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}/votes`);return Array.isArray(i)?i:[]}async rate_message(n,r,i,l=""){const u={value:i,note:l};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(u)})}async unrate_message(n,r){return await this._fetch("hub_unrate_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/rating`,{method:"DELETE"})}async rate(n,r,i,l,u=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:i,value:l,note:u})})}async _delete_reputation(n,r,i){return await this._fetch("hub_unrate",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}?axis=${encodeURIComponent(i)}`,{method:"DELETE"})}ws_url(){const n=new URL("api/hub/ws",document.baseURI);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.href}}const Lb=["commons"],Mb=3e4,Rb=5*6e4,kh={live:new Map,done:[],work:new Map},Sh=new Set(["proposed","planned","completed","deprecated"]);function Pb(s,n){const r=n&&typeof n=="object"?String(n.item||""):"";if(r&&Vs(r))return r;const i=s.startsWith("claim:")?s.slice(6):"";return i&&Vs(i)?i:null}function zb(s){const[n,r]=f.useState(kh),i=f.useRef(new tm),l=f.useRef(new Map),u=f.useRef(0),m=f.useRef(!1);return f.useEffect(()=>{let d=!0;const h=async()=>{if(!(m.current||Date.now()<u.current)){m.current=!0;try{const v=new Map,g=[],w=new Map;for(const L of Lb){let A=!1;try{const T=await i.current.work_rows(L);for(const B of T){const O=String(B.id||B.item||""),M=String(B.status||"").toLowerCase();!Vs(O)||!Sh.has(M)||w.set(O,{item:O,title:typeof B.title=="string"?B.title:void 0,status:M,owner:typeof B.owner=="string"?B.owner:void 0,receipt:typeof B.receipt=="string"?B.receipt:void 0,card:typeof B.card=="string"?B.card:void 0,updated_at:B.updated_at})}A=!0}catch{}const $=await i.current.store_keys(L);for(const T of $){const B=String(T.key||"");if(B.startsWith("work:")){if(A)continue;const G=B.slice(5);if(!Vs(G))continue;const Ne=Number(T.version||0),je=`${L}\0${B}`,we=l.current.get(je);let ve;if(we&&we.version===Ne)ve=we.value;else{const X=await i.current.store_get(L,B);ve=X==null?void 0:X.value,l.current.set(je,{version:Ne,value:ve})}const H=ve&&typeof ve=="object"?String(ve.status||"").toLowerCase():"";if(!Sh.has(H))continue;w.set(G,{item:G,title:typeof ve.title=="string"?ve.title:void 0,status:H,owner:typeof ve.owner=="string"?ve.owner:void 0,receipt:typeof ve.receipt=="string"?ve.receipt:void 0,card:typeof ve.card=="string"?ve.card:void 0,updated_at:T.updated_at});continue}if(!B.startsWith("claim:"))continue;const O=Number(T.version||0),M=`${L}\0${B}`,P=l.current.get(M);let E;if(P&&P.version===O)E=P.value;else{const G=await i.current.store_get(L,B);E=G==null?void 0:G.value,l.current.set(M,{version:O,value:E})}if(!E||typeof E!="object"||typeof E.owner!="string"||!E.owner)continue;const Q=Pb(B,E)||B.slice(6);if(!Q)continue;!!E.done||String(E.status||"").toLowerCase()==="done"?g.push({item:Q,owner:E.owner,receipt:typeof E.receipt=="string"?E.receipt:void 0,updated_at:T.updated_at}):v.has(Q)||v.set(Q,E)}}g.sort((L,A)=>(A.updated_at||0)-(L.updated_at||0)),d&&r(L=>L.live.size===v.size&&[...v.keys()].every($=>JSON.stringify(L.live.get($))===JSON.stringify(v.get($)))&&JSON.stringify(L.done)===JSON.stringify(g)&&L.work.size===w.size&&[...w.keys()].every($=>JSON.stringify(L.work.get($))===JSON.stringify(w.get($)))?L:{live:v,done:g,work:w})}catch{u.current=Date.now()+Rb,d&&r(v=>v.live.size||v.done.length||v.work.size?kh:v)}finally{m.current=!1}}};h();const x=setInterval(()=>void h(),Mb);return()=>{d=!1,clearInterval(x)}},[s]),n}const Ib=40,Db=4;function Ob(s){const{gateway:n,can_use_gateway:r,data_nonce:i}=s,[l,u]=f.useState([]),[m,d]=f.useState(!1),[h,x]=f.useState(""),[v,g]=f.useState(""),[w,L]=f.useState(null),[A,$]=f.useState(null),[T,B]=f.useState({}),O=f.useRef({}),M=f.useRef(!1),P=f.useCallback(async G=>{if(r&&!M.current){M.current=!0,G!=null&&G.background||d(!0);try{const[Ne,je,we,ve,H]=await Promise.allSettled([n.backlog_list("proposed"),n.backlog_list("planned"),n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:60}),n.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200})]),X=[],Z=[],U=(be,$e)=>be.status==="fulfilled"?be.value:(X.push($e),Z.push(be.reason),null),Y=U(Ne,"proposed list"),I=U(je,"planned list"),te=U(we,"live requests"),ae=U(ve,"recent history"),k=U(H,"busy set");if(L(Z.find(be=>Ai(be))??null),!Y&&!I&&!te&&!ae){x("Failed to load the board (all sources failed)");return}x("");const C=Array.isArray(te==null?void 0:te.requests)?te.requests:[];let re=Array.isArray(k==null?void 0:k.items)?k.items:[];k||(re=C.map(be=>({request_id:String(be.request_id||""),status:String(be.status||""),kind:"planned",filename:String(be.backlog_filename||"").trim(),relpath:String(be.backlog_relpath||"").trim()})).filter(be=>be.filename&&!/^batch\(\d+\)$/i.test(be.filename)));const he=Array.isArray(Y==null?void 0:Y.items)?Y.items:[],le=Array.isArray(I==null?void 0:I.items)?I.items:[];$(Y&&I?he.length+le.length:null);const D=pb({proposed:he,planned:le,active_requests:C,terminal_requests:Array.isArray(ae==null?void 0:ae.requests)?ae.requests:[],active_items:re});u(D),g(X.length?`#FALLBACK partial board — failed: ${X.join(", ")}`:""),E(D,he,le)}finally{M.current=!1,G!=null&&G.background||d(!1)}}},[n,r]);async function E(G,Ne,je){const we=new Map;for(const Z of Ne)we.set(String(Z.filename||"").trim(),"proposed");for(const Z of je)we.set(String(Z.filename||"").trim(),"planned");const ve=G.filter(Z=>Z.filename&&!O.current[Z.filename]&&we.has(Z.filename)).filter(Z=>!Kp(Z)||Z.column==="ready").slice(0,Ib).map(Z=>({filename:Z.filename,kind:we.get(Z.filename)}));if(!ve.length)return;const H=[...ve],X=Array.from({length:Math.min(Db,H.length)},async()=>{for(;;){const Z=H.shift();if(!Z)return;try{const U=await n.backlog_content(Z.kind,Z.filename),Y=Mi(String((U==null?void 0:U.content)||""));O.current={...O.current,[Z.filename]:Y}}catch{}}});await Promise.all(X),B(O.current)}const Q=f.useCallback(async(G,Ne)=>{try{const je=await n.backlog_content(G,Ne),we=Mi(String((je==null?void 0:je.content)||""));O.current={...O.current,[Ne]:we},B(O.current)}catch{}},[n]);return f.useEffect(()=>{P()},[P,i]),f.useEffect(()=>{if(!r)return;const G=setInterval(()=>{n.is_backing_off()||P({background:!0})},1e4);return()=>clearInterval(G)},[r,P,n]),{cards:l,loading:m,error:h,degraded:v,unconfigured:w!==null,unavailable:w,item_count:A,metadata:T,refresh:P,refresh_item_metadata:Q}}function Nh(s,n){return s.length<=n?s:`${s.slice(0,n-1).trimEnd()}…`}const Fb=new tm;function qb(s){if(!s)return"";const n=Math.max(0,Date.now()/1e3-s);return n<3600?`${Math.max(1,Math.round(n/60))}m`:n<172800?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function Bb(s){const{card:n}=s,r=n.work_id||"",i=!!(r&&Vs(r)),[l,u]=f.useState({loading:i,error:"",claims:[],decisions:[],messages:[]});f.useEffect(()=>{let h=!0;if(i)return u(x=>({...x,loading:!0,error:""})),Fb.work(r).then(x=>{h&&u({loading:!1,error:"",claims:Array.isArray(x==null?void 0:x.claims)?x.claims:[],decisions:Array.isArray(x==null?void 0:x.decisions)?x.decisions:[],messages:(Array.isArray(x==null?void 0:x.messages)?x.messages:[]).slice().sort((v,g)=>(g.created_at||0)-(v.created_at||0))})}).catch(x=>{h&&u({loading:!1,error:String((x==null?void 0:x.message)||x||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{h=!1}},[r,i]);const m=l.messages[0],d=n.claim_started_at!==void 0&&n.claim_owner?Up({owner:n.claim_owner,started_at:n.claim_started_at},Date.now()):null;return e.jsx("div",{className:"modal_backdrop",onClick:s.on_close,children:e.jsxs("div",{className:"modal_panel board_claim_panel board_activity_panel",onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"modal_head",children:[e.jsx("span",{className:"modal_title",children:n.title}),e.jsx("button",{className:"btn",onClick:s.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,n.claim_owner?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:n.column==="done"?"completed by:":"held by:"})," ",n.claim_owner,d?e.jsxs("span",{className:"muted",children:[" · ",d.label]}):null]}):null,n.summary?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"receipt:"})," ",n.summary]}):null,n.card_path?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"item file:"})," ",e.jsx("span",{className:"mono",children:n.card_path}),e.jsxs("span",{className:"muted",children:[" (in ",n.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 ",l.loading?"· loading…":l.messages.length?`· ${l.messages.length} citing message(s)`:""]}),l.error?e.jsxs("div",{className:"muted team_note",children:["#FALLBACK hub activity unavailable (",l.error.slice(0,80),") — the Team thread button below still works."]}):null,!l.loading&&!l.error&&i&&!l.messages.length?e.jsx("div",{className:"muted team_note",children:"No citing messages on the hub yet."}):null,i?null:e.jsx("div",{className:"muted team_note",children:"This claim has no ruled work id — discussion lives in the coordination channel."}),l.messages.slice(0,8).map(h=>e.jsxs("div",{className:"board_activity_msg",children:[e.jsxs("div",{className:"board_activity_msg_head mono",children:[e.jsx("span",{children:h.sender}),e.jsxs("span",{className:"muted",children:[h.channel," #",h.seq," · ",qb(h.created_at)]}),s.on_open_team?e.jsx("button",{className:"team_row_expand",onClick:()=>s.on_open_team({channel:String(h.channel||""),message_id:String(h.id||""),seq:Number(h.seq)}),title:"Open this message in its Team channel",children:"open ↗"}):null]}),h.title?e.jsx("div",{className:"board_activity_msg_title",children:Nh(String(h.title),140)}):null,h.body?e.jsx("div",{className:"board_activity_msg_body muted",children:Nh(String(h.body),220)}):null]},h.id||h.seq))]}),e.jsx("div",{className:"entity_skills_actions",children:s.on_open_team?e.jsx("button",{className:"btn primary",onClick:()=>s.on_open_team(m?{channel:String(m.channel||"commons"),message_id:String(m.id||""),seq:Number(m.seq)}:{channel:"commons"}),title:m?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function Ub(s){var Je;const{gateway:n,gateway_connected:r,data_nonce:i,on_mutated:l,on_open_executions:u}=s,m=s.default_execution_mode==="inplace"?"inplace":"uat",d=Zd("(max-width: 767.98px)"),[h,x]=Ab("board_column"),v=e_(n,r),g=Ob({gateway:n,can_use_gateway:r,data_nonce:i}),[w,L]=f.useState(0),A=Yd(n,r,i+w),$=g.unconfigured||((Je=A.status)==null?void 0:Je.available)===!1,T=!$&&g.item_count===0&&!g.error,B=zb(!0),O=f.useMemo(()=>gb(g.cards,B),[g.cards,B]),M=em({gateway:n,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:d,set_compact_pane:()=>{},on_status_transfer:()=>{}}),[P,E]=f.useState("");f.useEffect(()=>{var ue;if(!s.query_preset)return;const F=Vs(s.query_preset);E(F?F.num.padStart(4,"0"):s.query_preset),(ue=s.on_query_preset_consumed)==null||ue.call(s)},[s.query_preset]);const[Q,oe]=f.useState("all"),[G,Ne]=f.useState("all"),[je,we]=f.useState(""),[ve,H]=f.useState(!1),[X,Z]=f.useState(null),[U,Y]=f.useState(null),[I,te]=f.useState(null),[ae,k]=f.useState("uat"),[C,re]=f.useState(!1),[he,le]=f.useState(""),[D,be]=f.useState(""),[$e,Oe]=f.useState(null),Re=f.useRef(null),rt=O.some(F=>F.column==="in_progress"),[,qe]=f.useState(0);f.useEffect(()=>{if(!rt)return;const F=setInterval(()=>qe(ue=>(ue+1)%3600),1e3);return()=>clearInterval(F)},[rt]);const it=f.useMemo(()=>{const F=new Set;for(const ue of O)ue.package&&F.add(ue.package);return[...F].sort()},[O]),Ge=f.useMemo(()=>O.filter(F=>F.filename&&F.kind).length,[O]),ct=f.useMemo(()=>O.filter(F=>F.filename&&F.kind&&(Kp(F)||g.metadata[F.filename])).length,[O,g.metadata]),et=f.useMemo(()=>{const F=new Map;for(const ue of O)if(ue.filename)for(const ye of Pd(ue,g.metadata[ue.filename]))F.set(ye,(F.get(ye)||0)+1);return[...F.entries()].sort((ue,ye)=>ye[1]-ue[1]).slice(0,12)},[O,g.metadata]),fe=f.useMemo(()=>{const F=P.trim().toLowerCase();return O.filter(ue=>{if(Q!=="all"&&(ue.package||"")!==Q||G!=="all"&&String(ue.task_type||"").toLowerCase()!==G)return!1;const ye=ue.filename?g.metadata[ue.filename]:void 0,xe=Pd(ue,ye);return je&&!xe.includes(je)||ve&&!xe.some(J=>{const R=J.toLowerCase();return R==="decision-gate"||R.startsWith("wave-")||R.startsWith("seat-")})?!1:F?`${ue.item_id||""} ${ue.title} ${ue.filename||""} ${ue.package||""} ${ue.summary||""} ${ue.exec_status||""} ${xe.join(" ")} ${Rd(ue,ye)||""}`.toLowerCase().includes(F):!0})},[O,g.metadata,P,Q,G,je,ve]),ce=f.useMemo(()=>{var ye;const F=new Map;for(const xe of xh)F.set(xe.id,[]);for(const xe of fe)(ye=F.get(xe.column))==null||ye.push(xe);const ue=xe=>{const ke=xe.filename?Rd(xe,g.metadata[xe.filename]):null;return ke?sl.indexOf(ke):sl.length};for(const[xe,ke]of F)(xe==="triage"||xe==="ready")&&ke.sort((J,R)=>ue(J)-ue(R)||(R.item_id||0)-(J.item_id||0));return F},[fe,g.metadata]);async function Ee(F,ue){if(!(!F.filename||!F.kind||F.kind==="completed")&&F.kind!==ue){be("");try{await n.backlog_move({from_kind:F.kind,to_kind:ue,filename:F.filename}),await g.refresh(),l()}catch(ye){be(String((ye==null?void 0:ye.message)||ye||"Move failed"))}}}async function se(F){if(!F.filename)return;let ue=g.metadata[F.filename];if(!ue)try{const xe=await n.backlog_content("planned",F.filename);ue=Mi(String((xe==null?void 0:xe.content)||""))}catch{ue=void 0}const ye=ue?Qd({task_type:F.task_type},ue):null;le(""),k(m),te({filename:F.filename,title:F.title,readiness:ye}),M.load_exec_config()}async function W(F){if(!(!I||C)){re(!0),le("");try{const ue=M.exec_cfg||await M.load_exec_config();if(!ue||ue.can_execute!==!0){le((ue==null?void 0:ue.runner_error)||"Backlog exec is not available on this gateway.");return}const ye=!!(I.readiness&&!I.readiness.ok);await n.backlog_execute({kind:"planned",filename:I.filename,execution_mode:ae,executor:F==null?void 0:F.executor,target_model:F==null?void 0:F.target_model,target_reasoning_effort:F==null?void 0:F.target_reasoning_effort,dor:"check",override:ye}),te(null),await g.refresh(),l()}catch(ue){const ye=Td(ue);ye?(te(xe=>xe&&{...xe,readiness:ye,server_refused:!0}),le("")):le(String((ue==null?void 0:ue.message)||ue||"Execute failed"))}finally{re(!1)}}}function ie(F){if(!F.filename&&!F.request_id){const ue=rb(F.card_path);if(ue&&r){n.backlog_content(ue.kind,ue.filename).then(()=>{Z({filename:ue.filename,kind:ue.kind,title:F.title,work_id:F.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>Y(F));return}Y(F);return}Z({filename:F.filename||"",kind:F.kind||null,request_id:F.request_id,title:F.title,work_id:F.work_id,has_live_request:F.column==="in_progress"||F.column==="in_review",initial_tab:F.column==="in_review"?"review":F.column==="in_progress"?"runs":"spec"})}const Ce={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:P,onChange:F=>E(F.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:Q,onChange:F=>oe(F.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),it.map(F=>e.jsx("option",{value:F,children:F},F))]}),e.jsxs("select",{value:G,onChange:F=>Ne(F.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),er.map(F=>e.jsx("option",{value:F,children:F},F))]}),e.jsx("button",{className:`chip mono board_facet ${ve?"active":"muted"}`,onClick:()=>H(F=>!F),"aria-pressed":ve,title:"Room supervision: only operator decision gates + wave items (labels decision-gate / wave-* / seat-*)",children:"Supervision"}),e.jsx("div",{className:"board_toolbar_spacer"}),g.degraded&&!$?e.jsx("span",{className:"mono board_warn",title:g.degraded,children:"partial board"}):null,g.error&&!$?e.jsx("span",{className:"mono board_error",children:g.error}):null,D?e.jsx("span",{className:"mono board_error",children:D}):null,e.jsx("button",{className:`btn btn_icon ${g.loading?"is_loading":""}`,onClick:()=>void g.refresh(),disabled:!r||g.loading,children:g.loading?"Refreshing…":"Refresh"})]}),$?e.jsx(Xd,{gateway:n,surface:"the board",status:A.status,legacy:A.legacy,error:g.unavailable,on_changed:()=>{L(F=>F+1),g.refresh()}}):null,T?e.jsx(vb,{status:A.status,on_create:s.on_new_task}):null,!$&&(et.length||Ge)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),et.map(([F,ue])=>e.jsxs("button",{className:`chip mono board_facet ${je===F?"active":"info"}`,onClick:()=>we(ye=>ye===F?"":F),title:`${ue} scanned card(s) carry ${F} — click to filter (sprints are labels: sprint-N)`,children:[F," ",e.jsx("span",{className:"muted",children:ue})]},F)),je?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>we(""),children:"clear ✕"}):null,ct<Ge?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 ",ct,"/",Ge]}):null]}):null,e.jsx("div",{className:"board_columns",style:$?{display:"none"}:void 0,children:xh.map(F=>{const ue=ce.get(F.id)||[],ye=Ce[F.id],xe=h(F.id);return e.jsxs("div",{className:`board_column board_column_${F.id} ${$e===F.id?"drag_over":""}${xe?"":" list_collapsed"}`,onDragOver:ke=>{!ye||!Re.current||(ke.preventDefault(),Oe(F.id))},onDragLeave:()=>Oe(ke=>ke===F.id?null:ke),onDrop:ke=>{ke.preventDefault(),Oe(null);const J=Re.current;Re.current=null,J&&ye&&Ee(J,ye)},children:[e.jsx("div",{className:"board_column_header",title:F.hint,children:e.jsx(al,{open:xe,on_toggle:()=>x(F.id),controls:`board_column_body_${F.id}`,title:F.label,count:ue.length,title_class:"board_column_title",count_class:"board_column_count mono"})}),e.jsxs("div",{className:"board_column_body",id:`board_column_body_${F.id}`,hidden:!xe,children:[ue.map(ke=>{const J=Gp(ke,ke.filename?g.metadata[ke.filename]:void 0);return e.jsx(Wb,{card:ke,metadata:ke.filename?g.metadata[ke.filename]:void 0,draggable:!J&&!!(ke.kind&&ke.filename&&(ke.column==="triage"||ke.column==="ready")),on_drag_start:()=>{Re.current=ke},on_drag_end:()=>{Re.current=null,Oe(null)},on_open:()=>ie(ke),on_promote:!J&&F.id==="triage"?()=>void Ee(ke,"planned"):void 0,on_demote:!J&&F.id==="ready"?()=>void Ee(ke,"proposed"):void 0,on_execute:!J&&F.id==="ready"?()=>void se(ke):void 0,on_follow:ke.exec_status==="running"||ke.exec_status==="queued"?()=>u(ke.request_id):void 0},ke.key)}),ue.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},F.id)})}),e.jsx(Zp,{open:!!I,target:I?{kind:"planned",filename:I.filename,title:I.title}:null,execute_mode:ae,set_execute_mode:k,action_loading:C,action_error:he,exec_cfg:M.exec_cfg,exec_cfg_loading:M.exec_cfg_loading,exec_cfg_error:M.exec_cfg_error,executors:v,readiness:(I==null?void 0:I.readiness)??null,server_refused:(I==null?void 0:I.server_refused)===!0,show_readiness:!0,on_open_spec:I?()=>{const F=I;te(null),Z({filename:F.filename,kind:"planned",title:F.title,initial_tab:"spec"})}:void 0,on_confirm:F=>void W(F),on_close:()=>te(null)}),e.jsx(Jp,{gateway:n,can_use_gateway:r,target:X,on_close:()=>Z(null),on_mutated:async()=>{X!=null&&X.filename&&(X.kind==="proposed"||X.kind==="planned")&&await g.refresh_item_metadata(X.kind,X.filename),await g.refresh(),l()},on_open_executions:u}),U?e.jsx(Bb,{card:U,on_close:()=>Y(null),on_open_team:s.on_open_team}):null]})}function Wb(s){const{card:n,metadata:r,draggable:i,on_drag_start:l,on_drag_end:u,on_open:m,on_promote:d,on_demote:h,on_execute:x,on_follow:v}=s,g=Rd(n,r),w=Gp(n,r),L=!w&&r?Qd({task_type:n.task_type},r):null,A=tl(n.task_type),$=n.exec_status==="running"&&n.started_at?Math.max(0,Date.now()-Date.parse(n.started_at)):null;return e.jsxs("div",{className:`board_card ${i?"draggable":""} ${w?"gate":""}`,onClick:m,role:"button",tabIndex:0,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),m())},draggable:i,onDragStart:i?l:void 0,onDragEnd:i?u:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[L?e.jsx("span",{className:`board_ready_dot ${L.ok?"ok":"warn"}`,title:L.ok?"Definition of Ready: satisfied":`Not ready: ${L.checks.filter(T=>!T.ok).map(T=>T.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:n.title})]}),e.jsxs("div",{className:"board_card_chips",children:[w?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,n.item_id?e.jsxs("span",{className:"chip mono muted",children:["#",n.item_id]}):null,A&&!w?e.jsx("span",{className:`chip mono ${Fp(A)}`,title:qp(A),children:A}):null,g?e.jsx("span",{className:`chip mono board_prio_${g.toLowerCase()}`,children:g}):null,n.package?e.jsx("span",{className:"chip mono muted",children:n.package}):null,n.batch_size?e.jsxs("span",{className:"chip mono info",children:[n.batch_size," items"]}):null,Pd(n,r).filter(T=>!w||T.toLowerCase()!=="decision-gate").slice(0,3).map(T=>e.jsx("span",{className:"chip mono info",children:T},T)),n.exec_status?e.jsx("span",{className:`chip mono ${n.exec_status==="failed"?"danger":n.exec_status==="awaiting_qa"?"warn":"info"}`,children:n.exec_status}):null,$!==null?e.jsx("span",{className:"chip mono info",children:Hs($)}):null,n.recent_failures?e.jsxs("span",{className:"chip mono danger",title:`${n.recent_failures} recent failed attempt(s) — see the Failed lane`,children:["⚠ ",n.recent_failures]}):null,n.target_agent?e.jsx("span",{className:"chip mono muted",children:n.target_agent}):null,n.claim_owner?(()=>{const T=Up({owner:n.claim_owner,started_at:n.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${T!=null&&T.stale?"warn":"info"}`,title:`Live hub claim${n.work_id?` (claim:${n.work_id})`:""}${T!=null&&T.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",n.claim_owner,T?` · ${T.label.replace("claimed ","")}`:""]})})():null]}),d||h||x||v?e.jsxs("div",{className:"board_card_actions",onClick:T=>T.stopPropagation(),children:[d?e.jsx("button",{className:"btn",onClick:d,title:"Move to Ready (planned)",children:"→ Ready"}):null,x?e.jsx("button",{className:"btn primary",onClick:x,children:"Execute"}):null,h?e.jsx("button",{className:"btn",onClick:h,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,v?e.jsx("button",{className:"btn",onClick:v,children:"Follow live"}):null]}):null]})}function dd(s,n){const r=String(s||"").replace(/\r/g,"").trim();if(!r)return"";const l=(r.split(`
94
- `,1)[0]||"").trim();return l.length<=n?l:`${l.slice(0,Math.max(0,n-1))}…`}function Hb(s){const n=String(s||"").trim();if(n.length<2)return n;const r=n[0],i=n[n.length-1];return r==="'"&&i==="'"||r==='"'&&i==='"'?n.slice(1,-1):n}function r_(s){const n=String(s||"").trim();if(!n)return"";const r=n.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?Hb(String(r[1]||"").trim()):n}function Vb(s,n){const r=String(s||"").trim().toLowerCase();if(r==="error"||r==="turn.failed")return"error";if(r==="turn.completed"||r==="turn.succeeded"||r==="turn.success")return"ok";const i=n&&typeof n=="object"?n:null,l=i&&typeof i.item=="object"?i.item:null;if(l&&String(l.type||"").trim()==="command_execution"){const u=String(l.status||"").trim().toLowerCase();if(u==="failed")return"error";const m=l.exit_code,d=typeof m=="number"?m:Number.isFinite(Number(m))?Number(m):null;if(d!=null)return d===0?"ok":"error";if(u==="completed")return"ok"}return"info"}function Gb(s,n){var x;const r=n&&typeof n=="object"?n:{},i=r.item&&typeof r.item=="object"?r.item:null,l=i?String(i.type||"").trim():"",u=i?String(i.text||"").trim():"",m=i?String(i.command||"").trim():"",d=i&&Array.isArray(i.items)?i.items:[],h=String((r==null?void 0:r.message)||((x=r==null?void 0:r.error)==null?void 0:x.message)||"").trim();if(l==="command_execution"&&m)return r_(m)||m;if(l==="todo_list"&&d.length>0){const v=d.length,g=d.filter(B=>(B&&B.completed)===!0).length,w=d.find(B=>(B&&B.completed)!==!0),L=String((w==null?void 0:w.text)||"").trim(),A=v>1?` (+${v-1})`:"",$=v>0?` (${g}/${v})`:"",T=L?`todo: ${L}${A}`:`todo list (${v})`;return dd(`${T}${$}`,96)}return u?dd(u,96)||u:h?dd(h,96)||h:l||String(s||"").trim()||"event"}function Ch(s){const n=new Date(s),r=i=>String(i).padStart(2,"0");return`${r(n.getHours())}:${r(n.getMinutes())}`}function Kb(s){var i,l,u;const n=s&&typeof s=="object"?s:{},r=[n.at,n.created_at,n.timestamp,n.time,n.ts,n.datetime,(i=n.item)==null?void 0:i.at,(l=n.item)==null?void 0:l.created_at,(u=n.item)==null?void 0:u.timestamp];for(const m of r)if(m!=null){if(typeof m=="number"&&Number.isFinite(m)){const d=m>1e11?m:m*1e3;return Ch(d)}if(typeof m=="string"){const d=m.trim();if(!d)continue;const h=Date.parse(d.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(h))return Ch(h)}}return null}function Jb(s){var T;const{exec_selected:n,exec_detail:r,is_compact_layout:i,exec_log_name:l,set_exec_log_name:u,exec_log_text:m,exec_log_loading:d,exec_log_error:h,exec_log_truncated:x,exec_log_auto:v,set_exec_log_auto:g,exec_log_scroll_el_ref:w,exec_log_follow_ref:L,parsed_exec_events:A,load_exec_log_tail:$}=s;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:l,onChange:B=>u(B.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(Li,{variant:"sm",label:"Auto-refresh",action:"exec-log-auto",hint:"Follow the log as it grows.",checked:v,unavailableReason:n!=null&&n.request_id?null:"Pick an execution first.",reasonVisible:!1,onChange:B=>g(()=>B)}),e.jsxs("button",{className:`btn btn_icon ${d?"is_loading":""}`,onClick:()=>$(),disabled:d||!(n!=null&&n.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(Ue,{name:"refresh",size:16}),i?null:d?"Loading…":"Refresh"]})]})]}),h?e.jsx("div",{className:"detail_warn",children:h}):null,!h&&x?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,l==="events"&&A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:w,onScroll:B=>{L.current=_h(B.currentTarget,12)},children:A.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):A.events.map(B=>{var te;const O=B.payload,M=O&&typeof O.item=="object"?O.item:null,P=M?String(M.type||"").trim():"",E=M?String(M.id||"").trim():"",Q=O?String(O.thread_id||"").trim():"",oe=Vb(B.type,O),G=oe==="error"?"danger":oe==="ok"?"ok":"info",Ne=Kb(O),je=Gb(B.type,O),we=String((O==null?void 0:O.message)||((te=O==null?void 0:O.error)==null?void 0:te.message)||"").trim(),ve=M?String(M.text||"").trim():"",H=M?String(M.command||"").trim():"",X=M?String(M.status||"").trim():"",Z=M&&M.exit_code!=null?String(M.exit_code):"",U=M?String(M.aggregated_output||"").trim():"",Y=M&&Array.isArray(M.items)?M.items:[],I=H?r_(H)||H:"";return e.jsxs("details",{className:`exec_event ${oe}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[Ne?e.jsx("span",{className:"exec_event_when mono muted",children:Ne}):null,Ne?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:je,children:je}),e.jsx("span",{className:`chip mono ${G}`,children:P||B.type}),Z?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",Z]}):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:B.type}),E?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:E}):null,Q?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",_a(Q,18)]}):null]}),we?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:we}):null,Y&&Y.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Y.map((ae,k)=>e.jsxs("div",{children:[(ae&&ae.completed)===!0?"✓":"○"," ",String((ae==null?void 0:ae.text)||"").trim()]},`${B.idx}-todo-${k}`))}):null,H?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",X?`(${X})`:""," ",Z?`exit=${Z}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:I})]}):null,U?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",U.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:U})]}):null,ve?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(ns,{className:"md_doc",text:ve})}):null]})]},`${B.idx}-${E}-${B.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",A.bad?` (${A.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono exec_raw_log",children:A.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:w,onScroll:B=>{L.current=_h(B.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var O;if(String(m||"").trim())return m;if(l==="last_message"){const M=String(((O=r==null?void 0:r.result)==null?void 0:O.last_message)||n.last_message||"").trim();if(M)return M;const P=String(n.status||"").trim().toLowerCase();return P==="queued"||P==="running"?"(last message is written when the run finishes — use events for live output)":"(no last message yet)"}return l==="stderr"?"(no stderr yet)":"(no logs yet)"})()})}),(T=r==null?void 0:r.result)!=null&&T.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 Qb(s){const{pipeline:n,is_compact_layout:r,on_back_to_list:i,on_send_feedback:l,on_promote:u,on_deploy_uat:m}=s,d=n.exec_selected;if(!d)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:h,exec_detail_loading:x,exec_detail_error:v,exec_qa_feedback:g,set_exec_qa_feedback:w,exec_qa_loading:L,exec_qa_error:A,event_stats:$,time_stats:T,exec_log_name:B}=n;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:d.backlog_filename||d.backlog_relpath||d.request_id}),(()=>{const O=String(d.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${Zo(O)}`,children:O||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:_a(d.request_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[r?e.jsx("button",{className:"btn",onClick:i,disabled:x,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.request_id),disabled:x,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy request id"]}),d.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.backlog_relpath||""),disabled:x,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var P;const M=(Array.isArray((P=h==null?void 0:h.backlog_queue)==null?void 0:P.items)?h.backlog_queue.items:[]).map(E=>String((E==null?void 0:E.relpath)||"").trim()).filter(Boolean);return M.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(M.join(`
95
- `)),disabled:x,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),d.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.run_dir_relpath||""),disabled:x,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(Ue,{name:"copy",size:16}),r?null:"Copy run dir"]}):null]})]}),e.jsxs("div",{className:"detail_hint",style:{marginTop:0},children:[d.created_at?`created ${new Date(d.created_at).toLocaleString()}`:"",d.started_at?` • started ${new Date(d.started_at).toLocaleString()}`:"",d.finished_at?` • finished ${new Date(d.finished_at).toLocaleString()}`:""]}),d.error?e.jsx("div",{className:"detail_warn",children:d.error}):null,v?e.jsx("div",{className:"detail_warn",children:v}):null,e.jsx("div",{style:{marginTop:"12px"},children:x?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(Yb,{exec_selected:d,exec_detail:h,exec_qa_feedback:g,set_exec_qa_feedback:w,exec_qa_loading:L,exec_qa_error:A,on_send_feedback:l,on_promote:u,on_deploy_uat:m}),e.jsx(Xb,{exec_selected:d,exec_detail:h}),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:d.status||"unknown"})]}),d.executor_type?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"executor"}),e.jsx("span",{className:"fact_value",children:d.executor_type})]}):null,d.target_agent?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"target agent"}),e.jsx("span",{className:"fact_value",children:d.target_agent})]}):null,d.target_model?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"model"}),e.jsxs("span",{className:"fact_value",children:[d.target_model,d.target_reasoning_effort?` (reasoning ${d.target_reasoning_effort})`:""]})]}):null,d.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(d.exit_code)})]}):null,T.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Hs(T.age_ms)})]}):null,T.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:Hs(T.queue_delay_ms)})]}):null,T.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:Hs(T.run_ms)})]}):null,T.total_ms!=null&&T.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Hs(T.total_ms)})]}):null,$?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"commands"}),e.jsxs("span",{className:"fact_value",children:[$.command_count.toLocaleString(),$.command_fail_count?` (${$.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:$!=null&&$.has_tokens?e.jsxs(e.Fragment,{children:["in ",$.input_tokens.toLocaleString(),$.cached_input_tokens?` (cached ${$.cached_input_tokens.toLocaleString()})`:"",", out ",$.output_tokens.toLocaleString(),", total ",$.total_tokens.toLocaleString()]}):e.jsx("span",{className:"muted",children:B==="events"?"n/a":'select "events"'})})]}),d.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:d.run_dir_relpath})]}):null]}),e.jsx(tw,{exec_detail:h}),e.jsx(Zb,{exec_detail:h,exec_qa_loading:L,status:String(d.status||"")}),e.jsx(ew,{exec_detail:h}),e.jsx(nw,{exec_selected:d,exec_detail:h}),e.jsx("div",{className:"section_divider"}),e.jsx(Jb,{exec_selected:d,exec_detail:h,is_compact_layout:r,exec_log_name:n.exec_log_name,set_exec_log_name:n.set_exec_log_name,exec_log_text:n.exec_log_text,exec_log_loading:n.exec_log_loading,exec_log_error:n.exec_log_error,exec_log_truncated:n.exec_log_truncated,exec_log_auto:n.exec_log_auto,set_exec_log_auto:O=>n.set_exec_log_auto(O),exec_log_scroll_el_ref:n.exec_log_scroll_el_ref,exec_log_follow_ref:n.exec_log_follow_ref,parsed_exec_events:n.parsed_exec_events,load_exec_log_tail:()=>void n.load_exec_log_tail()})]})})]})}function Yb(s){const{exec_selected:n,exec_detail:r,exec_qa_feedback:i,set_exec_qa_feedback:l,exec_qa_loading:u,exec_qa_error:m,on_send_feedback:d,on_promote:h,on_deploy_uat:x}=s;if(String(n.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const g=String((r==null?void 0:r.execution_mode)||"").trim().toLowerCase()||"uat",w=String((r==null?void 0:r.candidate_relpath)||"").trim(),L=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),A=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),$=String((r==null?void 0:r.uat_current_relpath)||"").trim(),T=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),B=!!(r!=null&&r.uat_lock_acquired),O=!!(r!=null&&r.uat_pending),M=(r==null?void 0:r.uat_deploy)??null,P=String((r==null?void 0:r.uat_deploy_error)||"").trim(),E=r==null?void 0:r.attempt,Q=(r==null?void 0:r.promotion_report)??null,oe=!!(Q!=null&&Q.blocked),G=String((Q==null?void 0:Q.reason)||"").trim(),Ne=Array.isArray(Q==null?void 0:Q.conflicts)?(Q==null?void 0:Q.conflicts).slice(0,8):[],je=typeof(Q==null?void 0:Q.conflicts_total)=="number"?Number(Q.conflicts_total):Ne.length;let we="",ve="";const H=[];try{const X=M==null?void 0:M.processes;if(X&&typeof X=="object"&&!Array.isArray(X)){typeof X.status=="string"&&(we=String(X.status||"").trim()),typeof X.reason=="string"&&(ve=String(X.reason||"").trim());for(const[Z,U]of Object.entries(X)){if(!U||typeof U!="object"||Array.isArray(U))continue;const Y=U.probe;!Y||typeof Y!="object"||Y.ok===!1&&H.push(String(Z))}}}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:g})]}),typeof E=="number"?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"attempt"}),e.jsx("span",{className:"fact_value",children:E})]}):null,g==="uat"&&T?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[_a(T,18),B?" (owned)":O?" (pending)":""]})]}):null,w?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"candidate"}),e.jsx("span",{className:"fact_value mono",children:w})]}):null,A?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:A})]}):null,L?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:L})]}):null,$?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:$})]}):null]}),g==="inplace"?e.jsx("div",{className:"detail_warn",children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):g==="uat"&&O&&T&&!B?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",_a(T,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):g==="uat"&&B?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."}),H.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",H.slice(0,4).join(", "),H.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,g==="uat"&&we==="skipped"&&ve==="process_manager_disabled"?e.jsxs("div",{className:"detail_warn",children:["UAT services were not started: the process manager is off. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("code",{children:"abstractgateway config set process_manager on"}),")."]}):null,P?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",P]}):null,oe&&G==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",je," conflict",je===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",Ne.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:Ne.map((X,Z)=>e.jsxs("li",{children:[String((X==null?void 0:X.repo)||""),"/",String((X==null?void 0:X.path)||"")," (",String((X==null?void 0:X.reason)||"conflict"),")"]},`c:${Z}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[L?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(L),disabled:u,children:[e.jsx(Ue,{name:"copy",size:16}),"Copy patch path"]}):null,A?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(A),disabled:u,children:[e.jsx(Ue,{name:"copy",size:16}),"Copy manifest path"]}):null,w?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(w),disabled:u,children:[e.jsx(Ue,{name:"copy",size:16}),"Copy candidate path"]}):null]}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("textarea",{value:i,onChange:X=>l(X.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:u})}),m?e.jsx("div",{className:"detail_warn",children:m}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[g==="uat"?e.jsx("button",{className:"btn",onClick:x,disabled:u,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:h,disabled:u,children:g==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:d,disabled:u,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function Xb(s){const{exec_selected:n,exec_detail:r}=s;if(String(n.status||"").trim().toLowerCase()!=="promoted")return null;const l=String((r==null?void 0:r.promoted_at)||"").trim(),u=(r==null?void 0:r.promotion)??null,m=(r==null?void 0:r.promotion_report)??null,d=typeof(u==null?void 0:u.copied)=="number"?Number(u==null?void 0:u.copied):null,h=typeof(u==null?void 0:u.deleted)=="number"?Number(u==null?void 0:u.deleted):null,x=String((u==null?void 0:u.manifest_sha256)||"").trim(),v=String((u==null?void 0:u.mode)||"").trim(),g=(m==null?void 0:m.redeploy)??null,w=String((g==null?void 0:g.status)||"").trim(),L=String((g==null?void 0:g.reason)||"").trim(),A=String((m==null?void 0:m.redeploy_error)||"").trim();return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[l?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"promoted at"}),e.jsx("span",{className:"fact_value",children:new Date(l).toLocaleString()})]}):null,v?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:v})]}):null,x?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[x.slice(0,16),"…"]})]}):null,d!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[d," files"]})]}):null,h!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[h," files"]})]}):null,w?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsxs("span",{className:"fact_value",children:[w,L?` (${L})`:""]})]}):null,A?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:A})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function Zb(s){const{exec_detail:n,exec_qa_loading:r}=s;if(String(s.status||"").trim().toLowerCase()==="promoted")return null;const i=n&&typeof n.promotion=="object"?n.promotion:null;if(!i)return null;const l=n&&typeof n.promotion_report=="object"?n.promotion_report:null,u=String((i==null?void 0:i.mode)||"").trim(),m=(i==null?void 0:i.copied)!=null?String(i.copied):"",d=(i==null?void 0:i.deleted)!=null?String(i.deleted):"",h=String((i==null?void 0:i.manifest_sha256)||"").trim(),x=l&&typeof l.redeploy=="object"?l.redeploy:null,v=x?String(x.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:[u?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:u})]}):null,m?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[m," files"]})]}):null,d?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[d," files"]})]}):null,h?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:()=>ln(h),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(Ue,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[h.slice(0,16),"…"]})]}):null,v?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsx("span",{className:"fact_value",children:v})]}):null]})]})}function ew(s){var i,l;const r=(Array.isArray((l=(i=s.exec_detail)==null?void 0:i.backlog_queue)==null?void 0:l.items)?s.exec_detail.backlog_queue.items:[]).map(u=>String((u==null?void 0:u.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(u=>e.jsx("div",{children:u},`bq:${u}`))})]}):null}function tw(s){var h,x,v;const n=((h=s.exec_detail)==null?void 0:h.skills)||((v=(x=s.exec_detail)==null?void 0:x.payload)==null?void 0:v.skills);if(!n||typeof n!="object")return null;const r=Array.isArray(n.requested)?n.requested:[],i=Array.isArray(n.active)?n.active:[],l=n.resolved_tree_hashes&&typeof n.resolved_tree_hashes=="object"?n.resolved_tree_hashes:{},u=Array.isArray(n.verdicts)?n.verdicts:[];if(!r.length&&!i.length&&!u.length)return null;const m=new Set(i.map(g=>String(g))),d=u.filter(g=>{const w=String((g==null?void 0:g.status)||(g==null?void 0:g.state)||"").toLowerCase();return w&&w!=="active"});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Skills"}),n.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(n.source)})]})}):null,e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:r.map(g=>{const w=m.has(String(g)),L=l[String(g)];return e.jsxs("span",{className:`chip mono ${w?"ok":"warn"}`,title:w?L?`active · ${String(L).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[g,w?"":" (held)"]},`skill:${g}`)})}),d.map((g,w)=>{const L=String((g==null?void 0:g.name)||(g==null?void 0:g.skill)||"skill"),A=String((g==null?void 0:g.reason)||(g==null?void 0:g.detail)||(g==null?void 0:g.status)||"held");return e.jsxs("div",{className:"detail_warn",children:[L,": ",A]},`verdict:${w}:${L}`)})]})}function nw(s){var r,i;const n=String(((i=(r=s.exec_detail)==null?void 0:r.result)==null?void 0:i.last_message)||s.exec_selected.last_message||"").trim();return n?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(ns,{className:"md_doc",text:n})})]}):null}const sw=10;function aw(s){const{gateway:n,gateway_connected:r}=s,i=Zd("(max-width: 767.98px)"),l=f.useRef(null),u=f.useRef(null),m=I=>{const te=I==="detail"?u:l;requestAnimationFrame(()=>rl(te.current))},[d,h]=Mc("exec_active"),[x,v]=Mc("exec_recent"),[g,w]=f.useState(null);async function L(){try{const I=await n.admin_executors(),te=Array.isArray(I)?I:Array.isArray(I==null?void 0:I.executors)?I.executors:[];w(te)}catch{w(null)}}f.useEffect(()=>{if(!r){w(null);return}L()},[n,r]);const A=em({gateway:n,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:i,set_compact_pane:m,on_status_transfer:()=>{M()}}),[$,T]=f.useState([]),[B,O]=f.useState("");async function M(){if(r)try{const I=await n.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),te=Array.isArray(I==null?void 0:I.requests)?I.requests:[];te.sort((ae,k)=>{const C=String(ae.finished_at||ae.started_at||ae.created_at||"");return String(k.finished_at||k.started_at||k.created_at||"").localeCompare(C)}),T(te.slice(0,sw)),O("")}catch(I){O(String((I==null?void 0:I.message)||I||"Failed to load recent executions"))}}f.useEffect(()=>{if(!r)return;(async()=>{var k;const te=await A.refresh_exec_list("processing");await M();const ae=String(s.focus_request_id||"").trim();if(ae){const C=te.find(re=>re.request_id===ae);if(C)await A.load_exec_request(C);else try{const re=await n.backlog_exec_request(ae);re!=null&&re.payload&&await A.load_exec_request({request_id:ae,status:String(re.payload.status||"unknown")})}catch{}(k=s.on_focus_consumed)==null||k.call(s)}})();const I=setInterval(()=>{n.is_backing_off()||M()},15e3);return()=>clearInterval(I)},[r,s.focus_request_id]);const P=A.exec_requests.some(I=>String(I.status||"").toLowerCase()==="running"),[,E]=f.useState(0);f.useEffect(()=>{if(!P)return;const I=setInterval(()=>E(te=>(te+1)%3600),1e3);return()=>clearInterval(I)},[P]);const Q=A.exec_requests,oe=f.useMemo(()=>{let I=0,te=0,ae=0;for(const k of Q){const C=String(k.status||"").trim().toLowerCase();C==="queued"?I+=1:C==="running"?te+=1:C==="awaiting_qa"&&(ae+=1)}return{queued:I,running:te,awaiting:ae}},[Q]),G=A.exec_cfg,Ne=!!(G!=null&&G.runner_alive),je=String((G==null?void 0:G.executor)||"").trim(),we=!je||je==="none",ve=we?"execution agent":je,H=!!(G!=null&&G.can_execute),X=Ai(A.exec_error)||Ai(B),[Z,U]=f.useState(0),Y=Yd(n,r&&X,Z);return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&G?e.jsxs("span",{className:`chip mono ${H?"ok":"warn"}`,title:G.codex_model?`${ve}: ${G.codex_model}${G.codex_reasoning_effort?` (reasoning ${G.codex_reasoning_effort})`:""}`:void 0,children:[we?"no execution agent":`${ve} worker ${Ne?"on":"off"}`,!i&&G.codex_model?` · ${G.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!X&&A.exec_error?e.jsx("span",{className:"page_error mono",children:A.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${A.exec_loading?"is_loading":""}`,onClick:()=>{A.refresh_exec_list("processing"),M(),A.load_exec_config(),L()},disabled:!r||A.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:16})})]}),r&&G&&!H&&!X?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(Ue,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[we?g!=null&&g.length?"No default executor selected":"No execution agent on this gateway":Ne?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:we?"setup required":Ne?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!we)return G.runner_error?`The worker reports: ${G.runner_error} — new executions queue until it comes back.`:Ne?"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(!(g!=null&&g.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const I=g.map(k=>k.display||k.id),te=I.slice(0,4).join(", ")+(I.length>4?` +${I.length-4} more`:"");return g.some(k=>k.available!==!1)?`The gateway's registry serves ${g.length} executor${g.length===1?"":"s"} (${te}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${g.length} executor${g.length===1?"":"s"} (${te}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(g!=null&&g.length)||!g.some(I=>I.available!==!1))&&(we||!Ne)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
96
- abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
97
- # the agent program must be installed on the gateway's computer (on its PATH)`}):null,e.jsx("div",{className:"callout_actions",children:s.on_open_settings?e.jsx("button",{className:"btn primary",onClick:s.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,X?e.jsx(Xd,{gateway:n,surface:"the execution pipeline",status:Y.status,legacy:Y.legacy,error:Ai(A.exec_error)?A.exec_error:B,on_changed:()=>{U(I=>I+1),A.refresh_exec_list("processing")}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${oe.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:oe.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${oe.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:oe.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:oe.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${H?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:H?"on":we?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[ve,we?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"exec_side",ref:l,children:[e.jsxs("div",{className:`pane exec_pane_active${d?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(al,{open:d,on_toggle:h,controls:"exec_active_list",title:"Active",count:Q.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"exec_active_list",hidden:!d,children:Q.length?Q.map(I=>{var le;const te=String(I.status||"").trim().toLowerCase(),ae=nl(I),k=((le=A.exec_selected)==null?void 0:le.request_id)===I.request_id,C=te==="running"&&I.started_at?Math.max(0,Date.now()-Date.parse(I.started_at)):null,re=String(I.backlog_filename||I.backlog_relpath||"").trim(),he=I.target_agent||(I.target_model?`${String(I.executor_type||"agent").trim()||"agent"}:${I.target_model}`:"");return e.jsxs("button",{className:`run_card ${k?"selected":""} ${te==="running"?"is_running":""}`,onClick:()=>void A.load_exec_request(I),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:re,children:re||`request ${_a(I.request_id,12)}`}),e.jsx("span",{className:`chip mono ${Zo(te)}`,children:te||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:C!==null?`running ${Hs(C)}`:ae.queue_delay_ms!=null?`queued ${Hs(ae.queue_delay_ms)}`:" "}),he?e.jsx("span",{className:"chip mono muted",children:he}):null,e.jsx("span",{className:"run_card_id mono",children:_a(I.request_id,14)})]})]},I.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${x?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(al,{open:x,on_toggle:v,controls:"exec_recent_list",title:"Recently finished",count:$.length})}),e.jsxs("div",{className:"pane_body exec_recent_body",id:"exec_recent_list",hidden:!x,children:[B&&!X?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:B}):null,!B&&!$.length?e.jsx("div",{className:"empty_note",style:{padding:"10px 12px"},children:"No finished executions yet."}):null,$.length?e.jsx("div",{className:"recent_list",children:$.map(I=>{var re;const te=String(I.status||"").trim().toLowerCase(),ae=nl(I),k=((re=A.exec_selected)==null?void 0:re.request_id)===I.request_id,C=_a(I.backlog_filename||I.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${k?"selected":""}`,onClick:()=>void A.load_exec_request(I),title:String(I.backlog_filename||I.backlog_relpath||I.request_id),children:[e.jsx("span",{className:`chip mono ${Zo(te)}`,children:te||"?"}),e.jsx("span",{className:"recent_row_name",children:C}),e.jsx("span",{className:"recent_row_time mono",children:ae.run_ms!=null?Hs(ae.run_ms):""})]},`recent:${I.request_id}`)})}):null]})]})]}),e.jsxs("div",{className:"pane exec_detail_pane",ref:u,children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Run detail"}),A.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${Zo(String(A.exec_selected.status||"").toLowerCase())}`,children:String(A.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:_a(A.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(Qb,{pipeline:A,is_compact_layout:i,on_back_to_list:()=>m("list"),on_send_feedback:()=>void A.exec_send_feedback(async()=>{await A.refresh_exec_list("processing")}),on_promote:()=>void A.exec_promote_to_prod(async()=>{await A.refresh_exec_list("processing"),await M()}),on_deploy_uat:()=>void A.exec_deploy_uat_now(async()=>{await A.refresh_exec_list("processing")})})})]})]})]})]})}function md(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function rw(s){const n=String(s||"").trim().toLowerCase();return n==="running"?{cls:"ok",label:"running"}:n==="stopped"?{cls:"muted",label:"stopped"}:n.includes("restart")?{cls:"warn",label:n}:n.includes("error")||n.includes("failed")?{cls:"danger",label:n||"error"}:{cls:"warn",label:n||"unknown"}}function $h(s){const n=r=>{const i=String((r==null?void 0:r.id)||"").trim(),l=i.endsWith("_uat")?i.slice(0,-4):i;return l==="gateway"?0:l==="build"?1:l==="abstractobserver"?2:l==="abstractcode_web"?3:l==="abstractflow_backend"?4:l==="abstractflow_frontend"?5:10};return[...s||[]].sort((r,i)=>{const l=n(r),u=n(i);if(l!==u)return l-u;const m=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),d=String((i==null?void 0:i.label)||(i==null?void 0:i.id)||"").toLowerCase();return m<d?-1:m>d?1:0})}function iw(s){const n=String(s||"").trim().toLowerCase();return n==="override"?{cls:"ok",label:"override"}:n.startsWith("inherited")?{cls:"info",label:n}:n==="unset"?{cls:"warn",label:"unset"}:!n||n==="missing"?{cls:"muted",label:"missing"}:{cls:"muted",label:n}}function ow({gateway:s,gateway_connected:n}){const[r,i]=f.useState("prod"),[l,u]=f.useState(null),[m,d]=f.useState([]),[h,x]=f.useState(!1),[v,g]=f.useState(""),[w,L]=f.useState(!1),[A,$]=f.useState(null),[T,B]=f.useState([]),[O,M]=f.useState(!1),[P,E]=f.useState(""),[Q,oe]=f.useState({}),[G,Ne]=f.useState(!1),[je,we]=f.useState(null),[ve,H]=f.useState(""),[X,Z]=f.useState(""),[U,Y]=f.useState(!1),[I,te]=f.useState("idle"),ae=f.useRef(null),k=f.useMemo(()=>$h(m.filter(fe=>!String((fe==null?void 0:fe.id)||"").trim().endsWith("_uat"))),[m]),C=f.useMemo(()=>$h(m.filter(fe=>String((fe==null?void 0:fe.id)||"").trim().endsWith("_uat"))),[m]),re=r==="uat"?C:k,he=f.useCallback(async()=>{if(n){x(!0),g("");try{const fe=await s.list_processes();u(!!(fe!=null&&fe.enabled));const ce=Array.isArray(fe==null?void 0:fe.processes)?fe.processes:[];d(ce)}catch(fe){g(String((fe==null?void 0:fe.message)||fe||"Failed to list processes"))}finally{x(!1)}}},[s,n]),le=f.useCallback(async()=>{if(n){M(!0),E("");try{const fe=await s.list_process_env_vars();$(!!(fe!=null&&fe.enabled));const ce=Array.isArray(fe==null?void 0:fe.vars)?fe.vars:[];B(ce);const Ee=String((fe==null?void 0:fe.error)||"").trim();Ee&&E(Ee)}catch(fe){E(String((fe==null?void 0:fe.message)||fe||"Failed to list env vars"))}finally{M(!1)}}},[s,n]),D=f.useCallback(async()=>{if(!n)return;const fe=je;if(fe){Y(!0);try{const ce=await s.process_log_tail(String(fe.id||""),{max_bytes:16e4}),Ee=String((ce==null?void 0:ce.content)||""),se=typeof(ce==null?void 0:ce.bytes)=="number"?Number(ce.bytes):0,W=!!(ce!=null&&ce.truncated),ie=String((ce==null?void 0:ce.log_relpath)||"");H(Ee),Z(`${se.toLocaleString()} bytes${W?" (tail)":""}${ie?` • ${ie}`:""}`)}catch(ce){H(""),Z(String((ce==null?void 0:ce.message)||ce||"Failed to read logs"))}finally{Y(!1)}}},[s,n,je]),be=f.useCallback(async fe=>{we(fe),Ne(!0)},[]),$e=f.useCallback(()=>{Ne(!1),we(null),H(""),Z("")},[]);f.useEffect(()=>{n&&he()},[n,he]),f.useEffect(()=>{if(!n||r==="env"||!w)return;const fe=window.setInterval(()=>{s.is_backing_off()||he()},2e3);return()=>window.clearInterval(fe)},[n,r,w,he,s]),f.useEffect(()=>{n&&r==="env"&&le()},[n,r,le]),f.useEffect(()=>{if(n&&G)return D(),ae.current&&window.clearInterval(ae.current),ae.current=window.setInterval(()=>{s.is_backing_off()||D()},1500),()=>{ae.current&&window.clearInterval(ae.current),ae.current=null}},[n,G,D]);const Oe=f.useRef(!1),[Re,rt]=f.useState(!1);async function qe(fe,ce){if(!Oe.current){Oe.current=!0,rt(!0),g("");try{ce==="start"?await s.start_process(fe.id):ce==="stop"?await s.stop_process(fe.id):ce==="restart"?await s.restart_process(fe.id):ce==="redeploy"&&await s.redeploy_process(fe.id),await he()}catch(Ee){g(String((Ee==null?void 0:Ee.message)||Ee||`Failed to ${ce}`))}finally{Oe.current=!1,rt(!1)}}}async function it(fe){const ce=String(fe||"").trim();if(ce){E("");try{const Ee=String((Q==null?void 0:Q[ce])??""),se=await s.update_process_env_vars({set:{[ce]:Ee}});$(!!(se!=null&&se.enabled)),B(Array.isArray(se==null?void 0:se.vars)?se.vars:[]),oe(ie=>({...ie||{},[ce]:""}));const W=String((se==null?void 0:se.error)||"").trim();W&&E(W)}catch(Ee){E(String((Ee==null?void 0:Ee.message)||Ee||"Failed to set env var"))}}}async function Ge(fe){const ce=String(fe||"").trim();if(ce){E("");try{const Ee=await s.update_process_env_vars({unset:[ce]});$(!!(Ee!=null&&Ee.enabled)),B(Array.isArray(Ee==null?void 0:Ee.vars)?Ee.vars:[]),oe(W=>({...W||{},[ce]:""}));const se=String((Ee==null?void 0:Ee.error)||"").trim();se&&E(se)}catch(Ee){E(String((Ee==null?void 0:Ee.message)||Ee||"Failed to unset env var"))}}}const ct=l===null?"…":l?"enabled":"disabled",et=A===null?"…":A?"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:()=>i("prod"),children:"Production"}),e.jsx("button",{"aria-pressed":r==="uat",className:`seg_btn ${r==="uat"?"active":""}`,onClick:()=>i("uat"),children:"UAT"}),e.jsx("button",{"aria-pressed":r==="env",className:`seg_btn ${r==="env"?"active":""}`,onClick:()=>i("env"),children:"ENV"})]}),n?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection badge in the sidebar."}),n&&r!=="env"?e.jsxs("span",{className:`chip mono ${l===!1?"warn":"muted"}`,children:["manager ",ct]}):null,n&&r==="env"?e.jsxs("span",{className:`chip mono ${A===!1?"warn":"muted"}`,children:["env ",et]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsx(Li,{variant:"sm",label:"Auto-refresh",action:"auto-refresh",hint:"Refresh this list every few seconds.",checked:w,onChange:fe=>L(fe)}),e.jsxs("button",{className:`btn btn_icon ${h?"is_loading":""}`,onClick:()=>void he(),disabled:!n||h,children:[e.jsx(Ue,{name:"refresh",size:16}),h?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${O?"is_loading":""}`,onClick:()=>void le(),disabled:!n||O,children:[e.jsx(Ue,{name:"refresh",size:16}),O?"Refreshing…":"Refresh"]})]}),n&&r!=="env"&&l===!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,n&&r==="env"&&A===!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"&&v?e.jsx("div",{className:"page_error mono",children:v}):null,r==="env"&&P?e.jsx("div",{className:"page_error mono",children:P}):null,n&&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:re.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[re.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."]}),re.map(fe=>{const ce=String(fe.id||"").trim(),Ee=String(fe.label||ce).trim()||ce,se=rw(String(fe.status||"")),ie=String(fe.status||"").trim().toLowerCase()==="running",Ce=Array.isArray(fe==null?void 0:fe.actions)?fe.actions.map(ut=>String(ut||"").trim()):[],Je=Ce.includes("start"),F=Ce.includes("stop"),ue=Ce.includes("restart"),ye=Ce.includes("redeploy"),xe=Ce.includes("logs"),ke=typeof(fe==null?void 0:fe.pid)=="number"?Number(fe.pid):null,J=String((fe==null?void 0:fe.url)||"").trim(),R=String((fe==null?void 0:fe.description)||"").trim(),ee=String((fe==null?void 0:fe.last_error)||"").trim(),Pe=typeof(fe==null?void 0:fe.exit_code)=="number"?Number(fe.exit_code):null,Fe=[];ke&&Fe.push(`pid ${ke}`),Pe!==null&&Fe.push(`exit ${Pe}`);const Xe=Fe.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:Ee}),e.jsx("span",{className:`chip mono ${se.cls}`,children:se.label}),e.jsx("span",{className:"chip mono muted",children:ce}),Xe?e.jsx("span",{className:"entity_card_sub mono",children:Xe}):null]}),R?e.jsx("div",{className:"entity_card_sub mono",children:md(R,220)}):null,J?e.jsx("div",{className:"entity_card_sub mono",children:ie?e.jsx("a",{href:J,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:J}):e.jsx("span",{className:"mono",children:J})}):null,ee?e.jsx("div",{className:"page_error mono",children:md(ee,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[Je?e.jsx("button",{className:"btn primary",onClick:()=>void qe(fe,"start"),disabled:h||Re,children:"Start"}):null,F?e.jsx("button",{className:"btn danger",onClick:()=>void qe(fe,"stop"),disabled:h||Re,children:"Stop"}):null,ue?e.jsx("button",{className:"btn",onClick:()=>void qe(fe,"restart"),disabled:h||Re,children:"Restart"}):null,ye?e.jsx("button",{className:"btn",onClick:()=>void qe(fe,"redeploy"),disabled:h||Re,children:"Redeploy"}):null,xe?e.jsx("button",{className:"btn",onClick:()=>void be(fe),disabled:h,children:"Logs"}):null]})]},ce)})]})]}):null,n&&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:T.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:[T.map(fe=>{const ce=String((fe==null?void 0:fe.key)||"").trim();if(!ce)return null;const Ee=String((fe==null?void 0:fe.label)||ce).trim()||ce,se=String((fe==null?void 0:fe.description)||"").trim(),W=String((fe==null?void 0:fe.source)||"").trim(),ie=!!(fe!=null&&fe.secret),Ce=String((fe==null?void 0:fe.updated_at)||"").trim(),Je=iw(W),F=String((Q==null?void 0:Q[ce])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:Ee}),e.jsx("span",{className:`chip mono ${Je.cls}`,children:Je.label}),e.jsx("span",{className:"chip mono muted",children:ce})]}),se?e.jsx("div",{className:"entity_card_sub mono",children:md(se,280)}):null,Ce?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",Ce]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:F,onChange:ue=>oe(ye=>({...ye||{},[ce]:String(ue.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 it(ce),disabled:O,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void Ge(ce),disabled:O,children:"Unset"})]})]},`env:${ce}`)}),T.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,G&&je?e.jsxs(tr,{open:G,title:`${String(je.label||je.id||"logs").trim()||"Logs"}`,onClose:$e,children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:X}),e.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[e.jsxs("button",{className:`btn btn_icon ${U?"is_loading":""}`,onClick:()=>void D(),disabled:U,children:[e.jsx(Ue,{name:"refresh",size:16}),U?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{qx(ve||"").then(fe=>{te(fe?"copied":"failed"),window.setTimeout(()=>te("idle"),2e3)})},disabled:!ve,children:[e.jsx(Ue,{name:"copy",size:16}),I==="copied"?"Copied":I==="failed"?Ox:"Copy"]})]}),e.jsx("pre",{className:"mono",style:{marginTop:"10px",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.12)",background:"rgba(0,0,0,0.22)",overflowX:"auto",maxHeight:"55vh",whiteSpace:"pre-wrap"},children:ve||"(no logs yet)"})]}):null]})})}function Eh(s){const n=String(s||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Fo(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function fd(s){const n=String(s||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return n.length<=1?n[0]||"":n}function lw(s){const n=s.gateway,[r,i]=Mc("inbox_email"),l=f.useRef(null),u=f.useRef(null),[m,d]=f.useState([]),[h,x]=f.useState(""),[v,g]=f.useState(""),[w,L]=f.useState(""),[A,$]=f.useState("7d"),[T,B]=f.useState("unread"),[O,M]=f.useState(25),[P,E]=f.useState(!1),[Q,oe]=f.useState(!1),[G,Ne]=f.useState(!1),[je,we]=f.useState(!1),[ve,H]=f.useState(""),[X,Z]=f.useState(""),[U,Y]=f.useState(""),[I,te]=f.useState([]),[ae,k]=f.useState(""),[C,re]=f.useState(null),[he,le]=f.useState(!1),[D,be]=f.useState(""),[$e,Oe]=f.useState(""),[Re,rt]=f.useState(""),[qe,it]=f.useState(""),[Ge,ct]=f.useState(""),et=s.enabled,fe=f.useMemo(()=>(Array.isArray(m)?m:[]).map(ee=>({account:String((ee==null?void 0:ee.account)||"").trim(),can_read:(ee==null?void 0:ee.can_read)!==!1,can_send:(ee==null?void 0:ee.can_send)!==!1,label:""})).filter(ee=>!!ee.account),[m]),ce=f.useMemo(()=>{const R=String(v||"").trim();return R&&fe.find(ee=>ee.account===R)||null},[fe,v]),Ee=!!(ce!=null&&ce.can_read),se=!!(ce!=null&&ce.can_send),W=f.useMemo(()=>fe.map(R=>{const ee=R.can_read?R.can_send?"":" (read-only)":" (send-only)";return{...R,label:`${R.account}${ee}`}}),[fe]);async function ie(){if(et){H(""),E(!0);try{const R=await n.email_list_accounts();d(Array.isArray(R==null?void 0:R.accounts)?R.accounts:[]),x(String((R==null?void 0:R.default_account)||"").trim())}catch(R){H(String((R==null?void 0:R.message)||R||"Failed to list email accounts")),d([]),x("")}finally{E(!1)}}}f.useEffect(()=>{ie()},[et]),f.useEffect(()=>{if(!et)return;const R=String(v||"").trim();if(R&&fe.some(Pe=>Pe.account===R))return;const ee=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(ee&&fe.some(Pe=>Pe.account===ee)){g(ee);return}if(h&&fe.some(Pe=>Pe.account===h)){g(h);return}fe.length&&g(fe[0].account)},[et,v,h,fe]),f.useEffect(()=>{const R=String(v||"").trim();R&&localStorage.setItem("abstractcontinuum_email_account",R)},[v]);async function Ce(){if(!et)return;const R=String(v||"").trim();if(R){if(!Ee){H("Selected account is not allowed to read email."),te([]),k(""),re(null);return}H(""),oe(!0);try{const ee=await n.email_list_messages({account:R,mailbox:String(w||"").trim()||void 0,since:String(A||"").trim()||void 0,status:T,limit:O}),Pe=Array.isArray(ee==null?void 0:ee.messages)?ee.messages:[];te(Pe);const Fe=String(ae||"").trim();Fe&&!Pe.some(Xe=>String((Xe==null?void 0:Xe.uid)||"").trim()===Fe)&&(k(""),re(null))}catch(ee){H(String((ee==null?void 0:ee.message)||ee||"Failed to list emails")),te([]),k(""),re(null)}finally{oe(!1)}}}f.useEffect(()=>{et&&String(v||"").trim()&&Ce()},[et,v]);async function Je(R){if(!et)return;const ee=String(v||"").trim(),Pe=String(R||"").trim();if(!(!ee||!Pe)&&Ee){k(Pe),re(null),Z(""),Ne(!0);try{const Fe=await n.email_read_message(Pe,{account:ee,mailbox:String(w||"").trim()||void 0,max_body_chars:2e4});re(Fe)}catch(Fe){Z(String((Fe==null?void 0:Fe.message)||Fe||"Failed to read email"))}finally{Ne(!1)}}}function F(R){Y(""),be(String((R==null?void 0:R.to)||"").trim()),Oe(""),rt(""),it(String((R==null?void 0:R.subject)||"").trim()),ct(String((R==null?void 0:R.body)||"")),le(!0)}function ue(){if(!C)return;const R=String((C==null?void 0:C.from)||"").trim(),ee=String((C==null?void 0:C.subject)||"").trim(),Pe=ee.toLowerCase().startsWith("re:")?ee:`Re: ${ee||"(no subject)"}`,Fe=String((C==null?void 0:C.body_text)||"").trim(),Xe=`
98
-
99
- ---
100
- On ${Eh((C==null?void 0:C.date)||"")}, ${R} wrote:
101
-
102
- ${Fe}`;F({to:R,subject:Pe,body:Xe})}async function ye(){if(!et||je)return;const R=String(v||"").trim();if(R){if(!se){Y("Selected account is not allowed to send email.");return}Y(""),we(!0);try{const ee=fd(D);if(!ee)throw new Error("to is required");const Pe=String(qe||"").trim();if(!Pe)throw new Error("subject is required");const Fe=String(Ge||"").trim();if(!Fe)throw new Error("body is required");await n.email_send({account:R,to:ee,subject:Pe,body_text:Fe,cc:fd($e),bcc:fd(Re)}),le(!1),be(""),Oe(""),rt(""),it(""),ct(""),await Ce()}catch(ee){Y(String((ee==null?void 0:ee.message)||ee||"Failed to send email"))}finally{we(!1)}}}const xe=f.useMemo(()=>{const R=String(ae||"").trim();return R&&I.find(ee=>String((ee==null?void 0:ee.uid)||"").trim()===R)||null},[I,ae]),ke=String((C==null?void 0:C.body_text)||"").trim()||String((C==null?void 0:C.body_html)||"").trim(),J=String((C==null?void 0:C.body_text)||"").trim()?"Body (text)":String((C==null?void 0:C.body_html)||"").trim()?"Body (html, raw)":"Body";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`inbox_layout exec_layout${r?"":" list_collapsed"}`,children:[e.jsxs("div",{className:`pane inbox_list_pane${r?"":" list_collapsed"}`,ref:l,onClickCapture:R=>{var ee,Pe;(Pe=(ee=R.target)==null?void 0:ee.closest)!=null&&Pe.call(ee,".inbox_item")&&requestAnimationFrame(()=>rl(u.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(al,{open:r,on_toggle:i,controls:"inbox_email_list",title:"Email",count:I.length})}),e.jsxs("div",{className:"pane_body email_list_body",id:"inbox_email_list",hidden:!r,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:v,onChange:R=>g(String(R.target.value||"")),disabled:!et||P,children:W.length?W.map(R=>e.jsx("option",{value:R.account,children:R.label},R.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void ie(),disabled:!et||P,children:P?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ce(),disabled:!et||Q||!String(v||"").trim()||!Ee,children:Q?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>F(),disabled:!et||!String(v||"").trim()||!se,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:A,onChange:R=>$(String(R.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:T,onChange:R=>B(String(R.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:R=>M(Number(R.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:w,onChange:R=>L(String(R.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void Ce(),disabled:!et||Q||!String(v||"").trim()||!Ee,children:"Apply"})})]}),ve?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ve}):null,e.jsx("div",{className:"inbox_list",children:I.length?I.map((R,ee)=>{const Pe=String((R==null?void 0:R.uid)||"").trim(),Fe=!!Pe&&Pe===String(ae||"").trim(),Xe=String((R==null?void 0:R.subject)||"").trim()||"(no subject)",ut=String((R==null?void 0:R.from)||"").trim(),mt=String((R==null?void 0:R.date)||"").trim(),Le=!!(R!=null&&R.seen);return e.jsxs("button",{className:`inbox_item ${Fe?"active":""}`,onClick:()=>void Je(Pe),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${Le?"approved":"pending"}`,children:Le?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:Fo(Xe,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:Fo(ut,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Fo(mt,36)||"(date?)"," • uid ",Fo(Pe,10)]})]},Pe||`idx:${ee}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane inbox_detail_pane",ref:u,children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>rl(l.current),children:"← Back to the list"})}),ae?G?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):X?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:X}):C?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((C==null?void 0:C.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((C==null?void 0:C.account)||"").trim()||v}),e.jsx("span",{className:"pill muted",children:String((C==null?void 0:C.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",Fo(String((C==null?void 0:C.uid)||ae),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>ln(String((C==null?void 0:C.message_id)||"")),disabled:!String((C==null?void 0:C.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>ln(String(ae||"")),disabled:!String(ae||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>ue(),disabled:!se||!String((C==null?void 0:C.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((C==null?void 0:C.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((C==null?void 0:C.to)||"").trim()||"(to?)"})]}),String((C==null?void 0:C.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((C==null?void 0:C.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:Eh(String((C==null?void 0:C.date)||(xe==null?void 0:xe.date)||"").trim())||String((C==null?void 0:C.date)||(xe==null?void 0:xe.date)||"").trim()||"(date?)"})]}),Array.isArray(C==null?void 0:C.attachments)&&C.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:C.attachments.map((R,ee)=>e.jsxs("div",{children:[String((R==null?void 0:R.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((R==null?void 0:R.content_type)||"").trim()?`(${String((R==null?void 0:R.content_type)||"").trim()})`:""})]},`${(R==null?void 0:R.filename)||""}:${ee}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:J}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255, 255, 255, 0.10)",background:"rgba(0, 0, 0, 0.12)",maxHeight:"60vh",overflow:"auto"},children:ke||"(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(tr,{open:he,title:`Compose (${String(v||"").trim()||"account"})`,onClose:()=>{je||le(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[U?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:U}):null,e.jsx("button",{className:"btn",onClick:()=>le(!1),disabled:je,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ye(),disabled:je,children:je?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:D,onChange:R=>be(String(R.target.value||"")),placeholder:"you@example.com"})]}),e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Cc"}),e.jsx("input",{value:$e,onChange:R=>Oe(String(R.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:Re,onChange:R=>rt(String(R.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:qe,onChange:R=>it(String(R.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Ge,onChange:R=>ct(String(R.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 Th(s){const n=String(s||"").trim();if(!n)return"";const r=n.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function bc(s){const n=String(s||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Ni(s,n){const r=String(s||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function cw(s){const n=s.gateway,r=!!s.enable_triage,[i,l]=Mc("inbox_reports"),u=f.useRef(null),m=f.useRef(null),[d,h]=f.useState(r?"messages":"email"),[x,v]=f.useState([]),[g,w]=f.useState([]),[L,A]=f.useState([]),[$,T]=f.useState(!1),[B,O]=f.useState(""),[M,P]=f.useState(null),[E,Q]=f.useState(""),[oe,G]=f.useState(!1),[Ne,je]=f.useState(""),[we,ve]=f.useState("pending"),[H,X]=f.useState(null),[Z,U]=f.useState(""),[Y,I]=f.useState(null),[te,ae]=f.useState(""),[k,C]=f.useState(!1),[re,he]=f.useState(!1),[le,D]=f.useState(""),[be,$e]=f.useState(""),Oe=!!be,[Re,rt]=f.useState(""),[qe,it]=f.useState(""),[Ge,ct]=f.useState(""),[et,fe]=f.useState(!1),ce=s.gateway_connected;f.useEffect(()=>{!r&&d!=="email"&&h("email")},[r,d]);const Ee=f.useMemo(()=>d==="bugs"?x:d==="features"?g:[],[d,x,g]);f.useEffect(()=>{d==="email"&&(O(""),T(!1))},[d]);async function se(){const J=await n.list_bug_reports();v(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function W(){const J=await n.list_feature_requests();w(Array.isArray(J==null?void 0:J.items)?J.items:[])}async function ie(){const J=await n.list_triage_decisions({status:we||void 0,limit:500}),R=Array.isArray(J==null?void 0:J.decisions)?J.decisions:[];A(R),H&&!R.some(ee=>ee.decision_id===H.decision_id)&&(X(null),U(""),I(null),ae(""))}async function Ce(){if(ce&&r&&d!=="email"){O(""),T(!0);try{d==="bugs"?await se():d==="features"?await W():await ie()}catch(J){O(String((J==null?void 0:J.message)||J||"Refresh failed"))}finally{T(!1)}}}f.useEffect(()=>{Ce()},[d,ce,we,r]);async function Je(J){P(J),Q(""),je(""),G(!0);try{if(J.report_type==="bug"){const R=await n.get_bug_report_content(J.filename);Q(String((R==null?void 0:R.content)||""))}else{const R=await n.get_feature_request_content(J.filename);Q(String((R==null?void 0:R.content)||""))}}catch(R){je(String((R==null?void 0:R.message)||R||"Failed to load report"))}finally{G(!1)}}async function F(J){X(J),U(""),I(null),ae("");const R=Th(J.report_relpath);if(R)try{if(J.report_type==="bug"){const ee=await n.get_bug_report_content(R);U(String((ee==null?void 0:ee.content)||""))}else if(J.report_type==="feature"){const ee=await n.get_feature_request_content(R);U(String((ee==null?void 0:ee.content)||""))}}catch(ee){ae(String((ee==null?void 0:ee.message)||ee||"Failed to load report"))}}async function ue(J){ae(""),I(null);const R=String(J.draft_relpath||"").trim();if(!R)return;const ee=Th(R);if(ee)try{const Pe=await n.backlog_content("proposed",ee);I(Pe)}catch(Pe){ae(String((Pe==null?void 0:Pe.message)||Pe||"Failed to load draft (is repo root configured on gateway?)"))}}async function ye(J,R){if(H&&!k){ae(""),C(!0);try{const ee=await n.apply_triage_decision(H.decision_id,{action:J,defer_days:R??null});await ie();const Pe=String(we||"").trim().toLowerCase(),Fe=String((ee==null?void 0:ee.status)||"").trim().toLowerCase();if(!(!Pe||Pe===Fe))X(null),U(""),I(null);else if(X(ee),String(ee.draft_relpath||"").trim())try{await ue(ee)}catch{}}catch(ee){ae(String((ee==null?void 0:ee.message)||ee||"Decision action failed"))}finally{C(!1)}}}async function xe(){if(!re){O(""),he(!0);try{const J=await n.triage_run({write_drafts:!1,enable_llm:!1});D(`Scanned ${(J==null?void 0:J.reports)??0} report(s); updated ${(J==null?void 0:J.updated_decisions)??0} decision(s).`),await ie()}catch(J){O(String((J==null?void 0:J.message)||J||"Triage failed"))}finally{he(!1)}}}f.useEffect(()=>{Oe&&(ct(""),it(""),fe(!1),rt(String(s.default_session_id||"").trim()))},[Oe,s.default_session_id]);async function ke(){var J,R;if(be&&!et){ct(""),fe(!0);try{const ee=String(Re||"").trim();if(!ee)throw new Error("session_id is required");const Pe=String(qe||"").trim();if(!Pe)throw new Error("description is required");const Fe={session_id:ee,description:Pe,active_run_id:String(s.default_active_run_id||"").trim()||void 0,workflow_id:String(s.default_workflow_id||"").trim()||void 0,client:"abstractcontinuum/web",client_version:"",user_agent:String(((J=globalThis==null?void 0:globalThis.navigator)==null?void 0:J.userAgent)||""),url:String(((R=globalThis==null?void 0:globalThis.location)==null?void 0:R.href)||"")};if(be==="bug"){const Xe=await n.bug_report_create(Fe),ut=String((Xe==null?void 0:Xe.filename)||"").trim();$e(""),h("bugs");const mt=await n.list_bug_reports(),Le=Array.isArray(mt==null?void 0:mt.items)?mt.items:[];v(Le);const nt=Le.find(ht=>ht.filename===ut)||null;nt&&await Je(nt)}else{const Xe=await n.feature_report_create(Fe),ut=String((Xe==null?void 0:Xe.filename)||"").trim();$e(""),h("features");const mt=await n.list_feature_requests(),Le=Array.isArray(mt==null?void 0:mt.items)?mt.items:[];w(Le);const nt=Le.find(ht=>ht.filename===ut)||null;nt&&await Je(nt)}}catch(ee){ct(String((ee==null?void 0:ee.message)||ee||"Failed to create report"))}finally{fe(!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":d==="messages",className:`seg_btn ${d==="messages"?"active":""}`,onClick:()=>h("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"}),e.jsx("button",{"aria-pressed":d==="bugs",className:`seg_btn ${d==="bugs"?"active":""}`,onClick:()=>h("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":d==="features",className:`seg_btn ${d==="features"?"active":""}`,onClick:()=>h("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>h("email"),children:"Email"})}),r&&d!=="email"&&le?e.jsx("span",{className:"page_hint mono",children:le}):null,r&&d!=="email"&&B?e.jsx("span",{className:"page_error mono",children:B}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r?e.jsxs(e.Fragment,{children:[d==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:we,onChange:J=>ve(String(J.target.value)),title:"Filter triage decisions by status",children:[e.jsx("option",{value:"pending",children:"pending"}),e.jsx("option",{value:"approved",children:"approved"}),e.jsx("option",{value:"deferred",children:"deferred"}),e.jsx("option",{value:"rejected",children:"rejected"}),e.jsx("option",{value:"",children:"all"})]}),e.jsx("button",{className:"btn",onClick:()=>void Ce(),disabled:!ce||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void xe(),disabled:!ce||re,children:re?"Running…":"Run triage"})]}):d==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void Ce(),disabled:!ce||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>$e("bug"),disabled:!ce,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>$e("feature"),disabled:!ce,children:"File feature"})]}):null]}),d==="email"?e.jsx(lw,{gateway:n,enabled:ce}):e.jsxs("div",{className:`inbox_layout exec_layout${i?"":" list_collapsed"}`,children:[e.jsxs("div",{className:`pane inbox_list_pane${i?"":" list_collapsed"}`,ref:u,onClickCapture:J=>{var R,ee;(ee=(R=J.target)==null?void 0:R.closest)!=null&&ee.call(R,".inbox_item")&&requestAnimationFrame(()=>rl(m.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(al,{open:i,on_toggle:l,controls:"inbox_report_list",title:d==="messages"?"Triage decisions":d==="bugs"?"Bug reports":"Feature requests",count:d==="messages"?L.length:Ee.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"inbox_report_list",hidden:!i,children:d==="messages"?e.jsx(e.Fragment,{children:L.length?L.map(J=>{const R=(H==null?void 0:H.decision_id)===J.decision_id,ee=Array.isArray(J.missing_fields)?J.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${R?"active":""}`,onClick:()=>void F(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(J.status||"").toLowerCase()}`,children:String(J.status||"pending")}),e.jsx("span",{className:"mono",children:J.report_type}),e.jsx("span",{className:"mono muted",children:Ni(J.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[ee?`${ee} missing`:"complete"," • ",bc(J.updated_at||J.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:Ni(J.report_relpath||"",46)})]},J.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:Ee.length?Ee.map(J=>{const R=(M==null?void 0:M.filename)===J.filename&&(M==null?void 0:M.report_type)===J.report_type,ee=String(J.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${R?"active":""}`,onClick:()=>void Je(J),children:[e.jsxs("div",{className:"inbox_item_title",children:[ee?e.jsx("span",{className:`pill ${ee}`,children:ee}):null,e.jsx("span",{className:"mono",children:Ni(J.title||J.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[bc(J.created_at)||"(time?)"," • ",J.session_id?Ni(J.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:J.filename})]},J.relpath)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})})]}),e.jsx("div",{className:"pane inbox_detail_pane",ref:m,children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>rl(u.current),children:"← Back to the list"})}),d==="messages"?H?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:H.report_type}),e.jsx("span",{className:"chip mono muted",children:H.status}),e.jsx("span",{className:"chip mono muted",children:Ni(H.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{ln(H.report_relpath||"")},children:"Copy report path"}),H.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void ue(H),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void ye("approve"),disabled:k,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void ye("defer",1),disabled:k,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void ye("defer",7),disabled:k,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void ye("reject"),disabled:k,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[H.updated_at?`updated ${bc(H.updated_at)}`:null,H.created_at?`${H.updated_at?" • ":""}created ${bc(H.created_at)}`:null,H.defer_until?` • defer until ${H.defer_until}`:null]}),te?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:te}):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"}),H.missing_fields&&H.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:H.missing_fields.map(J=>e.jsx("li",{children:J},J))}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."}),e.jsx("div",{className:"section_title",style:{marginTop:"10px"},children:"Possible duplicates"}),H.duplicates&&H.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:H.duplicates.slice(0,20).map((J,R)=>{const ee=String((J==null?void 0:J.title)||(J==null?void 0:J.ref)||(J==null?void 0:J.kind)||"duplicate").trim(),Pe=typeof(J==null?void 0:J.score)=="number"&&Number.isFinite(J.score)?` (score ${J.score.toFixed(2)})`:"";return e.jsxs("li",{children:[ee,Pe]},`${ee}_${R}`)})}):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"}),H.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:H.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)."})]})]}),Y?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(ns,{className:"md_doc",text:String(Y.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),Z?e.jsx(ns,{className:"md_doc",text:Z}):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."}):M?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:M.report_type==="bug"?"Bug report":"Feature request"}),M.triage_status?e.jsx("span",{className:`pill ${M.triage_status}`,children:M.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:M.filename}),M.session_id?e.jsx("span",{className:"chip mono muted",children:Ni(M.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{ln(M.relpath||"")},children:"Copy path"})})]}),Ne?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ne}):null,oe?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):E?e.jsx(ns,{className:"md_doc",text:E}):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(tr,{open:Oe,title:be==="bug"?"File bug report":"File feature request",onClose:()=>$e(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>$e(""),disabled:et,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ke(),disabled:et,children:et?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:Re,onChange:J=>rt(J.target.value),placeholder:"session id (required)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"This correlates runs + attachments (via the session memory run)."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:be==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:qe,onChange:J=>it(J.target.value),placeholder:be==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Ge?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Ge}):null]})]})}const uw="api/continuum/settings";async function i_(s){const n=await fetch(uw,{...s,signal:AbortSignal.timeout(1e4),headers:s!=null&&s.body?{"Content-Type":"application/json"}:void 0}),r=await n.text();let i=null;try{i=JSON.parse(r)}catch{}if(!n.ok||!i||typeof i!="object"||!i.settings){const l=i&&typeof i=="object"?i.detail||i.error:"",u=new Error(l||`settings unavailable (HTTP ${n.status})`);throw u.status=n.status,u}return i}function dw(){return i_()}function mw(s,n){return i_({method:"PUT",body:JSON.stringify({[s]:n})})}const o_="abstractcontinuum_voice_override_v1",hd={enabled:!1};function Id(){try{const s=localStorage.getItem(o_);if(!s)return{...hd};const n=JSON.parse(s);return!n||typeof n!="object"?{...hd}:{enabled:!!n.enabled,provider:Ws(n.provider),model:Ws(n.model),profile:Ws(n.profile),voice:Ws(n.voice),quality_preset:Ws(n.quality_preset)}}catch{return{...hd}}}const Dd="abstractcontinuum:voice_override_changed";function fw(s){try{localStorage.setItem(o_,JSON.stringify(s))}catch{}try{window.dispatchEvent(new CustomEvent(Dd))}catch{}}function l_(s){if(!s)return{};const n={},r=Ws(s.quality_preset);if(r&&(n.quality_preset=r),!s.enabled)return n;for(const i of["provider","model","profile","voice"]){const l=Ws(s[i]);l&&(n[i]=l)}return n}function Ws(s){return String(s??"").trim()||void 0}function c_(s){const n=s&&typeof s=="object"?s.routes:null;if(!Array.isArray(n))return{};const r=x=>n.find(v=>v&&typeof v=="object"&&String(v.key||"").trim()===x&&!!v.configured),i=r("output.voice.tts")||r("output.voice");if(!i)return{};const l={},u=Ws(i.provider),m=Ws(i.model),d=i.options,h=d&&typeof d=="object"?Ws(d.voice):void 0;return u&&(l.provider=u),m&&(l.model=m),h&&(l.voice=h),l}function hw(s){let n=String(s||"");return n=n.replace(/```[\s\S]*?```/g," "),n=n.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),n=n.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1"),n=n.replace(/`([^`]+)`/g,"$1"),n=n.replace(/^[ \t]*#{1,6}[ \t]+/gm,""),n=n.replace(/^[ \t]*>[ \t]?/gm,""),n=n.replace(/^[ \t]*[-*+][ \t]+/gm,""),n=n.replace(/^[ \t]*\d+[.)][ \t]+/gm,""),n=n.replace(/^[ \t]*\|/gm,"").replace(/\|[ \t]*$/gm,"").replace(/\|/g,", "),n=n.replace(/(\*\*|__|~~)(.*?)\1/g,"$2"),n=n.replace(/\*([^*\n]+)\*/g,"$1"),n=n.replace(/(^|[^\w])_([^_\n]+)_(?=[^\w]|$)/g,"$1$2"),n=n.replace(/^[ \t]*([-*_])(?:[ \t]*\1){2,}[ \t]*$/gm," "),n=n.replace(/\s+/g," ").trim(),n}const qo={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function pw(s){const n={};if(!Array.isArray(s))return n;for(const r of s){if(!r||typeof r!="object")continue;const i=r.voice_kinds;if(!(Array.isArray(i)&&i.some(h=>String(h).toLowerCase().includes("clone"))))continue;const u=String(r.provider||"").trim(),m=String(r.id||r.voice||r.name||"").trim();if(!m)continue;const d=u||"*";(n[d]||(n[d]=[])).push(m)}for(const r of Object.keys(n))n[r]=[...new Set(n[r])];return n}function Od(s){if(!Array.isArray(s))return[];const n=[];for(const r of s)if(typeof r=="string"){const i=r.trim();i&&n.push(i)}else if(r&&typeof r=="object"){const i=String(r.id||r.name||r.voice||r.value||"").trim();i&&n.push(i)}return[...new Set(n)]}function pd(s){const n={};if(s&&typeof s=="object"&&!Array.isArray(s))for(const[r,i]of Object.entries(s)){const l=Od(i);l.length&&(n[String(r)]=l)}return n}function _w(s){const{gateway:n,gateway_connected:r}=s,[i,l]=f.useState(()=>Id()),[u,m]=f.useState(qo),[d,h]=f.useState(!1),[x,v]=f.useState(""),g=f.useRef(null),w=f.useCallback(M=>{l(P=>{const E={...P,...M};return fw(E),E})},[]);f.useEffect(()=>{if(!r){m(qo);return}if(typeof(n==null?void 0:n.voice_voices)!="function"){m(qo);return}let M=!0;m(E=>({...E,loading:!0,error:""}));let P;try{P=n.voice_voices()}catch(E){m({...qo,error:String((E==null?void 0:E.message)||E||"voice catalog unavailable")});return}return P.then(E=>{if(!M)return;const Q=[...new Set([...Od(E==null?void 0:E.providers),...Od(E==null?void 0:E.tts_providers)])];m({loading:!1,error:"",providers:Q,models_by_provider:pd(E==null?void 0:E.tts_models_by_provider),profiles_by_provider:pd(E==null?void 0:E.tts_profiles_by_provider),voices_by_provider:pd(E==null?void 0:E.tts_voices_by_provider),cloned_by_provider:pw(E==null?void 0:E.items)})}).catch(E=>{M&&m({...qo,error:String((E==null?void 0:E.message)||E||"voice catalog unavailable")})}),()=>{M=!1}},[n,r]);const L=i.provider||"",A=L&&u.models_by_provider[L]?u.models_by_provider[L]:[],$=L&&u.voices_by_provider[L]?u.voices_by_provider[L]:[],T=L&&u.profiles_by_provider[L]?u.profiles_by_provider[L]:[],B=[...L&&u.cloned_by_provider[L]?u.cloned_by_provider[L]:[],...u.cloned_by_provider["*"]||[]];async function O(){if(!(d||!r)){h(!0),v("");try{const M=await Kd("abstractcontinuum_team_voice");let P={};if(typeof n.capability_defaults=="function")try{P=c_(await n.capability_defaults())}catch{P={}}const E=await n.voice_tts(M,{text:"This is the voice AbstractContinuum will use to read your messages.",...P,...l_(i),timeout_s:30}),Q=E==null?void 0:E.audio_artifact,oe=Q&&typeof Q=="object"?String(Q.$artifact||"").trim():"";if(!oe)throw new Error("no audio returned");const G=await n.download_run_artifact_content(M,oe),Ne=URL.createObjectURL(G);if(g.current)try{g.current.pause()}catch{}const je=g.current;if(je){try{je.pause()}catch{}const ve=je.src;ve.startsWith("blob:")&&URL.revokeObjectURL(ve)}const we=new Audio(Ne);g.current=we,we.onended=()=>{URL.revokeObjectURL(Ne),v("")};try{await we.play(),v("Playing…")}catch(ve){v(String((ve==null?void 0:ve.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((ve==null?void 0:ve.message)||ve).slice(0,80)}`),URL.revokeObjectURL(Ne)}}catch(M){v(`Test failed: ${String((M==null?void 0:M.message)||M||"synthesis error").slice(0,120)}`)}finally{h(!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.jsx(Li,{variant:"row",label:"Custom voice",description:"Read messages with the voice below instead of the gateway's default, in this browser.",action:"custom-voice",checked:i.enabled,onChange:M=>w({enabled:M})}),u.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",u.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,u.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,i.enabled&&!L&&(i.voice||i.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,i.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(wc,{value:L,options:u.providers,placeholder:"gateway default",onChange:M=>w({provider:M,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(wc,{value:i.model||"",options:A,placeholder:"default",onChange:M=>w({model:M})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(wc,{value:i.profile||"",options:T,placeholder:"default",onChange:M=>w({profile:M})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(wc,{value:i.voice||"",options:[...B,...$],placeholder:"none",onChange:M=>w({voice:M})})]})]}):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:i.quality_preset||"",onChange:M=>w({quality_preset:M.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:d,onClick:()=>void O(),children:d?"Synthesizing…":"Test voice"}),x?e.jsx("span",{className:"muted team_note",children:x}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function wc(s){const n=Bt.useId();return e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"team_compose_control mono",list:n,value:s.value,placeholder:s.placeholder||"",onChange:r=>s.onChange(r.target.value.trim())}),s.options.length?e.jsx("datalist",{id:n,children:s.options.map(r=>e.jsx("option",{value:r},r))}):null]})}const gw=["minimal","low","medium","high","xhigh"];function yw(s){const{gateway:n,connected:r,model:i,value:l,onChange:u}=s,[m,d]=f.useState({state:"unknown",levels:[]}),[h,x]=f.useState(!1);if(f.useEffect(()=>{x(!1);const w=String(i||"").trim();if(!w||!r){d({state:"unknown",levels:[]});return}let L=!1;return d({state:"loading",levels:[]}),n.discovery_model_capabilities(w).then(A=>{if(L)return;const $=A!=null&&A.capabilities&&typeof A.capabilities=="object"?A.capabilities:{},T=$.thinking_support,B=Array.isArray($.reasoning_levels)?$.reasoning_levels.map(O=>String(O)):[];d(T===!0?{state:"supported",levels:B}:T===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{L||d({state:"unknown",levels:[]})}),()=>{L=!0}},[i,r]),!String(i||"").trim())return null;const v=m.state==="unsupported"||m.state==="unknown"&&!h||m.state==="loading",g=m.state==="supported"&&m.levels.length?m.levels:m.state==="unknown"&&h?[...gw]:[];return e.jsxs("div",{className:"field","data-testid":"reasoning_select",children:[e.jsxs("label",{children:["Reasoning (effort for ",i,")"]}),e.jsxs("select",{value:v?"":l,onChange:w=>u(String(w.target.value||"")),disabled:v,title:m.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":m.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":m.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:m.state==="unsupported"?"none — this model doesn't reason":m.state==="loading"?"checking…":m.state==="unknown"&&!h?"unknown — no served facts":"gateway default"}),g.map(w=>e.jsx("option",{value:w,children:w},w))]}),m.state==="unknown"&&!v?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,m.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:h,onChange:w=>{x(w.target.checked),w.target.checked||u("")}}),"set anyway (I know this model reasons)"]}):null]})}function vw(s){const[n,r]=f.useState(!1),[i,l]=f.useState("");return n?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono",style:{minWidth:260},value:i,onChange:u=>l(u.target.value),placeholder:"/path/to/a/folder/with/docs/backlog",disabled:s.busy}),e.jsx("button",{className:"btn primary",disabled:s.busy||!i.trim(),onClick:()=>{s.on_apply(i.trim()),r(!1)},children:"Apply"}),e.jsx("button",{className:"btn",disabled:s.busy,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx("button",{className:"btn",disabled:s.busy,onClick:()=>{l(s.current),r(!0)},children:s.current?"Change…":"Set…"})}function xw(s){const n=String(s||"").trim();if(!n)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."]},[i,l,u]=r[n]||[n,"muted",""];return e.jsx("span",{className:`chip mono ${l}`,title:u,"data-testid":"hub_seat_source",children:i})}function bw(){var A;const[s,n]=f.useState(null),[r,i]=f.useState(""),[l,u]=f.useState(""),[m,d]=f.useState(!1),[h,x]=f.useState("");f.useEffect(()=>{let $=!1;return dw().then(T=>{var B;$||(n(T),u(String(((B=T.settings.hub_seat)==null?void 0:B.value)??"")))}).catch(T=>{$||i(String((T==null?void 0:T.message)||T))}),()=>{$=!0}},[]);async function v($){var T;d(!0),x("");try{const B=await mw("hub_seat",$);n(B),u(String(((T=B.settings.hub_seat)==null?void 0:T.value)??""))}catch(B){x(String((B==null?void 0:B.message)||B||"Save refused"))}finally{d(!1)}}const g=s==null?void 0:s.settings.hub_seat,w=String((g==null?void 0:g.value)??""),L=!!((A=s==null?void 0:s.writable)!=null&&A.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:s?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:w}),xw(g==null?void 0:g.source),e.jsx("div",{className:"admin_row_action",children:L?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono","aria-label":"Hub seat",value:l,onChange:$=>u($.target.value),placeholder:"your seat",disabled:m}),e.jsx("button",{className:"btn primary",disabled:m||!l.trim()||l.trim()===w&&(g==null?void 0:g.source)==="setting",onClick:()=>void v(l.trim()),children:"Save"}),(g==null?void 0:g.source)==="setting"?e.jsx("button",{className:"btn",disabled:m,onClick:()=>void v(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:s.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.",(g==null?void 0:g.source)==="flag"?" A launch flag sets the seat for this run; a saved value applies once Continuum restarts without it.":null]}),h?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:h}):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 ww(s){var X,Z;const{gateway:n,gateway_connected:r,settings:i,set_settings:l}=s,u=(Z=(X=s.connection)==null?void 0:X.gateway)==null?void 0:Z.principal,[m,d]=f.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[h,x]=f.useState(null),[v,g]=f.useState(null),[w,L]=f.useState(!1),[A,$]=f.useState(null),[T,B]=f.useState([]),[O,M]=f.useState(""),[P,E]=f.useState(""),[Q,oe]=f.useState(!1),[G,Ne]=f.useState(0);async function je(U,Y=""){if(!Q){oe(!0),M(""),E("");try{const I=await n.admin_runtime_config_update(U);x(I),E(Y),Ne(te=>te+1)}catch(I){M(String((I==null?void 0:I.message)||I||"Config update refused"))}finally{oe(!1)}}}f.useEffect(()=>{if(!r)return;let U=!1;return(async()=>{var I;const Y={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const te=await n.backlog_exec_config(),ae=!!(te!=null&&te.runner_enabled),k=!!(te!=null&&te.runner_alive),C=(te==null?void 0:te.can_execute)===!0;Y.exec_pipeline=C?"on":ae||k?"degraded":"off",Y.exec_detail=C?"":ae?k?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",Y.executor=String((te==null?void 0:te.executor)||"").trim()}catch{Y.exec_pipeline=null}try{const te=await n.admin_runtime_config();if(te&&typeof te=="object"){U||(x(te),Y.process_manager=xc(te.process_manager),Y.backlog_root=((I=te.triage_repo_root)==null?void 0:I.available)!==void 0?!!te.triage_repo_root.available:xc(te.triage_repo_root),d(Y));return}}catch{}try{const te=await n.list_processes();Y.process_manager=!!(te!=null&&te.enabled)}catch{Y.process_manager=null}try{await n.backlog_template(),Y.backlog_root=!0}catch(te){Y.backlog_root=Ai(te)?!1:null}U||d(Y)})(),(async()=>{try{const Y=await n.admin_data_homes();U||($(Array.isArray(Y==null?void 0:Y.homes)?Y.homes:[]),B(Array.isArray(Y==null?void 0:Y.warnings)?Y.warnings:[]))}catch{U||$(null)}})(),(async()=>{try{const Y=await n.list_bundles(),I=Array.isArray(Y==null?void 0:Y.items)?Y.items:Array.isArray(Y==null?void 0:Y.bundles)?Y.bundles:Array.isArray(Y)?Y:[],te=[];for(const C of I){const re=String((C==null?void 0:C.bundle_id)||(C==null?void 0:C.id)||"").trim();if(!re)continue;const he=Array.isArray(C==null?void 0:C.entrypoints)?C.entrypoints:[];for(const le of he){if((le==null?void 0:le.deprecated)===!0||!(Array.isArray(le==null?void 0:le.interfaces)?le.interfaces:[]).some($e=>String($e||"").trim().length>0))continue;const be=String((le==null?void 0:le.name)||"").trim();te.push({id:re,name:be?`${re} · ${be}`:re,description:String((le==null?void 0:le.description)||"").trim()||void 0})}}const ae=new Set,k=te.filter(C=>ae.has(C.id)?!1:(ae.add(C.id),!0));k.sort((C,re)=>C.name.localeCompare(re.name)),U||g(k)}catch{U||g(null)}})(),()=>{U=!0}},[n,r,G]);function we(U){return typeof U!="number"||!Number.isFinite(U)||U<0?"":U>=1e12?`${(U/1e12).toFixed(1)} TB`:U>=1e9?`${(U/1e9).toFixed(1)} GB`:U>=1e6?`${(U/1e6).toFixed(1)} MB`:U>=1e3?`${(U/1e3).toFixed(1)} KB`:`${U} B`}function ve(U,Y="on",I="off"){return U===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${U?"ok":"warn"}`,children:U?Y:I})}function H(U){const Y=String(U||"").trim();if(!Y)return null;const I={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."]},[te,ae,k]=I[Y]||[Y,"muted",""];return e.jsx("span",{className:`chip mono ${ae}`,title:k,"data-testid":"source_chip",children:te})}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:i.default_execution_mode,onChange:U=>l(Y=>({...Y,default_execution_mode:U.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(Ng,{disabled:!r,value:{provider:i.maintenance_ai_provider,model:i.maintenance_ai_model},onChange:U=>l(Y=>({...Y,maintenance_ai_provider:U.provider,maintenance_ai_model:U.model,maintenance_ai_reasoning:U.model===Y.maintenance_ai_model?Y.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const U=await n.discovery_providers();return(Array.isArray(U==null?void 0:U.items)?U.items:[]).map(Y=>({name:Y.name,display_name:Y.display_name}))},fetchModels:async U=>{const Y=await n.discovery_provider_models(U);return Array.isArray(Y==null?void 0:Y.models)?Y.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(yw,{gateway:n,connected:r,model:i.maintenance_ai_model,value:i.maintenance_ai_reasoning,onChange:U=>l(Y=>({...Y,maintenance_ai_reasoning:U}))}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Advisor workflow (executable workflows served by this gateway)"}),v===null?e.jsx("input",{className:"mono",value:i.backlog_advisor_agent,onChange:U=>l(Y=>({...Y,backlog_advisor_agent:String(U.target.value||"")})),placeholder:"basic-agent",title:"This gateway does not serve the workflow catalog — enter a bundle id."}):(()=>{const U=String(i.backlog_advisor_agent||"").trim(),Y=U===""||v.some(I=>I.id===U);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:Y&&!w?U:"__custom__",onChange:I=>{const te=I.target.value;te==="__custom__"?L(!0):(L(!1),l(ae=>({...ae,backlog_advisor_agent:te})))},title:"Workflows the gateway can run for advice; blank = the shipped basic-agent",children:[e.jsx("option",{value:"",children:"gateway default (basic-agent)"}),v.map(I=>e.jsx("option",{value:I.id,title:I.description||void 0,children:I.name||I.id},I.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!Y||w?e.jsx("input",{className:"mono",style:{marginTop:6},value:i.backlog_advisor_agent,onChange:I=>l(te=>({...te,backlog_advisor_agent:String(I.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(_w,{gateway:n,gateway_connected:r}),e.jsx(bw,{}),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:[u!=null&&u.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:u.user_id}),u.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):u.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 k,C,re,he,le,D,be,$e,Oe;const U=(h==null?void 0:h.writable)===!0,Y=Array.isArray(h==null?void 0:h.executors)?h.executors:[],I=U?null:h?h.writable===!1?"Only a gateway admin can change this.":"This gateway does not say whether you may change it.":"This gateway does not serve its settings to Continuum (older build).",te=h?xc(h.backlog_exec_runner)===!0:m.exec_pipeline==="on"||m.exec_pipeline==="degraded",ae=h?xc(h.process_manager)===!0:m.process_manager===!0;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"}),ve(m.backlog_root,"available","not available"),H((k=h==null?void 0:h.triage_repo_root)==null?void 0:k.source),e.jsxs("div",{className:"admin_row_action",children:[U&&((C=h==null?void 0:h.triage_repo_root)!=null&&C.default_path)&&Do(h==null?void 0:h.triage_repo_root)!==h.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:Q,onClick:()=>{var Re;return void je({triage_repo_root:((Re=h==null?void 0:h.triage_repo_root)==null?void 0:Re.default_path)||null})},title:h.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,U?e.jsx(vw,{current:Do(h==null?void 0:h.triage_repo_root),busy:Q,on_apply:Re=>void je({triage_repo_root:Re})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((re=h==null?void 0:h.triage_repo_root)==null?void 0:re.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",Do(h==null?void 0:h.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:Do(h==null?void 0:h.triage_repo_root)})]}):null,((he=h==null?void 0:h.triage_repo_root)==null?void 0:he.available)===!1&&h.triage_repo_root.reason?e.jsxs(e.Fragment,{children:[" — not available: ",h.triage_repo_root.reason]}):null]})]}),e.jsxs("div",{className:"admin_row","data-testid":"admin_row_exec_runner",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx(Li,{label:"Exec runner",action:"exec-runner",checked:te,unavailableReason:I,busy:Q,onChange:Re=>void je({backlog_exec_runner:Re},Re?"Exec runner is on.":"Exec runner is off.")}),m.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",title:"The gateway did not report the runner's state.",children:"state unknown"}):te&&m.exec_pipeline!=="on"?e.jsx("span",{className:"chip mono warn",title:m.exec_detail,children:"degraded"}):null,H((le=h==null?void 0:h.backlog_exec_runner)==null?void 0:le.source)]}),e.jsxs("div",{className:"admin_row_detail",children:[((D=h==null?void 0:h.backlog_exec_runner)==null?void 0:D.help)||"Runs the backlog items queued for execution on the gateway's computer.",m.exec_detail?e.jsxs(e.Fragment,{children:[" — ",m.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"}),m.executor&&m.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:m.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),H((be=h==null?void 0:h.executor)==null?void 0:be.source),e.jsx("div",{className:"admin_row_action",children:U&&Y.length?e.jsx("select",{value:Do(h==null?void 0:h.executor),disabled:Q,onChange:Re=>void je({executor:String(Re.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:Y.map(Re=>e.jsxs("option",{value:Re.id,disabled:Re.available===!1,children:[Re.display||Re.id,Re.available===!1?" (unavailable)":""]},Re.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","data-testid":"admin_row_process_manager",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx(Li,{label:"Process manager",action:"process-manager",checked:ae,unavailableReason:I,busy:Q,onChange:Re=>void je({process_manager:Re},Re?"Process manager is on.":"Process manager is off.")}),!h&&m.process_manager===null?e.jsx("span",{className:"chip mono muted",title:"The gateway did not report the process manager's state.",children:"state unknown"}):null,H(($e=h==null?void 0:h.process_manager)==null?void 0:$e.source)]}),e.jsx("div",{className:"admin_row_detail",children:((Oe=h==null?void 0:h.process_manager)==null?void 0:Oe.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),O?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:O}):null,P&&!O?e.jsx("div",{className:"muted",role:"status","data-testid":"admin_notice",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:P}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:h?h.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.":h.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:A?`server-side — ${A.length} registered home${A.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?A===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:[...A].sort((U,Y)=>(Y.size_bytes||0)-(U.size_bytes||0)).map(U=>e.jsxs("tr",{title:U.description||U.path,children:[e.jsx("td",{children:U.name}),e.jsx("td",{children:e.jsx("span",{className:"chip mono muted",children:U.kind})}),e.jsx("td",{className:"muted",children:U.owner}),e.jsx("td",{children:U.exists===!1?e.jsx("span",{className:"chip mono warn",children:"missing"}):we(U.size_bytes)}),e.jsx("td",{children:U.safe_to_purge?e.jsx("span",{className:"chip mono ok",children:"purgeable"}):e.jsx("span",{className:"chip mono warn",title:U.description||"Protected — the owner's rule refuses purge",children:"protected"})})]},U.name))})]})}),T.map((U,Y)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:U},`dhw:${Y}`)),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 jw=/^(```+|~~~+)\s*mermaid\s*$/i;function kw(s){const n=String(s||"").split(`
103
- `),r=[];let i=[],l=0;for(;l<n.length;){const u=n[l].match(jw);if(!u){i.push(n[l]),l+=1;continue}const m=u[1];let d=-1;for(let h=l+1;h<n.length;h++){const x=n[h].trimEnd();if(x.startsWith(m[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(x)&&x[0]===m[0]){d=h;break}}if(d===-1){i.push(n[l]),l+=1;continue}i.length&&(r.push({kind:"md",text:i.join(`
104
- `)}),i=[]),r.push({kind:"mermaid",text:n.slice(l+1,d).join(`
105
- `)}),l=d+1}return i.length&&r.push({kind:"md",text:i.join(`
106
- `)}),r}const Sw="modulepreload",Nw=function(s,n){return new URL(s,n).href},Ah={},Cw=function(n,r,i){let l=Promise.resolve();if(r&&r.length>0){let m=function(v){return Promise.all(v.map(g=>Promise.resolve(g).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};const d=document.getElementsByTagName("link"),h=document.querySelector("meta[property=csp-nonce]"),x=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));l=m(r.map(v=>{if(v=Nw(v,i),v in Ah)return;Ah[v]=!0;const g=v.endsWith(".css"),w=g?'[rel="stylesheet"]':"";if(!!i)for(let $=d.length-1;$>=0;$--){const T=d[$];if(T.href===v&&(!g||T.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${w}`))return;const A=document.createElement("link");if(A.rel=g?"stylesheet":Sw,g||(A.as="script"),A.crossOrigin="",A.href=v,x&&A.setAttribute("nonce",x),document.head.appendChild(A),g)return new Promise(($,T)=>{A.addEventListener("load",$),A.addEventListener("error",()=>T(new Error(`Unable to preload CSS for ${v}`)))})}))}function u(m){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=m,window.dispatchEvent(d),!d.defaultPrevented)throw m}return l.then(m=>{for(const d of m||[])d.status==="rejected"&&u(d.reason);return n().catch(u)})};let _d=null;function $w(){return _d||(_d=Cw(()=>import("./mermaid.core-DtYr0_Mo.js").then(s=>s.bp),[],import.meta.url).then(s=>{const n=s.default||s;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),n})),_d}let Ew=0;function Tw(s){const n=f.useRef(null),[r,i]=f.useState("");return f.useEffect(()=>{let l=!0;return i(""),$w().then(async u=>{const m=`af_mermaid_${Ew+=1}`,{svg:d}=await u.render(m,s.text);l&&n.current&&(n.current.innerHTML=d)}).catch(u=>{l&&i(String((u==null?void 0:u.message)||u||"mermaid render failed"))}),()=>{l=!1}},[s.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:s.text})]}):e.jsx("div",{className:"team_mermaid",ref:n})}const u_=5e4,Aw="abstractcontinuum history_window.estimate_tokens (~4 chars per token)";function Lw(s){const n=String(s??"");return n?Math.max(1,Math.floor(n.length/4)):0}function Mw(s,n,r=u_){if(!Number.isInteger(r)||r<=0)throw new Error(`history window max_tokens must be a positive integer, got ${r}`);const i=s.map(h=>({item:h,tokens:n(h)}));let l=0,u=i.length,m=!1;for(let h=i.length-1;h>=0;h--){const x=i[h].tokens;if(l+x>r){u===i.length&&(m=!0,l+=x,u=h);break}l+=x,u=h}const d=i.slice(0,u);return{kept:i.slice(u).map(h=>h.item),report:{policy:"newest_whole_messages",max_tokens:r,token_estimator:Aw,total_messages:i.length,replayed_messages:i.length-u,replayed_tokens:l,dropped_messages:d.length,dropped_tokens:d.reduce((h,x)=>h+x.tokens,0),oversize_message_kept:m}}}const Rw=400;function Pw(s){const n=new Map;for(const l of s)n.set(l.id,l);const r=l=>{let u=l,m=!1;const d=new Set([u.id]);for(let h=0;h<Rw;h++){const x=String(u.reply_to||"");if(!x)break;const v=n.get(x);if(!v){m=u.id===l.id||m;break}if(d.has(v.id))break;d.add(v.id),u=v}return{root:u,orphan:m&&u.id===l.id}},i=new Map;for(const l of[...s].sort((u,m)=>(u.seq||0)-(m.seq||0))){const{root:u,orphan:m}=r(l);let d=i.get(u.id);d||(d={root:u,replies:[],orphan:u.id===l.id?m:!1,last_seq:u.seq||0},i.set(u.id,d)),l.id!==u.id&&(d.replies.push(l),d.last_seq=Math.max(d.last_seq,l.seq||0))}return[...i.values()].sort((l,u)=>l.last_seq-u.last_seq||(l.root.seq||0)-(u.root.seq||0))}const Lh=[{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 d_(s,n,r){var l,u,m,d,h;if(s.retracted===!0)return n==="all"?!0:n==="unread"?!!((l=r.unread_seqs)!=null&&l.has(s.seq)||(u=r.unread_snapshot_seqs)!=null&&u.has(s.seq)):!1;const i=String(s.status||"").toLowerCase();switch(n){case"all":return!0;case"unread":return!!((m=r.unread_seqs)!=null&&m.has(s.seq)||(d=r.unread_snapshot_seqs)!=null&&d.has(s.seq));case"asks":return i==="open"||i==="blocked";case"fyi":return i==="fyi";case"resolved":return i==="resolved";case"to_me":return Array.isArray(s.to)&&s.to.includes(r.seat);case"vigilance":{const x=(i==="open"||i==="blocked")&&s.has_resolved_reply!==!0,v=s.critical===!0,g=Array.isArray(s.to)&&s.to.includes(r.seat),w=!!((h=r.escalated_seqs)!=null&&h.has(s.seq));return x||v||g||w}}}function Mh(s,n,r){return n==="all"?s:s.filter(i=>[i.root,...i.replies].some(l=>d_(l,n,r)))}function zw(s,n,r){return d_(s,n,r)}function Iw(s){const n={},r={};for(const i of s){const l=String(i.channel||"");if(!l)continue;const u=Number(i.seq);if(Number.isFinite(u)){const m=n[l]||(n[l]=new Set);if(m.has(u))continue;m.add(u)}r[l]=(r[l]||0)+1}return r}function Dw(s){const n={};for(const r of s){const i=String(r.channel||""),l=Number(r.seq);!i||!Number.isFinite(l)||(n[i]||(n[i]=new Set)).add(l)}return n}function Ow(s,n){const r={};for(const i of s){const l=String(i.channel||""),u=Number(i.seq);if(!l||!Number.isFinite(u))continue;const m=String(i.status||"").toLowerCase(),d=Array.isArray(i.to)&&n?i.to.includes(n):!1;(m==="open"||m==="blocked"||(m==="reply"||m==="fyi")&&d)&&(r[l]||(r[l]=new Set)).add(u)}return r}function Fw(s){const n={};for(const r of s){const i=String(r.channel||""),l=Number(r.seq);if(!i||!Number.isFinite(l))continue;const u=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||u==="interrupt")&&(n[i]||(n[i]=new Set)).add(l)}return n}function qw(s,n){const r=n?n.replace(/\/+$/,"")+"/":"",i=new Map,l=[];for(const u of s){const m=String(u.path||"");if(!m.startsWith(r))continue;const d=m.slice(r.length);if(!d)continue;const h=d.indexOf("/");if(h===-1)l.push(u);else{const x=d.slice(0,h);i.set(x,(i.get(x)||0)+1)}}return{dirs:[...i.entries()].map(([u,m])=>({name:u,path:r+u,count:m})).sort((u,m)=>u.name.localeCompare(m.name)),leaves:l.sort((u,m)=>u.path.localeCompare(m.path))}}function Rh(s,n){const r=String(s||"");if(!r.startsWith("dm:")||!n)return"";const i=r.slice(3);return i.startsWith(`${n}--`)?i.slice(n.length+2):i.endsWith(`--${n}`)?i.slice(0,i.length-n.length-2):""}function Bw(s){return s.is_reply?"reply":s.in_dm||s.kind==="ask"?"open":"fyi"}function Uw(s){const n=new Map;for(const i of s)i.id&&n.set(i.id,String(i.sender||""));const r=new Set;for(const i of s){const l=i.reply_to?String(i.reply_to):"";if(!l)continue;const u=n.get(l);(u===void 0||u!==String(i.sender||""))&&r.add(l)}return r}const Ww=/(?:^|[\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,Hw=4;function Vw(s){const n=[];for(const r of String(s||"").matchAll(Ww)){const i=r[1],l=r.index===void 0?-1:r.index,u=l>=0?String(s).slice(Math.max(0,l-12),l+1):"";if(!(u.includes("://")||/\/api\//.test(u))&&(n.includes(i)||n.push(i),n.length>=Hw))break}return n}function Gw(s,n,r){var l,u;const i=s.split("/").pop()||s;if(n!=null&&n.has(s))return{kind:"fs",path:s,rewritten:!1};for(let m=0;m<r.length;m++)if(String(((l=r[m])==null?void 0:l.filename)||"")===s)return{kind:"attachment",attachment_index:m};if(n){const m=[];for(const d of n)(d===i||d.endsWith(`/${i}`))&&m.push(d);if(m.length===1)return{kind:"fs",path:m[0],rewritten:m[0]!==s}}for(let m=0;m<r.length;m++){const d=String(((u=r[m])==null?void 0:u.filename)||"");if(d&&(d===i||d.split("/").pop()===i))return{kind:"attachment",attachment_index:m}}return null}const Ph=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function gd(s){const n=[];for(const i of s.matchAll(Ph)){const l=i[1].toLowerCase();n.includes(l)||n.push(l)}return{title:s.replace(Ph," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:n}}function yd(s){const n=[];for(const r of String(s||"").split(/[\s,;]+/)){const i=r.replace(/^@/,"").toLowerCase();!i||!/^[a-z0-9][a-z0-9_.-]*$/.test(i)||n.includes(i)||n.push(i)}return n}function vd(s,n){let r=s.toLowerCase().replace(/[^a-z0-9_.-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"");r||(r="group"),r=r.slice(0,40).replace(/[-.]+$/g,"");let i=r,l=1;for(;n.has(i);)l+=1,i=`${r}-${l}`;return i}const zh=400,Ih=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Dh=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Kw(s){if(!s||s.length<zh)return s;const n=s.split(/(```[\s\S]*?(?:```|$))/),r=[];for(const i of n){if(i.startsWith("```")){r.push(i);continue}const l=i.split(/(\n{2,})/);for(const u of l){if(/\n/.test(u)||u.length<zh){r.push(u);continue}const m=u.split(/(`[^`\n]*`)/);let d=0;for(const h of m)h.startsWith("`")||(d+=(h.match(Ih)||[]).length+(h.match(Dh)||[]).length);if(d<2){r.push(u);continue}r.push(m.map(h=>h.startsWith("`")?h:h.replace(Ih,`$1
107
-
108
- $2 `).replace(Dh,`$1
109
-
110
- `)).join(""))}}return r.join("")}const Jw=/https?:\/\/[^\s<>()[\]{}"'`]+/g,Qw=/\.(png|jpe?g|gif|webp)$/i;function Yw(s,n){if(!n)return s;const r=n.replace(/\/+$/,"");if(!s.startsWith(r+"/"))return s;const l=s.slice(r.length).match(/^\/channels\/([^/]+)\/attachments\/([A-Za-z0-9_.-]+)$/);return l?`api/hub/channels/${l[1]}/attachments/${l[2]}`:s}function Xw(s,n){if(!s||!/https?:\/\//.test(s))return s;const r=(n==null?void 0:n.hub_base)||"",i=(n==null?void 0:n.app_origin)||"",l=s.split(/(```[\s\S]*?(?:```|$))/),u=[];for(let m=0;m<l.length;m++){const d=l[m];if(d.startsWith("```")){u.push(d);continue}const h=d.split(/(`[^`\n]*`)/);for(let x=0;x<h.length;x++){const v=h[x];if(v.startsWith("`")){u.push(v);continue}u.push(v.replace(Jw,(g,w)=>{const L=v.slice(Math.max(0,w-2),w);if(L.endsWith("](")||L.endsWith("("))return g;const A=g.replace(/[.,;:!?]+$/,""),$=g.slice(A.length);let T="";try{T=new URL(A).pathname}catch{return g}const B=Yw(A,r),O=Qw.test(T),M=B!==A||i!==""&&B.startsWith(i+"/");return O&&M?`![image](${B})${$}`:`[${A}](${B})${$}`}))}}return u.join("")}const Zw=/^api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function ej(s){const n=s.trim(),r=n.replace(/^\.\//,"").replace(/^\//,"");return r.startsWith("api/")?n.startsWith("/")||/\s/.test(r)||r.includes("..")?!0:!Zw.test(r):!1}function Qo(s){if(!s||!s.includes("api/"))return s;const n=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return s.replace(n,(r,i,l,u)=>ej(String(u))?"`"+(String(l||"").trim()||String(u)).replace(/`/g,"")+" (blocked link)`":r)}function nm(s){let n=0;for(let r=0;r<s.length;r++)n=n*31+s.charCodeAt(r)>>>0;return n%360}function tj(s){var u,m,d,h;const n=Array.isArray(s.to)&&s.to.length?` to=[${s.to.join(",")}]`:"",r=(m=(u=s.data)==null?void 0:u.asks)!=null&&m.length?` asks=${s.data.asks.map(x=>`${x.id}:"${x.text}"`).join("; ")}`:"",i=(h=(d=s.data)==null?void 0:d.answers)!=null&&h.length?` answers=[${s.data.answers.join(",")}]`:"",l=s.reply_to?` reply_to=${s.reply_to}`:"";return`#${s.seq} [${s.sender}] (${s.status})${n}${l}${r}${i}
111
- ${s.title?`title: ${s.title}
112
- `:""}${String(s.body||"").trim()}`}function Oh(s,n){const r=u_,l=[...s].sort((h,x)=>(h.seq||0)-(x.seq||0)).map(tj),{kept:u,report:m}=Mw(l,Lw,r),d=[`TRANSCRIPT WINDOW: ${m.replayed_messages} of ${m.total_messages} message(s), ~${m.replayed_tokens} tokens (the newest whole messages up to ${r} tokens).`];return m.dropped_messages>0&&d.push(`#TRUNCATION: the ${m.dropped_messages} oldest message(s) (~${m.dropped_tokens} tokens) were dropped by the history window (the newest whole messages up to ${r} tokens; abstractcontinuum team_model); this transcript starts mid-conversation.`),{text:`${d.join(`
113
- `)}
114
-
115
- ${u.join(`
116
-
117
- `)}`,report:m}}function Fh(s){const n=r=>`message${r===1?"":"s"}`;return s.dropped_messages<=0?`${s.replayed_messages} ${n(s.replayed_messages)}`:`${s.replayed_messages} of ${s.total_messages} ${n(s.total_messages)} (${s.dropped_messages} oldest dropped by the ${s.max_tokens.toLocaleString("en-US")}-token history window)`}function nj(s,n){let r=Number(s.up||0),i=Number(s.down||0),l=Number(s.mine||0);return n===void 0?{up:r,down:i,mine:l,caught_up:!1}:n===l?{up:r,down:i,mine:l,caught_up:!0}:(l>0?r-=1:l<0&&(i-=1),n>0?r+=1:n<0&&(i+=1),{up:Math.max(0,r),down:Math.max(0,i),mine:n,caught_up:!1})}function sj(s,n){const r=Array.from(String(s??"")),i=(n??[]).filter(m=>Array.isArray(m)&&m.length>=2&&Number.isFinite(m[0])&&Number.isFinite(m[1])&&m[0]>=0&&m[1]>0).sort((m,d)=>m[0]-d[0]),l=[];let u=0;for(const[m,d]of i){if(m>=r.length)break;const h=Math.max(m,u),x=Math.min(m+d,r.length);x<=h||(h>u&&l.push({text:r.slice(u,h).join(""),hit:!1}),l.push({text:r.slice(h,x).join(""),hit:!0}),u=x)}return u<r.length&&l.push({text:r.slice(u).join(""),hit:!1}),!l.length&&r.length&&l.push({text:r.join(""),hit:!1}),l}const jc=[{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"}],aj=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Ir(s,n){const r=s.toLowerCase().split(".").pop()||"",i=String(n||"").toLowerCase();if(r==="md"||r==="markdown"||i==="text/markdown")return"md";if(aj.has(i))return"image";const l=new Set(["txt","json","yaml","yml","csv","log","ts","tsx","js","py","sh","toml","ini","env"]);return!(i.includes("html")||i.includes("xml")||i.includes("svg"))&&(i.startsWith("text/")||l.has(r))?"text":"download"}function rj({url:s,name:n}){const[r,i]=Bt.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:s,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",n]})]}):e.jsx("img",{className:"team_fileview_img",src:s,alt:n,onError:()=>i(!0)})}function ij({view:s,onClose:n}){if(!s)return null;const r=s.url?e.jsxs("a",{className:"btn primary",href:s.url,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",s.name]}):null;return e.jsxs(tr,{open:!0,title:s.name,onClose:n,variant:"default",children:[s.meta?e.jsx("div",{className:"muted team_note",style:{marginBottom:8},children:s.meta}):null,s.loading?e.jsx("div",{className:"muted team_note",children:"Loading…"}):s.error?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("div",{className:"page_error mono",children:s.error}),r]}):s.mode==="md"?e.jsx("div",{className:"team_fileview_md",children:kw(s.text||"").map((i,l)=>i.kind==="mermaid"?e.jsx(Tw,{text:i.text},l):e.jsx(ns,{className:"md_doc",text:Qo(i.text)},l))}):s.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:s.text||""}):s.mode==="image"&&s.url?e.jsx(rj,{url:s.url,name:s.name},s.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",s.content_type?` (${s.content_type})`:"","."]}),r]})]})}const oj=Bt.memo(ns),lj=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function qh(s){let n='"';for(let r=0;r<s.length;r++){const i=s.charCodeAt(r),l=s[r];l==='"'?n+='\\"':l==="\\"?n+="\\\\":i===8?n+="\\b":i===9?n+="\\t":i===10?n+="\\n":i===12?n+="\\f":i===13?n+="\\r":i<32||i>126?n+="\\u"+i.toString(16).padStart(4,"0"):n+=l}return n+'"'}class m_{constructor(n){this.value=n}}function Bh(s){if(!Number.isFinite(s))throw new Error("py_float_repr: non-finite");if(Object.is(s,-0))return"-0.0";if(s===0)return"0.0";const n=s<0,r=Math.abs(s),l=r.toExponential().match(/^(\d)(?:\.(\d+))?e([+-]\d+)$/);if(!l)return(n?"-":"")+String(r);const u=l[1]+(l[2]||""),d=parseInt(l[3],10)+1;let h;if(d<=-4||d>16){const x=u.length>1?`${u[0]}.${u.slice(1)}`:u[0],v=d-1,g=(v<0?"-":"+")+String(Math.abs(v)).padStart(2,"0");h=`${x}e${g}`}else d<=0?h="0."+"0".repeat(-d)+u:d>=u.length?h=u+"0".repeat(d-u.length)+".0":h=u.slice(0,d)+"."+u.slice(d);return(n?"-":"")+h}function Fd(s){if(s==null)return"null";if(typeof s=="boolean")return s?"true":"false";if(s instanceof m_){if(!Number.isFinite(s.value))throw new Error("canonical_json: non-finite number");return Bh(s.value)}if(typeof s=="number"){if(!Number.isFinite(s))throw new Error("canonical_json: non-finite number");return Number.isInteger(s)&&!Object.is(s,-0)?String(s):Bh(s)}if(typeof s=="string")return qh(s);if(Array.isArray(s))return"["+s.map(Fd).join(",")+"]";if(typeof s=="object")return"{"+Object.keys(s).sort().map(r=>qh(r)+":"+Fd(s[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof s}`)}async function cj(s){return zp(s)}async function uj(s,n,r){const i={};for(const l of lj)l!=="channel"&&(i[l]=n[l]??null);return i.channel=r,typeof i.created_at=="number"&&(i.created_at=new m_(i.created_at)),await cj(s+`
118
- `+Fd(i))}async function dj(s){const n=s.channel;let r="",i=0,l=0,u=null,m="";for(const h of s.turns){if(h.hash===null||h.hash===void 0){i>0&&u===null&&(u=h.seq),l+=1,r="";continue}const x=await uj(r,h,n);x!==h.hash&&u===null&&(u=h.seq),r=h.hash,m=x,i+=1}const d=u===null&&String(s.head||"")!==m;return{ok:u===null&&!d,broken_at:u,head_mismatch:d,computed_head:m,hashed:i,legacy:l}}const mj=5e3,fj=6,ha=200,hj=50,kc=380,Uh=240,Wh=2,pj=12,Bo=8,Hh=16*1024*1024,_j=new Set(["image/png","image/jpeg","image/gif","image/webp"]),el=256*1024;function gj(){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 Vh(){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 Sc(s){return s.length<=el?s:s.slice(0,el)+`
119
-
120
- ---
121
- #TRUNCATION: preview clamped at ${Gn(el)} of ${Gn(s.length)} — download the file for the full content.`}function xd(s,n){try{return JSON.stringify(s)===JSON.stringify(n)}catch{return!1}}function bd(s,n){const r=Object.keys(s);if(r.length!==Object.keys(n).length)return!1;for(const i of r){const l=s[i],u=n[i];if(!u||l.size!==u.size)return!1;for(const m of l)if(!u.has(m))return!1}return!0}function Gn(s){if(!Number.isFinite(s)||s<0)return"—";if(s<1024)return`${s} B`;const n=s/1024;return n<1024?`${Math.round(n)} KiB`:`${(s/(1024*1024)).toFixed(1)} MiB`}const f_="abstractcontinuum_team_drafts_v1";function yj(){try{const s=window.localStorage.getItem(f_),n=s?JSON.parse(s):{};return n&&typeof n=="object"?n:{}}catch{return{}}}function Uo(s){try{window.localStorage.setItem(f_,JSON.stringify(s))}catch{}}const Nc="agora/0.4";function Wo(s){if(!s)return"";const n=Math.max(0,Math.floor(Date.now()/1e3-s));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function Ho(s){if(!s)return"";try{return new Date(s*1e3).toLocaleString()}catch{return""}}function Gh(s){return{color:`hsl(${nm(s)}, 60%, 55%)`}}function Qa(s){const n=nm(s),r=n>=40&&n<=190?36:45;return{background:`hsl(${n}, 55%, ${r}%)`,color:"#fff"}}const Ti=[{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."}],vj=[{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."}],Kh={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(Ti.map(s=>[s.id,`${s.help} Every standing vote counts.`]))};function Vo(s){const n=Ti.find(r=>r.id===s);return n?n.label:s==="general"?"General":s.charAt(0).toUpperCase()+s.slice(1)}function xj(s){if(!s)return"";try{return new Date(s*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function bj(s){var Tt,bs,an,gn,Fs,la;const n=s.gateway,r=!!s.gateway_connected,i=f.useMemo(()=>new tm,[]),l=f.useMemo(()=>{if(s.advisor)return s.advisor;if(!r||!n)return;const p=s.advisor_agent;return async(b,N)=>{const S=[...N.map(de=>({role:de.role,content:de.content})),{role:"user",content:b}],z=await n.backlog_advisor({messages:S,agent:p||null});return String((z==null?void 0:z.reply)||"").trim()||"(the model returned an empty reply)"}},[s.advisor,n,r,s.advisor_agent]),u=!!l,[m,d]=f.useState(""),[h,x]=f.useState(()=>Id()),[v,g]=f.useState(""),w=f.useRef(h);w.current=h;const L=f.useRef({});f.useEffect(()=>{if(!r||!n){d("");return}let p=!0;return(async()=>{try{const b=await Kd("abstractcontinuum_team_voice");p&&d(b)}catch{p&&d("")}})(),typeof n.capability_defaults=="function"&&Promise.resolve().then(()=>n.capability_defaults()).then(b=>{p&&(L.current=c_(b))}).catch(()=>{p&&(L.current={})}),()=>{p=!1}},[n,r]),f.useEffect(()=>{const p=()=>x(Id());return window.addEventListener(Dd,p),window.addEventListener("storage",p),()=>{window.removeEventListener(Dd,p),window.removeEventListener("storage",p)}},[]);const A=f.useMemo(()=>{const p=String(m||"").trim();if(!(!r||!n||!p))return b=>{const N=n.voice_stream_transport(p,{text:b,...L.current,...l_(w.current)});return Wy({path:N.path,body:N.body,headers:N.headers})}},[n,r,m]),$=cp({tts_stream:A,on_error:g});f.useEffect(()=>{if(!v)return;W(v);const p=setTimeout(()=>g(""),6e3);return()=>clearTimeout(p)},[v]);const[T,B]=f.useState(null),O=f.useRef(null);f.useEffect(()=>{O.current=T},[T]);const[M,P]=f.useState(""),[E,Q]=f.useState(null),[oe,G]=f.useState([]),[Ne,je]=f.useState({}),[we,ve]=f.useState({}),[H,X]=f.useState({}),[Z,U]=f.useState({}),[Y,I]=f.useState(null),[te,ae]=f.useState(""),k=f.useRef(0),C=f.useRef(!1),re=f.useRef(!1);async function he(){if(!C.current&&!(Date.now()-k.current<3e4)){k.current=Date.now();try{const p=await i.desk();I(b=>b==="loading"?b:p),p.rows.length&&!re.current&&Jn(b=>b!==""?b:(re.current=!0,"desk"))}catch(p){((p==null?void 0:p.status)===403||(p==null?void 0:p.status)===404)&&(C.current=!0)}}}async function le(){I("loading"),ae("");try{const p=await i.desk();I(p),k.current=Date.now(),C.current=!1}catch(p){I(null),ae((p==null?void 0:p.status)===403?"The desk serves operators and reporting delegates only — this console's seat is neither.":(p==null?void 0:p.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((p==null?void 0:p.message)||p||"network error").slice(0,120)}) — transient; Refresh retries.`)}}const[D,be]=f.useState(""),[$e,Oe]=f.useState("channels"),[Re,rt]=f.useState(!1),[qe,it]=f.useState([]),[Ge,ct]=f.useState("all"),et=f.useRef(null),[fe,ce]=f.useState(null),Ee=f.useRef(""),[se,W]=f.useState(""),[ie,Ce]=f.useState(!1),[Je,F]=f.useState({}),[ue,ye]=f.useState({}),[xe,ke]=f.useState({}),J=f.useRef(new Set),R=f.useRef(0),[ee,Pe]=f.useState(""),[Fe,Xe]=f.useState(""),[ut,mt]=f.useState([]),[Le,nt]=f.useState(!1),ht=f.useRef(null),[Pt,wt]=f.useState(!1),tn=f.useRef(null);f.useEffect(()=>{const p=tn.current;p&&(p.style.height="auto",p.style.height=`${Math.min(p.scrollHeight+2,160)}px`)},[ee,D]);const[ge,Te]=f.useState("fyi"),[Ye,yt]=f.useState(""),[_t,jt]=f.useState(""),[ot,$n]=f.useState(null),[$s,nr]=f.useState({}),[Es,ls]=f.useState(""),nn=f.useRef(yj()),Gs=f.useRef(""),[Ks,Ts]=f.useState(!1),[Pi,As]=f.useState(!1),[Ur,ft]=f.useState(""),[Ht,sr]=f.useState(null),[Rt,ar]=f.useState(null),[zi,ll]=f.useState({});function Ii(p,b){b.length&&ll(N=>{const S={...N},z=new Set(S[p]||[]);for(const de of b)z.add(de);return S[p]=z,S})}function It(p,b){const N=new Set(b.map(S=>String(S.agent_id||"")).filter(Boolean));N.size&&ll(S=>{const z=S[p];if(!z||![...z].some(Se=>N.has(Se)))return S;const de=new Set([...z].filter(Se=>!N.has(Se))),V={...S};return de.size?V[p]=de:delete V[p],V})}const Wr=f.useRef(0),[Hr,rr]=f.useState(""),[Js,cl]=f.useState(null),[Vr,cs]=f.useState(""),[hn,Gr]=f.useState(!1),[pn,ul]=f.useState(""),[ga,dl]=f.useState([]);function ya(){i.delegations().then(p=>{cl(p),cs("")}).catch(p=>{cl([]);const b=String((p==null?void 0:p.message)||p);cs((p==null?void 0:p.status)===404||/allowlist/i.test(b)?"Delegation needs the updated console/hub — restart the stack to pick it up.":b)})}async function Kr(){if(!(!pn||!ga.length||hn)){Gr(!0),cs("");try{await i.set_delegation(pn,ga),ul(""),dl([]),ya()}catch(p){cs(String((p==null?void 0:p.message)||p||"delegation failed"))}finally{Gr(!1)}}}async function ir(p){if(!hn){Gr(!0),cs("");try{await i.revoke_delegation(p),ya()}catch(b){cs(String((b==null?void 0:b.message)||b||"resign failed"))}finally{Gr(!1)}}}const[bn,Qs]=f.useState(null),[Jr,Ls]=f.useState(null),[Vt,Xt]=f.useState(""),[Ms,va]=f.useState(null),[Rs,kt]=f.useState([]),[Gt,us]=f.useState(""),[Qr,zn]=f.useState(""),[Yr,Di]=f.useState(""),[or,lr]=f.useState(!1),[ds,Kn]=f.useState(""),[En,Ps]=f.useState({open:!1,name:"",is_private:!1}),[cn,_n]=f.useState(!1),[Pc,xa]=f.useState({}),[Et,Jn]=f.useState(""),[In,ba]=f.useState(null),[Xr,ml]=f.useState(""),[wn,wa]=f.useState("channel"),[ms,cr]=f.useState(""),[Oi,ur]=f.useState(null),[Zr,dr]=f.useState(""),[mr,Fi]=f.useState(""),[Dn,fs]=f.useState(""),[Ys,ei]=f.useState(null),[ja,ka]=f.useState(""),[Xs,sn]=f.useState(""),[Sa,Kt]=f.useState(null),[zs,qi]=f.useState([]),[ti,fr]=f.useState(""),[Zs,Na]=f.useState(!1),[Bi,Ui]=f.useState(""),[fl,hl]=f.useState(""),ni=f.useRef(null),pl=f.useRef(0),Wi=f.useRef(!1),_l=f.useRef(0),[Hi,Vi]=f.useState(!1),Gi=f.useRef(""),On=f.useRef([]),Is=f.useRef([]),Ds=f.useRef(null),Ki=f.useRef(!1),hr=f.useRef(null);Gi.current=D,On.current=oe,Is.current=qe,f.useEffect(()=>{for(const p of qe){const b=_r.current[p.id];b!==void 0&&p.ratings&&Number(p.ratings.mine||0)===b&&delete _r.current[p.id]}},[qe]);const Ji=f.useRef(!1);async function zc(p){var b;try{const N=await i.inbox(),S=Iw(N),z=Dw(N);ve(Ve=>bd(Ve,z)?Ve:z);const de=Ow(N,((b=O.current)==null?void 0:b.seat)||"");X(Ve=>bd(Ve,de)?Ve:de);const V=Fw(N);U(Ve=>bd(Ve,V)?Ve:V),he();const Se=p.slice(0,pj),Ie=await Promise.allSettled(Se.map(Ve=>i.digest(Ve.name))),Be={};for(const Ve of p)Be[Ve.name]={unread:S[Ve.name]||0,open_questions:0};Ie.forEach((Ve,$t)=>{var jn;const zt=Se[$t].name;if(Ve.status==="fulfilled"){const xt=(jn=Ve.value)==null?void 0:jn.counts;Be[zt]={...Be[zt],open_questions:Number((xt==null?void 0:xt.open_questions)||0)}}}),je(Ve=>xd(Ve,Be)?Ve:Be)}catch{}}async function Ca(p){if(Ki.current){hr.current=p;return}Ki.current=!0;let b=p;try{for(;b;)hr.current=null,await zc(b),b=hr.current}finally{Ki.current=!1}}async function $a(){const b=[...await i.channels()];return b.sort((N,S)=>(S.last_at||0)-(N.last_at||0)),G(N=>xd(N,b)?N:b),On.current=b,b}async function hs(){try{const[p,b]=await Promise.all([i.meta(),i.channels()]);B({seat:p.seat,seat_key_present:p.seat_key_present}),P(String(p.hub_url||"")),i.healthz().then(z=>Q(z)).catch(()=>Q(null)),i.presence().then(z=>{const de=[...new Set(z.map(V=>String(V.agent_id||"")).filter(V=>V&&V!==p.seat))].sort();kt(de)}).catch(()=>kt([]));const N=[...b];N.sort((z,de)=>(de.last_at||0)-(z.last_at||0)),G(N);const S=N.filter(z=>!z.name.startsWith("dm:"));!D&&S.length&&be(S[0].name),W(""),Ca(N)}catch(p){W(String((p==null?void 0:p.message)||p||"Hub unreachable"))}}async function ea(p,b){var S,z,de;if(!p)return;const N=R.current;b!=null&&b.background||Ce(!0);try{const V=Is.current.length&&Is.current[Is.current.length-1].seq||0,Se=((S=On.current.find(lt=>lt.name===p))==null?void 0:S.last_seq)||0;let Ie=Se,Be=null;if(!(b!=null&&b.background))if(Se>0)Be=$a().catch(()=>null);else try{const lt=await $a();if(N!==R.current)return;Ie=((z=lt.find(Lt=>Lt.name===p))==null?void 0:z.last_seq)||0}catch{}const Ve=Math.max(0,Ie-ha),$t=b!=null&&b.background&&V>0?Math.max(0,V-hj):Ve,zt=await i.messages(p,{since:$t,limit:ha});if(N!==R.current)return;const jn=new Set(Is.current.map(lt=>lt.id)),xt=zt.some(lt=>!jn.has(lt.id));if(b!=null&&b.background&&!xt&&V>0){const lt=Date.now();if(lt-_l.current>1e4){_l.current=lt;try{const Lt=await $a();if(N!==R.current)return;const gt=((de=Lt.find(We=>We.name===p))==null?void 0:de.last_seq)||0;if(gt>0&&gt<V){const We=Math.max(0,gt-ha),St=await i.messages(p,{since:We,limit:ha});if(N!==R.current)return;St.sort((Ot,Ut)=>(Ot.seq||0)-(Ut.seq||0)),it(St),W("");return}}catch{}}}zt.sort((lt,Lt)=>(lt.seq||0)-(Lt.seq||0)),it(lt=>{if(b!=null&&b.background&&lt.length){if(!zt.length)return lt;const Lt=new Set(lt.map(Zt=>Zt.id)),gt=zt.filter(Zt=>!Lt.has(Zt.id)),We=new Map(zt.map(Zt=>[Zt.id,Zt]));let St=0;const Ot=lt.map(Zt=>{const Mt=We.get(Zt.id);if(!Mt)return Zt;const Qt=JSON.stringify(Mt.ratings??null)!==JSON.stringify(Zt.ratings??null)||(Mt.has_resolved_reply??null)!==(Zt.has_resolved_reply??null)||JSON.stringify(Mt.pending_asks??null)!==JSON.stringify(Zt.pending_asks??null)||!!Mt.retracted!=!!Zt.retracted;return Qt&&St++,Qt?Mt:Zt});if(!gt.length&&!St)return lt;const Ut=[...St?Ot:lt,...gt];return Ut.length>ha*2?Ut.slice(Ut.length-ha*2):Ut}return zt}),W(""),!(b!=null&&b.background)&&Be&&(async()=>{var lt;try{const Lt=await Be;if(N!==R.current||!Lt)return;const gt=((lt=Lt.find(We=>We.name===p))==null?void 0:lt.last_seq)||0;if(gt>0&&gt!==Se){const We=Math.max(0,gt-ha),St=await i.messages(p,{since:We,limit:ha});if(N!==R.current)return;St.sort((Ot,Ut)=>(Ot.seq||0)-(Ut.seq||0)),it(Ot=>xd(Ot,St)?Ot:St)}}catch{}})()}catch(V){if(N!==R.current)return;W(String((V==null?void 0:V.message)||V||"Failed to load messages"))}finally{!(b!=null&&b.background)&&N===R.current&&Ce(!1)}}f.useEffect(()=>{hs()},[]),f.useEffect(()=>{let p=null,b=!1,N=0,S=0;const z=()=>{if(!b){try{p=new WebSocket(i.ws_url())}catch{Vi(!1),N+=1,setTimeout(z,Math.min(15e3,1e3*Math.max(1,N)));return}p.onopen=()=>{Vi(!0),S=Date.now(),(!On.current.length||!O.current)&&hs()},p.onmessage=de=>{var V;try{const Se=JSON.parse(String(de.data||"{}"));if((Se==null?void 0:Se.type)!=="envelope")return;const Ie=String(((V=Se.envelope)==null?void 0:V.channel)||"");Ie&&Ie===Gi.current&&ea(Ie,{background:!0}),Ie&&!On.current.some(Be=>Be.name===Ie)&&$a(),Ds.current&&clearTimeout(Ds.current),Ds.current=setTimeout(()=>void Ca(On.current),800)}catch{}},p.onclose=()=>{Vi(!1),b||(S&&Date.now()-S>=15e3?N=0:N+=1,S=0,setTimeout(z,Math.min(15e3,1e3*Math.max(1,N))))},p.onerror=()=>{try{p==null||p.close()}catch{}}}};return z(),()=>{b=!0,Ds.current&&clearTimeout(Ds.current);try{p==null||p.close()}catch{}}},[]),f.useEffect(()=>{R.current+=1,F({}),ye({}),ke({}),J.current=new Set,sr(null),ar(null);try{$.stop_tts()}catch{}Wr.current=0,_r.current={},Ct("recency"),La(null),jr(""),ei(null),ka(""),sn(""),Kt(null),Qs(null),Ls(null),va(null),Xt(""),zn(""),xa({}),qi([]),Ui(""),hl(""),Na(!1),fr(""),it([]),ct(et.current||"all"),et.current=null,$n(null),nr({}),ls(""),mt([]),Gs.current&&Gs.current!==D&&(ee||Fe?nn.current[Gs.current]={text:ee,title:Fe,kind:ge}:delete nn.current[Gs.current],Uo(nn.current));const p=nn.current[D];if(Pe((p==null?void 0:p.text)||""),Xe((p==null?void 0:p.title)||""),Te((p==null?void 0:p.kind)||"fyi"),Gs.current=D,Ji.current=!0,ea(D),!D)return;Et==="files"&&to(),Et==="members"&&pr();const b=setInterval(()=>{pl.current+=1,Wi.current||(Wi.current=!0,ea(D,{background:!0}).finally(()=>{Wi.current=!1})),pl.current%fj===0&&($a().then(N=>Ca(N)).catch(()=>Ca(On.current)),i.healthz().then(Q).catch(()=>{}),i.meta().then(N=>B(N)).catch(()=>{}))},mj);return()=>clearInterval(b)},[D]);const gl=f.useRef({text:"",title:"",kind:"fyi",selected:""});gl.current={text:ee,title:Fe,kind:ge,selected:D},f.useEffect(()=>{if(!D)return;const p=setTimeout(()=>{ee||Fe?nn.current[D]={text:ee,title:Fe,kind:ge}:delete nn.current[D],Uo(nn.current)},300);return()=>clearTimeout(p)},[ee,Fe,ge,D]),f.useEffect(()=>{const p=()=>{const b=gl.current;b.selected&&(b.text||b.title?nn.current[b.selected]={text:b.text,title:b.title,kind:b.kind}:delete nn.current[b.selected],Uo(nn.current))};return window.addEventListener("pagehide",p),window.addEventListener("beforeunload",p),()=>{window.removeEventListener("pagehide",p),window.removeEventListener("beforeunload",p),p()}},[]),f.useEffect(()=>{const p=ni.current;if(!p||!qe.length)return;if(Ji.current){Ji.current=!1,p.scrollTop=p.scrollHeight;return}p.scrollHeight-p.scrollTop-p.clientHeight<240&&(p.scrollTop=p.scrollHeight)},[qe]),f.useEffect(()=>{if(Ge!=="unread"||!D){ce(null);return}const p=we[D];ce(new Set(p||[])),Ee.current=""},[Ge,D]),f.useEffect(()=>{if(Ge!=="unread"||!D||!fe||!fe.size)return;const p=Math.min(...fe),b=qe.length&&qe[0].seq||0;if(!p||!b||b<=p)return;const N=`${D}:${p}`;if(Ee.current===N)return;Ee.current=N;const S=R.current;i.messages(D,{since:Math.max(0,p-1),limit:ha}).then(z=>{S!==R.current||!z.length||it(de=>{const V=new Set(de.map(Ie=>Ie.id)),Se=z.filter(Ie=>!V.has(Ie.id));return Se.length?[...de,...Se].sort((Ie,Be)=>(Ie.seq||0)-(Be.seq||0)):de})}).catch(()=>{S===R.current&&(ft("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ft(""),6e3))})},[Ge,D,fe,qe]);function yl(p){J.current.has(p.id)||(J.current.add(p.id),i.read_message(p.channel,p.id).catch(()=>{}),i.ack(p.channel,p.seq).catch(()=>{}),ve(b=>{const N=b[p.channel];if(!N||!N.has(p.seq))return b;const S=new Set(N);return S.delete(p.seq),{...b,[p.channel]:S}}),Ds.current&&clearTimeout(Ds.current),Ds.current=setTimeout(()=>void Ca(On.current),500),p.critical&&(ft(`Read recorded for critical #${p.seq}.`),setTimeout(()=>ft(""),2500)))}function vl(p){const b=!Je[p.id];F(N=>({...N,[p.id]:b})),b&&yl(p)}function Ic(p){const b=window.getSelection();if(b&&!b.isCollapsed)return;const N=String(p.body||""),S=p.status==="reply"?Uh:kc;N.length>S?vl(p):yl(p)}async function Dc(){if(!D||Ht==="running")return;const p=R.current;sr("running");try{const b=await i.ledger(D),N=await dj(b);if(p!==R.current)return;sr(N)}catch(b){if(p!==R.current)return;sr({error:String((b==null?void 0:b.message)||b||"verification failed")})}}function pr(){{const p=R.current;ar("loading"),Qs(null),rr(""),Ls(null),i.channel_info(D).then(b=>{p===R.current&&ar(b)}).catch(b=>{p===R.current&&ar({error:String((b==null?void 0:b.message)||b||"info failed")})}),i.members(D).then(b=>{p===R.current&&(Qs(b),rr(""),It(D,b))}).catch(b=>{p===R.current&&(Qs([]),rr(String((b==null?void 0:b.message)||b||"members unavailable")))}),i.list_blocks().then(b=>{p===R.current&&Ls(b)}).catch(()=>{p===R.current&&Ls([])}),i.retired_agents().then(b=>{p===R.current&&va(b)}).catch(()=>{p===R.current&&va([])})}}function ss(p){const b=Et===p?"":p;if(Jn(b),b==="files"&&to(),b==="members"){let N=0;for(const S of Is.current)String(S.sender||"")==="hub"&&(S.seq||0)>N&&(N=S.seq||0);Wr.current=N,pr(),ya()}b==="leaderboard"&&Qi(wn),b==="desk"&&le()}function Qi(p){const b=R.current;ba(null),ml(""),cr(""),ur(null),fs(""),(p==="hub"?i.reputation_hub():i.reputation(D)).then(S=>{b===R.current&&ba(S)}).catch(S=>{if(b!==R.current)return;const z=Number((S==null?void 0:S.status)||0);ml(z===404||z===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((S==null?void 0:S.message)||S||"failed to load leaderboard"))})}function Yi(p){const b=ms===p?"":p;if(cr(b),ur(null),fs(""),!b||wn==="hub")return;const N=R.current;i.reputation_votes(D,b).then(S=>{N===R.current&&ur(S)}).catch(S=>{N===R.current&&(ur(null),fs(`votes list failed: ${String((S==null?void 0:S.message)||S||"fetch failed")}`))})}const[si,Xi]=f.useState(""),[ta,ai]=f.useState("");f.useEffect(()=>{if(!ta)return;const p=setTimeout(()=>ai(""),6e3);return()=>clearTimeout(p)},[ta]);async function Ea(p){if(ta!==p.id){ai(p.id);return}ai("");try{const b=Array.isArray(p.pending_asks)?p.pending_asks.filter(Boolean):[];await i.post_message(p.channel,{body:`Declined on the record by ${(T==null?void 0:T.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:p.id,to:p.sender?[p.sender]:void 0,...b.length?{answers:b}:{}}),X(N=>{const S=N[p.channel];if(!(S!=null&&S.has(p.seq)))return N;const z=new Set(S);return z.delete(p.seq),{...N,[p.channel]:z}})}catch(b){W(String((b==null?void 0:b.message)||b||"decline failed"))}}const _r=f.useRef({});function Zi(p){const b=p.ratings;return b?nj(b,_r.current[p.id]):null}async function xl(p,b){var z,de;const N=(T==null?void 0:T.seat)||"";if(!p||!N||si)return;const S=Is.current.find(V=>V.id===p)||((z=Ma.current)==null?void 0:z.find(V=>V.id===p));if(S){Xi(`${p}:${b}`),fs("");try{const V=((de=Zi(S))==null?void 0:de.mine)??0;V===b?await i.unrate_message(D,p):await i.rate_message(D,p,b),_r.current[p]=V===b?0:b}catch(V){fs(String((V==null?void 0:V.message)||V||"rating failed"))}finally{Xi("")}}}async function eo(p,b,N){if(!mr){Fi(`${p}:${b}:${N}`),fs("");try{await i.rate(D,p,b,N,Zr.trim()),dr("");const S=R.current,[z,de]=await Promise.all([i.reputation(D),i.reputation_votes(D,p)]);S===R.current&&(ba(z),ur(de))}catch(S){fs(String((S==null?void 0:S.message)||S||"vote failed"))}finally{Fi("")}}}function to(){const p=R.current;ei(null),ka(""),sn(""),i.fs_list(D).then(b=>{p===R.current&&ei(b)}).catch(b=>{p===R.current&&ka(String((b==null?void 0:b.message)||b||"failed to list files"))})}async function gr(p){const b=R.current,N=Ir(p.path,"text/markdown"),S=`${p.updated_by||"?"} · ${Ho(p.updated_at)} · v${p.version}`;Kt({name:p.path,mode:N==="image"?"text":N,meta:S,loading:!0});try{const z=await i.fs_read(D,p.path);if(b!==R.current)return;const de=Ir(p.path,z.mime);Kt({name:p.path,mode:de==="image"?"text":de,text:Sc(z.content),content_type:z.mime,meta:S,loading:!1})}catch(z){if(b!==R.current)return;Kt({name:p.path,mode:"text",meta:S,error:String((z==null?void 0:z.message)||z||"failed to read file")})}}const Qn=f.useRef(null);function yr(){const p=Qn.current,b=Is.current;if(!p||!b.length)return;if(p.message_id?b.some(S=>S.id===p.message_id):!1){Qn.current=null,requestAnimationFrame(()=>{const S=document.getElementById(`hubmsg-${p.message_id}`);S==null||S.scrollIntoView({block:"center"}),S==null||S.classList.add("hit"),setTimeout(()=>S==null?void 0:S.classList.remove("hit"),2500)});return}if(p.seq&&Number.isFinite(p.seq)){const S=R.current,z=p.seq;Qn.current={...p,seq:void 0},i.messages(D,{since:Math.max(0,z-3),limit:10}).then(de=>{S!==R.current||!de.length||it(V=>{const Se=new Set(V.map(Be=>Be.id)),Ie=de.filter(Be=>!Se.has(Be.id));return Ie.length?[...V,...Ie].sort((Be,Ve)=>(Be.seq||0)-(Ve.seq||0)):V})}).catch(()=>{})}}f.useEffect(()=>{var S;if(!s.focus)return;const{channel:p,message_id:b,seq:N}=s.focus;(S=s.on_focus_consumed)==null||S.call(s),p&&(Qn.current={message_id:b,seq:N},Oe("thread"),p===D?yr():be(p))},[s.focus]),f.useEffect(()=>{yr()},[qe]),f.useEffect(()=>{if(Et!=="members"||!D)return;let p=0,b="";for(const S of qe){if(S.channel&&S.channel!==D||String(S.sender||"")!=="hub")continue;const z=`${String(S.title||"")} ${String(S.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(z)&&(S.seq||0)>p&&(p=S.seq||0,b=z)}if(!p||p<=Wr.current)return;const N=R.current;i.members(D).then(S=>{N===R.current&&(Wr.current=p,Qs(S),rr(""),It(D,S))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(b)&&i.list_blocks(D).then(S=>{N===R.current&&Ls(S)}).catch(()=>{})},[qe,Et,D]);const[ri,ii]=f.useState(null),oi=f.useRef(0);f.useEffect(()=>{if(ii(null),oi.current=0,!D)return;const p=R.current;i.fs_list(D).then(b=>{p===R.current&&ii(new Set(b.map(N=>String(N.path||"")).filter(Boolean)))}).catch(()=>{p===R.current&&ii(null)})},[D]),f.useEffect(()=>{const p=qe.reduce((N,S)=>{if(S.channel&&S.channel!==D)return N;const z=String(S.title||"");return(z.startsWith("fs:put")||z.startsWith("fs:delete"))&&(S.seq||0)>N?S.seq||0:N},0);if(!p||p<=oi.current)return;const b=R.current;i.fs_list(D).then(N=>{b===R.current&&(oi.current=p,ii(new Set(N.map(S=>String(S.path||"")).filter(Boolean))))}).catch(()=>{})},[qe,D]);async function no(p){const b=R.current,N=Ir(p,"text/markdown");Kt({name:p,mode:N==="image"?"text":N,loading:!0});try{const S=await i.fs_read(D,p);if(b!==R.current)return;const z=Ir(p,S.mime),de=S.updated_by?`${S.updated_by} · ${Ho(S.updated_at)} · v${S.version??"?"}`:void 0;Kt({name:p,mode:z==="image"?"text":z,text:Sc(S.content),content_type:S.mime,meta:de,loading:!1})}catch(S){if(b!==R.current)return;Kt({name:p,mode:"text",error:String((S==null?void 0:S.message)||S||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function Ta(p,b){const N=R.current,S=i.attachment_url(p,b.id),z=Ir(b.filename,b.content_type);if(z==="image"){Kt({name:b.filename,mode:"image",url:S,content_type:b.content_type,size:b.size});return}if(z==="md"||z==="text"){if(b.size>el){Kt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size,error:`too large to preview inline (${Gn(b.size)} > ${Gn(el)}) — download to view`});return}Kt({name:b.filename,mode:z,url:S,content_type:b.content_type,size:b.size,loading:!0});try{const de=await fetch(S);if(!de.ok)throw new Error(`fetch failed (${de.status})`);const V=await de.text();if(N!==R.current)return;Kt({name:b.filename,mode:z,url:S,content_type:b.content_type,size:b.size,text:Sc(V)})}catch(de){if(N!==R.current)return;Kt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size,error:String((de==null?void 0:de.message)||de||"failed to load")})}return}Kt({name:b.filename,mode:"download",url:S,content_type:b.content_type,size:b.size})}async function vr(p,b,N="channel"){if(!Gt){us(`${N}:${b}:${p}`),zn("");try{N==="hub"?b==="unblock"?await i.hub_unblock(p):await i.hub_block(p,b==="kick"?{seconds:3600,reason:"hub kick (Continuum Team page)"}:{reason:"hub ban (Continuum Team page)"}):b==="unblock"?await i.unblock(D,p):await i.block(D,p,b==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ft(`${N==="hub"?"hub ":""}${b} → ${p} applied.`),setTimeout(()=>ft(""),3e3);const S=R.current,z=await i.members(D).catch(()=>null);z&&S===R.current&&Qs(z);const de=await i.list_blocks().catch(()=>null);de&&S===R.current&&Ls(de)}catch(S){zn(String((S==null?void 0:S.message)||S||"moderation refused"))}finally{us("")}}}async function bl(p){if(!Gt){us(`retire:${p}`),zn("");try{await i.retire_agent(p,"decommissioned via Continuum Team page"),Xt(""),ft(`${p} retired (decommissioned — not banned).`),setTimeout(()=>ft(""),3500);const b=R.current,N=await i.members(D).catch(()=>null);N&&b===R.current&&Qs(N);const S=await i.retired_agents().catch(()=>null);S&&b===R.current&&va(S)}catch(b){const N=b==null?void 0:b.status,S=String((b==null?void 0:b.message)||b||"");N===404||/not found|hub_route_not_allowed/i.test(S)?(ft("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ft(""),6e3)):zn(S||"retire refused")}finally{us("")}}}async function wl(p){if(!Gt){us(`unretire:${p}`),zn("");try{await i.unretire_agent(p),Xt(""),ft(`${p} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ft(""),3500);const b=await i.retired_agents().catch(()=>null);b&&va(b)}catch(b){zn(String((b==null?void 0:b.message)||b||"un-retire refused"))}finally{us("")}}}async function Oc(p){if(!Gt){us(`delete:${p}`),zn("");try{await i.delete_agent(p),Xt(""),ft(`${p} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ft(""),3500);const b=await i.retired_agents().catch(()=>null);b&&va(b)}catch(b){const N=String((b==null?void 0:b.message)||b);zn((b==null?void 0:b.status)===404||/not found|allowlist/i.test(N)?"Delete needs the updated hub/console (0.12.41+) — restart the stack to pick it up.":/409|active/i.test(N)?`${p} is still active — retire it first, then delete.`:N||"delete refused")}finally{us("")}}}async function jl(p){if(!cn){_n(!0),zn("");try{let b={state:p},N;try{const S=await i.channel_meta(D);S&&typeof S.value=="object"&&S.value&&(b={...S.value,state:p}),typeof(S==null?void 0:S.version)=="number"&&(N=S.version)}catch{}await i.put_channel_meta(D,b,N),ft(p==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ft(""),3500),pr(),hs()}catch(b){zn(String((b==null?void 0:b.message)||b||"channel state change refused"))}finally{_n(!1)}}}const[Fc,kl]=f.useState("");async function qc(p){if(!cn){_n(!0),W("");try{await i.leave(p),kl(""),D===p&&be(""),await hs(),ft("Direct message removed from your list."),setTimeout(()=>ft(""),3e3)}catch(b){W(String((b==null?void 0:b.message)||b||"leave refused"))}finally{_n(!1)}}}const[Yn,na]=f.useState("");async function Sl(p){if(!cn){_n(!0),W("");try{await i.archive(p),na(""),D===p&&be(""),await hs(),ft(`Channel #${p} archived (history preserved).`),setTimeout(()=>ft(""),3500)}catch(b){const N=String((b==null?void 0:b.message)||b||"");(b==null?void 0:b.status)===404||/not found|hub_route_not_allowed/i.test(N)?(na(""),ft("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ft(""),6e3)):W(N||"archive refused")}finally{_n(!1)}}}async function so(){const p=En.name.trim();if(!(!p||cn)){_n(!0),W("");try{await i.create_channel(p,En.is_private),Ps({open:!1,name:"",is_private:!1}),await hs(),be(p),ft(`Channel #${p} created.`),setTimeout(()=>ft(""),3e3)}catch(b){W(String((b==null?void 0:b.message)||b||"channel create refused"))}finally{_n(!1)}}}async function ao(p,b){if(!l)throw new Error("AI advisor is not available");return l(p,b)}async function Nl(p){if(!u)return;const b=p.root.id,N=R.current,S=p.replies.length+1;xa(z=>{var de;return{...z,[b]:{busy:!0,text:((de=z[b])==null?void 0:de.text)||"",error:"",count:S}}});try{const z=Oh([p.root,...p.replies]),de=`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.
122
-
123
- THREAD TRANSCRIPT:
124
- ${z.text}`,V=await ao(de,[]);if(N!==R.current)return;const Se=Fh(z.report);xa(Ie=>({...Ie,[b]:{busy:!1,text:V,error:"",count:S,window:Se}}))}catch(z){if(N!==R.current)return;xa(de=>({...de,[b]:{busy:!1,text:"",error:String((z==null?void 0:z.message)||z||"summary failed"),count:S}}))}}async function li(p){const b=p.trim();if(!b||Zs||!u)return;const N=R.current;Jn("assistant"),Na(!0),Ui(""),qi(S=>[...S,{role:"user",content:b}]);try{const S=Oh(qe);hl(Fh(S.report));const z=`You are the operator's analyst for the agora hub channel #${D}. 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.
125
-
126
- CHANNEL TRANSCRIPT (window):
127
- ${S.text}
128
-
129
- QUESTION: ${b}`,de=await ao(z,zs);if(N!==R.current)return;qi(V=>[...V,{role:"assistant",content:de}])}catch(S){if(N!==R.current)return;Ui(String((S==null?void 0:S.message)||S||"assistant failed"))}finally{N===R.current&&Na(!1)}}const[ci,Cl]=f.useState(""),[ps,ui]=f.useState("");async function xr(p){if(!Ks){Ts(!0),W("");try{await i.retract_message(D,p.id),ui(""),ft(`#${p.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ft(""),4e3),await ea(D,{background:!0})}catch(b){const N=String((b==null?void 0:b.message)||b||"retract failed");W(/404|not found/i.test(N)?"Retraction ships with the hub's next bounce (0.12.16) — the running hub predates the verb. Nothing was changed.":N)}finally{Ts(!1)}}}async function ro(p){if(!Ks){Ts(!0),W("");try{const b=Rh(D,vt);await i.post_message(D,{body:"Resolved.",status:"resolved",to:b?[b]:void 0,reply_to:p.id}),Cl(""),ft(`Marked #${p.seq} resolved.`),setTimeout(()=>ft(""),3e3),await ea(D,{background:!0})}catch(b){W(String((b==null?void 0:b.message)||b||"Resolve failed"))}finally{Ts(!1)}}}async function io(p){if(!p||!p.length||Le)return;const b=Array.from(p);if(ut.length+b.length>Bo){W(`At most ${Bo} attachments per message.`);return}const N=b.find(V=>V.size>Hh);if(N){W(`"${N.name}" is ${Gn(N.size)} — the limit is ${Gn(Hh)}.`);return}const S=R.current,z=D;nt(!0),W("");let de=0;try{for(const V of b){const Se=await i.upload_attachment(z,V);if(S!==R.current||D!==z)return;mt(Ie=>[...Ie,Se]),de+=1}}catch(V){const Se=V==null?void 0:V.status,Ie=String((V==null?void 0:V.message)||V||"");if(Se===404||/not found|hub_route_not_allowed/i.test(Ie))ft("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ft(""),6e3);else{const Be=b.length>1?` (${de} of ${b.length} attached before this)`:"";W(`${Ie||"attachment upload failed"}${Be}`)}}finally{nt(!1),ht.current&&(ht.current.value="")}}function di(p){var N;$n(p);const b=((N=p.data)==null?void 0:N.asks)||[];nr(b.length===1?{[b[0].id]:!0}:{}),ls(""),Te("fyi")}function sa(){$n(null),nr({}),ls("")}async function oo(p){const{title:b,members:N}=gd(p);if(!N.length){W("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const S=b||`focused work with ${N.join(", ")}`;await co({title:S,members:N})}async function lo(p,b,N){const S=[],z=[];for(const de of N)try{const V=await fetch(i.attachment_url(p,de.id));if(!V.ok)throw new Error(`fetch ${V.status}`);const Se=await V.blob(),Ie=new File([Se],de.filename||"attachment",{type:de.content_type||Se.type||"application/octet-stream"}),Be=await i.upload_attachment(b,Ie);S.push({id:Be.id,filename:Be.filename||de.filename})}catch(V){z.push(`${de.filename||de.id.slice(0,8)} (${String((V==null?void 0:V.message)||V)})`)}return{migrated:S,att_failed:z}}async function br(p,b,N){try{const S=await i.create_invite(p,b);return await i.send_dm(b,{title:`invite to ${p}${N?`: ${N}`:""}`.slice(0,120),body:`You are invited to '${p}'${N?` — ${N}`:""}. Join with join_channel(channel='${p}', invite_token='${S}'), read the recent messages, and work the topic THERE.`}),null}catch(S){return String((S==null?void 0:S.message)||S)}}async function $l(p){var b,N;if(!(!D||!p)){lr(!0),Kn("");try{const S=Rt&&typeof Rt=="object"&&"meta"in Rt?String(((b=Rt.meta)==null?void 0:b.purpose)||""):"",z=!!((N=On.current.find(V=>V.name===D))!=null&&N.private);let de=null;if(z)de=await br(D,p,S||void 0);else try{await i.send_dm(p,{title:`join ${D}${S?`: ${S}`:""}`.slice(0,120),body:`You are invited to '${D}' (public)${S?` — ${S}`:""}. Join with join_channel(channel='${D}'), read the recent messages, and work the topic THERE.`})}catch(V){de=String((V==null?void 0:V.message)||V)}de?Kn(de.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${de}`):(Kn(`Invited @${p} — join pointer DM'd.`),Di(""),Ii(D,[p]))}finally{lr(!1),setTimeout(()=>Kn(""),8e3)}}}async function El(p,b){var N;try{const S=gd(b).members;if(!S.length)return;const z=await i.members(p),de=new Set(z.map(Ve=>String(Ve.agent_id||""))),V=S.filter(Ve=>!de.has(Ve)&&Rs.includes(Ve)&&Ve!==vt);if(!V.length)return;const Se=!!((N=On.current.find(Ve=>Ve.name===p))!=null&&N.private),Ie=[],Be=[];for(const Ve of V)if(Se){const $t=await br(p,Ve);$t?Be.push(`${Ve} (${$t})`):Ie.push(Ve)}else try{await i.send_dm(Ve,{title:`you were mentioned in #${p}`.slice(0,120),body:`You were mentioned in #${p} (public). Join with join_channel(channel='${p}') and read the recent messages.`}),Ie.push(Ve)}catch($t){Be.push(`${Ve} (${String(($t==null?void 0:$t.message)||$t)})`)}Ie.length&&(Ii(p,Ie),ft(`Posted — @${Ie.join(", @")} ${Se?"invited":"nudged"} (mentioned, not yet member${Ie.length===1?"":"s"}).`)),Be.length&&W(Be.some(Ve=>Ve.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 co(p){var de,V;const{title:b,members:N}=p,S=[...ut],z=D;Ts(!0),W("");try{const Se=new Set(On.current.map(xt=>xt.name)),Ie=vd(b,Se);let Be=[],Ve=[],$t=!1;try{const xt=await i.create_group({name:Ie,members:N,purpose:b,opening_post:((de=p.opening_body)==null?void 0:de.trim())||b,private:!0});$t=!0,Be=Array.isArray(xt==null?void 0:xt.invited)?xt.invited.map(String):N,Ve=Array.isArray(xt==null?void 0:xt.failed)?xt.failed.map(lt=>typeof lt=="string"?lt:`${(lt==null?void 0:lt.agent)||(lt==null?void 0:lt.member)||(lt==null?void 0:lt.peer)||"?"} (${String((lt==null?void 0:lt.error)||(lt==null?void 0:lt.detail)||"failed")})`):[]}catch(xt){const lt=String((xt==null?void 0:xt.message)||xt||"");if(!((xt==null?void 0:xt.status)===404||lt.includes("outside the Team page allowlist")||lt.includes("Not Found")))throw xt;try{await i.create_invite("__group-preflight__",N[0])}catch(gt){if(String((gt==null?void 0:gt.message)||gt).includes("outside the Team page allowlist")){W("/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 i.create_channel(Ie,!0),await i.put_channel_meta(Ie,{purpose:b},0);for(const gt of N)try{const We=await i.create_invite(Ie,gt);await i.send_dm(gt,{title:`invite to ${Ie}: ${b}`.slice(0,120),body:`You are invited to '${Ie}' — focused room: ${b}. Join with join_channel(channel='${Ie}', invite_token='${We}'), read the opening post, and work the topic THERE (not in commons).`}),Be.push(gt)}catch(We){Ve.push(`${gt} (${String((We==null?void 0:We.message)||We)})`)}}const{migrated:zt,att_failed:jn}=await lo(z,Ie,S);$t?zt.length&&await i.post_message(Ie,{body:"Attachments carried over from the create request.",status:"fyi",attachments:zt}):await i.post_message(Ie,{body:((V=p.opening_body)==null?void 0:V.trim())||b,title:b.slice(0,120),status:"open",attachments:zt.length?zt:void 0}),Ii(Ie,Be),ft(`Room '${Ie}' created — private, ${Be.length} invited${Be.length?`: ${Be.join(", ")}`:""}.`+(zt.length?` ${zt.length} attachment(s) carried over.`:"")+(Ve.length?` Invite FAILED for ${Ve.join("; ")}.`:"")),Ve.length&&W(`Some invites failed — ${Ve.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),jn.length&&W(`Attachment carry-over failed for ${jn.join("; ")} — the room and post were created; re-attach in the new room.`),Pe(""),Xe(""),jt(""),Te("fyi"),mt([]),delete nn.current[D],Uo(nn.current),await hs(),be(Ie),setTimeout(()=>ft(""),6e3)}catch(Se){W(`group creation failed: ${String((Se==null?void 0:Se.message)||Se)}`)}finally{Ts(!1)}}async function uo(){var de;const p=ee.trim(),b=ut.length>0,N=!ot&&!D.startsWith("dm:")&&ge==="group";if(!p&&!b&&!N||Ks||!D)return;if(N){const V=yd(_t);if(!V.length){W("Group needs at least one member — write their names like: @entity @assistant");return}const Se=Fe.trim()||(p?p.split(`
130
- `)[0].slice(0,80):`focused work with ${V.join(", ")}`);await co({title:Se,members:V,opening_body:p});return}if(/^\/assistant(?=\s|$)/i.test(p)){if(!u){W("AI advisor is not configured — connect a gateway or inject an advisor.");return}const V=p.replace(/^\/assistant/i,"").trim();Pe(""),V?li(V):Jn("assistant");return}if(/^\/group(?=\s|$)/i.test(p)){await oo(p.replace(/^\/group/i,"").trim());return}if(/^\//.test(p)){W(`Unknown command "${p.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const S=Object.entries($s).filter(([,V])=>V).map(([V])=>V),z=D.startsWith("dm:");if(ot&&(((de=ot.data)==null?void 0:de.asks)||[]).length&&!S.length&&Es!=="void_reply"){ls("void_reply");return}if(!ot&&!z&&ge==="ask"&&!Fe.trim()&&Es!=="untitled_open"){ls("untitled_open");return}if(!ot&&!z&&ge==="dm"&&!Ye.trim()){W("Pick a recipient for the direct message.");return}Ts(!0),W("");try{if(!ot&&!z&&ge==="dm"){const V=Ye.trim(),Se=[...ut],Ie=D;await i.send_dm(V,{body:p||(Se.length?`(${Se.length} attachment${Se.length===1?"":"s"})`:p),title:Fe.trim()||void 0});const Be=`dm:${[vt,V].sort().join("--")}`;if(Se.length){const{migrated:Ve,att_failed:$t}=await lo(Ie,Be,Se);Ve.length&&await i.post_message(Be,{body:"",to:[V],attachments:Ve}),ft(`DM sent to ${V}${Ve.length?` with ${Ve.length} attachment(s)`:""}.`),$t.length&&W(`Attachment carry-over failed for ${$t.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ft(`DM sent to ${V}.`);await hs(),be(Be)}else{const V=ut.map(Be=>({id:Be.id,filename:Be.filename})),Se=z?Rh(D,vt):"";z&&!Se&&W(`#FALLBACK this dm's pair does not include seat '${vt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const Ie={body:p,title:Fe.trim()||void 0,status:Bw({is_reply:!!ot,in_dm:z,kind:ge}),to:Se?[Se]:void 0,reply_to:ot==null?void 0:ot.id,answers:ot&&S.length?S:void 0,attachments:V.length?V:void 0};try{await i.post_message(D,Ie)}catch(Be){if(Se&&/address non-members/i.test(String((Be==null?void 0:Be.message)||Be)))await i.post_message(D,{...Ie,to:void 0}),W(`#FALLBACK '${Se}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw Be}ft(z?"Sent.":"Posted."),await ea(D,{background:!0}),!z&&p&&El(D,p)}Pe(""),Xe(""),mt([]),$n(null),nr({}),Te("fyi"),yt(""),ls(""),delete nn.current[D],Uo(nn.current),setTimeout(()=>ft(""),3e3)}catch(V){W(String((V==null?void 0:V.message)||V||"Post failed"))}finally{Ts(!1)}}async function Tl(p){if(!(!D||!p||Pi||ie)){As(!0);try{await i.ack(D,p),ft(`Marked read to #${p}.`),setTimeout(()=>ft(""),3e3),Ca(On.current)}catch(b){W(String((b==null?void 0:b.message)||b||"Ack failed"))}finally{As(!1)}}}const Tn=!!(T!=null&&T.seat_key_present)&&!(E!=null&&E.paused),vt=(T==null?void 0:T.seat)||"",Jt=D.startsWith("dm:"),wr=(()=>{if(!Jt)return"";const p=D.slice(3);return vt&&p.startsWith(`${vt}--`)?p.slice(vt.length+2):vt&&p.endsWith(`--${vt}`)?p.slice(0,p.length-vt.length-2):p||D})(),Bc=f.useMemo(()=>Uw(qe),[qe]),Os=f.useMemo(()=>({seat:vt,unread_seqs:we[D],unread_snapshot_seqs:Ge==="unread"&&fe||void 0,escalated_seqs:Z[D]}),[vt,we,D,Ge,fe,Z]),Fn=f.useMemo(()=>{if(ot)return null;const p=new Set(oe.map(N=>N.name)),b=ee.trimStart();if(/^\/group(\s|$)/i.test(b)){const{title:N,members:S}=gd(b.replace(/^\/group/i,"").trim()),z=N||(S.length?`focused work with ${S.join(", ")}`:"");return{name:z?vd(z,p):"group",members:S,source:"slash"}}if(ge==="group"&&!D.startsWith("dm:")){const N=yd(_t),S=Fe.trim()||(N.length?`focused work with ${N.join(", ")}`:"");return{name:S?vd(S,p):"group",members:N,source:"kind"}}return null},[ee,ot,oe,ge,_t,Fe,D]),_s=f.useMemo(()=>Pw(qe),[qe]),aa=f.useMemo(()=>Mh(_s,Ge,Os),[_s,Ge,Os]),[Aa,Ct]=f.useState("recency"),[ra,La]=f.useState(null),Ma=f.useRef(null);f.useEffect(()=>{Ma.current=ra},[ra]);const[mo,jr]=f.useState("");function kr(){const p=R.current;La(null),jr(""),i.messages(D,{sort:"votes",limit:50}).then(b=>{p===R.current&&La(b)}).catch(b=>{if(p!==R.current)return;const N=String((b==null?void 0:b.message)||b);jr((b==null?void 0:b.status)===400||(b==null?void 0:b.status)===404||/allowlist/i.test(N)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":N)})}function mi(p){Qn.current={message_id:p.id,seq:p.seq},Ct("recency"),requestAnimationFrame(()=>yr())}const[ia,fo]=f.useState(""),[Ra,Uc]=f.useState("all"),[An,Pa]=f.useState(""),[Ln,za]=f.useState(null),[Sr,Xn]=f.useState(null),qn=f.useRef(0);function fi(p,b,N){if(!p&&!N)return;const S=++qn.current;Xn(null),za({q:p,report:null,error:"",busy:!0}),i.search({q:p,channel:b==="channel"&&D?[D]:void 0,rated:N||void 0,sort:!p&&N?"votes":void 0}).then(z=>{S===qn.current&&za({q:p,report:z,error:"",busy:!1})}).catch(z=>{if(S!==qn.current)return;const de=String((z==null?void 0:z.message)||z);za({q:p,report:null,busy:!1,error:(z==null?void 0:z.status)===404||/allowlist/i.test(de)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":de})})}function Al(p){fi(p.trim(),Ra,An)}function ho(){qn.current+=1,za(null),Xn(null),Pa("")}function Wc(p,b){const N=(Ln==null?void 0:Ln.q)||"";if(!N&&!An)return;const S=++qn.current;Xn({label:p,kind:b,hits:[],total:0,cursor:null,busy:!0,error:""}),i.search({q:N,kind:b,sort:"recent",limit:50,rated:An||void 0,channel:Ra==="channel"&&D?[D]:void 0}).then(z=>{if(S!==qn.current)return;const de=gs(z,b);Xn({label:p,kind:b,hits:de.hits,total:de.total,cursor:z.next_cursor??null,busy:!1,error:""})}).catch(z=>{S===qn.current&&Xn({label:p,kind:b,hits:[],total:0,cursor:null,busy:!1,error:String((z==null?void 0:z.message)||z)})})}function po(){const p=Sr,b=(Ln==null?void 0:Ln.q)||"";if(!p||!p.cursor||p.busy||!b&&!An)return;const N=qn.current;Xn({...p,busy:!0}),i.search({q:b,kind:p.kind,sort:"recent",limit:50,cursor:p.cursor,rated:An||void 0,channel:Ra==="channel"&&D?[D]:void 0}).then(S=>{if(N!==qn.current)return;const z=gs(S,p.kind);Xn(de=>de&&de.kind===p.kind?{...de,hits:[...de.hits,...z.hits],cursor:S.next_cursor??null,busy:!1}:de)}).catch(S=>{N===qn.current&&Xn(z=>z&&z.kind===p.kind?{...z,busy:!1,error:String((S==null?void 0:S.message)||S)}:z)})}function gs(p,b){const N=jc.find(z=>z.kind===b),S=N?p[N.id]:void 0;return S?{hits:S.hits||[],total:S.total||0}:{hits:[],total:0}}function Ll(p){const b=String(p.channel||"");b&&(Qn.current={message_id:p.kind==="message"?p.ref:void 0,seq:p.seq??void 0},ho(),Ct("recency"),b===D?yr():be(b))}async function Ia(p){const b=String(p.channel||""),N=String(p.ref||"");if(!b||!N)return;const S=Ir(N,"text/markdown");Kt({name:N,mode:S==="image"?"text":S,meta:`#${b}`,loading:!0});try{const z=await i.fs_read(b,N),de=Ir(N,z.mime);Kt({name:N,mode:de==="image"?"text":de,text:Sc(z.content),content_type:z.mime,meta:`#${b} · ${z.updated_by||"?"} · v${z.version??"?"}`,loading:!1})}catch(z){Kt({name:N,mode:"text",meta:`#${b}`,error:String((z==null?void 0:z.message)||z||"failed to read file")})}}function Zn(p){const b=p.kind==="message"&&!!p.channel,N=p.kind==="file"&&!!p.channel,S=b||N,z=sj(String(p.snippet||""),p.highlights),de=p.ratings,V=String(p.channel||""),Se=V?V.startsWith("dm:")?V:`#${V}`:"";return e.jsxs("div",{className:`team_search_hit${S?" clickable":""}`,onClick:S?()=>N?void Ia(p):Ll(p):void 0,role:S?"button":void 0,title:b?"Open this message in its thread":N?"Open this file":void 0,children:[e.jsxs("div",{className:"team_search_hit_head",children:[p.kind!=="message"?e.jsx("span",{className:"team_search_kind mono",children:p.kind}):null,Se?e.jsx("span",{className:"team_search_chan mono",children:Se}):null,p.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${nm(String(p.sender))}, 60%, 55%)`},children:p.sender}):null,typeof p.seq=="number"&&p.seq>0?e.jsxs("span",{className:"muted mono",children:["#",p.seq]}):null,p.status==="open"||p.status==="blocked"?e.jsx("span",{className:"team_search_status mono",title:"This thread still carries an unresolved obligation",children:p.status}):null,typeof p.thread_hits=="number"&&p.thread_hits>1?e.jsxs("span",{className:"muted",title:"More matches in the same thread",children:[p.thread_hits," in thread"]}):null,de&&(de.up||de.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",de.up," ▽",de.down]}):null,p.created_at?e.jsx("span",{className:"muted team_search_time",children:Ho(p.created_at)}):null]}),String(p.title||"").trim()?e.jsx("div",{className:"team_search_title",children:p.title}):null,z.length?e.jsx("div",{className:"team_search_snippet",children:z.map((Ie,Be)=>Ie.hit?e.jsx("mark",{children:Ie.text},Be):e.jsx(Bt.Fragment,{children:Ie.text},Be))}):null,!b&&!N&&p.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:p.ref}):null]},`${p.kind}:${V}:${p.ref}`)}const Nr=f.useMemo(()=>{let p=0;for(const b of aa)for(const N of[b.root,...b.replies])p=Math.max(p,N.seq||0);return p},[aa]),ys=f.useMemo(()=>{const p={};for(const b of["asks","vigilance","fyi","resolved","to_me"])p[b]=Mh(_s,b,Os).length;return p.unread=qe.filter(b=>{var N,S;return((N=Os.unread_seqs)==null?void 0:N.has(b.seq))||((S=Os.unread_snapshot_seqs)==null?void 0:S.has(b.seq))}).length,p},[_s,qe,Os]);function _o(){var p,b;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(Vn,{tone:Rt.state==="open"?"success":"warning",size:"sm",children:Rt.state}):null,(p=Rt.channel)!=null&&p.private?e.jsx(Vn,{tone:"muted",size:"sm",children:"private"}):e.jsx(Vn,{tone:"muted",size:"sm",children:"public"}),Rt.response_sla_minutes?e.jsxs(Vn,{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"]})]}),(b=Rt.meta)!=null&&b.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(ns,{className:"md_doc",text:Qo(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:Yr,onChange:N=>Di(N.target.value),disabled:!!or,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Rs.filter(N=>!(bn||[]).some(S=>String(S.agent_id||"")===N)).filter(N=>!(zi[D]||new Set).has(N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),e.jsx("button",{className:"btn",disabled:!Yr||!!or,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void $l(Yr),children:or?"Inviting…":"Invite"})]}):null,ds?e.jsx("div",{className:"muted team_note",children:ds}):null,(()=>{const N=[...zi[D]||[]].filter(S=>!(bn||[]).some(z=>String(z.agent_id||"")===S));return!N.length||bn===null?null:N.map(S=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:S}),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:${S}`))})(),Hr?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Hr.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(N=>{const S=String(N.agent_id||"");return S?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(N.about||""),children:S}),S!==vt&&!Jt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void vr(S,"kick"),children:Gt===`channel:kick:${S}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Vt===`channel:ban:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Vt===`channel:ban:${S}`?(Xt(""),vr(S,"ban")):Xt(`channel:ban:${S}`)},children:Gt===`channel:ban:${S}`?"banning…":Vt===`channel:ban:${S}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`hub:ban:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Vt===`hub:ban:${S}`?(Xt(""),vr(S,"ban","hub")):Xt(`hub:ban:${S}`)},children:Gt===`hub:ban:${S}`?"hub-banning…":Vt===`hub:ban:${S}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`retire:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Retire: decommission this agent WITHOUT blame — removed from all channels/rosters, the id is reserved (never reused), never shown as blocked (operator-only). Two clicks to confirm.",onClick:()=>{Vt===`retire:${S}`?(Xt(""),bl(S)):Xt(`retire:${S}`)},children:Gt===`retire:${S}`?"retiring…":Vt===`retire:${S}`?"confirm retire":"retire"})]}):S===vt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},S):null})]}),!Jt&&Jr&&Jr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",Jr.length,")"]}),Jr.map(N=>{const S=String(N.agent_id||N.agent||"");if(!S)return null;const z=String(N.scope||""),de=z==="hub",V=de?"hub":"channel",Se=N.expires_at?` · until ${new Date(Number(N.expires_at)*1e3).toLocaleString()}`:" · indefinite",Ie=de?"hub-wide":`#${z}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(N.reason||""),children:[S,e.jsxs("span",{className:"muted team_note",children:[Ie,Se]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:de?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void vr(S,"unblock",V),children:Gt===`${V}:unblock:${S}`?"unblocking…":"unblock"})})]},`blocked:${z}:${S}`)})]}):null,!Jt&&Ms&&Ms.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Ms.length,")"]}),Ms.map(N=>{const S=String(N.id||"");if(!S)return null;const z=N.retired_at?` · ${new Date(Number(N.retired_at)*1e3).toLocaleDateString()}`:"";return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(N.reason||""),children:[S,e.jsxs("span",{className:"muted team_note",children:["decommissioned",z]})]}),e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:`team_row_expand ${Vt===`unretire:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Vt===`unretire:${S}`?(Xt(""),wl(S)):Xt(`unretire:${S}`)},children:Gt===`unretire:${S}`?"un-retiring…":Vt===`unretire:${S}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Vt===`delete:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Delete from the hub: irreversible cleanup — removes this agent from every roster and board (its votes/ratings purged), id stays reserved. History keeps its old messages. Two clicks to confirm.",onClick:()=>{Vt===`delete:${S}`?(Xt(""),Oc(S)):Xt(`delete:${S}`)},children:Gt===`delete:${S}`?"deleting…":Vt===`delete:${S}`?"confirm delete":"delete"})]})]},`retired:${S}`)})]}):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:"ⓘ"})]}),Js===null?e.jsx("span",{className:"muted team_note",children:Vr||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Js.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Js.map(N=>{const S=String(N.agent_id||""),z=Array.isArray(N.powers)?N.powers.map(String):[],de=Number(N.expires_at||N.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:S}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(N.note||""),children:[z.join(" + ")||"(no powers?)",de?` · until ${new Date(de*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Vt===`resign:${S}`?"team_danger":""}`,disabled:hn,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Vt===`resign:${S}`?(Xt(""),ir(S)):Xt(`resign:${S}`)},children:hn?"resigning…":Vt===`resign:${S}`?"confirm resign":"resign"})]},S)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pn,onChange:N=>ul(N.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(N=>String(typeof N=="string"?N:(N==null?void 0:N.agent_id)||(N==null?void 0:N.id)||"")).filter(N=>N&&N!==vt&&!Js.some(S=>String(S.agent_id)===N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),pn?e.jsxs("div",{className:"team_delegation_powers_pick",children:[vj.map(N=>e.jsxs("label",{className:"team_delegation_power",title:N.help,children:[e.jsx("input",{type:"checkbox",checked:ga.includes(N.id),onChange:S=>dl(z=>S.target.checked?[...z,N.id]:z.filter(de=>de!==N.id))}),N.id]},N.id)),e.jsx("button",{className:"btn",disabled:hn||!ga.length,title:ga.length?`Grant ${pn} the powers: ${ga.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Kr(),children:hn?"Assigning…":"Assign"})]}):null]}),Vr?e.jsx("div",{className:"page_error mono",children:Vr}):null]})]}),Jt?null:e.jsx("div",{className:"team_chan_admin",children:At?String(Rt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:cn,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void jl("closed"),children:cn?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:cn,title:"Reopen this channel for member posts",onClick:()=>void jl("open"),children:cn?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",xs||"unknown",")."]})}),Qr?e.jsx("div",{className:"page_error mono",children:Qr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function Hc(p){var N;const b=((N=p.data)==null?void 0:N.attachments)||p.attachments||[];return b.length?e.jsx("div",{className:"team_attachments",children:b.map((S,z)=>{const de=`${S.id}:${z}`,V=i.attachment_url(p.channel,S.id);return _j.has(String(S.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${S.filename} · ${Gn(S.size)} — click to preview`,onClick:()=>void Ta(p.channel,S),children:[e.jsx("img",{className:"team_attach_img",src:V,alt:S.filename,loading:"lazy",onError:Ie=>{var $t;const Be=Ie.currentTarget;Be.style.display="none";const Ve=($t=Be.parentElement)==null?void 0:$t.querySelector(".team_attach_fallback");Ve&&(Ve.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Gn(S.size)})]})]},de):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${S.content_type} · ${Gn(S.size)} — click to preview`,onClick:()=>void Ta(p.channel,S),children:[e.jsx(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Gn(S.size)})]},de)})}):null}function Vc(p,b){var Se;const N=[],S=String(p.status||"").toLowerCase();(S==="open"||S==="blocked")&&(p.has_resolved_reply===!0||(p.id?Bc.has(p.id):!1))?N.push(e.jsx(Vn,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):S==="open"||S==="blocked"?N.push(e.jsx(Vn,{tone:S==="blocked"?"error":"warning",size:"sm",children:S},"st")):S==="resolved"&&b&&N.push(e.jsx(Vn,{tone:"success",size:"sm",children:"resolved"},"st")),p.critical&&N.push(e.jsx(Vn,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const de=((Se=p.data)==null?void 0:Se.answers)||[];S==="reply"&&de.length&&N.push(e.jsxs(Vn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${de.join(", ")} of its parent.`,children:["✓ answers ",de.join(",")]},"dis"));const V=p.to||[];for(const Ie of V.slice(0,2))N.push(e.jsxs(Vn,{tone:"muted",size:"sm",children:["@",Ie]},`to:${Ie}`));return V.length>2&&N.push(e.jsxs(Vn,{tone:"muted",size:"sm",title:V.map(Ie=>`@${Ie}`).join(" "),children:["+",V.length-2]},"to+")),N}function vs(p,b){return e.jsx(t_,{resetKey:`${p.retracted?1:0}:${(p.body||"").length}:${(p.title||"").length}`,fallback:e.jsx("div",{className:"team_row team_row_broken",id:`hubmsg-${p.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:Gh(p.sender),children:p.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",p.seq," · ",Wo(p.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:(p.title?p.title+`
131
- `:"")+String(p.body||"(no text)")})]})}),children:Cr(p,b)},p.id)}function Cr(p,b){var xt,lt,Lt,gt;const N=!!Je[p.id],S=String(p.body||""),z=b.is_root?kc:Uh,de=S.length>z,V=de&&!N,Se=((xt=p.data)==null?void 0:xt.asks)||[],Ie=!!((lt=Os.unread_seqs)!=null&&lt.has(p.seq)),Be=Ge!=="all"&&zw(p,Ge,Os),Ve=String(p.title||"").trim(),$t=((Lt=S.trim().split(`
132
- `)[0])==null?void 0:Lt.trim())||"",zt=Ve&&(Ve===S.trim()||Ve===$t),jn=(ot==null?void 0:ot.id)===p.id;return e.jsxs("div",{className:`team_row ${p.sender===vt?"own":""} ${Be?"hit":""} ${jn?"replying":""} ${Ie?"unread":""} ${p.retracted?"retracted":""}`,id:`hubmsg-${p.id}`,onClick:()=>Ic(p),title:de?void 0:p.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Qa(p.sender),"aria-hidden":"true",children:(p.sender[0]||"?").toUpperCase()}),e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[(gt=H[p.channel])!=null&&gt.has(p.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 ${ta===p.id?"armed":""}`,title:ta===p.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(),Ea(p)},children:ta===p.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"}):p.read===!1&&b.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:Gh(p.sender),children:p.sender}),Vc(p,b.is_root),(()=>{const We=Zi(p);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:Ho(p.created_at),children:["#",p.seq," · ",Wo(p.created_at)]})]}),Ve&&!zt?e.jsx("div",{className:"team_row_title",children:Ve}):null,e.jsx("div",{className:`team_row_body ${V?b.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(oj,{className:"md_doc",text:Qo(Xw(Kw(S),{hub_base:M}))})}),Hc(p),(()=>{var Zt;const We=Vw(`${String(p.title||"")}
133
- ${S}`),St=((Zt=p.data)==null?void 0:Zt.attachments)||p.attachments||[],Ot=We.map(Mt=>({mention:Mt,res:Gw(Mt,ri,St)})).filter(Mt=>Mt.res!==null).filter(Mt=>{var Qt;return!(Mt.res.kind==="attachment"&&String(((Qt=St[Mt.res.attachment_index])==null?void 0:Qt.filename)||"")===Mt.mention)}),Ut=s.on_open_board?lb(`${String(p.title||"")}
134
- ${S}`):[];return!Ot.length&&!Ut.length?null:e.jsxs("div",{className:"team_fs_chips",children:[Ot.map(({mention:Mt,res:Qt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Qt.kind==="fs"?Qt.rewritten?`Opens ${Qt.path} (the mention's path moved — matched by name in #${D}'s files)`:`Open ${Qt.path} from #${D}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:un=>{un.stopPropagation(),Qt.kind==="fs"?no(Qt.path):Ta(p.channel,St[Qt.attachment_index])},children:[e.jsx(Vh,{}),e.jsx("span",{className:"team_attach_name",children:Mt}),Qt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Qt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},Mt)),Ut.map(Mt=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${Mt} — open the Board filtered to it`,onClick:Qt=>{var un;Qt.stopPropagation(),(un=s.on_open_board)==null||un.call(s,Mt)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:Mt})]},`w:${Mt}`))]})})(),Se.length?e.jsx("div",{className:"team_row_asks",children:Se.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,de?e.jsx("button",{className:"team_row_expand",onClick:We=>{We.stopPropagation(),vl(p)},children:N?"collapse":"show more"}):null]}),Tn?e.jsxs("div",{className:"team_row_rail",children:[p.id&&p.sender!==vt&&p.sender!=="hub"&&!p.retracted?(()=>{const We=Zi(p);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:!!si,onClick:St=>{St.stopPropagation(),xl(p.id,1)},children:[e.jsx(Ue,{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:!!si,onClick:St=>{St.stopPropagation(),xl(p.id,-1)},children:[e.jsx(Ue,{name:We.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),We.down?e.jsx("span",{className:"team_thumb_count",children:We.down}):null]})]}):null})():null,$.tts_supported&&p.id?(()=>{const We=$.tts_playback.key===p.id&&$.tts_playback.status==="playing",St=$.tts_playback.key===p.id&&$.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${We||St?"team_speak_on":""}`,title:We?"Pause":St?"Synthesizing…":h.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":We?"Pause reading":"Read this message aloud",onClick:Ot=>{Ot.stopPropagation();const Ut=hw(p.body||p.title||"");Ut?$.toggle_tts(p.id,Ut):W("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(Ue,{name:We?"pause":St?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:Se.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:We=>{We.stopPropagation(),di(p)},children:"↩ Reply"}),p.sender===vt&&!p.retracted?e.jsx("button",{className:`btn btn_icon ${ps===p.id?"team_danger":""}`,title:ps===p.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(),ps===p.id?xr(p):ui(p.id)},children:ps===p.id?"⌫ confirm retract":"⌫ Retract"}):null,b.is_root&&(String(p.status||"").toLowerCase()==="open"||String(p.status||"").toLowerCase()==="blocked")?e.jsx("button",{className:`btn btn_icon ${ci===p.id?"team_danger":""}`,title:ci===p.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(),ci===p.id?ro(p):Cl(p.id)},children:ci===p.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},p.id)}function Da(p){const b=p.replies.length,N=!!xe[p.root.id],S=!!ue[p.root.id],z=N?[]:S||Ge!=="all"||b<=Wh+1?p.replies:p.replies.slice(b-Wh),de=N?b:b-z.length,V=Pc[p.root.id];return e.jsxs("div",{className:`team_thread_group ${b?"has_replies":""}`,children:[p.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,vs(p.root,{is_root:!0}),de>0||b>0||String(p.root.body||"").length>kc?e.jsxs("div",{className:"team_trail_bar",children:[b>0?e.jsx("button",{className:"team_replies_more",onClick:()=>ke(Se=>({...Se,[p.root.id]:!Se[p.root.id]})),children:N?`show ${b} repl${b===1?"y":"ies"}`:"fold thread"}):null,!N&&de>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>ye(Se=>({...Se,[p.root.id]:!0})),children:["↓ ",de," earlier repl",de===1?"y":"ies"]}):null,!N&&u&&(b>0||String(p.root.body||"").length>kc)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(V!=null&&V.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void Nl(p),children:V!=null&&V.busy?"✦ summarizing…":`✦ Summarize (${b+1})`}):null]}):null,!N&&b>0?e.jsx("div",{className:"team_replies",children:z.map(Se=>vs(Se,{is_root:!1}))}):null,!N&&(V!=null&&V.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",V.window||`${V.count} message${V.count===1?"":"s"}`]}),e.jsx("button",{className:"team_row_expand",onClick:()=>xa(Se=>({...Se,[p.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(ns,{className:"md_doc",text:Qo(V.text)})]}):null,V!=null&&V.error?e.jsx("div",{className:"page_error mono",children:V.error}):null]},p.root.id)}const hi=qe.length?qe[qe.length-1].seq:0,go=Math.max(hi,((Tt=oe.find(p=>p.name===D))==null?void 0:Tt.last_seq)||0),oa=((bs=oe.find(p=>p.name===D))==null?void 0:bs.member_count)||0,xs=((an=(bn||[]).find(p=>String(p.role||"")==="owner"))==null?void 0:an.agent_id)||"",At=!!vt&&xs===vt;return e.jsxs("div",{className:"page page_pad team_page",onDragOver:p=>{var b;Array.from(((b=p.dataTransfer)==null?void 0:b.types)||[]).includes("Files")&&(p.preventDefault(),Tn&&!Le&&wt(!0))},onDragLeave:p=>{p.currentTarget.contains(p.relatedTarget)||wt(!1)},onDrop:p=>{var b,N;(N=(b=p.dataTransfer)==null?void 0:b.files)!=null&&N.length&&(p.preventDefault(),wt(!1),!(!Tn||Le)&&io(p.dataTransfer.files))},children:[Pt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Jt?wr:`#${D}`]})}):null,E!=null&&E.protocol&&E.protocol!==Nc||E!=null&&E.paused||se||Dn||Ur||T&&!T.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[T&&!T.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,E!=null&&E.protocol&&E.protocol!==Nc?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${E.protocol}; this page was written against ${Nc}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",E.protocol," ≠ ",Nc]}):null,E!=null&&E.paused?e.jsx("span",{className:"chip mono warn",title:"The operator paused the hub — posting resumes when it does.",children:"hub paused"}):null,se?e.jsx("span",{className:"page_error mono",children:se}):null,Dn?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",Dn]}):null,Ur?e.jsx("span",{className:"chip mono ok",children:Ur}):null]}):null,e.jsxs("div",{className:`team_layout ${Et?"with_drawer":""} ${Et==="leaderboard"?"drawer_wide":""} team_mobile_${$e} ${Re?"team_tools_open":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",onClickCapture:p=>{var b,N;(N=(b=p.target)==null?void 0:b.closest)!=null&&N.call(b,".team_channel")&&Oe("thread")},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(p=>!p.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:()=>Ps(p=>({...p,open:!p.open})),children:e.jsx(Ue,{name:"plus",size:14})})})]}),En.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:En.name,onChange:p=>Ps(b=>({...b,name:p.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:p=>{p.key==="Enter"&&so()}}),e.jsx(Li,{variant:"sm",label:"Private",hint:"Private channels need invites; public ones are joinable by any registered agent.",action:"new-channel-private",checked:En.is_private,onChange:p=>Ps(b=>({...b,is_private:p}))}),e.jsx("button",{className:"btn primary",disabled:!En.name.trim()||cn,onClick:()=>void so(),children:cn?"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:se?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),oe.filter(p=>!p.name.startsWith("dm:")).map(p=>{const b=Ne[p.name],N=Yn===p.name;return e.jsxs("div",{className:`team_channel team_dm_row ${D===p.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(p.name),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&be(p.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${b!=null&&b.unread?"has_unread":""}`,children:["#",p.name]}),e.jsxs("span",{className:"team_channel_badges",children:[b!=null&&b.unread?e.jsx("span",{className:"team_badge unread",role:"button",tabIndex:0,title:`${b.unread>=100?"100 or more":b.unread} unread message(s) for your seat — the Unread tab shows the same number. Click to open with the Unread filter.`,onClick:S=>{S.stopPropagation(),p.name!==D&&(et.current="unread"),be(p.name),ct("unread")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),p.name!==D&&(et.current="unread"),be(p.name),ct("unread"))},children:b.unread>=100?"99+":b.unread}):null,b!=null&&b.open_questions?e.jsx("span",{className:"team_badge asks",role:"button",tabIndex:0,title:`${b.open_questions} open question(s) in this room still awaiting answers (channel digest) — click to open with the Asks filter`,onClick:S=>{S.stopPropagation(),p.name!==D&&(et.current="asks"),be(p.name),ct("asks")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),p.name!==D&&(et.current="asks"),be(p.name),ct("asks"))},children:b.open_questions}):null,e.jsx("button",{className:`team_dm_trash ${N?"arming":""}`,title:N?"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":N?"Confirm archive channel":"Archive channel",disabled:cn,onClick:S=>{S.stopPropagation(),N?Sl(p.name):na(p.name)},children:e.jsx(Ue,{name:N?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:N?"archive? click ✕":`${p.member_count} seats · ${Wo(p.last_at)}`})]},p.name)}),(()=>{const p=oe.filter(b=>b.name.startsWith("dm:"));return p.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"team_rail_section",children:"Direct messages"}),p.map(b=>{const N=Ne[b.name],S=b.name.replace(/^dm:/,"").split("--").filter(de=>de!==vt).join("")||b.name,z=Fc===b.name;return e.jsxs("div",{className:`team_channel team_dm_row ${D===b.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(b.name),onKeyDown:de=>{(de.key==="Enter"||de.key===" ")&&be(b.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${N!=null&&N.unread?"has_unread":""}`,children:["@",S]}),e.jsxs("span",{className:"team_channel_badges",children:[N!=null&&N.unread?e.jsx("span",{className:"team_badge unread",title:`${N.unread>=100?"100 or more":N.unread} unread message(s)`,children:N.unread>=100?"99+":N.unread}):null,e.jsx("button",{className:`team_dm_trash ${z?"arming":""}`,title:z?"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":z?"Confirm remove direct message":"Remove direct message",disabled:cn,onClick:de=>{de.stopPropagation(),z?qc(b.name):kl(b.name)},children:e.jsx(Ue,{name:z?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:z?"remove? click ✕":Wo(b.last_at)})]},b.name)})]}):null})()]})]}),e.jsxs("div",{className:"pane team_thread_pane",children:[e.jsxs("div",{className:"pane_header team_thread_header",children:[e.jsx("button",{type:"button",className:"btn team_back_btn",onClick:()=>{Oe("channels"),rt(!1),Et&&Jn("")},"aria-label":"Back to channels",title:"Back to channels",children:"← Channels"}),e.jsx("button",{type:"button",className:"btn team_tools_btn",onClick:()=>rt(p=>!p),"aria-expanded":Re,"aria-label":Re?"Hide thread tools":"Show thread tools (filters, search, panels)",title:"Filters, search, panels and actions",children:Re?"Less":"More"}),e.jsx("span",{className:"pane_title team_pane_title",children:D?Jt?`@${wr} — direct`:`#${D}`:"Select a channel"}),D&&oa?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{Et!=="members"&&ss("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[oa," members"]}):null,ie?e.jsx("span",{className:"muted team_note",children:"loading…"}):null,e.jsxs("span",{className:"pane_header_actions",children:[$.tts_playback.status!=="idle"?e.jsx("button",{className:"btn team_speak_stop",title:"Stop reading aloud",onClick:()=>$.stop_tts(),children:"◼ Stop reading"}):null,(()=>{const p=Ge==="all"?go:Nr;return e.jsx("button",{className:"btn",onClick:()=>void Tl(p),disabled:!D||!qe.length||!p||Pi||ie,title:Ge==="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:Pi?"Marking…":`Mark read → #${p||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{hs(),ea(D)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(Ue,{name:"refresh",size:14})}),Ht&&Ht!=="running"&&typeof Ht=="object"&&"ok"in Ht?Ht.ok?e.jsxs(Vn,{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(Vn,{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(Vn,{tone:"warning",size:"sm",title:Ht.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void Dc(),disabled:!D||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:Lh.map(p=>{const b=Ge===p.id,N=ys[p.id];return e.jsxs("button",{className:`seg_btn ${b?"active":""}`,"aria-pressed":b,title:p.title,onClick:()=>ct(p.id),children:[p.label,typeof N=="number"&&N>0?e.jsx("span",{className:"team_filter_count",children:N}):null]},p.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:p=>{p.preventDefault();const b=ia.trim();if(!b&&!An){Pa("down"),fi("",Ra,"down");return}Al(b)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:ia,onChange:p=>fo(p.target.value),onKeyDown:p=>{p.key==="Escape"&&(Ln&&ho(),fo(""))},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"}),Ln?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:ho,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 ${Aa==="recency"?"active":""}`,"aria-pressed":Aa==="recency",title:"Threads by last activity (default)",onClick:()=>Ct("recency"),children:"Recency"}),e.jsx("button",{className:`seg_btn ${Aa==="votes"?"active":""}`,"aria-pressed":Aa==="votes",title:"The channel's most-voted messages — whole channel, ranked by net standing ±1 (hub-served order)",onClick:()=>{Ct("votes"),kr()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Hi?"on":""}`,title:Hi?"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:Hi?"● live":"◌ polling"})," · ",aa.length!==_s.length?`${aa.length} of ${_s.length} threads`:_s.length?`${_s.length} threads`:"",T!=null&&T.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",T.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:ni,children:Ln?(()=>{const p=Ln;if(p.error)return e.jsx("div",{className:"muted team_note",children:p.error});if(p.busy||!p.report)return e.jsx("div",{className:"muted team_note",children:p.q?`Searching “${p.q}”…`:"Browsing rated messages…"});const b=p.report;if(Sr){const z=Sr;return e.jsxs("div",{className:"team_search_results",children:[e.jsxs("div",{className:"team_search_meta",children:[e.jsx("button",{className:"team_replies_more",onClick:()=>Xn(null),children:"← All results"}),e.jsxs("span",{className:"muted",children:[z.label," matching “",p.q,"” — newest first",z.total?` · ${z.hits.length} of ${z.total}`:""]})]}),z.error?e.jsx("div",{className:"muted team_note",children:z.error}):null,z.hits.map(de=>Zn(de)),z.busy?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,!z.busy&&z.cursor?e.jsx("button",{className:"team_replies_more team_search_more",onClick:po,children:"Load more"}):null,!z.busy&&!z.hits.length&&!z.error?e.jsxs("div",{className:"muted team_note",children:["Nothing in ",z.label.toLowerCase()," matches “",p.q,"”."]}):null]})}const N=jc.filter(z=>{var de;return!((((de=b[z.id])==null?void 0:de.total)??0)>0)}),S=N.length<jc.length;return e.jsxs("div",{className:"team_search_results",children:[b.relaxed&&(!b.mode_used||b.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,b.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:b.notice}):null,e.jsxs("div",{className:"team_search_meta",children:[e.jsxs("span",{className:"muted",children:[p.q?`“${p.q}”`:`rated messages${An?` (${An==="down"?"↓ downvoted":"↑ upvoted"}, net-vote order)`:""}`," · ",b.channels_searched??0," channel",(b.channels_searched??0)===1?"":"s"," searched",b.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:[" ","· ",b.mode_used,typeof b.semantic_coverage=="number"?` (${Math.round(b.semantic_coverage*100)}% embedded)`:""]}):null]}),e.jsx("span",{className:"seg team_search_rated",role:"group","aria-label":"Rated filter",children:["up","down"].map(z=>e.jsx("button",{className:`seg_btn ${An===z?"active":""}`,"aria-pressed":An===z,title:z==="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 de=An===z?"":z;Pa(de),fi(p.q,Ra,de)},children:z==="up"?"▲ rated":"▼ rated"},z))}),e.jsxs("label",{className:"team_search_scope",title:"Limit the search to the channel currently open in the rail (re-runs the query)",children:[e.jsx("input",{type:"checkbox",checked:Ra==="channel",onChange:z=>{const de=z.target.checked?"channel":"all";Uc(de),fi(p.q,de,An)}}),"this channel only"]})]}),jc.map(z=>{const de=b[z.id],V=(de==null?void 0:de.shown)??0,Se=(de==null?void 0:de.total)??0,Ie=(de==null?void 0:de.hits)??[];return!de||!Se&&!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:z.label}),e.jsx("span",{className:"muted mono",children:V<Se?`showing ${V} of ${Se}`:`${Se}`}),V<Se&&z.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>Wc(z.label,z.kind),title:`All ${Se} ${z.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Ie.map(Be=>Zn(Be))]},z.id)}),S?N.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",N.map(z=>z.label.toLowerCase()).join(", ")]}):null:e.jsx("div",{className:"muted team_note",children:p.q?`Nothing matches “${p.q}” in the channels this seat can read.`:"No rated messages match this lens."})]})})():Aa==="votes"?mo?e.jsx("div",{className:"muted team_note",children:mo}):ra===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):ra.length?ra.map((p,b)=>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:["#",b+1]}),e.jsx("button",{className:"team_replies_more",onClick:()=>mi(p),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),vs(p,{is_root:!0})]},p.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 p=[];let b="";for(const N of aa){const S=N.replies.length?N.replies[N.replies.length-1]:N.root,z=xj(S.created_at);z&&z!==b&&(b=z,p.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:z})},`day:${z}:${N.root.id}`))),p.push(Da(N))}return p})(),!aa.length&&D&&!ie?e.jsx("div",{className:"muted team_note",children:_s.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((gn=Lh.find(p=>p.id===Ge))==null?void 0:gn.label)||Ge})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>ct("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:p=>{p.key==="Escape"&&ot&&sa()},children:[ot?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 p;(p=document.getElementById(`hubmsg-${ot.id}`))==null||p.scrollIntoView({block:"center"})},children:["↩ #",ot.seq," (",ot.sender,") —"," ",(String(ot.title||"").trim()||String(ot.body||"").trim()).slice(0,80)||"(no text)"]}),(((Fs=ot.data)==null?void 0:Fs.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((la=ot.data)==null?void 0:la.asks)||[]).map(p=>e.jsxs("label",{title:p.text,children:[e.jsx("input",{type:"checkbox",checked:!!$s[p.id],onChange:b=>nr(N=>({...N,[p.id]:b.target.checked}))}),e.jsxs("span",{className:"team_reply_ask_text",children:["ask ",p.id,": ",p.text.length>70?p.text.slice(0,70)+"…":p.text]})]},p.id))}):null,e.jsx("button",{className:"team_row_expand",onClick:sa,children:"cancel (Esc)"})]}):null,Es==="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 ",ot?"Reply":"Post"," again to send as-is."]}):null,Es==="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,Fn?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:Fn.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:["#",Fn.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",Fn.members.map(p=>`@${p}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:Fn.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!ot&&!Jt&&(ge==="ask"||ge==="group")?e.jsx("input",{className:"team_ask_title",value:Fe,onChange:p=>Xe(p.target.value),placeholder:ge==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!Tn}):null,!ot&&!Jt&&ge==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:_t,onChange:p=>jt(p.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!Tn,list:"team_roster_options"}):null,!ot&&!Jt&&ge==="group"&&Rs.length?e.jsx("datalist",{id:"team_roster_options",children:Rs.map(p=>e.jsx("option",{value:`@${p}`},p))}):null,ut.length?e.jsx("div",{className:"team_attach_pending",children:ut.map(p=>e.jsxs("span",{className:"team_attach_chip",title:`${p.content_type} · ${Gn(p.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void Ta(D,p),"aria-label":`Preview ${p.filename}`,children:[e.jsx(Ue,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:p.filename}),e.jsx("span",{className:"muted",children:Gn(p.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${p.filename}`,title:"Remove this attachment",onClick:()=>mt(b=>b.filter(N=>N.id!==p.id)),children:e.jsx(Ue,{name:"x",size:10})})]},p.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!ot&&!Jt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:ge,onChange:p=>{const b=p.target.value,N=b==="ask"?"ask":b==="dm"?"dm":b==="group"?"group":"fyi";Te(N),N!=="ask"&&N!=="group"&&Xe(""),N!=="group"&&jt("")},disabled:!Tn,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,!ot&&!Jt&&ge==="dm"?Rs.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:Ye,onChange:p=>yt(p.target.value),disabled:!Tn,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Rs.map(p=>e.jsx("option",{value:p,children:p},p))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:Ye,onChange:p=>yt(p.target.value),placeholder:"to: agent id",disabled:!Tn,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:tn,className:"team_compose_text",rows:2,value:ee,onChange:p=>Pe(p.target.value),placeholder:Tn?ot?`Reply to #${ot.seq} in #${D}…`:Jt?`Message ${wr}…`:ge==="dm"?`Direct message${Ye.trim()?` to ${Ye.trim()}`:""}…`:u?`Message #${D||"…"} as ${(T==null?void 0:T.seat)||"operator"} — or /assistant <question>`:`Message #${D||"…"} as ${(T==null?void 0:T.seat)||"operator"}`:E!=null&&E.paused?"The hub is paused by the operator — posting resumes when it does.":"Read-only: the proxy has no operator seat key.",disabled:!Tn,onKeyDown:p=>{p.key!=="Enter"||p.shiftKey||p.nativeEvent.isComposing||p.keyCode===229||(p.preventDefault(),!Ks&&(ee.trim()||ut.length)&&uo())}}),e.jsx("input",{ref:ht,type:"file",multiple:!0,style:{display:"none"},onChange:p=>void io(p.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!Tn||Le||ut.length>=Bo,title:ut.length>=Bo?`Attachment limit (${Bo}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var p;return(p=ht.current)==null?void 0:p.click()},children:e.jsx(Ue,{name:"paperclip",size:14})}),e.jsxs("button",{className:"btn primary team_send",disabled:!Tn||Ks||!ee.trim()&&!ut.length&&!(ge==="group"&&!ot&&!Jt&&yd(_t).length>0),onClick:()=>void uo(),"aria-label":Ks?"Sending":void 0,children:[e.jsx("span",{className:"team_send_icon","aria-hidden":"true",children:e.jsx(Ue,{name:"send",size:16})}),e.jsx("span",{className:"team_send_label",children:Ks?"Sending…":Fn!=null&&Fn.members.length||!ot&&!Jt&&ge==="group"?"Create room":ot?"Reply":Jt||ge==="dm"?"Send DM":ge==="ask"?"Ask":"Send"})]})]})]})]}),Et==="assistant"?e.jsxs("div",{className:"pane team_drawer team_ai_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Assistant"}),e.jsxs("span",{className:"pane_count",children:["#",D]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[zs.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",D," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",qe.length," messages) and cites seqs. It never posts to the room."]}),zs.map((p,b)=>e.jsxs("div",{className:`team_ai_turn ${p.role}`,children:[e.jsx("div",{className:"team_ai_role mono",children:p.role==="user"?"you":"analyst"}),e.jsx(ns,{className:"md_doc",text:Qo(p.content)})]},b)),zs.length&&fl?e.jsxs("div",{className:"muted team_note",children:["Last answer read ",fl,"."]}):null,Zs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,Bi?e.jsx("div",{className:"page_error mono",children:Bi}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(ol,{value:ti,onChange:fr,onSubmit:()=>{const p=ti;fr(""),li(p)},placeholder:u?`Ask about #${D}…`:"AI advisor is not configured for this shell.",disabled:!u,busy:Zs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,Et==="members"?e.jsxs("div",{className:"pane team_drawer team_members_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Members"}),e.jsxs("span",{className:"pane_count",children:["#",D]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:_o()})]}):null,Et==="files"?e.jsxs("div",{className:"pane team_drawer team_files_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Files"}),e.jsxs("span",{className:"pane_count",children:["#",D]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${Xs===""?"active":""}`,onClick:()=>sn(""),title:"Channel root",children:["#",D||"…"]}),Xs?Xs.split("/").map((p,b,N)=>{const S=N.slice(0,b+1).join("/");return e.jsxs(Bt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${b===N.length-1?"active":""}`,onClick:()=>sn(S),children:p})]},S)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:Ys===null&&!ja?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):ja?e.jsx("div",{className:"page_error mono",children:ja}):Ys&&Ys.length?(()=>{const{dirs:p,leaves:b}=qw(Ys,Xs);return!p.length&&!b.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[p.map(N=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>sn(N.path),title:`${N.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(gj,{})}),e.jsx("span",{className:"team_file_path",children:N.name}),e.jsx("span",{className:"team_file_meta mono",children:N.count})]},N.path)),b.map(N=>e.jsxs("button",{className:"team_file_row",onClick:()=>void gr(N),title:`${N.updated_by||"?"} · ${Ho(N.updated_at)} · v${N.version} · ${Gn(N.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Vh,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:N.path.slice(Xs?Xs.length+1:0)}),N.description?e.jsx("span",{className:"team_file_desc muted",children:N.description}):null]}),e.jsxs("span",{className:"team_file_meta mono",children:[Gn(N.size)," · ",Wo(N.updated_at)]})]},N.path))]})})():e.jsx("div",{className:"muted team_note",children:"No files in this channel's virtual filesystem yet."})})]}):null,Et==="leaderboard"?e.jsxs("div",{className:"pane team_drawer team_lb_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Leaderboard"}),e.jsx("span",{className:"pane_count",children:wn==="hub"?"hub-wide":`#${D}`}),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:()=>{wa("channel"),Qi("channel")},disabled:!D,title:`This channel's board (#${D||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${wn==="hub"?"active":""}`,onClick:()=>{wa("hub"),Qi("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:In===null&&!Xr?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Xr?e.jsx("div",{className:"muted team_note",children:Xr}):!In||In.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(In==null?void 0:In.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 S;const p=Array.isArray(In.categories)||In.leaderboard.some(z=>z.breakdown!=null||typeof z.score=="number"),b=p?(S=In.categories)!=null&&S.length?In.categories:["general",...Ti.map(z=>z.id)]:[],N=p&&b.length!==5?{gridTemplateColumns:`20px 22px minmax(70px, 1.5fr) minmax(40px, 0.7fr) repeat(${b.length}, minmax(40px, 0.8fr))`}:void 0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_lb_legend","aria-hidden":"true",style:N,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"}),p?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"}),b.map(z=>e.jsx("span",{className:"team_lb_legend_axis",title:Kh[z]||`${Vo(z)} — reputation category.`,children:Vo(z)},z))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),Ti.map(z=>e.jsx("span",{className:"team_lb_legend_axis",title:z.help,children:z.label},z.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"})]})]}),In.leaderboard.map((z,de)=>e.jsxs(Bt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${ms===z.target?"open":""}`,style:N,onClick:()=>Yi(z.target),role:"button",tabIndex:0,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),Yi(z.target))},title:wn==="hub"?`${z.target}: rated in ${z.channels||0} channel(s) by ${z.raters} rater(s)`:p?`${z.target}: ${z.raters} rater(s) — click for attributed OPINION votes (general/thumbs live on the messages themselves)`:`${z.target}: ${z.raters} rater(s) — click for the votes behind the score`,children:[e.jsx("span",{className:`team_lb_rank ${de<3?`top${de+1}`:""}`,"aria-hidden":"true",children:de<3?"●":de+1}),e.jsx("span",{className:"team_avatar",style:Qa(z.target),"aria-hidden":"true",children:z.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:z.target}),p?e.jsxs(e.Fragment,{children:[(()=>{const V=Number(z.score||0),Se=z.votes;return e.jsxs("span",{className:`team_lb_total ${V>0?"pos":V<0?"neg":""}`,title:(()=>{const Ie=Object.entries(z.breakdown||{}).filter(([,Be])=>Be&&Number(Be.score||0)!==0).map(([Be,Ve])=>`${Vo(Be)} ${Number(Ve.score)>0?"+":""}${Number(Ve.score)}`).join(" · ");return`${z.target}: score ${V>0?"+":""}${V} = ${Ie||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${Se?` — total: ${Se.up} up, ${Se.down} down`:""}`})(),children:[V>0?`+${V}`:V,Se&&(Se.up||Se.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[Se.up,"↑"]}),e.jsxs("span",{className:Se.down>0?"rv_down_hot":"rv_down",children:[Se.down,"↓"]})]}):null]})})(),b.map(V=>{var Ve;const Se=(Ve=z.breakdown)==null?void 0:Ve[V],Ie=Number((Se==null?void 0:Se.score)||0),Be=!!(Se&&(Se.up||Se.down||Se.raters));return e.jsx("span",{className:`team_lb_axis ${Ie>0?"pos":Ie<0?"neg":""}`,title:Be?`${Vo(V)}: ${Ie>0?"+":""}${Ie} (▲${Se.up} ▼${Se.down} voices · ${Se.raters} engaged colleague${Se.raters===1?"":"s"}) — ${Kh[V]||"reputation category"}`:`${Vo(V)}: no standing input`,children:Be?Ie>0?`+${Ie}`:Ie:"·"},V)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`team_lb_total ${(z.total||0)>0?"pos":(z.total||0)<0?"neg":""}`,children:(z.total||0)>0?`+${z.total}`:z.total||0}),Ti.map(V=>{var Be;const Se=(Be=z.axes)==null?void 0:Be[V.id],Ie=(Se==null?void 0:Se.score)||0;return e.jsx("span",{className:`team_lb_axis ${Ie>0?"pos":Ie<0?"neg":""}`,title:Se?`${V.label}: ${Se.up} up, ${Se.down} down`:`${V.label}: no votes`,children:Se?Ie>0?`+${Ie}`:Ie:"·"},V.id)}),(()=>{const V=z.messages,Se=V?V.up-V.down:0;return e.jsx("span",{className:`team_lb_axis ${Se>0?"pos":Se<0?"neg":""}`,title:V&&(V.up||V.down)?`Message ratings: ${V.up} rater(s) net-up, ${V.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:V&&(V.up||V.down)?`▲${V.up}${V.down?` ▼${V.down}`:""}`:"·"})})()]})]}),ms===z.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 ${vt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",vt||"operator",":"]}),Ti.map(V=>e.jsxs("span",{className:"team_lb_cast_axis",title:V.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:V.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!mr||z.target===vt,onClick:Se=>{Se.stopPropagation(),eo(z.target,V.id,1)},title:`+1 ${V.label} for ${z.target}`,children:e.jsx(Ue,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!mr||z.target===vt,onClick:Se=>{Se.stopPropagation(),eo(z.target,V.id,-1)},title:`-1 ${V.label} for ${z.target}`,children:e.jsx(Ue,{name:"thumbsDown",size:12})})]},V.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Zr,maxLength:280,onChange:V=>dr(V.target.value),onClick:V=>V.stopPropagation()}),Dn?e.jsx("div",{className:"team_lb_error",children:Dn}):null,Oi===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Oi.length===0?e.jsx("div",{className:"muted team_note",children:p?"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."}):Oi.map(V=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Qa(V.rater),"aria-hidden":"true",children:V.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:V.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:V.axis}),e.jsx(Ue,{name:V.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${V.value>0?"pos":"neg"}`,title:V.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:V.note,children:V.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${V.rater}:${V.axis}`))]}):null,ms===z.target&&wn==="hub"?e.jsx("div",{className:"team_lb_detail",children:e.jsx("div",{className:"muted team_note",children:p?"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]},z.target)),e.jsx("div",{className:"muted team_lb_footnote",children:p?"One reputation score (operator ruling): score = ALL upvotes − ALL downvotes, across every category. Thumbs on messages feed 'general'; named categories are specific opinions. Expand a row to cast opinions; self-votes refused.":"Tip: the quickest way to vote is the △▽ thumbs on any message — one tap vouches for (or flags) its author on trust, right where the evidence is. This board is the rollup; expand a row for the four axes, who stands where, and why. ±1 per rater per axis, revising replaces, self-votes refused."})]})})()})})]}):null,Et==="desk"?e.jsxs("div",{className:"pane team_drawer_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Operator desk"}),e.jsxs("span",{className:"pane_header_actions",style:{marginLeft:"auto",display:"inline-flex",gap:6},children:[e.jsx("button",{className:"btn",onClick:()=>void le(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[Y==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,Y===null&&te?e.jsx("div",{className:"muted team_note",children:te}):null,Y!==null&&Y!=="loading"?e.jsxs(e.Fragment,{children:[Y.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),Y.rows.map((p,b)=>{const N=Number(p.age_minutes),S=Number.isFinite(N)?N<60?`${Math.max(1,Math.round(N))}m`:N<2880?`${Math.round(N/60)}h`:`${Math.round(N/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(p.kind)==="ask"?"warn":""}`,children:String(p.kind||"ask")}),e.jsx("span",{className:"mono muted",children:String(p.who_waits||"?")}),e.jsx("span",{className:"muted",style:{marginLeft:"auto"},title:"Waiting since (oldest first)",children:S})]}),e.jsx("div",{className:"team_desk_row_what",children:String(p.what||"")}),p.one_action?e.jsxs("div",{className:"team_desk_row_needed muted",children:["→ ",String(p.one_action)]}):null,p.channel?e.jsx("button",{className:"team_row_expand",onClick:()=>{Qn.current={message_id:p.id?String(p.id):void 0,seq:Number(p.seq)||void 0},String(p.channel)===D?yr():be(String(p.channel)),Jn("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(p.id||p.key||b))}),Y.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:"}),Y.satisfied.map((p,b)=>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(p.who_waits||"")})]}),e.jsx("div",{className:"team_desk_row_what muted",children:String(p.what||"")})]},String(p.key||b)))]}):null]}):null]})]}):null,e.jsxs("div",{className:"team_drawer_rail",children:[u?e.jsx("button",{className:`team_drawer_tab ${Et==="assistant"?"active":""}`,onClick:()=>ss("assistant"),disabled:!D,"aria-pressed":Et==="assistant",title:"Channel assistant — ask an LLM about this channel (also: type /assistant in the composer)",children:"Assistant"}):null,e.jsx("button",{className:`team_drawer_tab ${Et==="members"?"active":""}`,onClick:()=>ss("members"),disabled:!D,"aria-pressed":Et==="members","aria-label":"Open channel members drawer",title:"Channel members — roster, moderation, and channel lifecycle",children:"Members"}),e.jsx("button",{className:`team_drawer_tab ${Et==="files"?"active":""}`,onClick:()=>ss("files"),disabled:!D,"aria-pressed":Et==="files","aria-label":"Open channel files drawer",title:"Channel files — browse this channel's virtual filesystem (/fs)",children:"Files"}),e.jsx("button",{className:`team_drawer_tab ${Et==="leaderboard"?"active":""}`,onClick:()=>ss("leaderboard"),disabled:!D,"aria-pressed":Et==="leaderboard","aria-label":"Open reputation leaderboard drawer",title:"Reputation leaderboard — trust, wisdom, thorough, helper; per-channel and hub-wide",children:"Leaderboard"}),(()=>{const p=Y!==null&&Y!=="loading"?Y:null,b=p?p.rows.length:0,N=p?p.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${Et==="desk"?"active":""}`,onClick:()=>ss("desk"),"aria-pressed":Et==="desk","aria-label":b?`Open the operator desk — ${b} 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",b?e.jsx("span",{className:"team_desk_tab_badge",children:b>99?"99+":b}):null,!b&&N?e.jsx("span",{className:"team_desk_tab_badge ok",title:"Satisfied queue items — waits you can close",children:N>99?"99+":N}):null]})})()]})]}),e.jsx(ij,{view:Sa,onClose:()=>Kt(null)})]})}const Jh=[{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"}],qd="abstractcontinuum_settings_v1";function wj(){try{const s=window.localStorage.getItem(qd)||"{}",n=JSON.parse(s);if(n&&(n.auth_token||n.gateway_url)){delete n.auth_token,delete n.gateway_url;try{window.localStorage.setItem(qd,JSON.stringify(n))}catch{}}return{maintenance_ai_provider:String((n==null?void 0:n.maintenance_ai_provider)||""),maintenance_ai_model:String((n==null?void 0:n.maintenance_ai_model)||""),maintenance_ai_reasoning:String((n==null?void 0:n.maintenance_ai_reasoning)||""),backlog_advisor_agent:String((n==null?void 0:n.backlog_advisor_agent)||""),default_execution_mode:(n==null?void 0:n.default_execution_mode)==="inplace"?"inplace":"uat"}}catch{return{maintenance_ai_provider:"",maintenance_ai_model:"",maintenance_ai_reasoning:"",backlog_advisor_agent:"",default_execution_mode:"uat"}}}const jj={app:"continuum",name:"AbstractContinuum"},kj=["How do I create a backlog task?","What does the Team page show?","How do managed processes work?"];function Sj(){var fe;const[s,n]=f.useState("board"),r=ug("(max-width: 1023.98px)"),[i,l]=f.useState(!1),u=f.useRef(null),m=f.useRef(null),d=f.useRef(!1);f.useEffect(()=>{r||l(!1)},[r]),f.useEffect(()=>{var ce,Ee;if(r){if(i){const se=window.setTimeout(()=>{var ie;const W=(ie=m.current)==null?void 0:ie.querySelector(".shell_nav_item.active, .shell_nav_item");W==null||W.focus()},0);return()=>window.clearTimeout(se)}d.current&&(document.activeElement===document.body||!document.activeElement||(ce=m.current)!=null&&ce.contains(document.activeElement))&&((Ee=u.current)==null||Ee.focus())}},[i,r]),f.useEffect(()=>{d.current=i},[i]);function h(ce){n(ce),l(!1)}const[x,v]=f.useState(null),[g,w]=f.useState(null),[L,A]=f.useState(()=>wj()),[$,T]=f.useState(!1),[B,O]=f.useState(!1),[M,P]=f.useState(0),[E,Q]=f.useState(!1),[oe,G]=f.useState(!1),[Ne,je]=f.useState(!1),[we,ve]=Ly("continuum"),[H,X]=f.useState(0),[Z,U]=f.useState(null),[Y,I]=f.useState("");f.useEffect(()=>{if(!Z)return;const ce=setTimeout(()=>U(null),8e3);return()=>clearTimeout(ce)},[Z]);const[te,ae]=f.useState(!1);f.useEffect(()=>{var Ce;const ce=((Ce=document.querySelector('script[type="module"][src*="assets/"]'))==null?void 0:Ce.getAttribute("src"))||"";if(!ce)return;let Ee=!1;async function se(){try{const Je=await fetch("./",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Je.ok)return;const ue=(await Je.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),ye=(ue==null?void 0:ue[1])||"";!Ee&&ye&&ce&&ye!==ce&&ae(!0)}catch{}}const W=()=>void se();window.addEventListener("focus",W);const ie=setInterval(()=>void se(),300*1e3);return se(),()=>{Ee=!0,window.removeEventListener("focus",W),clearInterval(ie)}},[]);function k(ce){I(String(ce||"")),n("executions")}f.useEffect(()=>{const ce=Ee=>{var se;Array.from(((se=Ee.dataTransfer)==null?void 0:se.types)||[]).includes("Files")&&Ee.preventDefault()};return window.addEventListener("dragover",ce),window.addEventListener("drop",ce),()=>{window.removeEventListener("dragover",ce),window.removeEventListener("drop",ce)}},[]);const[C,re]=f.useState(!1);f.useEffect(()=>{s==="team"&&re(!0)},[s]);function he(ce){var ie;const Ee=ce.target,se=(ie=Ee==null?void 0:Ee.closest)==null?void 0:ie.call(Ee,"a[href]");if(!se||se.target==="_blank"||se.hasAttribute("download"))return;const W=se.getAttribute("href")||"";W.startsWith("/")&&(ce.preventDefault(),window.open(W,"_blank","noopener"))}f.useEffect(()=>{try{window.localStorage.setItem(qd,JSON.stringify(L))}catch{}},[L]);const le=f.useMemo(()=>new zx({base_url:""}),[]),D=Zg({appName:"AbstractContinuum",connectionPath:Ri,onStatusChange:()=>P(ce=>ce+1)}),be=D.status,$e=f.useMemo(()=>by("abstractcontinuum",Lx),[]),[Oe,Re]=f.useState(mh),rt=f.useRef(0);function qe(){const ce=++rt.current;Re(mh),Dx(le).then(Ee=>{ce===rt.current&&Re(Ee)})}const it=f.useRef(0);f.useEffect(()=>{let ce=!1,Ee;return(async()=>{try{await le.list_processes(),ce||(it.current=0,T(!0))}catch{if(ce)return;it.current+=1,it.current>=2?T(!1):Ee=window.setTimeout(()=>{ce||P(se=>se+1)},2e3)}})(),()=>{ce=!0,Ee!==void 0&&window.clearTimeout(Ee)}},[le,s,M]);const Ge=f.useRef($);f.useEffect(()=>{Ge.current&&!$&&(be!=null&&be.has_session)&&D.refresh(),Ge.current=$},[$,be==null?void 0:be.has_session]);async function ct(ce,Ee){const se=[...Ee.history.map(ie=>({role:ie.role,content:ie.content})),{role:"user",content:ce}],W=await le.backlog_advisor({messages:se,agent:L.backlog_advisor_agent||null});return String((W==null?void 0:W.reply)||"").trim()||"(the advisor returned an empty reply)"}const et=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shell_brand",title:"AbstractContinuum — continuous development console",children:[e.jsx("span",{className:"shell_brand_mark",children:"∞"}),e.jsx("span",{className:"shell_brand_name",children:"Continuum"})]}),e.jsx("nav",{className:"shell_nav","aria-label":"Pages",children:Jh.map(ce=>e.jsxs("button",{className:`shell_nav_item ${s===ce.id?"active":""}`,onClick:()=>h(ce.id),title:ce.label,"aria-current":s===ce.id?"page":void 0,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(Ue,{name:ce.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:ce.label})]},ce.id))})]});return e.jsxs("div",{className:"shell",onClickCapture:he,children:[r?null:e.jsx("aside",{className:"shell_sidebar",children:et}),e.jsxs("div",{className:"shell_main",...r&&i?{inert:""}:{},children:[e.jsxs("header",{className:"shell_header",children:[r?e.jsx("button",{ref:u,type:"button",className:"btn btn_icon shell_menu_btn","aria-label":"Open navigation","aria-expanded":i,title:"Pages",onClick:()=>l(ce=>!ce),children:e.jsx(Ue,{name:"list",size:18})}):null,e.jsx("div",{className:"shell_header_title",children:((fe=Jh.find(ce=>ce.id===s))==null?void 0:fe.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(Oy,{docs:{open:oe,onToggle:()=>{G(ce=>!ce),Q(!1)},label:"Docs assistant"},assistant:{open:E,onToggle:()=>{Q(ce=>!ce),G(!1)}},appearance:{onOpen:()=>je(!0)},about:{identity:$e,versions:Oe,onOpen:qe},extraActions:e.jsxs("button",{className:"btn primary shell_newtask_btn",onClick:()=>O(!0),disabled:!$,"aria-label":"+ New task",title:"New task",children:["+",e.jsx("span",{className:"shell_newtask_label",children:" New task"})]}),connection:{phase:D.phase,signingOut:D.signingOut,onConnect:D.openModal,onDisconnect:()=>void D.signOut()}})})]}),!$&&s!=="settings"?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"Gateway unreachable or not signed in."}),e.jsx("button",{className:"btn",onClick:D.openModal,children:"Connect"})]}):null,D.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",D.signOutError," — the session may still be live."]})}):null,Z?e.jsxs("div",{className:`shell_banner ${Z.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:Z.text}),e.jsx("button",{className:"btn",onClick:()=>U(null),children:"Dismiss"})]}):null,te?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:[s==="board"?e.jsx(Ub,{gateway:le,gateway_connected:$,data_nonce:H,on_mutated:()=>X(ce=>ce+1),on_open_executions:k,default_execution_mode:L.default_execution_mode,query_preset:x,on_query_preset_consumed:()=>v(null),on_open_team:ce=>{w(ce),n("team")},on_new_task:()=>O(!0)}):null,s==="executions"?e.jsx(aw,{gateway:le,gateway_connected:$,focus_request_id:Y,on_focus_consumed:()=>I(""),on_open_settings:()=>n("settings")}):null,s==="backlog"?e.jsx(Eb,{gateway:le,gateway_connected:$,maintenance_ai_provider:L.maintenance_ai_provider,maintenance_ai_model:L.maintenance_ai_model,maintenance_ai_reasoning:L.maintenance_ai_reasoning,backlog_advisor_agent:L.backlog_advisor_agent,default_execution_mode:L.default_execution_mode,on_open_executions:k}):null,s==="agents"?e.jsx(sb,{gateway:le,gateway_connected:$,backlog_advisor_agent:L.backlog_advisor_agent,on_open_assistant:()=>Q(!0),on_open_team:()=>n("team"),on_open_executions:()=>k()}):null,C?e.jsx("div",{style:{display:s==="team"?"contents":"none"},children:e.jsx(t_,{fallback:ce=>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(ce.message||ce)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(bj,{gateway:le,gateway_connected:$,advisor:$?async(ce,Ee)=>{const se=[...Ee.map(ie=>({role:ie.role,content:ie.content})),{role:"user",content:ce}],W=await le.backlog_advisor({messages:se,agent:L.backlog_advisor_agent||null});return String((W==null?void 0:W.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:L.backlog_advisor_agent,on_open_board:ce=>{v(ce||null),n("board")},focus:g,on_focus_consumed:()=>w(null)})})}):null,s==="inbox"?e.jsx(cw,{gateway:le,gateway_connected:$,enable_triage:!0}):null,s==="services"?e.jsx(ow,{gateway:le,gateway_connected:$}):null,s==="settings"?e.jsx(ww,{gateway:le,gateway_connected:$,settings:L,set_settings:A,connection:be}):null]})]}),e.jsx(ay,{...D.modalProps}),r?e.jsx(Nd,{open:i,onClose:()=>l(!1),label:"Navigation",side:"left",backdrop:!0,width:260,className:"shell_nav_drawer",children:e.jsxs("div",{ref:m,className:"shell_nav_drawer_body",children:[et,e.jsx("button",{type:"button",className:"btn shell_nav_close",onClick:()=>l(!1),children:"Close menu"})]})}):null,e.jsx(Nd,{open:E,onClose:()=>Q(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(ix,{ask:ct,assistantName:"Continuum advisor",blockedNotice:$?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(Tx,{open:oe,onClose:()=>G(!1),source:jj,fetchGateway:le.fetch_gateway,connected:$,placeholder:"Ask about AbstractContinuum…",suggestions:kj,className:"continuum-docs-assistant"}),e.jsx(ip,{open:Ne,onClose:()=>je(!1),value:we,onChange:ve}),e.jsx(Tb,{open:B,gateway:le,can_use_gateway:$,maint_provider:L.maintenance_ai_provider,maint_model:L.maintenance_ai_model,maint_reasoning:L.maintenance_ai_reasoning,on_close:()=>O(!1),on_created:async(ce,Ee,se)=>{X(ie=>ie+1);const W=String(ce||"");n(W==="recurrent"?"backlog":"board"),U(se?{text:`Task created (${Ee}), but attachments failed: ${se}`,tone:"warn"}:{text:`Task created: ${Ee} (${W||"?"})${W==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}mg();const h_=document.getElementById("root");if(!h_)throw new Error("root element missing");rg.createRoot(h_).render(e.jsx(Bt.StrictMode,{children:e.jsx(Sj,{})}));export{Cw as _,Y_ as g};
135
- //# sourceMappingURL=index-CBYVkpsN.js.map