@abstractframework/observer 0.1.11 → 0.1.12

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.
@@ -0,0 +1,140 @@
1
+ var Jx=Object.defineProperty;var Zx=(e,t,n)=>t in e?Jx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Da=(e,t,n)=>Zx(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function n(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(a){if(a.ep)return;a.ep=!0;const c=n(a);fetch(a.href,c)}})();function B_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yh={exports:{}},pd={},vh={exports:{}},Bt={};/**
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 Sp;function Qx(){if(Sp)return Bt;Sp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function x($){return $===null||typeof $!="object"?null:($=v&&$[v]||$["@@iterator"],typeof $=="function"?$:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,S={};function L($,K,se){this.props=$,this.context=K,this.refs=S,this.updater=se||b}L.prototype.isReactComponent={},L.prototype.setState=function($,K){if(typeof $!="object"&&typeof $!="function"&&$!=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,"setState")},L.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function M(){}M.prototype=L.prototype;function W($,K,se){this.props=$,this.context=K,this.refs=S,this.updater=se||b}var q=W.prototype=new M;q.constructor=W,C(q,L.prototype),q.isPureReactComponent=!0;var z=Array.isArray,Y=Object.prototype.hasOwnProperty,Q={current:null},Z={key:!0,ref:!0,__self:!0,__source:!0};function ne($,K,se){var le,he={},be=null,je=null;if(K!=null)for(le in K.ref!==void 0&&(je=K.ref),K.key!==void 0&&(be=""+K.key),K)Y.call(K,le)&&!Z.hasOwnProperty(le)&&(he[le]=K[le]);var Ee=arguments.length-2;if(Ee===1)he.children=se;else if(1<Ee){for(var Fe=Array(Ee),Ye=0;Ye<Ee;Ye++)Fe[Ye]=arguments[Ye+2];he.children=Fe}if($&&$.defaultProps)for(le in Ee=$.defaultProps,Ee)he[le]===void 0&&(he[le]=Ee[le]);return{$$typeof:e,type:$,key:be,ref:je,props:he,_owner:Q.current}}function ue($,K){return{$$typeof:e,type:$.type,key:K,ref:$.ref,props:$.props,_owner:$._owner}}function de($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function pe($){var K={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(se){return K[se]})}var D=/\/+/g;function E($,K){return typeof $=="object"&&$!==null&&$.key!=null?pe(""+$.key):K.toString(36)}function j($,K,se,le,he){var be=typeof $;(be==="undefined"||be==="boolean")&&($=null);var je=!1;if($===null)je=!0;else switch(be){case"string":case"number":je=!0;break;case"object":switch($.$$typeof){case e:case t:je=!0}}if(je)return je=$,he=he(je),$=le===""?"."+E(je,0):le,z(he)?(se="",$!=null&&(se=$.replace(D,"$&/")+"/"),j(he,K,se,"",function(Ye){return Ye})):he!=null&&(de(he)&&(he=ue(he,se+(!he.key||je&&je.key===he.key?"":(""+he.key).replace(D,"$&/")+"/")+$)),K.push(he)),1;if(je=0,le=le===""?".":le+":",z($))for(var Ee=0;Ee<$.length;Ee++){be=$[Ee];var Fe=le+E(be,Ee);je+=j(be,K,se,Fe,he)}else if(Fe=x($),typeof Fe=="function")for($=Fe.call($),Ee=0;!(be=$.next()).done;)be=be.value,Fe=le+E(be,Ee++),je+=j(be,K,se,Fe,he);else if(be==="object")throw K=String($),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return je}function R($,K,se){if($==null)return $;var le=[],he=0;return j($,le,"","",function(be){return K.call(se,be,he++)}),le}function O($){if($._status===-1){var K=$._result;K=K(),K.then(function(se){($._status===0||$._status===-1)&&($._status=1,$._result=se)},function(se){($._status===0||$._status===-1)&&($._status=2,$._result=se)}),$._status===-1&&($._status=0,$._result=K)}if($._status===1)return $._result.default;throw $._result}var ee={current:null},I={transition:null},P={ReactCurrentDispatcher:ee,ReactCurrentBatchConfig:I,ReactCurrentOwner:Q};function G(){throw Error("act(...) is not supported in production builds of React.")}return Bt.Children={map:R,forEach:function($,K,se){R($,function(){K.apply(this,arguments)},se)},count:function($){var K=0;return R($,function(){K++}),K},toArray:function($){return R($,function(K){return K})||[]},only:function($){if(!de($))throw Error("React.Children.only expected to receive a single React element child.");return $}},Bt.Component=L,Bt.Fragment=n,Bt.Profiler=a,Bt.PureComponent=W,Bt.StrictMode=o,Bt.Suspense=m,Bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P,Bt.act=G,Bt.cloneElement=function($,K,se){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var le=C({},$.props),he=$.key,be=$.ref,je=$._owner;if(K!=null){if(K.ref!==void 0&&(be=K.ref,je=Q.current),K.key!==void 0&&(he=""+K.key),$.type&&$.type.defaultProps)var Ee=$.type.defaultProps;for(Fe in K)Y.call(K,Fe)&&!Z.hasOwnProperty(Fe)&&(le[Fe]=K[Fe]===void 0&&Ee!==void 0?Ee[Fe]:K[Fe])}var Fe=arguments.length-2;if(Fe===1)le.children=se;else if(1<Fe){Ee=Array(Fe);for(var Ye=0;Ye<Fe;Ye++)Ee[Ye]=arguments[Ye+2];le.children=Ee}return{$$typeof:e,type:$.type,key:he,ref:be,props:le,_owner:je}},Bt.createContext=function($){return $={$$typeof:d,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:c,_context:$},$.Consumer=$},Bt.createElement=ne,Bt.createFactory=function($){var K=ne.bind(null,$);return K.type=$,K},Bt.createRef=function(){return{current:null}},Bt.forwardRef=function($){return{$$typeof:u,render:$}},Bt.isValidElement=de,Bt.lazy=function($){return{$$typeof:g,_payload:{_status:-1,_result:$},_init:O}},Bt.memo=function($,K){return{$$typeof:y,type:$,compare:K===void 0?null:K}},Bt.startTransition=function($){var K=I.transition;I.transition={};try{$()}finally{I.transition=K}},Bt.unstable_act=G,Bt.useCallback=function($,K){return ee.current.useCallback($,K)},Bt.useContext=function($){return ee.current.useContext($)},Bt.useDebugValue=function(){},Bt.useDeferredValue=function($){return ee.current.useDeferredValue($)},Bt.useEffect=function($,K){return ee.current.useEffect($,K)},Bt.useId=function(){return ee.current.useId()},Bt.useImperativeHandle=function($,K,se){return ee.current.useImperativeHandle($,K,se)},Bt.useInsertionEffect=function($,K){return ee.current.useInsertionEffect($,K)},Bt.useLayoutEffect=function($,K){return ee.current.useLayoutEffect($,K)},Bt.useMemo=function($,K){return ee.current.useMemo($,K)},Bt.useReducer=function($,K,se){return ee.current.useReducer($,K,se)},Bt.useRef=function($){return ee.current.useRef($)},Bt.useState=function($){return ee.current.useState($)},Bt.useSyncExternalStore=function($,K,se){return ee.current.useSyncExternalStore($,K,se)},Bt.useTransition=function(){return ee.current.useTransition()},Bt.version="18.3.1",Bt}var jp;function Gd(){return jp||(jp=1,vh.exports=Qx()),vh.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 kp;function ew(){if(kp)return pd;kp=1;var e=Gd(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function d(u,m,y){var g,v={},x=null,b=null;y!==void 0&&(x=""+y),m.key!==void 0&&(x=""+m.key),m.ref!==void 0&&(b=m.ref);for(g in m)o.call(m,g)&&!c.hasOwnProperty(g)&&(v[g]=m[g]);if(u&&u.defaultProps)for(g in m=u.defaultProps,m)v[g]===void 0&&(v[g]=m[g]);return{$$typeof:t,type:u,key:x,ref:b,props:v,_owner:a.current}}return pd.Fragment=n,pd.jsx=d,pd.jsxs=d,pd}var Np;function tw(){return Np||(Np=1,yh.exports=ew()),yh.exports}var s=tw(),h=Gd();const ye=B_(h);var Gf={},xh={exports:{}},Ns={},wh={exports:{}},bh={};/**
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 Cp;function nw(){return Cp||(Cp=1,(function(e){function t(I,P){var G=I.length;I.push(P);e:for(;0<G;){var $=G-1>>>1,K=I[$];if(0<a(K,P))I[$]=P,I[G]=K,G=$;else break e}}function n(I){return I.length===0?null:I[0]}function o(I){if(I.length===0)return null;var P=I[0],G=I.pop();if(G!==P){I[0]=G;e:for(var $=0,K=I.length,se=K>>>1;$<se;){var le=2*($+1)-1,he=I[le],be=le+1,je=I[be];if(0>a(he,G))be<K&&0>a(je,he)?(I[$]=je,I[be]=G,$=be):(I[$]=he,I[le]=G,$=le);else if(be<K&&0>a(je,G))I[$]=je,I[be]=G,$=be;else break e}}return P}function a(I,P){var G=I.sortIndex-P.sortIndex;return G!==0?G:I.id-P.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,u=d.now();e.unstable_now=function(){return d.now()-u}}var m=[],y=[],g=1,v=null,x=3,b=!1,C=!1,S=!1,L=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,W=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function q(I){for(var P=n(y);P!==null;){if(P.callback===null)o(y);else if(P.startTime<=I)o(y),P.sortIndex=P.expirationTime,t(m,P);else break;P=n(y)}}function z(I){if(S=!1,q(I),!C)if(n(m)!==null)C=!0,O(Y);else{var P=n(y);P!==null&&ee(z,P.startTime-I)}}function Y(I,P){C=!1,S&&(S=!1,M(ne),ne=-1),b=!0;var G=x;try{for(q(P),v=n(m);v!==null&&(!(v.expirationTime>P)||I&&!pe());){var $=v.callback;if(typeof $=="function"){v.callback=null,x=v.priorityLevel;var K=$(v.expirationTime<=P);P=e.unstable_now(),typeof K=="function"?v.callback=K:v===n(m)&&o(m),q(P)}else o(m);v=n(m)}if(v!==null)var se=!0;else{var le=n(y);le!==null&&ee(z,le.startTime-P),se=!1}return se}finally{v=null,x=G,b=!1}}var Q=!1,Z=null,ne=-1,ue=5,de=-1;function pe(){return!(e.unstable_now()-de<ue)}function D(){if(Z!==null){var I=e.unstable_now();de=I;var P=!0;try{P=Z(!0,I)}finally{P?E():(Q=!1,Z=null)}}else Q=!1}var E;if(typeof W=="function")E=function(){W(D)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,R=j.port2;j.port1.onmessage=D,E=function(){R.postMessage(null)}}else E=function(){L(D,0)};function O(I){Z=I,Q||(Q=!0,E())}function ee(I,P){ne=L(function(){I(e.unstable_now())},P)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(I){I.callback=null},e.unstable_continueExecution=function(){C||b||(C=!0,O(Y))},e.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"):ue=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return n(m)},e.unstable_next=function(I){switch(x){case 1:case 2:case 3:var P=3;break;default:P=x}var G=x;x=P;try{return I()}finally{x=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,P){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var G=x;x=I;try{return P()}finally{x=G}},e.unstable_scheduleCallback=function(I,P,G){var $=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?$+G:$):G=$,I){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=G+K,I={id:g++,callback:P,priorityLevel:I,startTime:G,expirationTime:K,sortIndex:-1},G>$?(I.sortIndex=G,t(y,I),n(m)===null&&I===n(y)&&(S?(M(ne),ne=-1):S=!0,ee(z,G-$))):(I.sortIndex=K,t(m,I),C||b||(C=!0,O(Y))),I},e.unstable_shouldYield=pe,e.unstable_wrapCallback=function(I){var P=x;return function(){var G=x;x=P;try{return I.apply(this,arguments)}finally{x=G}}}})(bh)),bh}var Ep;function rw(){return Ep||(Ep=1,wh.exports=nw()),wh.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 $p;function sw(){if($p)return Ns;$p=1;var e=Gd(),t=rw();function n(r){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+r,l=1;l<arguments.length;l++)i+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,a={};function c(r,i){d(r,i),d(r+"Capture",i)}function d(r,i){for(a[r]=i,r=0;r<i.length;r++)o.add(i[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},v={};function x(r){return m.call(v,r)?!0:m.call(g,r)?!1:y.test(r)?v[r]=!0:(g[r]=!0,!1)}function b(r,i,l,f){if(l!==null&&l.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function C(r,i,l,f){if(i===null||typeof i>"u"||b(r,i,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function S(r,i,l,f,p,w,A){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=f,this.attributeNamespace=p,this.mustUseProperty=l,this.propertyName=r,this.type=i,this.sanitizeURL=w,this.removeEmptyString=A}var L={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){L[r]=new S(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var i=r[0];L[i]=new S(i,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){L[r]=new S(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){L[r]=new S(r,2,!1,r,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(r){L[r]=new S(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){L[r]=new S(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){L[r]=new S(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){L[r]=new S(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){L[r]=new S(r,5,!1,r.toLowerCase(),null,!1,!1)});var M=/[\-:]([a-z])/g;function W(r){return r[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(r){var i=r.replace(M,W);L[i]=new S(i,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var i=r.replace(M,W);L[i]=new S(i,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var i=r.replace(M,W);L[i]=new S(i,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){L[r]=new S(r,1,!1,r.toLowerCase(),null,!1,!1)}),L.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){L[r]=new S(r,1,!1,r.toLowerCase(),null,!0,!0)});function q(r,i,l,f){var p=L.hasOwnProperty(i)?L[i]:null;(p!==null?p.type!==0:f||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(C(i,l,p,f)&&(l=null),f||p===null?x(i)&&(l===null?r.removeAttribute(i):r.setAttribute(i,""+l)):p.mustUseProperty?r[p.propertyName]=l===null?p.type===3?!1:"":l:(i=p.attributeName,f=p.attributeNamespace,l===null?r.removeAttribute(i):(p=p.type,l=p===3||p===4&&l===!0?"":""+l,f?r.setAttributeNS(f,i,l):r.setAttribute(i,l))))}var z=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),Q=Symbol.for("react.portal"),Z=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),ue=Symbol.for("react.profiler"),de=Symbol.for("react.provider"),pe=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),ee=Symbol.for("react.offscreen"),I=Symbol.iterator;function P(r){return r===null||typeof r!="object"?null:(r=I&&r[I]||r["@@iterator"],typeof r=="function"?r:null)}var G=Object.assign,$;function K(r){if($===void 0)try{throw Error()}catch(l){var i=l.stack.trim().match(/\n( *(at )?)/);$=i&&i[1]||""}return`
34
+ `+$+r}var se=!1;function le(r,i){if(!r||se)return"";se=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(_e){var f=_e}Reflect.construct(r,[],i)}else{try{i.call()}catch(_e){f=_e}r.call(i.prototype)}else{try{throw Error()}catch(_e){f=_e}r()}}catch(_e){if(_e&&f&&typeof _e.stack=="string"){for(var p=_e.stack.split(`
35
+ `),w=f.stack.split(`
36
+ `),A=p.length-1,J=w.length-1;1<=A&&0<=J&&p[A]!==w[J];)J--;for(;1<=A&&0<=J;A--,J--)if(p[A]!==w[J]){if(A!==1||J!==1)do if(A--,J--,0>J||p[A]!==w[J]){var re=`
37
+ `+p[A].replace(" at new "," at ");return r.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",r.displayName)),re}while(1<=A&&0<=J);break}}}finally{se=!1,Error.prepareStackTrace=l}return(r=r?r.displayName||r.name:"")?K(r):""}function he(r){switch(r.tag){case 5:return K(r.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return r=le(r.type,!1),r;case 11:return r=le(r.type.render,!1),r;case 1:return r=le(r.type,!0),r;default:return""}}function be(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case Z:return"Fragment";case Q:return"Portal";case ue:return"Profiler";case ne:return"StrictMode";case E:return"Suspense";case j:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case pe:return(r.displayName||"Context")+".Consumer";case de:return(r._context.displayName||"Context")+".Provider";case D:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case R:return i=r.displayName||null,i!==null?i:be(r.type)||"Memo";case O:i=r._payload,r=r._init;try{return be(r(i))}catch{}}return null}function je(r){var i=r.type;switch(r.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=i.render,r=r.displayName||r.name||"",i.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(i);case 8:return i===ne?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function Ee(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Fe(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Ye(r){var i=Fe(r)?"checked":"value",l=Object.getOwnPropertyDescriptor(r.constructor.prototype,i),f=""+r[i];if(!r.hasOwnProperty(i)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var p=l.get,w=l.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return p.call(this)},set:function(A){f=""+A,w.call(this,A)}}),Object.defineProperty(r,i,{enumerable:l.enumerable}),{getValue:function(){return f},setValue:function(A){f=""+A},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Ke(r){r._valueTracker||(r._valueTracker=Ye(r))}function Ct(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var l=i.getValue(),f="";return r&&(f=Fe(r)?r.checked?"true":"false":r.value),r=f,r!==l?(i.setValue(r),!0):!1}function wt(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function at(r,i){var l=i.checked;return G({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??r._wrapperState.initialChecked})}function yt(r,i){var l=i.defaultValue==null?"":i.defaultValue,f=i.checked!=null?i.checked:i.defaultChecked;l=Ee(i.value!=null?i.value:l),r._wrapperState={initialChecked:f,initialValue:l,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function nt(r,i){i=i.checked,i!=null&&q(r,"checked",i,!1)}function Ne(r,i){nt(r,i);var l=Ee(i.value),f=i.type;if(l!=null)f==="number"?(l===0&&r.value===""||r.value!=l)&&(r.value=""+l):r.value!==""+l&&(r.value=""+l);else if(f==="submit"||f==="reset"){r.removeAttribute("value");return}i.hasOwnProperty("value")?st(r,i.type,l):i.hasOwnProperty("defaultValue")&&st(r,i.type,Ee(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(r.defaultChecked=!!i.defaultChecked)}function Oe(r,i,l){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var f=i.type;if(!(f!=="submit"&&f!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+r._wrapperState.initialValue,l||i===r.value||(r.value=i),r.defaultValue=i}l=r.name,l!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,l!==""&&(r.name=l)}function st(r,i,l){(i!=="number"||wt(r.ownerDocument)!==r)&&(l==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+l&&(r.defaultValue=""+l))}var ve=Array.isArray;function Ie(r,i,l,f){if(r=r.options,i){i={};for(var p=0;p<l.length;p++)i["$"+l[p]]=!0;for(l=0;l<r.length;l++)p=i.hasOwnProperty("$"+r[l].value),r[l].selected!==p&&(r[l].selected=p),p&&f&&(r[l].defaultSelected=!0)}else{for(l=""+Ee(l),i=null,p=0;p<r.length;p++){if(r[p].value===l){r[p].selected=!0,f&&(r[p].defaultSelected=!0);return}i!==null||r[p].disabled||(i=r[p])}i!==null&&(i.selected=!0)}}function Ge(r,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return G({},i,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function At(r,i){var l=i.value;if(l==null){if(l=i.children,i=i.defaultValue,l!=null){if(i!=null)throw Error(n(92));if(ve(l)){if(1<l.length)throw Error(n(93));l=l[0]}i=l}i==null&&(i=""),l=i}r._wrapperState={initialValue:Ee(l)}}function Ft(r,i){var l=Ee(i.value),f=Ee(i.defaultValue);l!=null&&(l=""+l,l!==r.value&&(r.value=l),i.defaultValue==null&&r.defaultValue!==l&&(r.defaultValue=l)),f!=null&&(r.defaultValue=""+f)}function fn(r){var i=r.textContent;i===r._wrapperState.initialValue&&i!==""&&i!==null&&(r.value=i)}function Dt(r){switch(r){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 Tt(r,i){return r==null||r==="http://www.w3.org/1999/xhtml"?Dt(i):r==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var mn,Vn=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,l,f,p){MSApp.execUnsafeLocalFunction(function(){return r(i,l,f,p)})}:r})(function(r,i){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=i;else{for(mn=mn||document.createElement("div"),mn.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=mn.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;i.firstChild;)r.appendChild(i.firstChild)}});function jt(r,i){if(i){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=i;return}}r.textContent=i}var hn={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},Un=["Webkit","ms","Moz","O"];Object.keys(hn).forEach(function(r){Un.forEach(function(i){i=i+r.charAt(0).toUpperCase()+r.substring(1),hn[i]=hn[r]})});function Nn(r,i,l){return i==null||typeof i=="boolean"||i===""?"":l||typeof i!="number"||i===0||hn.hasOwnProperty(r)&&hn[r]?(""+i).trim():i+"px"}function yn(r,i){r=r.style;for(var l in i)if(i.hasOwnProperty(l)){var f=l.indexOf("--")===0,p=Nn(l,i[l],f);l==="float"&&(l="cssFloat"),f?r.setProperty(l,p):r[l]=p}}var Cn=G({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 Qt(r,i){if(i){if(Cn[r]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function ar(r,i){if(r.indexOf("-")===-1)return typeof i.is=="string";switch(r){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 _n=null;function Hn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var vn=null,Pn=null,te=null;function ge(r){if(r=fl(r)){if(typeof vn!="function")throw Error(n(280));var i=r.stateNode;i&&(i=mc(i),vn(r.stateNode,r.type,i))}}function Te(r){Pn?te?te.push(r):te=[r]:Pn=r}function qe(){if(Pn){var r=Pn,i=te;if(te=Pn=null,ge(r),i)for(r=0;r<i.length;r++)ge(i[r])}}function He(r,i){return r(i)}function it(){}var pt=!1;function vt(r,i,l){if(pt)return r(i,l);pt=!0;try{return He(r,i,l)}finally{pt=!1,(Pn!==null||te!==null)&&(it(),qe())}}function Rt(r,i){var l=r.stateNode;if(l===null)return null;var f=mc(l);if(f===null)return null;l=f[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(r=r.type,f=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!f;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(n(231,i,typeof l));return l}var lt=!1;if(u)try{var Pt={};Object.defineProperty(Pt,"passive",{get:function(){lt=!0}}),window.addEventListener("test",Pt,Pt),window.removeEventListener("test",Pt,Pt)}catch{lt=!1}function Vt(r,i,l,f,p,w,A,J,re){var _e=Array.prototype.slice.call(arguments,3);try{i.apply(l,_e)}catch(Ae){this.onError(Ae)}}var ce=!1,kt=null,Lt=!1,Ve=null,nn={onError:function(r){ce=!0,kt=r}};function pn(r,i,l,f,p,w,A,J,re){ce=!1,kt=null,Vt.apply(nn,arguments)}function cn(r,i,l,f,p,w,A,J,re){if(pn.apply(this,arguments),ce){if(ce){var _e=kt;ce=!1,kt=null}else throw Error(n(198));Lt||(Lt=!0,Ve=_e)}}function gn(r){var i=r,l=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(l=i.return),r=i.return;while(r)}return i.tag===3?l:null}function er(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function Vr(r){if(gn(r)!==r)throw Error(n(188))}function Nr(r){var i=r.alternate;if(!i){if(i=gn(r),i===null)throw Error(n(188));return i!==r?null:r}for(var l=r,f=i;;){var p=l.return;if(p===null)break;var w=p.alternate;if(w===null){if(f=p.return,f!==null){l=f;continue}break}if(p.child===w.child){for(w=p.child;w;){if(w===l)return Vr(p),r;if(w===f)return Vr(p),i;w=w.sibling}throw Error(n(188))}if(l.return!==f.return)l=p,f=w;else{for(var A=!1,J=p.child;J;){if(J===l){A=!0,l=p,f=w;break}if(J===f){A=!0,f=p,l=w;break}J=J.sibling}if(!A){for(J=w.child;J;){if(J===l){A=!0,l=w,f=p;break}if(J===f){A=!0,f=w,l=p;break}J=J.sibling}if(!A)throw Error(n(189))}}if(l.alternate!==f)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?r:i}function Gr(r){return r=Nr(r),r!==null?Gs(r):null}function Gs(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var i=Gs(r);if(i!==null)return i;r=r.sibling}return null}var $s=t.unstable_scheduleCallback,vi=t.unstable_cancelCallback,Ys=t.unstable_shouldYield,Or=t.unstable_requestPaint,an=t.unstable_now,ra=t.unstable_getCurrentPriorityLevel,Yr=t.unstable_ImmediatePriority,Ms=t.unstable_UserBlockingPriority,As=t.unstable_NormalPriority,Ks=t.unstable_LowPriority,rt=t.unstable_IdlePriority,rn=null,Cr=null;function xi(r){if(Cr&&typeof Cr.onCommitFiberRoot=="function")try{Cr.onCommitFiberRoot(rn,r,void 0,(r.current.flags&128)===128)}catch{}}var _r=Math.clz32?Math.clz32:Za,sa=Math.log,Ja=Math.LN2;function Za(r){return r>>>=0,r===0?32:31-(sa(r)/Ja|0)|0}var Wn=64,as=4194304;function Gn(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Xs(r,i){var l=r.pendingLanes;if(l===0)return 0;var f=0,p=r.suspendedLanes,w=r.pingedLanes,A=l&268435455;if(A!==0){var J=A&~p;J!==0?f=Gn(J):(w&=A,w!==0&&(f=Gn(w)))}else A=l&~p,A!==0?f=Gn(A):w!==0&&(f=Gn(w));if(f===0)return 0;if(i!==0&&i!==f&&(i&p)===0&&(p=f&-f,w=i&-i,p>=w||p===16&&(w&4194240)!==0))return i;if((f&4)!==0&&(f|=l&16),i=r.entangledLanes,i!==0)for(r=r.entanglements,i&=f;0<i;)l=31-_r(i),p=1<<l,f|=r[l],i&=~p;return f}function ia(r,i){switch(r){case 1:case 2:case 4:return i+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 i+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 In(r,i){for(var l=r.suspendedLanes,f=r.pingedLanes,p=r.expirationTimes,w=r.pendingLanes;0<w;){var A=31-_r(w),J=1<<A,re=p[A];re===-1?((J&l)===0||(J&f)!==0)&&(p[A]=ia(J,i)):re<=i&&(r.expiredLanes|=J),w&=~J}}function ls(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Yn(){var r=Wn;return Wn<<=1,(Wn&4194240)===0&&(Wn=64),r}function cs(r){for(var i=[],l=0;31>l;l++)i.push(r);return i}function Fn(r,i,l){r.pendingLanes|=i,i!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,i=31-_r(i),r[i]=l}function us(r,i){var l=r.pendingLanes&~i;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=i,r.mutableReadLanes&=i,r.entangledLanes&=i,i=r.entanglements;var f=r.eventTimes;for(r=r.expirationTimes;0<l;){var p=31-_r(l),w=1<<p;i[p]=0,f[p]=-1,r[p]=-1,l&=~w}}function Js(r,i){var l=r.entangledLanes|=i;for(r=r.entanglements;l;){var f=31-_r(l),p=1<<f;p&i|r[f]&i&&(r[f]|=i),l&=~p}}var Yt=0;function go(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var oa,aa,zr,Qa,Zs,yo=!1,wi=[],tr=null,nr=null,Er=null,bi=new Map,ds=new Map,Ir=[],fs="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 el(r,i){switch(r){case"focusin":case"focusout":tr=null;break;case"dragenter":case"dragleave":nr=null;break;case"mouseover":case"mouseout":Er=null;break;case"pointerover":case"pointerout":bi.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(i.pointerId)}}function ms(r,i,l,f,p,w){return r===null||r.nativeEvent!==w?(r={blockedOn:i,domEventName:l,eventSystemFlags:f,nativeEvent:w,targetContainers:[p]},i!==null&&(i=fl(i),i!==null&&aa(i)),r):(r.eventSystemFlags|=f,i=r.targetContainers,p!==null&&i.indexOf(p)===-1&&i.push(p),r)}function Xl(r,i,l,f,p){switch(i){case"focusin":return tr=ms(tr,r,i,l,f,p),!0;case"dragenter":return nr=ms(nr,r,i,l,f,p),!0;case"mouseover":return Er=ms(Er,r,i,l,f,p),!0;case"pointerover":var w=p.pointerId;return bi.set(w,ms(bi.get(w)||null,r,i,l,f,p)),!0;case"gotpointercapture":return w=p.pointerId,ds.set(w,ms(ds.get(w)||null,r,i,l,f,p)),!0}return!1}function Qs(r){var i=no(r.target);if(i!==null){var l=gn(i);if(l!==null){if(i=l.tag,i===13){if(i=er(l),i!==null){r.blockedOn=i,Zs(r.priority,function(){zr(l)});return}}else if(i===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Zi(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var l=ae(r.domEventName,r.eventSystemFlags,i[0],r.nativeEvent);if(l===null){l=r.nativeEvent;var f=new l.constructor(l.type,l);_n=f,l.target.dispatchEvent(f),_n=null}else return i=fl(l),i!==null&&aa(i),r.blockedOn=l,!1;i.shift()}return!0}function la(r,i,l){Zi(r)&&l.delete(i)}function Si(){yo=!1,tr!==null&&Zi(tr)&&(tr=null),nr!==null&&Zi(nr)&&(nr=null),Er!==null&&Zi(Er)&&(Er=null),bi.forEach(la),ds.forEach(la)}function hs(r,i){r.blockedOn===i&&(r.blockedOn=null,yo||(yo=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Si)))}function vo(r){function i(p){return hs(p,r)}if(0<wi.length){hs(wi[0],r);for(var l=1;l<wi.length;l++){var f=wi[l];f.blockedOn===r&&(f.blockedOn=null)}}for(tr!==null&&hs(tr,r),nr!==null&&hs(nr,r),Er!==null&&hs(Er,r),bi.forEach(i),ds.forEach(i),l=0;l<Ir.length;l++)f=Ir[l],f.blockedOn===r&&(f.blockedOn=null);for(;0<Ir.length&&(l=Ir[0],l.blockedOn===null);)Qs(l),l.blockedOn===null&&Ir.shift()}var ei=z.ReactCurrentBatchConfig,pr=!0;function fu(r,i,l,f){var p=Yt,w=ei.transition;ei.transition=null;try{Yt=1,xo(r,i,l,f)}finally{Yt=p,ei.transition=w}}function Ts(r,i,l,f){var p=Yt,w=ei.transition;ei.transition=null;try{Yt=4,xo(r,i,l,f)}finally{Yt=p,ei.transition=w}}function xo(r,i,l,f){if(pr){var p=ae(r,i,l,f);if(p===null)pa(r,i,f,F,l),el(r,f);else if(Xl(p,r,i,l,f))f.stopPropagation();else if(el(r,f),i&4&&-1<fs.indexOf(r)){for(;p!==null;){var w=fl(p);if(w!==null&&oa(w),w=ae(r,i,l,f),w===null&&pa(r,i,f,F,l),w===p)break;p=w}p!==null&&f.stopPropagation()}else pa(r,i,f,null,l)}}var F=null;function ae(r,i,l,f){if(F=null,r=Hn(f),r=no(r),r!==null)if(i=gn(r),i===null)r=null;else if(l=i.tag,l===13){if(r=er(i),r!==null)return r;r=null}else if(l===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null);return F=r,null}function we(r){switch(r){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(ra()){case Yr:return 1;case Ms:return 4;case As:case Ks:return 16;case rt:return 536870912;default:return 16}default:return 16}}var ke=null,$e=null,We=null;function dt(){if(We)return We;var r,i=$e,l=i.length,f,p="value"in ke?ke.value:ke.textContent,w=p.length;for(r=0;r<l&&i[r]===p[r];r++);var A=l-r;for(f=1;f<=A&&i[l-f]===p[w-f];f++);return We=p.slice(r,1<f?1-f:void 0)}function tt(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function ct(){return!0}function Ot(){return!1}function Gt(r){function i(l,f,p,w,A){this._reactName=l,this._targetInst=p,this.type=f,this.nativeEvent=w,this.target=A,this.currentTarget=null;for(var J in r)r.hasOwnProperty(J)&&(l=r[J],this[J]=l?l(w):w[J]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?ct:Ot,this.isPropagationStopped=Ot,this}return G(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ct)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ct)},persist:function(){},isPersistent:ct}),i}var Kt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Et=Gt(Kt),en=G({},Kt,{view:0,detail:0}),En=Gt(en),un,Dr,Kn,ji=G({},en,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tc,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Kn&&(Kn&&r.type==="mousemove"?(un=r.screenX-Kn.screenX,Dr=r.screenY-Kn.screenY):Dr=un=0,Kn=r),un)},movementY:function(r){return"movementY"in r?r.movementY:Dr}}),ki=Gt(ji),wo=G({},ji,{dataTransfer:0}),bo=Gt(wo),mu=G({},en,{relatedTarget:0}),So=Gt(mu),tl=G({},Kt,{animationName:0,elapsedTime:0,pseudoElement:0}),Jl=Gt(tl),Zd=G({},Kt,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Zl=Gt(Zd),hu=G({},Kt,{data:0}),nl=Gt(hu),Ql={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ec={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"},Qd={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function jo(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=Qd[r])?!!i[r]:!1}function tc(){return jo}var _u=G({},en,{key:function(r){if(r.key){var i=Ql[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=tt(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?ec[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tc,charCode:function(r){return r.type==="keypress"?tt(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?tt(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),pu=Gt(_u),gu=G({},ji,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),nc=Gt(gu),Vm=G({},en,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tc}),yu=Gt(Vm),Gm=G({},Kt,{propertyName:0,elapsedTime:0,pseudoElement:0}),ef=Gt(Gm),vu=G({},ji,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Ht=Gt(vu),xu=[9,13,27,32],wu=u&&"CompositionEvent"in window,Ls=null;u&&"documentMode"in document&&(Ls=document.documentMode);var Ym=u&&"TextEvent"in window&&!Ls,rl=u&&(!wu||Ls&&8<Ls&&11>=Ls),tf=" ",rr=!1;function Rs(r,i){switch(r){case"keyup":return xu.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ca(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var ua=!1;function sl(r,i){switch(r){case"compositionend":return ca(i);case"keypress":return i.which!==32?null:(rr=!0,tf);case"textInput":return r=i.data,r===tf&&rr?null:r;default:return null}}function bu(r,i){if(ua)return r==="compositionend"||!wu&&Rs(r,i)?(r=dt(),We=$e=ke=null,ua=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return rl&&i.locale!=="ko"?null:i.data;default:return null}}var Km={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 Su(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!Km[r.type]:i==="textarea"}function rc(r,i,l,f){Te(f),i=Mi(i,"onChange"),0<i.length&&(l=new Et("onChange","change",null,l,f),r.push({event:l,listeners:i}))}var ko=null,da=null;function sc(r){Ni(r,0)}function il(r){var i=Lo(r);if(Ct(i))return r}function nf(r,i){if(r==="change")return i}var rf=!1;if(u){var fa;if(u){var ic="oninput"in document;if(!ic){var oc=document.createElement("div");oc.setAttribute("oninput","return;"),ic=typeof oc.oninput=="function"}fa=ic}else fa=!1;rf=fa&&(!document.documentMode||9<document.documentMode)}function sf(){ko&&(ko.detachEvent("onpropertychange",ac),da=ko=null)}function ac(r){if(r.propertyName==="value"&&il(da)){var i=[];rc(i,da,r,Hn(r)),vt(sc,i)}}function Xm(r,i,l){r==="focusin"?(sf(),ko=i,da=l,ko.attachEvent("onpropertychange",ac)):r==="focusout"&&sf()}function of(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return il(da)}function Jm(r,i){if(r==="click")return il(i)}function ju(r,i){if(r==="input"||r==="change")return il(i)}function Zm(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Kr=typeof Object.is=="function"?Object.is:Zm;function ol(r,i){if(Kr(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var l=Object.keys(r),f=Object.keys(i);if(l.length!==f.length)return!1;for(f=0;f<l.length;f++){var p=l[f];if(!m.call(i,p)||!Kr(r[p],i[p]))return!1}return!0}function af(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function lf(r,i){var l=af(r);r=0;for(var f;l;){if(l.nodeType===3){if(f=r+l.textContent.length,r<=i&&f>=i)return{node:l,offset:i-r};r=f}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=af(l)}}function No(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?No(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function ku(){for(var r=window,i=wt();i instanceof r.HTMLIFrameElement;){try{var l=typeof i.contentWindow.location.href=="string"}catch{l=!1}if(l)r=i.contentWindow;else break;i=wt(r.document)}return i}function ma(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}function Qm(r){var i=ku(),l=r.focusedElem,f=r.selectionRange;if(i!==l&&l&&l.ownerDocument&&No(l.ownerDocument.documentElement,l)){if(f!==null&&ma(l)){if(i=f.start,r=f.end,r===void 0&&(r=i),"selectionStart"in l)l.selectionStart=i,l.selectionEnd=Math.min(r,l.value.length);else if(r=(i=l.ownerDocument||document)&&i.defaultView||window,r.getSelection){r=r.getSelection();var p=l.textContent.length,w=Math.min(f.start,p);f=f.end===void 0?w:Math.min(f.end,p),!r.extend&&w>f&&(p=f,f=w,w=p),p=lf(l,w);var A=lf(l,f);p&&A&&(r.rangeCount!==1||r.anchorNode!==p.node||r.anchorOffset!==p.offset||r.focusNode!==A.node||r.focusOffset!==A.offset)&&(i=i.createRange(),i.setStart(p.node,p.offset),r.removeAllRanges(),w>f?(r.addRange(i),r.extend(A.node,A.offset)):(i.setEnd(A.node,A.offset),r.addRange(i)))}}for(i=[],r=l;r=r.parentNode;)r.nodeType===1&&i.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<i.length;l++)r=i[l],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var lc=u&&"documentMode"in document&&11>=document.documentMode,Ps=null,Co=null,ti=null,Eo=!1;function al(r,i,l){var f=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Eo||Ps==null||Ps!==wt(f)||(f=Ps,"selectionStart"in f&&ma(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),ti&&ol(ti,f)||(ti=f,f=Mi(Co,"onSelect"),0<f.length&&(i=new Et("onSelect","select",null,i,l),r.push({event:i,listeners:f}),i.target=Ps)))}function ha(r,i){var l={};return l[r.toLowerCase()]=i.toLowerCase(),l["Webkit"+r]="webkit"+i,l["Moz"+r]="moz"+i,l}var $o={animationend:ha("Animation","AnimationEnd"),animationiteration:ha("Animation","AnimationIteration"),animationstart:ha("Animation","AnimationStart"),transitionend:ha("Transition","TransitionEnd")},Mo={},Nu={};u&&(Nu=document.createElement("div").style,"AnimationEvent"in window||(delete $o.animationend.animation,delete $o.animationiteration.animation,delete $o.animationstart.animation),"TransitionEvent"in window||delete $o.transitionend.transition);function Qi(r){if(Mo[r])return Mo[r];if(!$o[r])return r;var i=$o[r],l;for(l in i)if(i.hasOwnProperty(l)&&l in Nu)return Mo[r]=i[l];return r}var ll=Qi("animationend"),cf=Qi("animationiteration"),Cu=Qi("animationstart"),uf=Qi("transitionend"),df=new Map,cl="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 gr(r,i){df.set(r,i),c(i,[r])}for(var eo=0;eo<cl.length;eo++){var Eu=cl[eo],cc=Eu.toLowerCase(),eh=Eu[0].toUpperCase()+Eu.slice(1);gr(cc,"on"+eh)}gr(ll,"onAnimationEnd"),gr(cf,"onAnimationIteration"),gr(Cu,"onAnimationStart"),gr("dblclick","onDoubleClick"),gr("focusin","onFocus"),gr("focusout","onBlur"),gr(uf,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),c("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),c("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),c("onBeforeInput",["compositionend","keypress","textInput","paste"]),c("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),c("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ao="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(" "),ul=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ao));function Xr(r,i,l){var f=r.type||"unknown-event";r.currentTarget=l,cn(f,i,void 0,r),r.currentTarget=null}function Ni(r,i){i=(i&4)!==0;for(var l=0;l<r.length;l++){var f=r[l],p=f.event;f=f.listeners;e:{var w=void 0;if(i)for(var A=f.length-1;0<=A;A--){var J=f[A],re=J.instance,_e=J.currentTarget;if(J=J.listener,re!==w&&p.isPropagationStopped())break e;Xr(p,J,_e),w=re}else for(A=0;A<f.length;A++){if(J=f[A],re=J.instance,_e=J.currentTarget,J=J.listener,re!==w&&p.isPropagationStopped())break e;Xr(p,J,_e),w=re}}}if(Lt)throw r=Ve,Lt=!1,Ve=null,r}function dn(r,i){var l=i[Mu];l===void 0&&(l=i[Mu]=new Set);var f=r+"__bubble";l.has(f)||(ni(i,r,2,!1),l.add(f))}function Ci(r,i,l){var f=0;i&&(f|=4),ni(l,r,f,i)}var _a="_reactListening"+Math.random().toString(36).slice(2);function Ei(r){if(!r[_a]){r[_a]=!0,o.forEach(function(l){l!=="selectionchange"&&(ul.has(l)||Ci(l,!1,r),Ci(l,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[_a]||(i[_a]=!0,Ci("selectionchange",!1,i))}}function ni(r,i,l,f){switch(we(i)){case 1:var p=fu;break;case 4:p=Ts;break;default:p=xo}l=p.bind(null,i,l,r),p=void 0,!lt||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(p=!0),f?p!==void 0?r.addEventListener(i,l,{capture:!0,passive:p}):r.addEventListener(i,l,!0):p!==void 0?r.addEventListener(i,l,{passive:p}):r.addEventListener(i,l,!1)}function pa(r,i,l,f,p){var w=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var A=f.tag;if(A===3||A===4){var J=f.stateNode.containerInfo;if(J===p||J.nodeType===8&&J.parentNode===p)break;if(A===4)for(A=f.return;A!==null;){var re=A.tag;if((re===3||re===4)&&(re=A.stateNode.containerInfo,re===p||re.nodeType===8&&re.parentNode===p))return;A=A.return}for(;J!==null;){if(A=no(J),A===null)return;if(re=A.tag,re===5||re===6){f=w=A;continue e}J=J.parentNode}}f=f.return}vt(function(){var _e=w,Ae=Hn(l),Le=[];e:{var Me=df.get(r);if(Me!==void 0){var Xe=Et,Ze=r;switch(r){case"keypress":if(tt(l)===0)break e;case"keydown":case"keyup":Xe=pu;break;case"focusin":Ze="focus",Xe=So;break;case"focusout":Ze="blur",Xe=So;break;case"beforeblur":case"afterblur":Xe=So;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Xe=ki;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Xe=bo;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Xe=yu;break;case ll:case cf:case Cu:Xe=Jl;break;case uf:Xe=ef;break;case"scroll":Xe=En;break;case"wheel":Xe=Ht;break;case"copy":case"cut":case"paste":Xe=Zl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Xe=nc}var Qe=(i&4)!==0,Qn=!Qe&&r==="scroll",fe=Qe?Me!==null?Me+"Capture":null:Me;Qe=[];for(var oe=_e,me;oe!==null;){me=oe;var De=me.stateNode;if(me.tag===5&&De!==null&&(me=De,fe!==null&&(De=Rt(oe,fe),De!=null&&Qe.push($i(oe,De,me)))),Qn)break;oe=oe.return}0<Qe.length&&(Me=new Xe(Me,Ze,null,l,Ae),Le.push({event:Me,listeners:Qe}))}}if((i&7)===0){e:{if(Me=r==="mouseover"||r==="pointerover",Xe=r==="mouseout"||r==="pointerout",Me&&l!==_n&&(Ze=l.relatedTarget||l.fromElement)&&(no(Ze)||Ze[ii]))break e;if((Xe||Me)&&(Me=Ae.window===Ae?Ae:(Me=Ae.ownerDocument)?Me.defaultView||Me.parentWindow:window,Xe?(Ze=l.relatedTarget||l.toElement,Xe=_e,Ze=Ze?no(Ze):null,Ze!==null&&(Qn=gn(Ze),Ze!==Qn||Ze.tag!==5&&Ze.tag!==6)&&(Ze=null)):(Xe=null,Ze=_e),Xe!==Ze)){if(Qe=ki,De="onMouseLeave",fe="onMouseEnter",oe="mouse",(r==="pointerout"||r==="pointerover")&&(Qe=nc,De="onPointerLeave",fe="onPointerEnter",oe="pointer"),Qn=Xe==null?Me:Lo(Xe),me=Ze==null?Me:Lo(Ze),Me=new Qe(De,oe+"leave",Xe,l,Ae),Me.target=Qn,Me.relatedTarget=me,De=null,no(Ae)===_e&&(Qe=new Qe(fe,oe+"enter",Ze,l,Ae),Qe.target=me,Qe.relatedTarget=Qn,De=Qe),Qn=De,Xe&&Ze)t:{for(Qe=Xe,fe=Ze,oe=0,me=Qe;me;me=Jr(me))oe++;for(me=0,De=fe;De;De=Jr(De))me++;for(;0<oe-me;)Qe=Jr(Qe),oe--;for(;0<me-oe;)fe=Jr(fe),me--;for(;oe--;){if(Qe===fe||fe!==null&&Qe===fe.alternate)break t;Qe=Jr(Qe),fe=Jr(fe)}Qe=null}else Qe=null;Xe!==null&&$r(Le,Me,Xe,Qe,!1),Ze!==null&&Qn!==null&&$r(Le,Qn,Ze,Qe,!0)}}e:{if(Me=_e?Lo(_e):window,Xe=Me.nodeName&&Me.nodeName.toLowerCase(),Xe==="select"||Xe==="input"&&Me.type==="file")var et=nf;else if(Su(Me))if(rf)et=ju;else{et=of;var mt=Xm}else(Xe=Me.nodeName)&&Xe.toLowerCase()==="input"&&(Me.type==="checkbox"||Me.type==="radio")&&(et=Jm);if(et&&(et=et(r,_e))){rc(Le,et,l,Ae);break e}mt&&mt(r,Me,_e),r==="focusout"&&(mt=Me._wrapperState)&&mt.controlled&&Me.type==="number"&&st(Me,"number",Me.value)}switch(mt=_e?Lo(_e):window,r){case"focusin":(Su(mt)||mt.contentEditable==="true")&&(Ps=mt,Co=_e,ti=null);break;case"focusout":ti=Co=Ps=null;break;case"mousedown":Eo=!0;break;case"contextmenu":case"mouseup":case"dragend":Eo=!1,al(Le,l,Ae);break;case"selectionchange":if(lc)break;case"keydown":case"keyup":al(Le,l,Ae)}var ht;if(wu)e:{switch(r){case"compositionstart":var St="onCompositionStart";break e;case"compositionend":St="onCompositionEnd";break e;case"compositionupdate":St="onCompositionUpdate";break e}St=void 0}else ua?Rs(r,l)&&(St="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(St="onCompositionStart");St&&(rl&&l.locale!=="ko"&&(ua||St!=="onCompositionStart"?St==="onCompositionEnd"&&ua&&(ht=dt()):(ke=Ae,$e="value"in ke?ke.value:ke.textContent,ua=!0)),mt=Mi(_e,St),0<mt.length&&(St=new nl(St,r,null,l,Ae),Le.push({event:St,listeners:mt}),ht?St.data=ht:(ht=ca(l),ht!==null&&(St.data=ht)))),(ht=Ym?sl(r,l):bu(r,l))&&(_e=Mi(_e,"onBeforeInput"),0<_e.length&&(Ae=new nl("onBeforeInput","beforeinput",null,l,Ae),Le.push({event:Ae,listeners:_e}),Ae.data=ht))}Ni(Le,i)})}function $i(r,i,l){return{instance:r,listener:i,currentTarget:l}}function Mi(r,i){for(var l=i+"Capture",f=[];r!==null;){var p=r,w=p.stateNode;p.tag===5&&w!==null&&(p=w,w=Rt(r,l),w!=null&&f.unshift($i(r,w,p)),w=Rt(r,i),w!=null&&f.push($i(r,w,p))),r=r.return}return f}function Jr(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function $r(r,i,l,f,p){for(var w=i._reactName,A=[];l!==null&&l!==f;){var J=l,re=J.alternate,_e=J.stateNode;if(re!==null&&re===f)break;J.tag===5&&_e!==null&&(J=_e,p?(re=Rt(l,w),re!=null&&A.unshift($i(l,re,J))):p||(re=Rt(l,w),re!=null&&A.push($i(l,re,J)))),l=l.return}A.length!==0&&r.push({event:i,listeners:A})}var To=/\r\n?/g,ga=/\u0000|\uFFFD/g;function dl(r){return(typeof r=="string"?r:""+r).replace(To,`
38
+ `).replace(ga,"")}function ri(r,i,l){if(i=dl(i),dl(r)!==i&&l)throw Error(n(425))}function ya(){}var va=null,_s=null;function si(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var ps=typeof setTimeout=="function"?setTimeout:void 0,ff=typeof clearTimeout=="function"?clearTimeout:void 0,uc=typeof Promise=="function"?Promise:void 0,th=typeof queueMicrotask=="function"?queueMicrotask:typeof uc<"u"?function(r){return uc.resolve(null).then(r).catch(dc)}:ps;function dc(r){setTimeout(function(){throw r})}function fc(r,i){var l=i,f=0;do{var p=l.nextSibling;if(r.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"){if(f===0){r.removeChild(p),vo(i);return}f--}else l!=="$"&&l!=="$?"&&l!=="$!"||f++;l=p}while(l);vo(i)}function gs(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return r}function $u(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"){if(i===0)return r;i--}else l==="/$"&&i++}r=r.previousSibling}return null}var to=Math.random().toString(36).slice(2),Os="__reactFiber$"+to,xa="__reactProps$"+to,ii="__reactContainer$"+to,Mu="__reactEvents$"+to,mf="__reactListeners$"+to,nh="__reactHandles$"+to;function no(r){var i=r[Os];if(i)return i;for(var l=r.parentNode;l;){if(i=l[ii]||l[Os]){if(l=i.alternate,i.child!==null||l!==null&&l.child!==null)for(r=$u(r);r!==null;){if(l=r[Os])return l;r=$u(r)}return i}r=l,l=r.parentNode}return null}function fl(r){return r=r[Os]||r[ii],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Lo(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function mc(r){return r[xa]||null}var hc=[],wa=-1;function Ai(r){return{current:r}}function ln(r){0>wa||(r.current=hc[wa],hc[wa]=null,wa--)}function xn(r,i){wa++,hc[wa]=r.current,r.current=i}var ys={},sr=Ai(ys),lr=Ai(!1),ro=ys;function zs(r,i){var l=r.type.contextTypes;if(!l)return ys;var f=r.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===i)return f.__reactInternalMemoizedMaskedChildContext;var p={},w;for(w in l)p[w]=i[w];return f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=i,r.__reactInternalMemoizedMaskedChildContext=p),p}function Fr(r){return r=r.childContextTypes,r!=null}function Ro(){ln(lr),ln(sr)}function hf(r,i,l){if(sr.current!==ys)throw Error(n(168));xn(sr,i),xn(lr,l)}function Po(r,i,l){var f=r.stateNode;if(i=i.childContextTypes,typeof f.getChildContext!="function")return l;f=f.getChildContext();for(var p in f)if(!(p in i))throw Error(n(108,je(r)||"Unknown",p));return G({},l,f)}function _c(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||ys,ro=sr.current,xn(sr,r),xn(lr,lr.current),!0}function ml(r,i,l){var f=r.stateNode;if(!f)throw Error(n(169));l?(r=Po(r,i,ro),f.__reactInternalMemoizedMergedChildContext=r,ln(lr),ln(sr),xn(sr,r)):ln(lr),xn(lr,l)}var Ti=null,Is=!1,pc=!1;function ba(r){Ti===null?Ti=[r]:Ti.push(r)}function hl(r){Is=!0,ba(r)}function Li(){if(!pc&&Ti!==null){pc=!0;var r=0,i=Yt;try{var l=Ti;for(Yt=1;r<l.length;r++){var f=l[r];do f=f(!0);while(f!==null)}Ti=null,Is=!1}catch(p){throw Ti!==null&&(Ti=Ti.slice(r+1)),$s(Yr,Li),p}finally{Yt=i,pc=!1}}return null}var so=[],oi=0,Sa=null,Ri=0,Br=[],vs=0,ai=null,li=1,Pi="";function Oo(r,i){so[oi++]=Ri,so[oi++]=Sa,Sa=r,Ri=i}function io(r,i,l){Br[vs++]=li,Br[vs++]=Pi,Br[vs++]=ai,ai=r;var f=li;r=Pi;var p=32-_r(f)-1;f&=~(1<<p),l+=1;var w=32-_r(i)+p;if(30<w){var A=p-p%5;w=(f&(1<<A)-1).toString(32),f>>=A,p-=A,li=1<<32-_r(i)+p|l<<p|f,Pi=w+r}else li=1<<w|l<<p|f,Pi=r}function cr(r){r.return!==null&&(Oo(r,1),io(r,1,0))}function ja(r){for(;r===Sa;)Sa=so[--oi],so[oi]=null,Ri=so[--oi],so[oi]=null;for(;r===ai;)ai=Br[--vs],Br[vs]=null,Pi=Br[--vs],Br[vs]=null,li=Br[--vs],Br[vs]=null}var Mr=null,Zr=null,$n=!1,Ur=null;function _f(r,i){var l=hi(5,null,null,0);l.elementType="DELETED",l.stateNode=i,l.return=r,i=r.deletions,i===null?(r.deletions=[l],r.flags|=16):i.push(l)}function ka(r,i){switch(r.tag){case 5:var l=r.type;return i=i.nodeType!==1||l.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(r.stateNode=i,Mr=r,Zr=gs(i.firstChild),!0):!1;case 6:return i=r.pendingProps===""||i.nodeType!==3?null:i,i!==null?(r.stateNode=i,Mr=r,Zr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(l=ai!==null?{id:li,overflow:Pi}:null,r.memoizedState={dehydrated:i,treeContext:l,retryLane:1073741824},l=hi(18,null,null,0),l.stateNode=i,l.return=r,r.child=l,Mr=r,Zr=null,!0):!1;default:return!1}}function gc(r){return(r.mode&1)!==0&&(r.flags&128)===0}function zo(r){if($n){var i=Zr;if(i){var l=i;if(!ka(r,i)){if(gc(r))throw Error(n(418));i=gs(l.nextSibling);var f=Mr;i&&ka(r,i)?_f(f,l):(r.flags=r.flags&-4097|2,$n=!1,Mr=r)}}else{if(gc(r))throw Error(n(418));r.flags=r.flags&-4097|2,$n=!1,Mr=r}}}function Au(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Mr=r}function _l(r){if(r!==Mr)return!1;if(!$n)return Au(r),$n=!0,!1;var i;if((i=r.tag!==3)&&!(i=r.tag!==5)&&(i=r.type,i=i!=="head"&&i!=="body"&&!si(r.type,r.memoizedProps)),i&&(i=Zr)){if(gc(r))throw pf(),Error(n(418));for(;i;)_f(r,i),i=gs(i.nextSibling)}if(Au(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"){if(i===0){Zr=gs(r.nextSibling);break e}i--}else l!=="$"&&l!=="$!"&&l!=="$?"||i++}r=r.nextSibling}Zr=null}}else Zr=Mr?gs(r.stateNode.nextSibling):null;return!0}function pf(){for(var r=Zr;r;)r=gs(r.nextSibling)}function Io(){Zr=Mr=null,$n=!1}function yc(r){Ur===null?Ur=[r]:Ur.push(r)}var gf=z.ReactCurrentBatchConfig;function pl(r,i,l){if(r=l.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var f=l.stateNode}if(!f)throw Error(n(147,r));var p=f,w=""+r;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===w?i.ref:(i=function(A){var J=p.refs;A===null?delete J[w]:J[w]=A},i._stringRef=w,i)}if(typeof r!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,r))}return r}function gl(r,i){throw r=Object.prototype.toString.call(i),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r))}function yl(r){var i=r._init;return i(r._payload)}function yf(r){function i(fe,oe){if(r){var me=fe.deletions;me===null?(fe.deletions=[oe],fe.flags|=16):me.push(oe)}}function l(fe,oe){if(!r)return null;for(;oe!==null;)i(fe,oe),oe=oe.sibling;return null}function f(fe,oe){for(fe=new Map;oe!==null;)oe.key!==null?fe.set(oe.key,oe):fe.set(oe.index,oe),oe=oe.sibling;return fe}function p(fe,oe){return fe=za(fe,oe),fe.index=0,fe.sibling=null,fe}function w(fe,oe,me){return fe.index=me,r?(me=fe.alternate,me!==null?(me=me.index,me<oe?(fe.flags|=2,oe):me):(fe.flags|=2,oe)):(fe.flags|=1048576,oe)}function A(fe){return r&&fe.alternate===null&&(fe.flags|=2),fe}function J(fe,oe,me,De){return oe===null||oe.tag!==6?(oe=fh(me,fe.mode,De),oe.return=fe,oe):(oe=p(oe,me),oe.return=fe,oe)}function re(fe,oe,me,De){var et=me.type;return et===Z?Ae(fe,oe,me.props.children,De,me.key):oe!==null&&(oe.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===O&&yl(et)===oe.type)?(De=p(oe,me.props),De.ref=pl(fe,oe,me),De.return=fe,De):(De=Df(me.type,me.key,me.props,null,fe.mode,De),De.ref=pl(fe,oe,me),De.return=fe,De)}function _e(fe,oe,me,De){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==me.containerInfo||oe.stateNode.implementation!==me.implementation?(oe=mh(me,fe.mode,De),oe.return=fe,oe):(oe=p(oe,me.children||[]),oe.return=fe,oe)}function Ae(fe,oe,me,De,et){return oe===null||oe.tag!==7?(oe=Ol(me,fe.mode,De,et),oe.return=fe,oe):(oe=p(oe,me),oe.return=fe,oe)}function Le(fe,oe,me){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=fh(""+oe,fe.mode,me),oe.return=fe,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case Y:return me=Df(oe.type,oe.key,oe.props,null,fe.mode,me),me.ref=pl(fe,null,oe),me.return=fe,me;case Q:return oe=mh(oe,fe.mode,me),oe.return=fe,oe;case O:var De=oe._init;return Le(fe,De(oe._payload),me)}if(ve(oe)||P(oe))return oe=Ol(oe,fe.mode,me,null),oe.return=fe,oe;gl(fe,oe)}return null}function Me(fe,oe,me,De){var et=oe!==null?oe.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return et!==null?null:J(fe,oe,""+me,De);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case Y:return me.key===et?re(fe,oe,me,De):null;case Q:return me.key===et?_e(fe,oe,me,De):null;case O:return et=me._init,Me(fe,oe,et(me._payload),De)}if(ve(me)||P(me))return et!==null?null:Ae(fe,oe,me,De,null);gl(fe,me)}return null}function Xe(fe,oe,me,De,et){if(typeof De=="string"&&De!==""||typeof De=="number")return fe=fe.get(me)||null,J(oe,fe,""+De,et);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case Y:return fe=fe.get(De.key===null?me:De.key)||null,re(oe,fe,De,et);case Q:return fe=fe.get(De.key===null?me:De.key)||null,_e(oe,fe,De,et);case O:var mt=De._init;return Xe(fe,oe,me,mt(De._payload),et)}if(ve(De)||P(De))return fe=fe.get(me)||null,Ae(oe,fe,De,et,null);gl(oe,De)}return null}function Ze(fe,oe,me,De){for(var et=null,mt=null,ht=oe,St=oe=0,Sr=null;ht!==null&&St<me.length;St++){ht.index>St?(Sr=ht,ht=null):Sr=ht.sibling;var sn=Me(fe,ht,me[St],De);if(sn===null){ht===null&&(ht=Sr);break}r&&ht&&sn.alternate===null&&i(fe,ht),oe=w(sn,oe,St),mt===null?et=sn:mt.sibling=sn,mt=sn,ht=Sr}if(St===me.length)return l(fe,ht),$n&&Oo(fe,St),et;if(ht===null){for(;St<me.length;St++)ht=Le(fe,me[St],De),ht!==null&&(oe=w(ht,oe,St),mt===null?et=ht:mt.sibling=ht,mt=ht);return $n&&Oo(fe,St),et}for(ht=f(fe,ht);St<me.length;St++)Sr=Xe(ht,fe,St,me[St],De),Sr!==null&&(r&&Sr.alternate!==null&&ht.delete(Sr.key===null?St:Sr.key),oe=w(Sr,oe,St),mt===null?et=Sr:mt.sibling=Sr,mt=Sr);return r&&ht.forEach(function(Ia){return i(fe,Ia)}),$n&&Oo(fe,St),et}function Qe(fe,oe,me,De){var et=P(me);if(typeof et!="function")throw Error(n(150));if(me=et.call(me),me==null)throw Error(n(151));for(var mt=et=null,ht=oe,St=oe=0,Sr=null,sn=me.next();ht!==null&&!sn.done;St++,sn=me.next()){ht.index>St?(Sr=ht,ht=null):Sr=ht.sibling;var Ia=Me(fe,ht,sn.value,De);if(Ia===null){ht===null&&(ht=Sr);break}r&&ht&&Ia.alternate===null&&i(fe,ht),oe=w(Ia,oe,St),mt===null?et=Ia:mt.sibling=Ia,mt=Ia,ht=Sr}if(sn.done)return l(fe,ht),$n&&Oo(fe,St),et;if(ht===null){for(;!sn.done;St++,sn=me.next())sn=Le(fe,sn.value,De),sn!==null&&(oe=w(sn,oe,St),mt===null?et=sn:mt.sibling=sn,mt=sn);return $n&&Oo(fe,St),et}for(ht=f(fe,ht);!sn.done;St++,sn=me.next())sn=Xe(ht,fe,St,sn.value,De),sn!==null&&(r&&sn.alternate!==null&&ht.delete(sn.key===null?St:sn.key),oe=w(sn,oe,St),mt===null?et=sn:mt.sibling=sn,mt=sn);return r&&ht.forEach(function(Xx){return i(fe,Xx)}),$n&&Oo(fe,St),et}function Qn(fe,oe,me,De){if(typeof me=="object"&&me!==null&&me.type===Z&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case Y:e:{for(var et=me.key,mt=oe;mt!==null;){if(mt.key===et){if(et=me.type,et===Z){if(mt.tag===7){l(fe,mt.sibling),oe=p(mt,me.props.children),oe.return=fe,fe=oe;break e}}else if(mt.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===O&&yl(et)===mt.type){l(fe,mt.sibling),oe=p(mt,me.props),oe.ref=pl(fe,mt,me),oe.return=fe,fe=oe;break e}l(fe,mt);break}else i(fe,mt);mt=mt.sibling}me.type===Z?(oe=Ol(me.props.children,fe.mode,De,me.key),oe.return=fe,fe=oe):(De=Df(me.type,me.key,me.props,null,fe.mode,De),De.ref=pl(fe,oe,me),De.return=fe,fe=De)}return A(fe);case Q:e:{for(mt=me.key;oe!==null;){if(oe.key===mt)if(oe.tag===4&&oe.stateNode.containerInfo===me.containerInfo&&oe.stateNode.implementation===me.implementation){l(fe,oe.sibling),oe=p(oe,me.children||[]),oe.return=fe,fe=oe;break e}else{l(fe,oe);break}else i(fe,oe);oe=oe.sibling}oe=mh(me,fe.mode,De),oe.return=fe,fe=oe}return A(fe);case O:return mt=me._init,Qn(fe,oe,mt(me._payload),De)}if(ve(me))return Ze(fe,oe,me,De);if(P(me))return Qe(fe,oe,me,De);gl(fe,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,oe!==null&&oe.tag===6?(l(fe,oe.sibling),oe=p(oe,me),oe.return=fe,fe=oe):(l(fe,oe),oe=fh(me,fe.mode,De),oe.return=fe,fe=oe),A(fe)):l(fe,oe)}return Qn}var Na=yf(!0),vf=yf(!1),vc=Ai(null),Ca=null,Ea=null,vl=null;function Tu(){vl=Ea=Ca=null}function xc(r){var i=vc.current;ln(vc),r._currentValue=i}function Lu(r,i,l){for(;r!==null;){var f=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,f!==null&&(f.childLanes|=i)):f!==null&&(f.childLanes&i)!==i&&(f.childLanes|=i),r===l)break;r=r.return}}function oo(r,i){Ca=r,vl=Ea=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&i)!==0&&(fr=!0),r.firstContext=null)}function Pe(r){var i=r._currentValue;if(vl!==r)if(r={context:r,memoizedValue:i,next:null},Ea===null){if(Ca===null)throw Error(n(308));Ea=r,Ca.dependencies={lanes:0,firstContext:r}}else Ea=Ea.next=r;return i}var ci=null;function ur(r){ci===null?ci=[r]:ci.push(r)}function Xt(r,i,l,f){var p=i.interleaved;return p===null?(l.next=l,ur(i)):(l.next=p.next,p.next=l),i.interleaved=l,Mn(r,f)}function Mn(r,i){r.lanes|=i;var l=r.alternate;for(l!==null&&(l.lanes|=i),l=r,r=r.return;r!==null;)r.childLanes|=i,l=r.alternate,l!==null&&(l.childLanes|=i),l=r,r=r.return;return l.tag===3?l.stateNode:null}var ui=!1;function wc(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Do(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function di(r,i){return{eventTime:r,lane:i,tag:0,payload:null,callback:null,next:null}}function ft(r,i,l){var f=r.updateQueue;if(f===null)return null;if(f=f.shared,(Zt&2)!==0){var p=f.pending;return p===null?i.next=i:(i.next=p.next,p.next=i),f.pending=i,Mn(r,l)}return p=f.interleaved,p===null?(i.next=i,ur(f)):(i.next=p.next,p.next=i),f.interleaved=i,Mn(r,l)}function bc(r,i,l){if(i=i.updateQueue,i!==null&&(i=i.shared,(l&4194240)!==0)){var f=i.lanes;f&=r.pendingLanes,l|=f,i.lanes=l,Js(r,l)}}function Sc(r,i){var l=r.updateQueue,f=r.alternate;if(f!==null&&(f=f.updateQueue,l===f)){var p=null,w=null;if(l=l.firstBaseUpdate,l!==null){do{var A={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};w===null?p=w=A:w=w.next=A,l=l.next}while(l!==null);w===null?p=w=i:w=w.next=i}else p=w=i;l={baseState:f.baseState,firstBaseUpdate:p,lastBaseUpdate:w,shared:f.shared,effects:f.effects},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=i:r.next=i,l.lastBaseUpdate=i}function jc(r,i,l,f){var p=r.updateQueue;ui=!1;var w=p.firstBaseUpdate,A=p.lastBaseUpdate,J=p.shared.pending;if(J!==null){p.shared.pending=null;var re=J,_e=re.next;re.next=null,A===null?w=_e:A.next=_e,A=re;var Ae=r.alternate;Ae!==null&&(Ae=Ae.updateQueue,J=Ae.lastBaseUpdate,J!==A&&(J===null?Ae.firstBaseUpdate=_e:J.next=_e,Ae.lastBaseUpdate=re))}if(w!==null){var Le=p.baseState;A=0,Ae=_e=re=null,J=w;do{var Me=J.lane,Xe=J.eventTime;if((f&Me)===Me){Ae!==null&&(Ae=Ae.next={eventTime:Xe,lane:0,tag:J.tag,payload:J.payload,callback:J.callback,next:null});e:{var Ze=r,Qe=J;switch(Me=i,Xe=l,Qe.tag){case 1:if(Ze=Qe.payload,typeof Ze=="function"){Le=Ze.call(Xe,Le,Me);break e}Le=Ze;break e;case 3:Ze.flags=Ze.flags&-65537|128;case 0:if(Ze=Qe.payload,Me=typeof Ze=="function"?Ze.call(Xe,Le,Me):Ze,Me==null)break e;Le=G({},Le,Me);break e;case 2:ui=!0}}J.callback!==null&&J.lane!==0&&(r.flags|=64,Me=p.effects,Me===null?p.effects=[J]:Me.push(J))}else Xe={eventTime:Xe,lane:Me,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Ae===null?(_e=Ae=Xe,re=Le):Ae=Ae.next=Xe,A|=Me;if(J=J.next,J===null){if(J=p.shared.pending,J===null)break;Me=J,J=Me.next,Me.next=null,p.lastBaseUpdate=Me,p.shared.pending=null}}while(!0);if(Ae===null&&(re=Le),p.baseState=re,p.firstBaseUpdate=_e,p.lastBaseUpdate=Ae,i=p.shared.interleaved,i!==null){p=i;do A|=p.lane,p=p.next;while(p!==i)}else w===null&&(p.shared.lanes=0);ns|=A,r.lanes=A,r.memoizedState=Le}}function xf(r,i,l){if(r=i.effects,i.effects=null,r!==null)for(i=0;i<r.length;i++){var f=r[i],p=f.callback;if(p!==null){if(f.callback=null,f=l,typeof p!="function")throw Error(n(191,p));p.call(f)}}}var $a={},fi=Ai($a),xl=Ai($a),wl=Ai($a);function Oi(r){if(r===$a)throw Error(n(174));return r}function Ru(r,i){switch(xn(wl,i),xn(xl,r),xn(fi,$a),r=i.nodeType,r){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Tt(null,"");break;default:r=r===8?i.parentNode:i,i=r.namespaceURI||null,r=r.tagName,i=Tt(i,r)}ln(fi),xn(fi,i)}function dr(){ln(fi),ln(xl),ln(wl)}function kc(r){Oi(wl.current);var i=Oi(fi.current),l=Tt(i,r.type);i!==l&&(xn(xl,r),xn(fi,l))}function Pu(r){xl.current===r&&(ln(fi),ln(xl))}var On=Ai(0);function Nc(r){for(var i=r;i!==null;){if(i.tag===13){var l=i.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Cc=[];function bl(){for(var r=0;r<Cc.length;r++)Cc[r]._workInProgressVersionPrimary=null;Cc.length=0}var Ec=z.ReactCurrentDispatcher,jn=z.ReactCurrentBatchConfig,ao=0,kn=null,Jt=null,Xn=null,lo=!1,Fo=!1,zi=0,Ou=0;function yr(){throw Error(n(321))}function zu(r,i){if(i===null)return!1;for(var l=0;l<i.length&&l<r.length;l++)if(!Kr(r[l],i[l]))return!1;return!0}function Iu(r,i,l,f,p,w){if(ao=w,kn=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Ec.current=r===null||r.memoizedState===null?sh:ih,r=l(f,p),Fo){w=0;do{if(Fo=!1,zi=0,25<=w)throw Error(n(301));w+=1,Xn=Jt=null,i.updateQueue=null,Ec.current=oh,r=l(f,p)}while(Fo)}if(Ec.current=Ac,i=Jt!==null&&Jt.next!==null,ao=0,Xn=Jt=kn=null,lo=!1,i)throw Error(n(300));return r}function Sl(){var r=zi!==0;return zi=0,r}function xs(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xn===null?kn.memoizedState=Xn=r:Xn=Xn.next=r,Xn}function ws(){if(Jt===null){var r=kn.alternate;r=r!==null?r.memoizedState:null}else r=Jt.next;var i=Xn===null?kn.memoizedState:Xn.next;if(i!==null)Xn=i,Jt=r;else{if(r===null)throw Error(n(310));Jt=r,r={memoizedState:Jt.memoizedState,baseState:Jt.baseState,baseQueue:Jt.baseQueue,queue:Jt.queue,next:null},Xn===null?kn.memoizedState=Xn=r:Xn=Xn.next=r}return Xn}function Bo(r,i){return typeof i=="function"?i(r):i}function Du(r){var i=ws(),l=i.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var f=Jt,p=f.baseQueue,w=l.pending;if(w!==null){if(p!==null){var A=p.next;p.next=w.next,w.next=A}f.baseQueue=p=w,l.pending=null}if(p!==null){w=p.next,f=f.baseState;var J=A=null,re=null,_e=w;do{var Ae=_e.lane;if((ao&Ae)===Ae)re!==null&&(re=re.next={lane:0,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null}),f=_e.hasEagerState?_e.eagerState:r(f,_e.action);else{var Le={lane:Ae,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null};re===null?(J=re=Le,A=f):re=re.next=Le,kn.lanes|=Ae,ns|=Ae}_e=_e.next}while(_e!==null&&_e!==w);re===null?A=f:re.next=J,Kr(f,i.memoizedState)||(fr=!0),i.memoizedState=f,i.baseState=A,i.baseQueue=re,l.lastRenderedState=f}if(r=l.interleaved,r!==null){p=r;do w=p.lane,kn.lanes|=w,ns|=w,p=p.next;while(p!==r)}else p===null&&(l.lanes=0);return[i.memoizedState,l.dispatch]}function Qr(r){var i=ws(),l=i.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var f=l.dispatch,p=l.pending,w=i.memoizedState;if(p!==null){l.pending=null;var A=p=p.next;do w=r(w,A.action),A=A.next;while(A!==p);Kr(w,i.memoizedState)||(fr=!0),i.memoizedState=w,i.baseQueue===null&&(i.baseState=w),l.lastRenderedState=w}return[w,f]}function Uo(){}function Bn(r,i){var l=kn,f=ws(),p=i(),w=!Kr(f.memoizedState,p);if(w&&(f.memoizedState=p,fr=!0),f=f.queue,Ar(wf.bind(null,l,f,r),[r]),f.getSnapshot!==i||w||Xn!==null&&Xn.memoizedState.tag&1){if(l.flags|=2048,Ma(9,Bu.bind(null,l,f,p,i),void 0,null),Tn===null)throw Error(n(349));(ao&30)!==0||Fu(l,i,p)}return p}function Fu(r,i,l){r.flags|=16384,r={getSnapshot:i,value:l},i=kn.updateQueue,i===null?(i={lastEffect:null,stores:null},kn.updateQueue=i,i.stores=[r]):(l=i.stores,l===null?i.stores=[r]:l.push(r))}function Bu(r,i,l,f){i.value=l,i.getSnapshot=f,bf(i)&&Sf(r)}function wf(r,i,l){return l(function(){bf(i)&&Sf(r)})}function bf(r){var i=r.getSnapshot;r=r.value;try{var l=i();return!Kr(r,l)}catch{return!0}}function Sf(r){var i=Mn(r,1);i!==null&&k(i,r,1,-1)}function Uu(r){var i=xs();return typeof r=="function"&&(r=r()),i.memoizedState=i.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Bo,lastRenderedState:r},i.queue=r,r=r.dispatch=Ef.bind(null,kn,r),[i.memoizedState,r]}function Ma(r,i,l,f){return r={tag:r,create:i,destroy:l,deps:f,next:null},i=kn.updateQueue,i===null?(i={lastEffect:null,stores:null},kn.updateQueue=i,i.lastEffect=r.next=r):(l=i.lastEffect,l===null?i.lastEffect=r.next=r:(f=l.next,l.next=r,r.next=f,i.lastEffect=r)),r}function jf(){return ws().memoizedState}function $c(r,i,l,f){var p=xs();kn.flags|=r,p.memoizedState=Ma(1|i,l,void 0,f===void 0?null:f)}function Wt(r,i,l,f){var p=ws();f=f===void 0?null:f;var w=void 0;if(Jt!==null){var A=Jt.memoizedState;if(w=A.destroy,f!==null&&zu(f,A.deps)){p.memoizedState=Ma(i,l,w,f);return}}kn.flags|=r,p.memoizedState=Ma(1|i,l,w,f)}function An(r,i){return $c(8390656,8,r,i)}function Ar(r,i){return Wt(2048,8,r,i)}function Mc(r,i){return Wt(4,2,r,i)}function jl(r,i){return Wt(4,4,r,i)}function Hu(r,i){if(typeof i=="function")return r=r(),i(r),function(){i(null)};if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function kf(r,i,l){return l=l!=null?l.concat([r]):null,Wt(4,4,Hu.bind(null,i,r),l)}function Wu(){}function qu(r,i){var l=ws();i=i===void 0?null:i;var f=l.memoizedState;return f!==null&&i!==null&&zu(i,f[1])?f[0]:(l.memoizedState=[r,i],r)}function Ho(r,i){var l=ws();i=i===void 0?null:i;var f=l.memoizedState;return f!==null&&i!==null&&zu(i,f[1])?f[0]:(r=r(),l.memoizedState=[r,i],r)}function Nf(r,i,l){return(ao&21)===0?(r.baseState&&(r.baseState=!1,fr=!0),r.memoizedState=l):(Kr(l,i)||(l=Yn(),kn.lanes|=l,ns|=l,r.baseState=!0),i)}function rh(r,i){var l=Yt;Yt=l!==0&&4>l?l:4,r(!0);var f=jn.transition;jn.transition={};try{r(!1),i()}finally{Yt=l,jn.transition=f}}function Cf(){return ws().memoizedState}function Aa(r,i,l){var f=_(r);if(l={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null},Vu(r))Gu(i,l);else if(l=Xt(r,i,l,f),l!==null){var p=br();k(l,r,f,p),Yu(l,i,f)}}function Ef(r,i,l){var f=_(r),p={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null};if(Vu(r))Gu(i,p);else{var w=r.alternate;if(r.lanes===0&&(w===null||w.lanes===0)&&(w=i.lastRenderedReducer,w!==null))try{var A=i.lastRenderedState,J=w(A,l);if(p.hasEagerState=!0,p.eagerState=J,Kr(J,A)){var re=i.interleaved;re===null?(p.next=p,ur(i)):(p.next=re.next,re.next=p),i.interleaved=p;return}}catch{}finally{}l=Xt(r,i,p,f),l!==null&&(p=br(),k(l,r,f,p),Yu(l,i,f))}}function Vu(r){var i=r.alternate;return r===kn||i!==null&&i===kn}function Gu(r,i){Fo=lo=!0;var l=r.pending;l===null?i.next=i:(i.next=l.next,l.next=i),r.pending=i}function Yu(r,i,l){if((l&4194240)!==0){var f=i.lanes;f&=r.pendingLanes,l|=f,i.lanes=l,Js(r,l)}}var Ac={readContext:Pe,useCallback:yr,useContext:yr,useEffect:yr,useImperativeHandle:yr,useInsertionEffect:yr,useLayoutEffect:yr,useMemo:yr,useReducer:yr,useRef:yr,useState:yr,useDebugValue:yr,useDeferredValue:yr,useTransition:yr,useMutableSource:yr,useSyncExternalStore:yr,useId:yr,unstable_isNewReconciler:!1},sh={readContext:Pe,useCallback:function(r,i){return xs().memoizedState=[r,i===void 0?null:i],r},useContext:Pe,useEffect:An,useImperativeHandle:function(r,i,l){return l=l!=null?l.concat([r]):null,$c(4194308,4,Hu.bind(null,i,r),l)},useLayoutEffect:function(r,i){return $c(4194308,4,r,i)},useInsertionEffect:function(r,i){return $c(4,2,r,i)},useMemo:function(r,i){var l=xs();return i=i===void 0?null:i,r=r(),l.memoizedState=[r,i],r},useReducer:function(r,i,l){var f=xs();return i=l!==void 0?l(i):i,f.memoizedState=f.baseState=i,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:i},f.queue=r,r=r.dispatch=Aa.bind(null,kn,r),[f.memoizedState,r]},useRef:function(r){var i=xs();return r={current:r},i.memoizedState=r},useState:Uu,useDebugValue:Wu,useDeferredValue:function(r){return xs().memoizedState=r},useTransition:function(){var r=Uu(!1),i=r[0];return r=rh.bind(null,r[1]),xs().memoizedState=r,[i,r]},useMutableSource:function(){},useSyncExternalStore:function(r,i,l){var f=kn,p=xs();if($n){if(l===void 0)throw Error(n(407));l=l()}else{if(l=i(),Tn===null)throw Error(n(349));(ao&30)!==0||Fu(f,i,l)}p.memoizedState=l;var w={value:l,getSnapshot:i};return p.queue=w,An(wf.bind(null,f,w,r),[r]),f.flags|=2048,Ma(9,Bu.bind(null,f,w,l,i),void 0,null),l},useId:function(){var r=xs(),i=Tn.identifierPrefix;if($n){var l=Pi,f=li;l=(f&~(1<<32-_r(f)-1)).toString(32)+l,i=":"+i+"R"+l,l=zi++,0<l&&(i+="H"+l.toString(32)),i+=":"}else l=Ou++,i=":"+i+"r"+l.toString(32)+":";return r.memoizedState=i},unstable_isNewReconciler:!1},ih={readContext:Pe,useCallback:qu,useContext:Pe,useEffect:Ar,useImperativeHandle:kf,useInsertionEffect:Mc,useLayoutEffect:jl,useMemo:Ho,useReducer:Du,useRef:jf,useState:function(){return Du(Bo)},useDebugValue:Wu,useDeferredValue:function(r){var i=ws();return Nf(i,Jt.memoizedState,r)},useTransition:function(){var r=Du(Bo)[0],i=ws().memoizedState;return[r,i]},useMutableSource:Uo,useSyncExternalStore:Bn,useId:Cf,unstable_isNewReconciler:!1},oh={readContext:Pe,useCallback:qu,useContext:Pe,useEffect:Ar,useImperativeHandle:kf,useInsertionEffect:Mc,useLayoutEffect:jl,useMemo:Ho,useReducer:Qr,useRef:jf,useState:function(){return Qr(Bo)},useDebugValue:Wu,useDeferredValue:function(r){var i=ws();return Jt===null?i.memoizedState=r:Nf(i,Jt.memoizedState,r)},useTransition:function(){var r=Qr(Bo)[0],i=ws().memoizedState;return[r,i]},useMutableSource:Uo,useSyncExternalStore:Bn,useId:Cf,unstable_isNewReconciler:!1};function Ds(r,i){if(r&&r.defaultProps){i=G({},i),r=r.defaultProps;for(var l in r)i[l]===void 0&&(i[l]=r[l]);return i}return i}function Ku(r,i,l,f){i=r.memoizedState,l=l(f,i),l=l==null?i:G({},i,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var Tc={isMounted:function(r){return(r=r._reactInternals)?gn(r)===r:!1},enqueueSetState:function(r,i,l){r=r._reactInternals;var f=br(),p=_(r),w=di(f,p);w.payload=i,l!=null&&(w.callback=l),i=ft(r,w,p),i!==null&&(k(i,r,p,f),bc(i,r,p))},enqueueReplaceState:function(r,i,l){r=r._reactInternals;var f=br(),p=_(r),w=di(f,p);w.tag=1,w.payload=i,l!=null&&(w.callback=l),i=ft(r,w,p),i!==null&&(k(i,r,p,f),bc(i,r,p))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var l=br(),f=_(r),p=di(l,f);p.tag=2,i!=null&&(p.callback=i),i=ft(r,p,f),i!==null&&(k(i,r,f,l),bc(i,r,f))}};function Xu(r,i,l,f,p,w,A){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(f,w,A):i.prototype&&i.prototype.isPureReactComponent?!ol(l,f)||!ol(p,w):!0}function Lc(r,i,l){var f=!1,p=ys,w=i.contextType;return typeof w=="object"&&w!==null?w=Pe(w):(p=Fr(i)?ro:sr.current,f=i.contextTypes,w=(f=f!=null)?zs(r,p):ys),i=new i(l,w),r.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Tc,r.stateNode=i,i._reactInternals=r,f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=p,r.__reactInternalMemoizedMaskedChildContext=w),i}function $f(r,i,l,f){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(l,f),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(l,f),i.state!==r&&Tc.enqueueReplaceState(i,i.state,null)}function Ju(r,i,l,f){var p=r.stateNode;p.props=l,p.state=r.memoizedState,p.refs={},wc(r);var w=i.contextType;typeof w=="object"&&w!==null?p.context=Pe(w):(w=Fr(i)?ro:sr.current,p.context=zs(r,w)),p.state=r.memoizedState,w=i.getDerivedStateFromProps,typeof w=="function"&&(Ku(r,i,w,l),p.state=r.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(i=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),i!==p.state&&Tc.enqueueReplaceState(p,p.state,null),jc(r,l,p,f),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308)}function Ii(r,i){try{var l="",f=i;do l+=he(f),f=f.return;while(f);var p=l}catch(w){p=`
39
+ Error generating stack: `+w.message+`
40
+ `+w.stack}return{value:r,source:i,stack:p,digest:null}}function Zu(r,i,l){return{value:r,source:null,stack:l??null,digest:i??null}}function Di(r,i){try{console.error(i.value)}catch(l){setTimeout(function(){throw l})}}var Tr=typeof WeakMap=="function"?WeakMap:Map;function ir(r,i,l){l=di(-1,l),l.tag=3,l.payload={element:null};var f=i.value;return l.callback=function(){Al||(Al=!0,Fc=f),Di(r,i)},l}function Fs(r,i,l){l=di(-1,l),l.tag=3;var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var p=i.value;l.payload=function(){return f(p)},l.callback=function(){Di(r,i)}}var w=r.stateNode;return w!==null&&typeof w.componentDidCatch=="function"&&(l.callback=function(){Di(r,i),typeof f!="function"&&(Wi===null?Wi=new Set([this]):Wi.add(this));var A=i.stack;this.componentDidCatch(i.value,{componentStack:A!==null?A:""})}),l}function Fi(r,i,l){var f=r.pingCache;if(f===null){f=r.pingCache=new Tr;var p=new Set;f.set(i,p)}else p=f.get(i),p===void 0&&(p=new Set,f.set(i,p));p.has(l)||(p.add(l),r=Dx.bind(null,r,i,l),i.then(r,r))}function Bi(r){do{var i;if((i=r.tag===13)&&(i=r.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return r;r=r.return}while(r!==null);return null}function Bs(r,i,l,f,p){return(r.mode&1)===0?(r===i?r.flags|=65536:(r.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(i=di(-1,1),i.tag=2,ft(l,i,1))),l.lanes|=1),r):(r.flags|=65536,r.lanes=p,r)}var ah=z.ReactCurrentOwner,fr=!1;function Lr(r,i,l,f){i.child=r===null?vf(i,null,l,f):Na(i,r.child,l,f)}function Rc(r,i,l,f,p){l=l.render;var w=i.ref;return oo(i,p),f=Iu(r,i,l,f,w,p),l=Sl(),r!==null&&!fr?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~p,Hr(r,i,p)):($n&&l&&cr(i),i.flags|=1,Lr(r,i,f,p),i.child)}function Mf(r,i,l,f,p){if(r===null){var w=l.type;return typeof w=="function"&&!dh(w)&&w.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(i.tag=15,i.type=w,Af(r,i,w,f,p)):(r=Df(l.type,null,f,i,i.mode,p),r.ref=i.ref,r.return=i,i.child=r)}if(w=r.child,(r.lanes&p)===0){var A=w.memoizedProps;if(l=l.compare,l=l!==null?l:ol,l(A,f)&&r.ref===i.ref)return Hr(r,i,p)}return i.flags|=1,r=za(w,f),r.ref=i.ref,r.return=i,i.child=r}function Af(r,i,l,f,p){if(r!==null){var w=r.memoizedProps;if(ol(w,f)&&r.ref===i.ref)if(fr=!1,i.pendingProps=f=w,(r.lanes&p)!==0)(r.flags&131072)!==0&&(fr=!0);else return i.lanes=r.lanes,Hr(r,i,p)}return Wo(r,i,l,f,p)}function Qu(r,i,l){var f=i.pendingProps,p=f.children,w=r!==null?r.memoizedState:null;if(f.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},xn(Vo,Wr),Wr|=l;else{if((l&1073741824)===0)return r=w!==null?w.baseLanes|l:l,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:r,cachePool:null,transitions:null},i.updateQueue=null,xn(Vo,Wr),Wr|=r,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=w!==null?w.baseLanes:l,xn(Vo,Wr),Wr|=f}else w!==null?(f=w.baseLanes|l,i.memoizedState=null):f=l,xn(Vo,Wr),Wr|=f;return Lr(r,i,p,l),i.child}function co(r,i){var l=i.ref;(r===null&&l!==null||r!==null&&r.ref!==l)&&(i.flags|=512,i.flags|=2097152)}function Wo(r,i,l,f,p){var w=Fr(l)?ro:sr.current;return w=zs(i,w),oo(i,p),l=Iu(r,i,l,f,w,p),f=Sl(),r!==null&&!fr?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~p,Hr(r,i,p)):($n&&f&&cr(i),i.flags|=1,Lr(r,i,l,p),i.child)}function ed(r,i,l,f,p){if(Fr(l)){var w=!0;_c(i)}else w=!1;if(oo(i,p),i.stateNode===null)vr(r,i),Lc(i,l,f),Ju(i,l,f,p),f=!0;else if(r===null){var A=i.stateNode,J=i.memoizedProps;A.props=J;var re=A.context,_e=l.contextType;typeof _e=="object"&&_e!==null?_e=Pe(_e):(_e=Fr(l)?ro:sr.current,_e=zs(i,_e));var Ae=l.getDerivedStateFromProps,Le=typeof Ae=="function"||typeof A.getSnapshotBeforeUpdate=="function";Le||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(J!==f||re!==_e)&&$f(i,A,f,_e),ui=!1;var Me=i.memoizedState;A.state=Me,jc(i,f,A,p),re=i.memoizedState,J!==f||Me!==re||lr.current||ui?(typeof Ae=="function"&&(Ku(i,l,Ae,f),re=i.memoizedState),(J=ui||Xu(i,l,J,f,Me,re,_e))?(Le||typeof A.UNSAFE_componentWillMount!="function"&&typeof A.componentWillMount!="function"||(typeof A.componentWillMount=="function"&&A.componentWillMount(),typeof A.UNSAFE_componentWillMount=="function"&&A.UNSAFE_componentWillMount()),typeof A.componentDidMount=="function"&&(i.flags|=4194308)):(typeof A.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=re),A.props=f,A.state=re,A.context=_e,f=J):(typeof A.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{A=i.stateNode,Do(r,i),J=i.memoizedProps,_e=i.type===i.elementType?J:Ds(i.type,J),A.props=_e,Le=i.pendingProps,Me=A.context,re=l.contextType,typeof re=="object"&&re!==null?re=Pe(re):(re=Fr(l)?ro:sr.current,re=zs(i,re));var Xe=l.getDerivedStateFromProps;(Ae=typeof Xe=="function"||typeof A.getSnapshotBeforeUpdate=="function")||typeof A.UNSAFE_componentWillReceiveProps!="function"&&typeof A.componentWillReceiveProps!="function"||(J!==Le||Me!==re)&&$f(i,A,f,re),ui=!1,Me=i.memoizedState,A.state=Me,jc(i,f,A,p);var Ze=i.memoizedState;J!==Le||Me!==Ze||lr.current||ui?(typeof Xe=="function"&&(Ku(i,l,Xe,f),Ze=i.memoizedState),(_e=ui||Xu(i,l,_e,f,Me,Ze,re)||!1)?(Ae||typeof A.UNSAFE_componentWillUpdate!="function"&&typeof A.componentWillUpdate!="function"||(typeof A.componentWillUpdate=="function"&&A.componentWillUpdate(f,Ze,re),typeof A.UNSAFE_componentWillUpdate=="function"&&A.UNSAFE_componentWillUpdate(f,Ze,re)),typeof A.componentDidUpdate=="function"&&(i.flags|=4),typeof A.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof A.componentDidUpdate!="function"||J===r.memoizedProps&&Me===r.memoizedState||(i.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||J===r.memoizedProps&&Me===r.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=Ze),A.props=f,A.state=Ze,A.context=re,f=_e):(typeof A.componentDidUpdate!="function"||J===r.memoizedProps&&Me===r.memoizedState||(i.flags|=4),typeof A.getSnapshotBeforeUpdate!="function"||J===r.memoizedProps&&Me===r.memoizedState||(i.flags|=1024),f=!1)}return Pc(r,i,l,f,w,p)}function Pc(r,i,l,f,p,w){co(r,i);var A=(i.flags&128)!==0;if(!f&&!A)return p&&ml(i,l,!1),Hr(r,i,w);f=i.stateNode,ah.current=i;var J=A&&typeof l.getDerivedStateFromError!="function"?null:f.render();return i.flags|=1,r!==null&&A?(i.child=Na(i,r.child,null,w),i.child=Na(i,null,J,w)):Lr(r,i,J,w),i.memoizedState=f.state,p&&ml(i,l,!0),i.child}function Tf(r){var i=r.stateNode;i.pendingContext?hf(r,i.pendingContext,i.pendingContext!==i.context):i.context&&hf(r,i.context,!1),Ru(r,i.containerInfo)}function td(r,i,l,f,p){return Io(),yc(p),i.flags|=256,Lr(r,i,l,f),i.child}var uo={dehydrated:null,treeContext:null,retryLane:0};function nd(r){return{baseLanes:r,cachePool:null,transitions:null}}function kl(r,i,l){var f=i.pendingProps,p=On.current,w=!1,A=(i.flags&128)!==0,J;if((J=A)||(J=r!==null&&r.memoizedState===null?!1:(p&2)!==0),J?(w=!0,i.flags&=-129):(r===null||r.memoizedState!==null)&&(p|=1),xn(On,p&1),r===null)return zo(i),r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((i.mode&1)===0?i.lanes=1:r.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(A=f.children,r=f.fallback,w?(f=i.mode,w=i.child,A={mode:"hidden",children:A},(f&1)===0&&w!==null?(w.childLanes=0,w.pendingProps=A):w=Ff(A,f,0,null),r=Ol(r,f,l,null),w.return=i,r.return=i,w.sibling=r,i.child=w,i.child.memoizedState=nd(l),i.memoizedState=uo,r):Oc(i,A));if(p=r.memoizedState,p!==null&&(J=p.dehydrated,J!==null))return rd(r,i,A,f,J,p,l);if(w){w=f.fallback,A=i.mode,p=r.child,J=p.sibling;var re={mode:"hidden",children:f.children};return(A&1)===0&&i.child!==p?(f=i.child,f.childLanes=0,f.pendingProps=re,i.deletions=null):(f=za(p,re),f.subtreeFlags=p.subtreeFlags&14680064),J!==null?w=za(J,w):(w=Ol(w,A,l,null),w.flags|=2),w.return=i,f.return=i,f.sibling=w,i.child=f,f=w,w=i.child,A=r.child.memoizedState,A=A===null?nd(l):{baseLanes:A.baseLanes|l,cachePool:null,transitions:A.transitions},w.memoizedState=A,w.childLanes=r.childLanes&~l,i.memoizedState=uo,f}return w=r.child,r=w.sibling,f=za(w,{mode:"visible",children:f.children}),(i.mode&1)===0&&(f.lanes=l),f.return=i,f.sibling=null,r!==null&&(l=i.deletions,l===null?(i.deletions=[r],i.flags|=16):l.push(r)),i.child=f,i.memoizedState=null,f}function Oc(r,i){return i=Ff({mode:"visible",children:i},r.mode,0,null),i.return=r,r.child=i}function zc(r,i,l,f){return f!==null&&yc(f),Na(i,r.child,null,l),r=Oc(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function rd(r,i,l,f,p,w,A){if(l)return i.flags&256?(i.flags&=-257,f=Zu(Error(n(422))),zc(r,i,A,f)):i.memoizedState!==null?(i.child=r.child,i.flags|=128,null):(w=f.fallback,p=i.mode,f=Ff({mode:"visible",children:f.children},p,0,null),w=Ol(w,p,A,null),w.flags|=2,f.return=i,w.return=i,f.sibling=w,i.child=f,(i.mode&1)!==0&&Na(i,r.child,null,A),i.child.memoizedState=nd(A),i.memoizedState=uo,w);if((i.mode&1)===0)return zc(r,i,A,null);if(p.data==="$!"){if(f=p.nextSibling&&p.nextSibling.dataset,f)var J=f.dgst;return f=J,w=Error(n(419)),f=Zu(w,f,void 0),zc(r,i,A,f)}if(J=(A&r.childLanes)!==0,fr||J){if(f=Tn,f!==null){switch(A&-A){case 4:p=2;break;case 16:p=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:p=32;break;case 536870912:p=268435456;break;default:p=0}p=(p&(f.suspendedLanes|A))!==0?0:p,p!==0&&p!==w.retryLane&&(w.retryLane=p,Mn(r,p),k(f,r,p,-1))}return Ue(),f=Zu(Error(n(421))),zc(r,i,A,f)}return p.data==="$?"?(i.flags|=128,i.child=r.child,i=Fx.bind(null,r),p._reactRetry=i,null):(r=w.treeContext,Zr=gs(p.nextSibling),Mr=i,$n=!0,Ur=null,r!==null&&(Br[vs++]=li,Br[vs++]=Pi,Br[vs++]=ai,li=r.id,Pi=r.overflow,ai=i),i=Oc(i,f.children),i.flags|=4096,i)}function Lf(r,i,l){r.lanes|=i;var f=r.alternate;f!==null&&(f.lanes|=i),Lu(r.return,i,l)}function sd(r,i,l,f,p){var w=r.memoizedState;w===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:l,tailMode:p}:(w.isBackwards=i,w.rendering=null,w.renderingStartTime=0,w.last=f,w.tail=l,w.tailMode=p)}function Rf(r,i,l){var f=i.pendingProps,p=f.revealOrder,w=f.tail;if(Lr(r,i,f.children,l),f=On.current,(f&2)!==0)f=f&1|2,i.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Lf(r,l,i);else if(r.tag===19)Lf(r,l,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}f&=1}if(xn(On,f),(i.mode&1)===0)i.memoizedState=null;else switch(p){case"forwards":for(l=i.child,p=null;l!==null;)r=l.alternate,r!==null&&Nc(r)===null&&(p=l),l=l.sibling;l=p,l===null?(p=i.child,i.child=null):(p=l.sibling,l.sibling=null),sd(i,!1,p,l,w);break;case"backwards":for(l=null,p=i.child,i.child=null;p!==null;){if(r=p.alternate,r!==null&&Nc(r)===null){i.child=p;break}r=p.sibling,p.sibling=l,l=p,p=r}sd(i,!0,l,null,w);break;case"together":sd(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function vr(r,i){(i.mode&1)===0&&r!==null&&(r.alternate=null,i.alternate=null,i.flags|=2)}function Hr(r,i,l){if(r!==null&&(i.dependencies=r.dependencies),ns|=i.lanes,(l&i.childLanes)===0)return null;if(r!==null&&i.child!==r.child)throw Error(n(153));if(i.child!==null){for(r=i.child,l=za(r,r.pendingProps),i.child=l,l.return=i;r.sibling!==null;)r=r.sibling,l=l.sibling=za(r,r.pendingProps),l.return=i;l.sibling=null}return i.child}function lh(r,i,l){switch(i.tag){case 3:Tf(i),Io();break;case 5:kc(i);break;case 1:Fr(i.type)&&_c(i);break;case 4:Ru(i,i.stateNode.containerInfo);break;case 10:var f=i.type._context,p=i.memoizedProps.value;xn(vc,f._currentValue),f._currentValue=p;break;case 13:if(f=i.memoizedState,f!==null)return f.dehydrated!==null?(xn(On,On.current&1),i.flags|=128,null):(l&i.child.childLanes)!==0?kl(r,i,l):(xn(On,On.current&1),r=Hr(r,i,l),r!==null?r.sibling:null);xn(On,On.current&1);break;case 19:if(f=(l&i.childLanes)!==0,(r.flags&128)!==0){if(f)return Rf(r,i,l);i.flags|=128}if(p=i.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),xn(On,On.current),f)break;return null;case 22:case 23:return i.lanes=0,Qu(r,i,l)}return Hr(r,i,l)}var id,es,Ic,od;id=function(r,i){for(var l=i.child;l!==null;){if(l.tag===5||l.tag===6)r.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},es=function(){},Ic=function(r,i,l,f){var p=r.memoizedProps;if(p!==f){r=i.stateNode,Oi(fi.current);var w=null;switch(l){case"input":p=at(r,p),f=at(r,f),w=[];break;case"select":p=G({},p,{value:void 0}),f=G({},f,{value:void 0}),w=[];break;case"textarea":p=Ge(r,p),f=Ge(r,f),w=[];break;default:typeof p.onClick!="function"&&typeof f.onClick=="function"&&(r.onclick=ya)}Qt(l,f);var A;l=null;for(_e in p)if(!f.hasOwnProperty(_e)&&p.hasOwnProperty(_e)&&p[_e]!=null)if(_e==="style"){var J=p[_e];for(A in J)J.hasOwnProperty(A)&&(l||(l={}),l[A]="")}else _e!=="dangerouslySetInnerHTML"&&_e!=="children"&&_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&_e!=="autoFocus"&&(a.hasOwnProperty(_e)?w||(w=[]):(w=w||[]).push(_e,null));for(_e in f){var re=f[_e];if(J=p!=null?p[_e]:void 0,f.hasOwnProperty(_e)&&re!==J&&(re!=null||J!=null))if(_e==="style")if(J){for(A in J)!J.hasOwnProperty(A)||re&&re.hasOwnProperty(A)||(l||(l={}),l[A]="");for(A in re)re.hasOwnProperty(A)&&J[A]!==re[A]&&(l||(l={}),l[A]=re[A])}else l||(w||(w=[]),w.push(_e,l)),l=re;else _e==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,J=J?J.__html:void 0,re!=null&&J!==re&&(w=w||[]).push(_e,re)):_e==="children"?typeof re!="string"&&typeof re!="number"||(w=w||[]).push(_e,""+re):_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&(a.hasOwnProperty(_e)?(re!=null&&_e==="onScroll"&&dn("scroll",r),w||J===re||(w=[])):(w=w||[]).push(_e,re))}l&&(w=w||[]).push("style",l);var _e=w;(i.updateQueue=_e)&&(i.flags|=4)}},od=function(r,i,l,f){l!==f&&(i.flags|=4)};function Ta(r,i){if(!$n)switch(r.tailMode){case"hidden":i=r.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:f.sibling=null}}function xr(r){var i=r.alternate!==null&&r.alternate.child===r.child,l=0,f=0;if(i)for(var p=r.child;p!==null;)l|=p.lanes|p.childLanes,f|=p.subtreeFlags&14680064,f|=p.flags&14680064,p.return=r,p=p.sibling;else for(p=r.child;p!==null;)l|=p.lanes|p.childLanes,f|=p.subtreeFlags,f|=p.flags,p.return=r,p=p.sibling;return r.subtreeFlags|=f,r.childLanes=l,i}function ch(r,i,l){var f=i.pendingProps;switch(ja(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return xr(i),null;case 1:return Fr(i.type)&&Ro(),xr(i),null;case 3:return f=i.stateNode,dr(),ln(lr),ln(sr),bl(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(r===null||r.child===null)&&(_l(i)?i.flags|=4:r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Ur!==null&&(H(Ur),Ur=null))),es(r,i),xr(i),null;case 5:Pu(i);var p=Oi(wl.current);if(l=i.type,r!==null&&i.stateNode!=null)Ic(r,i,l,f,p),r.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!f){if(i.stateNode===null)throw Error(n(166));return xr(i),null}if(r=Oi(fi.current),_l(i)){f=i.stateNode,l=i.type;var w=i.memoizedProps;switch(f[Os]=i,f[xa]=w,r=(i.mode&1)!==0,l){case"dialog":dn("cancel",f),dn("close",f);break;case"iframe":case"object":case"embed":dn("load",f);break;case"video":case"audio":for(p=0;p<Ao.length;p++)dn(Ao[p],f);break;case"source":dn("error",f);break;case"img":case"image":case"link":dn("error",f),dn("load",f);break;case"details":dn("toggle",f);break;case"input":yt(f,w),dn("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!w.multiple},dn("invalid",f);break;case"textarea":At(f,w),dn("invalid",f)}Qt(l,w),p=null;for(var A in w)if(w.hasOwnProperty(A)){var J=w[A];A==="children"?typeof J=="string"?f.textContent!==J&&(w.suppressHydrationWarning!==!0&&ri(f.textContent,J,r),p=["children",J]):typeof J=="number"&&f.textContent!==""+J&&(w.suppressHydrationWarning!==!0&&ri(f.textContent,J,r),p=["children",""+J]):a.hasOwnProperty(A)&&J!=null&&A==="onScroll"&&dn("scroll",f)}switch(l){case"input":Ke(f),Oe(f,w,!0);break;case"textarea":Ke(f),fn(f);break;case"select":case"option":break;default:typeof w.onClick=="function"&&(f.onclick=ya)}f=p,i.updateQueue=f,f!==null&&(i.flags|=4)}else{A=p.nodeType===9?p:p.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Dt(l)),r==="http://www.w3.org/1999/xhtml"?l==="script"?(r=A.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof f.is=="string"?r=A.createElement(l,{is:f.is}):(r=A.createElement(l),l==="select"&&(A=r,f.multiple?A.multiple=!0:f.size&&(A.size=f.size))):r=A.createElementNS(r,l),r[Os]=i,r[xa]=f,id(r,i,!1,!1),i.stateNode=r;e:{switch(A=ar(l,f),l){case"dialog":dn("cancel",r),dn("close",r),p=f;break;case"iframe":case"object":case"embed":dn("load",r),p=f;break;case"video":case"audio":for(p=0;p<Ao.length;p++)dn(Ao[p],r);p=f;break;case"source":dn("error",r),p=f;break;case"img":case"image":case"link":dn("error",r),dn("load",r),p=f;break;case"details":dn("toggle",r),p=f;break;case"input":yt(r,f),p=at(r,f),dn("invalid",r);break;case"option":p=f;break;case"select":r._wrapperState={wasMultiple:!!f.multiple},p=G({},f,{value:void 0}),dn("invalid",r);break;case"textarea":At(r,f),p=Ge(r,f),dn("invalid",r);break;default:p=f}Qt(l,p),J=p;for(w in J)if(J.hasOwnProperty(w)){var re=J[w];w==="style"?yn(r,re):w==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&Vn(r,re)):w==="children"?typeof re=="string"?(l!=="textarea"||re!=="")&&jt(r,re):typeof re=="number"&&jt(r,""+re):w!=="suppressContentEditableWarning"&&w!=="suppressHydrationWarning"&&w!=="autoFocus"&&(a.hasOwnProperty(w)?re!=null&&w==="onScroll"&&dn("scroll",r):re!=null&&q(r,w,re,A))}switch(l){case"input":Ke(r),Oe(r,f,!1);break;case"textarea":Ke(r),fn(r);break;case"option":f.value!=null&&r.setAttribute("value",""+Ee(f.value));break;case"select":r.multiple=!!f.multiple,w=f.value,w!=null?Ie(r,!!f.multiple,w,!1):f.defaultValue!=null&&Ie(r,!!f.multiple,f.defaultValue,!0);break;default:typeof p.onClick=="function"&&(r.onclick=ya)}switch(l){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}}f&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return xr(i),null;case 6:if(r&&i.stateNode!=null)od(r,i,r.memoizedProps,f);else{if(typeof f!="string"&&i.stateNode===null)throw Error(n(166));if(l=Oi(wl.current),Oi(fi.current),_l(i)){if(f=i.stateNode,l=i.memoizedProps,f[Os]=i,(w=f.nodeValue!==l)&&(r=Mr,r!==null))switch(r.tag){case 3:ri(f.nodeValue,l,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&ri(f.nodeValue,l,(r.mode&1)!==0)}w&&(i.flags|=4)}else f=(l.nodeType===9?l:l.ownerDocument).createTextNode(f),f[Os]=i,i.stateNode=f}return xr(i),null;case 13:if(ln(On),f=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if($n&&Zr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)pf(),Io(),i.flags|=98560,w=!1;else if(w=_l(i),f!==null&&f.dehydrated!==null){if(r===null){if(!w)throw Error(n(318));if(w=i.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(n(317));w[Os]=i}else Io(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;xr(i),w=!1}else Ur!==null&&(H(Ur),Ur=null),w=!0;if(!w)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=l,i):(f=f!==null,f!==(r!==null&&r.memoizedState!==null)&&f&&(i.child.flags|=8192,(i.mode&1)!==0&&(r===null||(On.current&1)!==0?Zn===0&&(Zn=3):Ue())),i.updateQueue!==null&&(i.flags|=4),xr(i),null);case 4:return dr(),es(r,i),r===null&&Ei(i.stateNode.containerInfo),xr(i),null;case 10:return xc(i.type._context),xr(i),null;case 17:return Fr(i.type)&&Ro(),xr(i),null;case 19:if(ln(On),w=i.memoizedState,w===null)return xr(i),null;if(f=(i.flags&128)!==0,A=w.rendering,A===null)if(f)Ta(w,!1);else{if(Zn!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(A=Nc(r),A!==null){for(i.flags|=128,Ta(w,!1),f=A.updateQueue,f!==null&&(i.updateQueue=f,i.flags|=4),i.subtreeFlags=0,f=l,l=i.child;l!==null;)w=l,r=f,w.flags&=14680066,A=w.alternate,A===null?(w.childLanes=0,w.lanes=r,w.child=null,w.subtreeFlags=0,w.memoizedProps=null,w.memoizedState=null,w.updateQueue=null,w.dependencies=null,w.stateNode=null):(w.childLanes=A.childLanes,w.lanes=A.lanes,w.child=A.child,w.subtreeFlags=0,w.deletions=null,w.memoizedProps=A.memoizedProps,w.memoizedState=A.memoizedState,w.updateQueue=A.updateQueue,w.type=A.type,r=A.dependencies,w.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),l=l.sibling;return xn(On,On.current&1|2),i.child}r=r.sibling}w.tail!==null&&an()>Yo&&(i.flags|=128,f=!0,Ta(w,!1),i.lanes=4194304)}else{if(!f)if(r=Nc(A),r!==null){if(i.flags|=128,f=!0,l=r.updateQueue,l!==null&&(i.updateQueue=l,i.flags|=4),Ta(w,!0),w.tail===null&&w.tailMode==="hidden"&&!A.alternate&&!$n)return xr(i),null}else 2*an()-w.renderingStartTime>Yo&&l!==1073741824&&(i.flags|=128,f=!0,Ta(w,!1),i.lanes=4194304);w.isBackwards?(A.sibling=i.child,i.child=A):(l=w.last,l!==null?l.sibling=A:i.child=A,w.last=A)}return w.tail!==null?(i=w.tail,w.rendering=i,w.tail=i.sibling,w.renderingStartTime=an(),i.sibling=null,l=On.current,xn(On,f?l&1|2:l&1),i):(xr(i),null);case 22:case 23:return xe(),f=i.memoizedState!==null,r!==null&&r.memoizedState!==null!==f&&(i.flags|=8192),f&&(i.mode&1)!==0?(Wr&1073741824)!==0&&(xr(i),i.subtreeFlags&6&&(i.flags|=8192)):xr(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function ts(r,i){switch(ja(i),i.tag){case 1:return Fr(i.type)&&Ro(),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return dr(),ln(lr),ln(sr),bl(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 5:return Pu(i),null;case 13:if(ln(On),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(n(340));Io()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return ln(On),null;case 4:return dr(),null;case 10:return xc(i.type._context),null;case 22:case 23:return xe(),null;case 24:return null;default:return null}}var fo=!1,mr=!1,Pf=typeof WeakSet=="function"?WeakSet:Set,Je=null;function qo(r,i){var l=r.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(f){bn(r,i,f)}else l.current=null}function Us(r,i,l){try{l()}catch(f){bn(r,i,f)}}var Of=!1;function uh(r,i){if(va=pr,r=ku(),ma(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var f=l.getSelection&&l.getSelection();if(f&&f.rangeCount!==0){l=f.anchorNode;var p=f.anchorOffset,w=f.focusNode;f=f.focusOffset;try{l.nodeType,w.nodeType}catch{l=null;break e}var A=0,J=-1,re=-1,_e=0,Ae=0,Le=r,Me=null;t:for(;;){for(var Xe;Le!==l||p!==0&&Le.nodeType!==3||(J=A+p),Le!==w||f!==0&&Le.nodeType!==3||(re=A+f),Le.nodeType===3&&(A+=Le.nodeValue.length),(Xe=Le.firstChild)!==null;)Me=Le,Le=Xe;for(;;){if(Le===r)break t;if(Me===l&&++_e===p&&(J=A),Me===w&&++Ae===f&&(re=A),(Xe=Le.nextSibling)!==null)break;Le=Me,Me=Le.parentNode}Le=Xe}l=J===-1||re===-1?null:{start:J,end:re}}else l=null}l=l||{start:0,end:0}}else l=null;for(_s={focusedElem:r,selectionRange:l},pr=!1,Je=i;Je!==null;)if(i=Je,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,Je=r;else for(;Je!==null;){i=Je;try{var Ze=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Ze!==null){var Qe=Ze.memoizedProps,Qn=Ze.memoizedState,fe=i.stateNode,oe=fe.getSnapshotBeforeUpdate(i.elementType===i.type?Qe:Ds(i.type,Qe),Qn);fe.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var me=i.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(De){bn(i,i.return,De)}if(r=i.sibling,r!==null){r.return=i.return,Je=r;break}Je=i.return}return Ze=Of,Of=!1,Ze}function La(r,i,l){var f=i.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var p=f=f.next;do{if((p.tag&r)===r){var w=p.destroy;p.destroy=void 0,w!==void 0&&Us(i,l,w)}p=p.next}while(p!==f)}}function Ra(r,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var l=i=i.next;do{if((l.tag&r)===r){var f=l.create;l.destroy=f()}l=l.next}while(l!==i)}}function bs(r){var i=r.ref;if(i!==null){var l=r.stateNode;switch(r.tag){case 5:r=l;break;default:r=l}typeof i=="function"?i(r):i.current=r}}function Nl(r){var i=r.alternate;i!==null&&(r.alternate=null,Nl(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&(delete i[Os],delete i[xa],delete i[Mu],delete i[mf],delete i[nh])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function zf(r){return r.tag===5||r.tag===3||r.tag===4}function Ui(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||zf(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Cl(r,i,l){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?l.nodeType===8?l.parentNode.insertBefore(r,i):l.insertBefore(r,i):(l.nodeType===8?(i=l.parentNode,i.insertBefore(r,l)):(i=l,i.appendChild(r)),l=l._reactRootContainer,l!=null||i.onclick!==null||(i.onclick=ya));else if(f!==4&&(r=r.child,r!==null))for(Cl(r,i,l),r=r.sibling;r!==null;)Cl(r,i,l),r=r.sibling}function El(r,i,l){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?l.insertBefore(r,i):l.appendChild(r);else if(f!==4&&(r=r.child,r!==null))for(El(r,i,l),r=r.sibling;r!==null;)El(r,i,l),r=r.sibling}var qt=null,wr=!1;function mo(r,i,l){for(l=l.child;l!==null;)ad(r,i,l),l=l.sibling}function ad(r,i,l){if(Cr&&typeof Cr.onCommitFiberUnmount=="function")try{Cr.onCommitFiberUnmount(rn,l)}catch{}switch(l.tag){case 5:mr||qo(l,i);case 6:var f=qt,p=wr;qt=null,mo(r,i,l),qt=f,wr=p,qt!==null&&(wr?(r=qt,l=l.stateNode,r.nodeType===8?r.parentNode.removeChild(l):r.removeChild(l)):qt.removeChild(l.stateNode));break;case 18:qt!==null&&(wr?(r=qt,l=l.stateNode,r.nodeType===8?fc(r.parentNode,l):r.nodeType===1&&fc(r,l),vo(r)):fc(qt,l.stateNode));break;case 4:f=qt,p=wr,qt=l.stateNode.containerInfo,wr=!0,mo(r,i,l),qt=f,wr=p;break;case 0:case 11:case 14:case 15:if(!mr&&(f=l.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){p=f=f.next;do{var w=p,A=w.destroy;w=w.tag,A!==void 0&&((w&2)!==0||(w&4)!==0)&&Us(l,i,A),p=p.next}while(p!==f)}mo(r,i,l);break;case 1:if(!mr&&(qo(l,i),f=l.stateNode,typeof f.componentWillUnmount=="function"))try{f.props=l.memoizedProps,f.state=l.memoizedState,f.componentWillUnmount()}catch(J){bn(l,i,J)}mo(r,i,l);break;case 21:mo(r,i,l);break;case 22:l.mode&1?(mr=(f=mr)||l.memoizedState!==null,mo(r,i,l),mr=f):mo(r,i,l);break;default:mo(r,i,l)}}function ld(r){var i=r.updateQueue;if(i!==null){r.updateQueue=null;var l=r.stateNode;l===null&&(l=r.stateNode=new Pf),i.forEach(function(f){var p=Bx.bind(null,r,f);l.has(f)||(l.add(f),f.then(p,p))})}}function Ss(r,i){var l=i.deletions;if(l!==null)for(var f=0;f<l.length;f++){var p=l[f];try{var w=r,A=i,J=A;e:for(;J!==null;){switch(J.tag){case 5:qt=J.stateNode,wr=!1;break e;case 3:qt=J.stateNode.containerInfo,wr=!0;break e;case 4:qt=J.stateNode.containerInfo,wr=!0;break e}J=J.return}if(qt===null)throw Error(n(160));ad(w,A,p),qt=null,wr=!1;var re=p.alternate;re!==null&&(re.return=null),p.return=null}catch(_e){bn(p,i,_e)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)cd(i,r),i=i.sibling}function cd(r,i){var l=r.alternate,f=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Ss(i,r),Hs(r),f&4){try{La(3,r,r.return),Ra(3,r)}catch(Qe){bn(r,r.return,Qe)}try{La(5,r,r.return)}catch(Qe){bn(r,r.return,Qe)}}break;case 1:Ss(i,r),Hs(r),f&512&&l!==null&&qo(l,l.return);break;case 5:if(Ss(i,r),Hs(r),f&512&&l!==null&&qo(l,l.return),r.flags&32){var p=r.stateNode;try{jt(p,"")}catch(Qe){bn(r,r.return,Qe)}}if(f&4&&(p=r.stateNode,p!=null)){var w=r.memoizedProps,A=l!==null?l.memoizedProps:w,J=r.type,re=r.updateQueue;if(r.updateQueue=null,re!==null)try{J==="input"&&w.type==="radio"&&w.name!=null&&nt(p,w),ar(J,A);var _e=ar(J,w);for(A=0;A<re.length;A+=2){var Ae=re[A],Le=re[A+1];Ae==="style"?yn(p,Le):Ae==="dangerouslySetInnerHTML"?Vn(p,Le):Ae==="children"?jt(p,Le):q(p,Ae,Le,_e)}switch(J){case"input":Ne(p,w);break;case"textarea":Ft(p,w);break;case"select":var Me=p._wrapperState.wasMultiple;p._wrapperState.wasMultiple=!!w.multiple;var Xe=w.value;Xe!=null?Ie(p,!!w.multiple,Xe,!1):Me!==!!w.multiple&&(w.defaultValue!=null?Ie(p,!!w.multiple,w.defaultValue,!0):Ie(p,!!w.multiple,w.multiple?[]:"",!1))}p[xa]=w}catch(Qe){bn(r,r.return,Qe)}}break;case 6:if(Ss(i,r),Hs(r),f&4){if(r.stateNode===null)throw Error(n(162));p=r.stateNode,w=r.memoizedProps;try{p.nodeValue=w}catch(Qe){bn(r,r.return,Qe)}}break;case 3:if(Ss(i,r),Hs(r),f&4&&l!==null&&l.memoizedState.isDehydrated)try{vo(i.containerInfo)}catch(Qe){bn(r,r.return,Qe)}break;case 4:Ss(i,r),Hs(r);break;case 13:Ss(i,r),Hs(r),p=r.child,p.flags&8192&&(w=p.memoizedState!==null,p.stateNode.isHidden=w,!w||p.alternate!==null&&p.alternate.memoizedState!==null||(hd=an())),f&4&&ld(r);break;case 22:if(Ae=l!==null&&l.memoizedState!==null,r.mode&1?(mr=(_e=mr)||Ae,Ss(i,r),mr=_e):Ss(i,r),Hs(r),f&8192){if(_e=r.memoizedState!==null,(r.stateNode.isHidden=_e)&&!Ae&&(r.mode&1)!==0)for(Je=r,Ae=r.child;Ae!==null;){for(Le=Je=Ae;Je!==null;){switch(Me=Je,Xe=Me.child,Me.tag){case 0:case 11:case 14:case 15:La(4,Me,Me.return);break;case 1:qo(Me,Me.return);var Ze=Me.stateNode;if(typeof Ze.componentWillUnmount=="function"){f=Me,l=Me.return;try{i=f,Ze.props=i.memoizedProps,Ze.state=i.memoizedState,Ze.componentWillUnmount()}catch(Qe){bn(f,l,Qe)}}break;case 5:qo(Me,Me.return);break;case 22:if(Me.memoizedState!==null){dd(Le);continue}}Xe!==null?(Xe.return=Me,Je=Xe):dd(Le)}Ae=Ae.sibling}e:for(Ae=null,Le=r;;){if(Le.tag===5){if(Ae===null){Ae=Le;try{p=Le.stateNode,_e?(w=p.style,typeof w.setProperty=="function"?w.setProperty("display","none","important"):w.display="none"):(J=Le.stateNode,re=Le.memoizedProps.style,A=re!=null&&re.hasOwnProperty("display")?re.display:null,J.style.display=Nn("display",A))}catch(Qe){bn(r,r.return,Qe)}}}else if(Le.tag===6){if(Ae===null)try{Le.stateNode.nodeValue=_e?"":Le.memoizedProps}catch(Qe){bn(r,r.return,Qe)}}else if((Le.tag!==22&&Le.tag!==23||Le.memoizedState===null||Le===r)&&Le.child!==null){Le.child.return=Le,Le=Le.child;continue}if(Le===r)break e;for(;Le.sibling===null;){if(Le.return===null||Le.return===r)break e;Ae===Le&&(Ae=null),Le=Le.return}Ae===Le&&(Ae=null),Le.sibling.return=Le.return,Le=Le.sibling}}break;case 19:Ss(i,r),Hs(r),f&4&&ld(r);break;case 21:break;default:Ss(i,r),Hs(r)}}function Hs(r){var i=r.flags;if(i&2){try{e:{for(var l=r.return;l!==null;){if(zf(l)){var f=l;break e}l=l.return}throw Error(n(160))}switch(f.tag){case 5:var p=f.stateNode;f.flags&32&&(jt(p,""),f.flags&=-33);var w=Ui(r);El(r,w,p);break;case 3:case 4:var A=f.stateNode.containerInfo,J=Ui(r);Cl(r,J,A);break;default:throw Error(n(161))}}catch(re){bn(r,r.return,re)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function ud(r,i,l){Je=r,Pa(r)}function Pa(r,i,l){for(var f=(r.mode&1)!==0;Je!==null;){var p=Je,w=p.child;if(p.tag===22&&f){var A=p.memoizedState!==null||fo;if(!A){var J=p.alternate,re=J!==null&&J.memoizedState!==null||mr;J=fo;var _e=mr;if(fo=A,(mr=re)&&!_e)for(Je=p;Je!==null;)A=Je,re=A.child,A.tag===22&&A.memoizedState!==null?fd(p):re!==null?(re.return=A,Je=re):fd(p);for(;w!==null;)Je=w,Pa(w),w=w.sibling;Je=p,fo=J,mr=_e}$l(r)}else(p.subtreeFlags&8772)!==0&&w!==null?(w.return=p,Je=w):$l(r)}}function $l(r){for(;Je!==null;){var i=Je;if((i.flags&8772)!==0){var l=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:mr||Ra(5,i);break;case 1:var f=i.stateNode;if(i.flags&4&&!mr)if(l===null)f.componentDidMount();else{var p=i.elementType===i.type?l.memoizedProps:Ds(i.type,l.memoizedProps);f.componentDidUpdate(p,l.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var w=i.updateQueue;w!==null&&xf(i,w,f);break;case 3:var A=i.updateQueue;if(A!==null){if(l=null,i.child!==null)switch(i.child.tag){case 5:l=i.child.stateNode;break;case 1:l=i.child.stateNode}xf(i,A,l)}break;case 5:var J=i.stateNode;if(l===null&&i.flags&4){l=J;var re=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&l.focus();break;case"img":re.src&&(l.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var _e=i.alternate;if(_e!==null){var Ae=_e.memoizedState;if(Ae!==null){var Le=Ae.dehydrated;Le!==null&&vo(Le)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}mr||i.flags&512&&bs(i)}catch(Me){bn(i,i.return,Me)}}if(i===r){Je=null;break}if(l=i.sibling,l!==null){l.return=i.return,Je=l;break}Je=i.return}}function dd(r){for(;Je!==null;){var i=Je;if(i===r){Je=null;break}var l=i.sibling;if(l!==null){l.return=i.return,Je=l;break}Je=i.return}}function fd(r){for(;Je!==null;){var i=Je;try{switch(i.tag){case 0:case 11:case 15:var l=i.return;try{Ra(4,i)}catch(re){bn(i,l,re)}break;case 1:var f=i.stateNode;if(typeof f.componentDidMount=="function"){var p=i.return;try{f.componentDidMount()}catch(re){bn(i,p,re)}}var w=i.return;try{bs(i)}catch(re){bn(i,w,re)}break;case 5:var A=i.return;try{bs(i)}catch(re){bn(i,A,re)}}}catch(re){bn(i,i.return,re)}if(i===r){Je=null;break}var J=i.sibling;if(J!==null){J.return=i.return,Je=J;break}Je=i.return}}var If=Math.ceil,Ws=z.ReactCurrentDispatcher,md=z.ReactCurrentOwner,js=z.ReactCurrentBatchConfig,Zt=0,Tn=null,Dn=null,Jn=0,Wr=0,Vo=Ai(0),Zn=0,Hi=null,ns=0,Dc=0,Go=0,Ml=null,qr=null,hd=0,Yo=1/0,mi=null,Al=!1,Fc=null,Wi=null,Tl=!1,qi=null,Ll=0,Oa=0,Bc=null,Rl=-1,Pl=0;function br(){return(Zt&6)!==0?an():Rl!==-1?Rl:Rl=an()}function _(r){return(r.mode&1)===0?1:(Zt&2)!==0&&Jn!==0?Jn&-Jn:gf.transition!==null?(Pl===0&&(Pl=Yn()),Pl):(r=Yt,r!==0||(r=window.event,r=r===void 0?16:we(r.type)),r)}function k(r,i,l,f){if(50<Oa)throw Oa=0,Bc=null,Error(n(185));Fn(r,l,f),((Zt&2)===0||r!==Tn)&&(r===Tn&&((Zt&2)===0&&(Dc|=l),Zn===4&&X(r,Jn)),N(r,f),l===1&&Zt===0&&(i.mode&1)===0&&(Yo=an()+500,Is&&Li()))}function N(r,i){var l=r.callbackNode;In(r,i);var f=Xs(r,r===Tn?Jn:0);if(f===0)l!==null&&vi(l),r.callbackNode=null,r.callbackPriority=0;else if(i=f&-f,r.callbackPriority!==i){if(l!=null&&vi(l),i===1)r.tag===0?hl(Se.bind(null,r)):ba(Se.bind(null,r)),th(function(){(Zt&6)===0&&Li()}),l=null;else{switch(go(f)){case 1:l=Yr;break;case 4:l=Ms;break;case 16:l=As;break;case 536870912:l=rt;break;default:l=As}l=gp(l,T.bind(null,r))}r.callbackPriority=i,r.callbackNode=l}}function T(r,i){if(Rl=-1,Pl=0,(Zt&6)!==0)throw Error(n(327));var l=r.callbackNode;if(wn()&&r.callbackNode!==l)return null;var f=Xs(r,r===Tn?Jn:0);if(f===0)return null;if((f&30)!==0||(f&r.expiredLanes)!==0||i)i=$t(r,f);else{i=f;var p=Zt;Zt|=2;var w=ze();(Tn!==r||Jn!==i)&&(mi=null,Yo=an()+500,Ce(r,i));do try{Be();break}catch(J){Re(r,J)}while(!0);Tu(),Ws.current=w,Zt=p,Dn!==null?i=0:(Tn=null,Jn=0,i=Zn)}if(i!==0){if(i===2&&(p=ls(r),p!==0&&(f=p,i=B(r,p))),i===1)throw l=Hi,Ce(r,0),X(r,f),N(r,an()),l;if(i===6)X(r,f);else{if(p=r.current.alternate,(f&30)===0&&!V(p)&&(i=$t(r,f),i===2&&(w=ls(r),w!==0&&(f=w,i=B(r,w))),i===1))throw l=Hi,Ce(r,0),X(r,f),N(r,an()),l;switch(r.finishedWork=p,r.finishedLanes=f,i){case 0:case 1:throw Error(n(345));case 2:xt(r,qr,mi);break;case 3:if(X(r,f),(f&130023424)===f&&(i=hd+500-an(),10<i)){if(Xs(r,0)!==0)break;if(p=r.suspendedLanes,(p&f)!==f){br(),r.pingedLanes|=r.suspendedLanes&p;break}r.timeoutHandle=ps(xt.bind(null,r,qr,mi),i);break}xt(r,qr,mi);break;case 4:if(X(r,f),(f&4194240)===f)break;for(i=r.eventTimes,p=-1;0<f;){var A=31-_r(f);w=1<<A,A=i[A],A>p&&(p=A),f&=~w}if(f=p,f=an()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3e3>f?3e3:4320>f?4320:1960*If(f/1960))-f,10<f){r.timeoutHandle=ps(xt.bind(null,r,qr,mi),f);break}xt(r,qr,mi);break;case 5:xt(r,qr,mi);break;default:throw Error(n(329))}}}return N(r,an()),r.callbackNode===l?T.bind(null,r):null}function B(r,i){var l=Ml;return r.current.memoizedState.isDehydrated&&(Ce(r,i).flags|=256),r=$t(r,i),r!==2&&(i=qr,qr=l,i!==null&&H(i)),r}function H(r){qr===null?qr=r:qr.push.apply(qr,r)}function V(r){for(var i=r;;){if(i.flags&16384){var l=i.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var f=0;f<l.length;f++){var p=l[f],w=p.getSnapshot;p=p.value;try{if(!Kr(w(),p))return!1}catch{return!1}}}if(l=i.child,i.subtreeFlags&16384&&l!==null)l.return=i,i=l;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function X(r,i){for(i&=~Go,i&=~Dc,r.suspendedLanes|=i,r.pingedLanes&=~i,r=r.expirationTimes;0<i;){var l=31-_r(i),f=1<<l;r[l]=-1,i&=~f}}function Se(r){if((Zt&6)!==0)throw Error(n(327));wn();var i=Xs(r,0);if((i&1)===0)return N(r,an()),null;var l=$t(r,i);if(r.tag!==0&&l===2){var f=ls(r);f!==0&&(i=f,l=B(r,f))}if(l===1)throw l=Hi,Ce(r,0),X(r,i),N(r,an()),l;if(l===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=i,xt(r,qr,mi),N(r,an()),null}function ie(r,i){var l=Zt;Zt|=1;try{return r(i)}finally{Zt=l,Zt===0&&(Yo=an()+500,Is&&Li())}}function U(r){qi!==null&&qi.tag===0&&(Zt&6)===0&&wn();var i=Zt;Zt|=1;var l=js.transition,f=Yt;try{if(js.transition=null,Yt=1,r)return r()}finally{Yt=f,js.transition=l,Zt=i,(Zt&6)===0&&Li()}}function xe(){Wr=Vo.current,ln(Vo)}function Ce(r,i){r.finishedWork=null,r.finishedLanes=0;var l=r.timeoutHandle;if(l!==-1&&(r.timeoutHandle=-1,ff(l)),Dn!==null)for(l=Dn.return;l!==null;){var f=l;switch(ja(f),f.tag){case 1:f=f.type.childContextTypes,f!=null&&Ro();break;case 3:dr(),ln(lr),ln(sr),bl();break;case 5:Pu(f);break;case 4:dr();break;case 13:ln(On);break;case 19:ln(On);break;case 10:xc(f.type._context);break;case 22:case 23:xe()}l=l.return}if(Tn=r,Dn=r=za(r.current,null),Jn=Wr=i,Zn=0,Hi=null,Go=Dc=ns=0,qr=Ml=null,ci!==null){for(i=0;i<ci.length;i++)if(l=ci[i],f=l.interleaved,f!==null){l.interleaved=null;var p=f.next,w=l.pending;if(w!==null){var A=w.next;w.next=p,f.next=A}l.pending=f}ci=null}return r}function Re(r,i){do{var l=Dn;try{if(Tu(),Ec.current=Ac,lo){for(var f=kn.memoizedState;f!==null;){var p=f.queue;p!==null&&(p.pending=null),f=f.next}lo=!1}if(ao=0,Xn=Jt=kn=null,Fo=!1,zi=0,md.current=null,l===null||l.return===null){Zn=1,Hi=i,Dn=null;break}e:{var w=r,A=l.return,J=l,re=i;if(i=Jn,J.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var _e=re,Ae=J,Le=Ae.tag;if((Ae.mode&1)===0&&(Le===0||Le===11||Le===15)){var Me=Ae.alternate;Me?(Ae.updateQueue=Me.updateQueue,Ae.memoizedState=Me.memoizedState,Ae.lanes=Me.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Xe=Bi(A);if(Xe!==null){Xe.flags&=-257,Bs(Xe,A,J,w,i),Xe.mode&1&&Fi(w,_e,i),i=Xe,re=_e;var Ze=i.updateQueue;if(Ze===null){var Qe=new Set;Qe.add(re),i.updateQueue=Qe}else Ze.add(re);break e}else{if((i&1)===0){Fi(w,_e,i),Ue();break e}re=Error(n(426))}}else if($n&&J.mode&1){var Qn=Bi(A);if(Qn!==null){(Qn.flags&65536)===0&&(Qn.flags|=256),Bs(Qn,A,J,w,i),yc(Ii(re,J));break e}}w=re=Ii(re,J),Zn!==4&&(Zn=2),Ml===null?Ml=[w]:Ml.push(w),w=A;do{switch(w.tag){case 3:w.flags|=65536,i&=-i,w.lanes|=i;var fe=ir(w,re,i);Sc(w,fe);break e;case 1:J=re;var oe=w.type,me=w.stateNode;if((w.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(Wi===null||!Wi.has(me)))){w.flags|=65536,i&=-i,w.lanes|=i;var De=Fs(w,J,i);Sc(w,De);break e}}w=w.return}while(w!==null)}gt(l)}catch(et){i=et,Dn===l&&l!==null&&(Dn=l=l.return);continue}break}while(!0)}function ze(){var r=Ws.current;return Ws.current=Ac,r===null?Ac:r}function Ue(){(Zn===0||Zn===3||Zn===2)&&(Zn=4),Tn===null||(ns&268435455)===0&&(Dc&268435455)===0||X(Tn,Jn)}function $t(r,i){var l=Zt;Zt|=2;var f=ze();(Tn!==r||Jn!==i)&&(mi=null,Ce(r,i));do try{bt();break}catch(p){Re(r,p)}while(!0);if(Tu(),Zt=l,Ws.current=f,Dn!==null)throw Error(n(261));return Tn=null,Jn=0,Zn}function bt(){for(;Dn!==null;)ot(Dn)}function Be(){for(;Dn!==null&&!Ys();)ot(Dn)}function ot(r){var i=pp(r.alternate,r,Wr);r.memoizedProps=r.pendingProps,i===null?gt(r):Dn=i,md.current=null}function gt(r){var i=r;do{var l=i.alternate;if(r=i.return,(i.flags&32768)===0){if(l=ch(l,i,Wr),l!==null){Dn=l;return}}else{if(l=ts(l,i),l!==null){l.flags&=32767,Dn=l;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Zn=6,Dn=null;return}}if(i=i.sibling,i!==null){Dn=i;return}Dn=i=r}while(i!==null);Zn===0&&(Zn=5)}function xt(r,i,l){var f=Yt,p=js.transition;try{js.transition=null,Yt=1,Ln(r,i,l,f)}finally{js.transition=p,Yt=f}return null}function Ln(r,i,l,f){do wn();while(qi!==null);if((Zt&6)!==0)throw Error(n(327));l=r.finishedWork;var p=r.finishedLanes;if(l===null)return null;if(r.finishedWork=null,r.finishedLanes=0,l===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var w=l.lanes|l.childLanes;if(us(r,w),r===Tn&&(Dn=Tn=null,Jn=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||Tl||(Tl=!0,gp(As,function(){return wn(),null})),w=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||w){w=js.transition,js.transition=null;var A=Yt;Yt=1;var J=Zt;Zt|=4,md.current=null,uh(r,l),cd(l,r),Qm(_s),pr=!!va,_s=va=null,r.current=l,ud(l),Or(),Zt=J,Yt=A,js.transition=w}else r.current=l;if(Tl&&(Tl=!1,qi=r,Ll=p),w=r.pendingLanes,w===0&&(Wi=null),xi(l.stateNode),N(r,an()),i!==null)for(f=r.onRecoverableError,l=0;l<i.length;l++)p=i[l],f(p.value,{componentStack:p.stack,digest:p.digest});if(Al)throw Al=!1,r=Fc,Fc=null,r;return(Ll&1)!==0&&r.tag!==0&&wn(),w=r.pendingLanes,(w&1)!==0?r===Bc?Oa++:(Oa=0,Bc=r):Oa=0,Li(),null}function wn(){if(qi!==null){var r=go(Ll),i=js.transition,l=Yt;try{if(js.transition=null,Yt=16>r?16:r,qi===null)var f=!1;else{if(r=qi,qi=null,Ll=0,(Zt&6)!==0)throw Error(n(331));var p=Zt;for(Zt|=4,Je=r.current;Je!==null;){var w=Je,A=w.child;if((Je.flags&16)!==0){var J=w.deletions;if(J!==null){for(var re=0;re<J.length;re++){var _e=J[re];for(Je=_e;Je!==null;){var Ae=Je;switch(Ae.tag){case 0:case 11:case 15:La(8,Ae,w)}var Le=Ae.child;if(Le!==null)Le.return=Ae,Je=Le;else for(;Je!==null;){Ae=Je;var Me=Ae.sibling,Xe=Ae.return;if(Nl(Ae),Ae===_e){Je=null;break}if(Me!==null){Me.return=Xe,Je=Me;break}Je=Xe}}}var Ze=w.alternate;if(Ze!==null){var Qe=Ze.child;if(Qe!==null){Ze.child=null;do{var Qn=Qe.sibling;Qe.sibling=null,Qe=Qn}while(Qe!==null)}}Je=w}}if((w.subtreeFlags&2064)!==0&&A!==null)A.return=w,Je=A;else e:for(;Je!==null;){if(w=Je,(w.flags&2048)!==0)switch(w.tag){case 0:case 11:case 15:La(9,w,w.return)}var fe=w.sibling;if(fe!==null){fe.return=w.return,Je=fe;break e}Je=w.return}}var oe=r.current;for(Je=oe;Je!==null;){A=Je;var me=A.child;if((A.subtreeFlags&2064)!==0&&me!==null)me.return=A,Je=me;else e:for(A=oe;Je!==null;){if(J=Je,(J.flags&2048)!==0)try{switch(J.tag){case 0:case 11:case 15:Ra(9,J)}}catch(et){bn(J,J.return,et)}if(J===A){Je=null;break e}var De=J.sibling;if(De!==null){De.return=J.return,Je=De;break e}Je=J.return}}if(Zt=p,Li(),Cr&&typeof Cr.onPostCommitFiberRoot=="function")try{Cr.onPostCommitFiberRoot(rn,r)}catch{}f=!0}return f}finally{Yt=l,js.transition=i}}return!1}function ks(r,i,l){i=Ii(l,i),i=ir(r,i,1),r=ft(r,i,1),i=br(),r!==null&&(Fn(r,1,i),N(r,i))}function bn(r,i,l){if(r.tag===3)ks(r,r,l);else for(;i!==null;){if(i.tag===3){ks(i,r,l);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(Wi===null||!Wi.has(f))){r=Ii(l,r),r=Fs(i,r,1),i=ft(i,r,1),r=br(),i!==null&&(Fn(i,1,r),N(i,r));break}}i=i.return}}function Dx(r,i,l){var f=r.pingCache;f!==null&&f.delete(i),i=br(),r.pingedLanes|=r.suspendedLanes&l,Tn===r&&(Jn&l)===l&&(Zn===4||Zn===3&&(Jn&130023424)===Jn&&500>an()-hd?Ce(r,0):Go|=l),N(r,i)}function _p(r,i){i===0&&((r.mode&1)===0?i=1:(i=as,as<<=1,(as&130023424)===0&&(as=4194304)));var l=br();r=Mn(r,i),r!==null&&(Fn(r,i,l),N(r,l))}function Fx(r){var i=r.memoizedState,l=0;i!==null&&(l=i.retryLane),_p(r,l)}function Bx(r,i){var l=0;switch(r.tag){case 13:var f=r.stateNode,p=r.memoizedState;p!==null&&(l=p.retryLane);break;case 19:f=r.stateNode;break;default:throw Error(n(314))}f!==null&&f.delete(i),_p(r,l)}var pp;pp=function(r,i,l){if(r!==null)if(r.memoizedProps!==i.pendingProps||lr.current)fr=!0;else{if((r.lanes&l)===0&&(i.flags&128)===0)return fr=!1,lh(r,i,l);fr=(r.flags&131072)!==0}else fr=!1,$n&&(i.flags&1048576)!==0&&io(i,Ri,i.index);switch(i.lanes=0,i.tag){case 2:var f=i.type;vr(r,i),r=i.pendingProps;var p=zs(i,sr.current);oo(i,l),p=Iu(null,i,f,r,p,l);var w=Sl();return i.flags|=1,typeof p=="object"&&p!==null&&typeof p.render=="function"&&p.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,Fr(f)?(w=!0,_c(i)):w=!1,i.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,wc(i),p.updater=Tc,i.stateNode=p,p._reactInternals=i,Ju(i,f,r,l),i=Pc(null,i,f,!0,w,l)):(i.tag=0,$n&&w&&cr(i),Lr(null,i,p,l),i=i.child),i;case 16:f=i.elementType;e:{switch(vr(r,i),r=i.pendingProps,p=f._init,f=p(f._payload),i.type=f,p=i.tag=Hx(f),r=Ds(f,r),p){case 0:i=Wo(null,i,f,r,l);break e;case 1:i=ed(null,i,f,r,l);break e;case 11:i=Rc(null,i,f,r,l);break e;case 14:i=Mf(null,i,f,Ds(f.type,r),l);break e}throw Error(n(306,f,""))}return i;case 0:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ds(f,p),Wo(r,i,f,p,l);case 1:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ds(f,p),ed(r,i,f,p,l);case 3:e:{if(Tf(i),r===null)throw Error(n(387));f=i.pendingProps,w=i.memoizedState,p=w.element,Do(r,i),jc(i,f,null,l);var A=i.memoizedState;if(f=A.element,w.isDehydrated)if(w={element:f,isDehydrated:!1,cache:A.cache,pendingSuspenseBoundaries:A.pendingSuspenseBoundaries,transitions:A.transitions},i.updateQueue.baseState=w,i.memoizedState=w,i.flags&256){p=Ii(Error(n(423)),i),i=td(r,i,f,l,p);break e}else if(f!==p){p=Ii(Error(n(424)),i),i=td(r,i,f,l,p);break e}else for(Zr=gs(i.stateNode.containerInfo.firstChild),Mr=i,$n=!0,Ur=null,l=vf(i,null,f,l),i.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Io(),f===p){i=Hr(r,i,l);break e}Lr(r,i,f,l)}i=i.child}return i;case 5:return kc(i),r===null&&zo(i),f=i.type,p=i.pendingProps,w=r!==null?r.memoizedProps:null,A=p.children,si(f,p)?A=null:w!==null&&si(f,w)&&(i.flags|=32),co(r,i),Lr(r,i,A,l),i.child;case 6:return r===null&&zo(i),null;case 13:return kl(r,i,l);case 4:return Ru(i,i.stateNode.containerInfo),f=i.pendingProps,r===null?i.child=Na(i,null,f,l):Lr(r,i,f,l),i.child;case 11:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ds(f,p),Rc(r,i,f,p,l);case 7:return Lr(r,i,i.pendingProps,l),i.child;case 8:return Lr(r,i,i.pendingProps.children,l),i.child;case 12:return Lr(r,i,i.pendingProps.children,l),i.child;case 10:e:{if(f=i.type._context,p=i.pendingProps,w=i.memoizedProps,A=p.value,xn(vc,f._currentValue),f._currentValue=A,w!==null)if(Kr(w.value,A)){if(w.children===p.children&&!lr.current){i=Hr(r,i,l);break e}}else for(w=i.child,w!==null&&(w.return=i);w!==null;){var J=w.dependencies;if(J!==null){A=w.child;for(var re=J.firstContext;re!==null;){if(re.context===f){if(w.tag===1){re=di(-1,l&-l),re.tag=2;var _e=w.updateQueue;if(_e!==null){_e=_e.shared;var Ae=_e.pending;Ae===null?re.next=re:(re.next=Ae.next,Ae.next=re),_e.pending=re}}w.lanes|=l,re=w.alternate,re!==null&&(re.lanes|=l),Lu(w.return,l,i),J.lanes|=l;break}re=re.next}}else if(w.tag===10)A=w.type===i.type?null:w.child;else if(w.tag===18){if(A=w.return,A===null)throw Error(n(341));A.lanes|=l,J=A.alternate,J!==null&&(J.lanes|=l),Lu(A,l,i),A=w.sibling}else A=w.child;if(A!==null)A.return=w;else for(A=w;A!==null;){if(A===i){A=null;break}if(w=A.sibling,w!==null){w.return=A.return,A=w;break}A=A.return}w=A}Lr(r,i,p.children,l),i=i.child}return i;case 9:return p=i.type,f=i.pendingProps.children,oo(i,l),p=Pe(p),f=f(p),i.flags|=1,Lr(r,i,f,l),i.child;case 14:return f=i.type,p=Ds(f,i.pendingProps),p=Ds(f.type,p),Mf(r,i,f,p,l);case 15:return Af(r,i,i.type,i.pendingProps,l);case 17:return f=i.type,p=i.pendingProps,p=i.elementType===f?p:Ds(f,p),vr(r,i),i.tag=1,Fr(f)?(r=!0,_c(i)):r=!1,oo(i,l),Lc(i,f,p),Ju(i,f,p,l),Pc(null,i,f,!0,r,l);case 19:return Rf(r,i,l);case 22:return Qu(r,i,l)}throw Error(n(156,i.tag))};function gp(r,i){return $s(r,i)}function Ux(r,i,l,f){this.tag=r,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hi(r,i,l,f){return new Ux(r,i,l,f)}function dh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Hx(r){if(typeof r=="function")return dh(r)?1:0;if(r!=null){if(r=r.$$typeof,r===D)return 11;if(r===R)return 14}return 2}function za(r,i){var l=r.alternate;return l===null?(l=hi(r.tag,i,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=i,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&14680064,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,i=r.dependencies,l.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l}function Df(r,i,l,f,p,w){var A=2;if(f=r,typeof r=="function")dh(r)&&(A=1);else if(typeof r=="string")A=5;else e:switch(r){case Z:return Ol(l.children,p,w,i);case ne:A=8,p|=8;break;case ue:return r=hi(12,l,i,p|2),r.elementType=ue,r.lanes=w,r;case E:return r=hi(13,l,i,p),r.elementType=E,r.lanes=w,r;case j:return r=hi(19,l,i,p),r.elementType=j,r.lanes=w,r;case ee:return Ff(l,p,w,i);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case de:A=10;break e;case pe:A=9;break e;case D:A=11;break e;case R:A=14;break e;case O:A=16,f=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return i=hi(A,l,i,p),i.elementType=r,i.type=f,i.lanes=w,i}function Ol(r,i,l,f){return r=hi(7,r,f,i),r.lanes=l,r}function Ff(r,i,l,f){return r=hi(22,r,f,i),r.elementType=ee,r.lanes=l,r.stateNode={isHidden:!1},r}function fh(r,i,l){return r=hi(6,r,null,i),r.lanes=l,r}function mh(r,i,l){return i=hi(4,r.children!==null?r.children:[],r.key,i),i.lanes=l,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}function Wx(r,i,l,f,p){this.tag=i,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=cs(0),this.expirationTimes=cs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cs(0),this.identifierPrefix=f,this.onRecoverableError=p,this.mutableSourceEagerHydrationData=null}function hh(r,i,l,f,p,w,A,J,re){return r=new Wx(r,i,l,J,re),i===1?(i=1,w===!0&&(i|=8)):i=0,w=hi(3,null,null,i),r.current=w,w.stateNode=r,w.memoizedState={element:f,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},wc(w),r}function qx(r,i,l){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Q,key:f==null?null:""+f,children:r,containerInfo:i,implementation:l}}function yp(r){if(!r)return ys;r=r._reactInternals;e:{if(gn(r)!==r||r.tag!==1)throw Error(n(170));var i=r;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(Fr(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(r.tag===1){var l=r.type;if(Fr(l))return Po(r,l,i)}return i}function vp(r,i,l,f,p,w,A,J,re){return r=hh(l,f,!0,r,p,w,A,J,re),r.context=yp(null),l=r.current,f=br(),p=_(l),w=di(f,p),w.callback=i??null,ft(l,w,p),r.current.lanes=p,Fn(r,p,f),N(r,f),r}function Bf(r,i,l,f){var p=i.current,w=br(),A=_(p);return l=yp(l),i.context===null?i.context=l:i.pendingContext=l,i=di(w,A),i.payload={element:r},f=f===void 0?null:f,f!==null&&(i.callback=f),r=ft(p,i,A),r!==null&&(k(r,p,A,w),bc(r,p,A)),A}function Uf(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function xp(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<i?l:i}}function _h(r,i){xp(r,i),(r=r.alternate)&&xp(r,i)}function Vx(){return null}var wp=typeof reportError=="function"?reportError:function(r){console.error(r)};function ph(r){this._internalRoot=r}Hf.prototype.render=ph.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(n(409));Bf(r,i,null,null)},Hf.prototype.unmount=ph.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;U(function(){Bf(null,r,null,null)}),i[ii]=null}};function Hf(r){this._internalRoot=r}Hf.prototype.unstable_scheduleHydration=function(r){if(r){var i=Qa();r={blockedOn:null,target:r,priority:i};for(var l=0;l<Ir.length&&i!==0&&i<Ir[l].priority;l++);Ir.splice(l,0,r),l===0&&Qs(r)}};function gh(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Wf(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function bp(){}function Gx(r,i,l,f,p){if(p){if(typeof f=="function"){var w=f;f=function(){var _e=Uf(A);w.call(_e)}}var A=vp(i,f,r,0,null,!1,!1,"",bp);return r._reactRootContainer=A,r[ii]=A.current,Ei(r.nodeType===8?r.parentNode:r),U(),A}for(;p=r.lastChild;)r.removeChild(p);if(typeof f=="function"){var J=f;f=function(){var _e=Uf(re);J.call(_e)}}var re=hh(r,0,!1,null,null,!1,!1,"",bp);return r._reactRootContainer=re,r[ii]=re.current,Ei(r.nodeType===8?r.parentNode:r),U(function(){Bf(i,re,l,f)}),re}function qf(r,i,l,f,p){var w=l._reactRootContainer;if(w){var A=w;if(typeof p=="function"){var J=p;p=function(){var re=Uf(A);J.call(re)}}Bf(i,A,r,p)}else A=Gx(l,i,r,p,f);return Uf(A)}oa=function(r){switch(r.tag){case 3:var i=r.stateNode;if(i.current.memoizedState.isDehydrated){var l=Gn(i.pendingLanes);l!==0&&(Js(i,l|1),N(i,an()),(Zt&6)===0&&(Yo=an()+500,Li()))}break;case 13:U(function(){var f=Mn(r,1);if(f!==null){var p=br();k(f,r,1,p)}}),_h(r,1)}},aa=function(r){if(r.tag===13){var i=Mn(r,134217728);if(i!==null){var l=br();k(i,r,134217728,l)}_h(r,134217728)}},zr=function(r){if(r.tag===13){var i=_(r),l=Mn(r,i);if(l!==null){var f=br();k(l,r,i,f)}_h(r,i)}},Qa=function(){return Yt},Zs=function(r,i){var l=Yt;try{return Yt=r,i()}finally{Yt=l}},vn=function(r,i,l){switch(i){case"input":if(Ne(r,l),i=l.name,l.type==="radio"&&i!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<l.length;i++){var f=l[i];if(f!==r&&f.form===r.form){var p=mc(f);if(!p)throw Error(n(90));Ct(f),Ne(f,p)}}}break;case"textarea":Ft(r,l);break;case"select":i=l.value,i!=null&&Ie(r,!!l.multiple,i,!1)}},He=ie,it=U;var Yx={usingClientEntryPoint:!1,Events:[fl,Lo,mc,Te,qe,ie]},_d={findFiberByHostInstance:no,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Kx={bundleType:_d.bundleType,version:_d.version,rendererPackageName:_d.rendererPackageName,rendererConfig:_d.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:z.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Gr(r),r===null?null:r.stateNode},findFiberByHostInstance:_d.findFiberByHostInstance||Vx,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 Vf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vf.isDisabled&&Vf.supportsFiber)try{rn=Vf.inject(Kx),Cr=Vf}catch{}}return Ns.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Yx,Ns.createPortal=function(r,i){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gh(i))throw Error(n(200));return qx(r,i,null,l)},Ns.createRoot=function(r,i){if(!gh(r))throw Error(n(299));var l=!1,f="",p=wp;return i!=null&&(i.unstable_strictMode===!0&&(l=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onRecoverableError!==void 0&&(p=i.onRecoverableError)),i=hh(r,1,!1,null,null,l,!1,f,p),r[ii]=i.current,Ei(r.nodeType===8?r.parentNode:r),new ph(i)},Ns.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Gr(i),r=r===null?null:r.stateNode,r},Ns.flushSync=function(r){return U(r)},Ns.hydrate=function(r,i,l){if(!Wf(i))throw Error(n(200));return qf(null,r,i,!0,l)},Ns.hydrateRoot=function(r,i,l){if(!gh(r))throw Error(n(405));var f=l!=null&&l.hydratedSources||null,p=!1,w="",A=wp;if(l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(w=l.identifierPrefix),l.onRecoverableError!==void 0&&(A=l.onRecoverableError)),i=vp(i,null,r,1,l??null,p,!1,w,A),r[ii]=i.current,Ei(r),f)for(r=0;r<f.length;r++)l=f[r],p=l._getVersion,p=p(l._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[l,p]:i.mutableSourceEagerHydrationData.push(l,p);return new Hf(i)},Ns.render=function(r,i,l){if(!Wf(i))throw Error(n(200));return qf(null,r,i,!1,l)},Ns.unmountComponentAtNode=function(r){if(!Wf(r))throw Error(n(40));return r._reactRootContainer?(U(function(){qf(null,null,r,!1,function(){r._reactRootContainer=null,r[ii]=null})}),!0):!1},Ns.unstable_batchedUpdates=ie,Ns.unstable_renderSubtreeIntoContainer=function(r,i,l,f){if(!Wf(l))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return qf(r,i,l,!1,f)},Ns.version="18.3.1-next-f1338f8080-20240426",Ns}var Mp;function py(){if(Mp)return xh.exports;Mp=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),xh.exports=sw(),xh.exports}var Ap;function iw(){if(Ap)return Gf;Ap=1;var e=py();return Gf.createRoot=e.createRoot,Gf.hydrateRoot=e.hydrateRoot,Gf}var ow=iw();const aw=B_(ow);async function gy(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const n=document.createElement("textarea");return n.value=t,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}}}const lw=3,cw=Number.MAX_SAFE_INTEGER;function yy(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function vy(e){return Array.isArray(e)}function uw(e){const t=e.trim();if(!t)return e;if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function dw(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Kc({kind:e,children:t}){return s.jsx("span",{className:`json-token ${e}`,children:t})}function fw(e){const t=JSON.stringify(e.value),n=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[o,a]=h.useState(!n||e.expansion_mode==="unfolded");return h.useEffect(()=>{n&&a(e.expansion_mode==="unfolded")},[n,e.expansion_mode,e.expansion_version]),n?s.jsxs("span",{className:`json-string ${o?"open":"collapsed"}`,children:[s.jsx("button",{type:"button",className:"json-string__toggle",onClick:()=>a(c=>!c),"aria-label":o?"Collapse string value":"Expand string value","aria-expanded":o,children:o?"▾":"▸"}),o?s.jsx("span",{className:"json-token string json-string__value",children:t}):s.jsxs("button",{type:"button",className:"json-string__preview",onClick:()=>a(!0),"aria-label":"Expand string value",children:[s.jsx("span",{className:"json-token string json-string__preview_text",children:t}),s.jsx("span",{className:"json-string__suffix",children:"(...)"})]})]}):s.jsx(Kc,{kind:"string",children:t})}function mw(e,t,n){return e===null?s.jsx(Kc,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(fw,{value:e,expansion_mode:t,expansion_version:n}):typeof e=="number"?s.jsx(Kc,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(Kc,{kind:"boolean",children:e?"true":"false"}):s.jsx(Kc,{kind:"string",children:JSON.stringify(String(e))})}function hw(e){return vy(e)?e.length===1?"1 item":`${e.length} items`:yy(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function xy(e){const{label:t,value:n,depth:o,collapse_after_depth:a,expansion_mode:c,expansion_version:d,trailing_comma:u}=e,m=o*14,y=yy(n),g=vy(n),v=y||g,x=o<a,[b,C]=h.useState(x);h.useEffect(()=>{C(x)},[x,d]);const S=t?s.jsxs(s.Fragment,{children:[s.jsx(Kc,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[S,mw(n,c,d),u?",":""]});const L=g?"[":"{",M=g?"]":"}",W=hw(n),q=b?`${L}`:`${L}…${M}${W?` (${W})`:""}`,z=g?n.map((Y,Q)=>({key:String(Q),label:void 0,value:Y})):Object.entries(n).map(([Y,Q])=>({key:Y,label:Y,value:Q}));return s.jsxs("details",{className:"json-viewer__details",open:b,onToggle:Y=>C(Y.currentTarget.open),children:[s.jsxs("summary",{className:"json-viewer__summary",style:{paddingLeft:m},children:[S,s.jsx("span",{className:"json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),s.jsx("span",{className:"json-viewer__punct",children:q}),!b&&u?s.jsx("span",{className:"json-viewer__punct",children:","}):null]}),b?s.jsx("div",{className:"json-viewer__children",children:z.length===0?s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"json-viewer__punct",children:M}),u?",":""]}):s.jsxs(s.Fragment,{children:[z.map((Y,Q)=>{const Z=Q===z.length-1;return s.jsx(xy,{label:Y.label,value:Y.value,depth:o+1,collapse_after_depth:a,expansion_mode:c,expansion_version:d,trailing_comma:!Z},`${o}:${t||"root"}:${Y.key}`)}),s.jsxs("div",{className:"json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"json-viewer__punct",children:M}),u?",":""]})]})}):null]})}function wy(e){const{value:t,className:n,showCopy:o=!0}=e,[a,c]=h.useState({mode:"folded",version:0}),d=typeof e.collapseAfterDepth=="number"&&(Number.isFinite(e.collapseAfterDepth)||e.collapseAfterDepth===1/0)&&e.collapseAfterDepth>=0?e.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(e.collapseAfterDepth):lw,u=a.mode==="unfolded"?cw:d,m=h.useMemo(()=>typeof t=="string"?uw(t):t,[t]),y=h.useMemo(()=>dw(t),[t]),g=["json-viewer",n].filter(Boolean).join(" ");h.useEffect(()=>{c(x=>({mode:"folded",version:x.version+1}))},[m]);const v=()=>{c(x=>({mode:x.mode==="unfolded"?"folded":"unfolded",version:x.version+1}))};return s.jsxs("div",{className:g,children:[s.jsxs("div",{className:"json-viewer__toolbar",children:[s.jsx("button",{type:"button",className:"json-viewer__btn json-viewer__toggle-all",onClick:v,"aria-expanded":a.mode==="unfolded",children:a.mode==="unfolded"?"Fold all":"Unfold all"}),o?s.jsx("button",{type:"button",className:"json-viewer__btn json-viewer__copy",onClick:()=>void gy(y),children:"Copy"}):null]}),s.jsx("div",{className:"json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(xy,{value:m,depth:0,collapse_after_depth:u,expansion_mode:a.mode,expansion_version:a.version,trailing_comma:!1})})]})}function Sh(e){const t=[],n=String(e??"");let o=0,a="";const c=()=>{a&&(t.push(a),a="")};for(;o<n.length;){const d=n[o];if(d==="`"){const u=n.indexOf("`",o+1);if(u!==-1){c(),t.push(s.jsx("code",{children:n.slice(o+1,u)},`code:${o}`)),o=u+1;continue}}if(d==="*"&&n[o+1]==="*"){const u=n.indexOf("**",o+2);if(u!==-1){c(),t.push(s.jsx("strong",{children:n.slice(o+2,u)},`bold:${o}`)),o=u+2;continue}}a+=d,o+=1}return c(),t}function _w(e){return String(e??"").replace(/\r\n/g,`
41
+ `).replace(/\r/g,`
42
+ `).split(`
43
+ `)}function pw({text:e,className:t}){const n=_w(e),o=[];let a=0;for(;a<n.length;){const d=n[a],u=String(d??"");if(!u.trim()){a+=1;continue}if(u.trim().startsWith("```")){const x=u.trim().replace(/```/g,"").trim(),b=[];for(a+=1;a<n.length&&!String(n[a]??"").trim().startsWith("```");)b.push(String(n[a]??"")),a+=1;a<n.length&&(a+=1);const C=b.join(`
44
+ `);o.push(s.jsx("pre",{className:"mf-md_pre",children:s.jsx("code",{className:x?`language-${x}`:void 0,children:C})},`pre:${a}`));continue}const m=u.match(/^(#{1,3})\s+(.*)$/);if(m){const v=m[1].length,x=m[2]||"",b=Sh(x);v===1?o.push(s.jsx("h1",{children:b},`h1:${a}`)):v===2?o.push(s.jsx("h2",{children:b},`h2:${a}`)):o.push(s.jsx("h3",{children:b},`h3:${a}`)),a+=1;continue}const y=v=>{const x=v.trimStart();return x.startsWith("- ")||x.startsWith("* ")};if(y(u)){const v=[];for(;a<n.length&&y(String(n[a]??""));){const x=String(n[a]??"").trimStart();v.push(x.slice(2)),a+=1}o.push(s.jsx("ul",{className:"mf-md_ul",children:v.map((x,b)=>s.jsx("li",{children:Sh(x)},`li:${a}:${b}`))},`ul:${a}`));continue}const g=[];for(;a<n.length&&String(n[a]??"").trim();)g.push(String(n[a]??"")),a+=1;o.push(s.jsx("p",{className:"mf-md_p",children:g.map((v,x)=>s.jsxs(ye.Fragment,{children:[Sh(v),x<g.length-1?s.jsx("br",{}):null]},`pl:${a}:${x}`))},`p:${a}`))}const c=["mf-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:c,children:o})}const Tp="observe";function is(e){return!e||typeof e!="object"?null:e}function l_(e,t){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`:""}function Lp(e){const t=is(e);if(!t)return null;const n=typeof t.role=="string"?String(t.role).trim():"",o=typeof t.content=="string"?String(t.content):"";if(!n||o==="")return null;const a=typeof t.name=="string"?String(t.name).trim():"";return{role:n,content:o,name:a||void 0}}function gw(e){if(Array.isArray(e)){if(e.length===0)return null;const n=[];for(const o of e){const a=Lp(o);if(!a)return null;n.push(a)}return n}const t=Lp(e);return t?[t]:null}function yw(e){const t=String(e||"").trim();if(!t)return null;const n=t[0],o=t[t.length-1];if(!(n==="{"&&o==="}"||n==="["&&o==="]"))return null;try{const c=JSON.parse(t);return c&&typeof c=="object"||Array.isArray(c)?c:null}catch{return null}}function vw(e){const t=String(e||"");return t.trim()?!!(t.includes("```")||/\n\s*#{1,3}\s+/.test(t)||/\n\s*[-*]\s+/.test(t)||/\n\s*\d+[\.\)]\s+/.test(t)||t.includes("**")||t.includes("`")):!1}function Rp({text:e}){const t=String(e||""),n=yw(t);if(n!==null)return s.jsx(wy,{value:n});const o=t.trim();return o.startsWith("{")||o.startsWith("[")?s.jsx("pre",{className:"run-details-output",children:t||"(none)"}):t.includes(`
45
+ `)||vw(t)?s.jsx("div",{className:"run-details-output",children:s.jsx(pw,{text:t})}):s.jsx("pre",{className:"run-details-output",children:t||"(none)"})}function by({value:e}){if(e==null)return s.jsx("pre",{className:"run-details-output",children:"(none)"});const t=gw(e);return t?s.jsx("div",{className:"mf-msg-list",children:t.map((n,o)=>s.jsxs("div",{className:"mf-msg",children:[s.jsxs("div",{className:"mf-msg-meta",children:[s.jsx("span",{className:`mf-msg-role ${n.role}`,children:n.role}),n.name?s.jsx("span",{className:"mf-msg-name",children:n.name}):null]}),s.jsx("div",{className:"mf-msg-content",children:s.jsx(Rp,{text:n.content})})]},`${n.role}:${o}`))}):typeof e=="string"?s.jsx(Rp,{text:e}):s.jsx(wy,{value:e})}function Sy(e){const t=e.effect;return!t||typeof t!="object"?null:t}function Ya(e){const t=Sy(e);return(t&&typeof t.type=="string"?t.type:"")||"effect"}function Pm(e){const t=Sy(e),n=t==null?void 0:t.payload;return!n||typeof n!="object"?null:n}function U_(e){const t=e.result;return!t||typeof t!="object"?null:t}function jy(e){if(Ya(e)!=="tool_calls")return[];const n=U_(e),o=n&&Array.isArray(n.results)?n.results:null;if(!o)return[];const a=[];for(const c of o){const d=is(c);if(!d)continue;const u=typeof d.name=="string"?d.name.trim():"";u&&a.push({call_id:typeof d.call_id=="string"?d.call_id:void 0,name:u,success:!!d.success,output:d.output,error:d.error})}return a}function ky(e){if(Ya(e)!=="tool_calls")return[];const n=Pm(e),o=n&&Array.isArray(n.tool_calls)?n.tool_calls:null;if(!o)return[];const a=[];for(const c of o){const d=is(c);if(!d)continue;const u=typeof d.name=="string"?d.name.trim():"";if(!u)continue;const m=is(d.args)||is(d.arguments)||{};a.push({call_id:typeof d.call_id=="string"?d.call_id:void 0,name:u,args:m})}return a}function Om(e){const t=e.error;if(typeof t=="string")return t.trim();const n=is(t);if(n){const o=typeof n.message=="string"?n.message.trim():"",a=typeof n.stack=="string"?n.stack.trim():"";return o||a||""}return""}function Ny(e){if(!e)return"";const t=e.reasoning;if(typeof t=="string")return t.trim();const n=is(t);return n&&typeof n.text=="string"?n.text.trim():""}function Cy(e){const t=Ya(e),n=Pm(e),o=U_(e),a=(c,d)=>{const u=String(c||"").replace(/\s+/g," ").trim();return u?u.length<=d?u:`${u.slice(0,Math.max(0,d-1)).trimEnd()}…`:""};if(t==="llm_call"){const c=o==null?void 0:o.content,d=typeof c=="string"?c.replace(/\s+/g," ").trim():"",u=Ny(o),m=Array.isArray(o==null?void 0:o.tool_calls)?o.tool_calls:null,g=!!(m&&m.length>0)?u||d:d||u;return a(g,220)}if(t==="tool_calls"){const c=o&&Array.isArray(o.results)?o.results:null;if(!c)return"";const d=c.filter(u=>{var m;return((m=is(u))==null?void 0:m.success)===!1});return d.length>0?`${d.length} tool call(s) failed`:`${c.length} tool call(s) executed`}return t==="ask_user"&&n&&typeof n.prompt=="string"?String(n.prompt).trim():""}function ym(e){const t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||Om(e.step)?"failed":t}function xw(e){const t=e.map(n=>ym(n));return t.some(n=>n==="failed")?"failed":t.some(n=>n==="waiting")?"waiting":t.some(n=>n==="running")?"running":"completed"}function jh(e){return e.filter(t=>!t.hidden)}function ww(e){const t=Ya(e),n=Om(e);return jh(t==="llm_call"?[{id:"system",label:"System"},{id:"user",label:"User"},{id:"tools",label:"Tools"},{id:"response",label:"Response"},{id:"reasoning",label:"Reasoning"},{id:"errors",label:"Errors",hidden:!n},{id:"raw",label:"Raw"}]:t==="tool_calls"?[{id:"tools",label:"Tools"},{id:"errors",label:"Errors",hidden:!n},{id:"raw",label:"Raw"}]:[{id:"errors",label:"Errors",hidden:!n},{id:"raw",label:"Raw"}])}function bw(e){const t=Ya(e);return t==="llm_call"?"user":t==="tool_calls"?"tools":Om(e)?"errors":"raw"}function Sw(e){const t=new Map,n=Pm(e),o=n&&Array.isArray(n.tools)?n.tools:null;if(!o)return t;for(const a of o){const c=is(a);if(!c)continue;const d=typeof c.name=="string"?c.name.trim():"";if(!d)continue;const m=(Array.isArray(c.parameters)?c.parameters:[]).map(y=>{const g=is(y);return(g&&typeof g.id=="string"?g.id.trim():"")||""}).filter(Boolean);t.set(d,m)}return t}function Ey(e,t,n){const o=Object.keys(t||{}),a=n&&n.length?n.filter(m=>o.includes(m)):[],c=o.filter(m=>!a.includes(m)).sort(),d=[...a,...c],u=d.slice(0,5).map(m=>{const y=t[m];return typeof y=="string"?`${m}=${JSON.stringify(l_(y,42))}`:typeof y=="number"||typeof y=="boolean"?`${m}=${String(y)}`:y==null?`${m}=null`:`${m}=${l_(JSON.stringify(y),42)}`});return`${e}(${u.join(", ")}${d.length>5?", …":""})`}function jw(e){const t=e.ts?String(e.ts):"";if(!t)return"";try{const n=new Date(t);return Number.isFinite(n.getTime())?n.toLocaleTimeString():""}catch{return""}}function kh({item:e,label:t,toolDefs:n,defaultOpen:o=!1}){const a=e.step,c=Ya(a),d=ww(a),u=bw(a),[m,y]=h.useState(u),[g,v]=h.useState(!!o),x=Pm(a),b=U_(a),C=Om(a),S=jw(e),L=e.nodeId?String(e.nodeId):"",M=e.runId?String(e.runId):"",W=c==="tool_calls"?ky(a):[],q=c==="tool_calls"?jy(a):[],z=W.map(de=>Ey(de.name,de.args,n.get(de.name)||null)),Q=(()=>{if(m==="raw")return a;if(m==="errors")return C||null;if(c==="llm_call"){const de=x||{},pe=typeof de.system_prompt=="string"?String(de.system_prompt):"",D=typeof de.prompt=="string"?String(de.prompt):"",E=is(b==null?void 0:b.metadata),j=E?is(E._runtime_observability):null,R=j?is(j.llm_generate_kwargs):null,O=R&&Array.isArray(R.messages)?R.messages:null,ee=E?is(E._provider_request):null,I=ee?is(ee.payload):null,P=I&&Array.isArray(I.messages)?I.messages:null,G=Array.isArray(de.messages)?de.messages:[],$=O||P||G,K=$.filter(le=>String((le==null?void 0:le.role)||"").trim()==="system"),se=$.filter(le=>String((le==null?void 0:le.role)||"").trim()==="user");if(m==="system"){const le=[],he=pe.trim(),be=!!he&&K.some(je=>typeof(je==null?void 0:je.content)=="string"&&String(je.content).trim()===he);return he&&!be&&le.push({role:"system",name:"system_prompt",content:pe}),le.push(...K),le}if(m==="user"){const le=[],he=D.trim(),be=!!he&&se.some(je=>typeof(je==null?void 0:je.content)=="string"&&String(je.content).trim()===he);return he&&!be&&le.push({role:"user",name:"prompt",content:D}),le.push(...se),le}if(m==="tools")return de.tools||[];if(m==="response"){const le=b==null?void 0:b.content;if(typeof le=="string"&&le.trim())return le;const he=b==null?void 0:b.output;if(he!==void 0)return he;const be=Array.isArray(b==null?void 0:b.tool_calls)?b.tool_calls:null;return be&&be.length?{tool_calls:be}:b}if(m==="reasoning")return Ny(b)||null}return c==="tool_calls"&&m==="tools"?{tool_calls:W,tool_signatures:z,results:q}:a})(),Z=Cy(a),ne=ym(e),ue=ne==="completed"?"OK":ne==="failed"?"ERROR":ne==="waiting"?"WAITING":ne.toUpperCase();return s.jsxs("details",{className:`agent-trace-entry ${ne}`,open:g,onToggle:de=>v(de.currentTarget.open),children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${ne}`,children:ue}),s.jsx("span",{className:"agent-cycle-stage","data-stage":t,children:t}),s.jsx("span",{className:"agent-trace-kind",children:c}),S?s.jsx("span",{className:"agent-trace-node",children:S}):null,L?s.jsx("span",{className:"agent-trace-node",children:L}):null,M?s.jsx("span",{className:"agent-trace-run",children:M}):null]}),Z?s.jsx("div",{className:"agent-trace-preview",children:Z}):null,s.jsxs("div",{className:"agent-trace-body",children:[s.jsx("div",{className:"agent-trace-tabs",children:d.map(de=>s.jsx("button",{type:"button",className:`agent-trace-tab ${de.id===m?"active":""}`,onClick:()=>y(de.id),children:de.label},de.id))}),s.jsx(by,{value:Q})]})]})}function kw({acts:e}){const t=e.flatMap(c=>jy(c.step)),n=t.filter(c=>c.success===!1),o=n.length?`${n.length} error(s)`:t.length?`${t.length} tool result(s)`:"(none)",a=n.length?"failed":"completed";return s.jsxs("details",{className:`agent-trace-entry ${a}`,open:!1,children:[s.jsxs("summary",{className:"agent-trace-summary",children:[s.jsx("span",{className:`agent-trace-status ${a}`,children:n.length?"ERROR":"OK"}),s.jsx("span",{className:"agent-cycle-stage","data-stage":Tp,children:Tp}),s.jsx("span",{className:"agent-trace-kind",children:"OBSERVATIONS"}),s.jsx("span",{className:"agent-trace-preview-inline",children:o})]}),s.jsx("div",{className:"agent-observe-body",children:t.length===0?s.jsx("div",{className:"agent-observe-empty",children:"(no tool results)"}):s.jsx("div",{className:"agent-observe-results",children:t.map((c,d)=>{const u=c.success?"completed":"failed",m=c.success?"OK":"ERROR",y=c.success?c.output:c.error??c.output;return s.jsxs("details",{className:`agent-observe-result ${u}`,open:!1,children:[s.jsxs("summary",{className:"agent-observe-summary",children:[s.jsx("span",{className:`agent-trace-status ${u}`,children:m}),s.jsx("span",{className:"agent-observe-name",children:c.name}),c.call_id?s.jsx("span",{className:"agent-observe-callid",children:c.call_id}):null]}),s.jsx(by,{value:y})]},`${c.name}:${c.call_id||""}:${d}`)})})})]})}function Nw({items:e,subRunId:t,title:n,subtitle:o,onOpenSubRun:a,defaultOpenLatest:c=!0}){const d=h.useMemo(()=>{const v=Array.isArray(e)?e.slice():[];return v.sort((x,b)=>{const C=x.ts?new Date(x.ts).getTime():NaN,S=b.ts?new Date(b.ts).getTime():NaN;return Number.isFinite(C)&&Number.isFinite(S)?C-S:0}),v},[e]),u=h.useMemo(()=>{const v=[];let x=null,b=0;for(const C of d){const S=Ya(C.step);if(S==="llm_call"){b+=1,x={id:`cycle:${C.runId}:${b}:${C.ts||""}`,index:b,items:[C],think:C,acts:[],others:[],status:ym(C),ts:C.ts},v.push(x);continue}x||(b+=1,x={id:`cycle:${C.runId}:${b}:${C.ts||""}`,index:b,items:[],think:null,acts:[],others:[],status:ym(C),ts:C.ts},v.push(x)),x.items.push(C),S==="tool_calls"?x.acts.push(C):x.others.push(C),x.status=xw(x.items)}return v},[d]),m=typeof n=="string"&&n.trim()?n.trim():"Agent calls",y=typeof o=="string"&&o.trim()?o.trim():"Live per-effect trace (LLM/tool calls).",g=typeof t=="string"?t.trim():"";return s.jsxs("div",{className:"agent-trace-panel",children:[s.jsxs("div",{className:"agent-trace-header",children:[s.jsx("div",{className:"agent-trace-title",children:m}),s.jsxs("div",{className:"agent-trace-subtitle",children:[y,g?s.jsxs("span",{className:"agent-trace-subrun",children:[" ","sub_run_id: ",g,s.jsx("button",{type:"button",className:"agent-trace-copy",onClick:v=>{v.stopPropagation(),gy(g)},title:`Copy sub_run_id: ${g}`,"aria-label":"Copy sub run id",children:"⧉"}),a?s.jsx("button",{type:"button",className:"agent-trace-open",onClick:v=>{v.stopPropagation(),a()},title:"Open sub-run",children:"Open"}):null]}):null]})]}),d.length===0?s.jsx("div",{className:"agent-trace-empty",children:"No trace entries yet."}):s.jsxs("div",{className:"agent-cycle-list",children:[s.jsxs("div",{className:"agent-cycle-meta",children:[u.length," cycle(s)"]}),u.map(v=>{const x=v.status,b=x==="completed"?"OK":x==="failed"?"ERROR":x==="waiting"?"WAITING":x.toUpperCase(),C=x==="completed"?"✓":x==="failed"?"✗":"",S=C?`${C} ${b}`:b,L=v.think?Cy(v.think.step):"",M=v.think?Sw(v.think.step):new Map,q=v.acts.flatMap(Y=>ky(Y.step)).map(Y=>Ey(Y.name,Y.args,M.get(Y.name)||null)),z=c&&v.index===u.length;return s.jsxs("details",{className:`agent-cycle ${x}`,open:z,children:[s.jsxs("summary",{className:"agent-cycle-summary",children:[s.jsx("span",{className:`agent-trace-status ${x}`,children:S}),s.jsx("span",{className:"agent-cycle-label",children:"cycle"}),s.jsxs("span",{className:"agent-cycle-index",children:["#",v.index]}),q.length?s.jsxs("span",{className:"agent-trace-badges",children:[q.slice(0,3).map(Y=>s.jsx("span",{className:"run-metric-badge metric-tool",title:Y,children:l_(Y,62)},Y)),q.length>3?s.jsxs("span",{className:"run-metric-badge metric-tool",children:["+",q.length-3]}):null]}):null,s.jsx("span",{className:"agent-cycle-spacer"}),L?s.jsx("span",{className:"agent-cycle-preview",children:L}):null]}),s.jsxs("div",{className:"agent-cycle-body",children:[v.think?s.jsx(kh,{item:v.think,label:"think",toolDefs:M,defaultOpen:z}):null,v.acts.map(Y=>s.jsx(kh,{item:Y,label:"act",toolDefs:M},Y.id)),s.jsx(kw,{acts:v.acts}),v.others.length?s.jsxs("div",{className:"agent-cycle-others",children:[s.jsx("div",{className:"agent-cycle-others-title",children:"other"}),v.others.map(Y=>{const Q=z&&Ya(Y.step)==="answer_user";return s.jsx(kh,{item:Y,label:"other",toolDefs:M,defaultOpen:Q},Y.id)})]}):null]})]},v.id)})]})]})}function Xi(e){return typeof e=="string"?e.trim():""}function Cw(e){var t;return Xi(e.run_id)||Xi((t=e.record)==null?void 0:t.run_id)}function c_(e){return Xi(e==null?void 0:e.node_id)}const Ew=new Set(["reason","act","observe","thought","think"]);function u_(e){const t=Xi(e);if(!t.includes("::"))return t;const n=t.split("::");if(n.length<2)return t;const o=String(n[n.length-1]||"").trim().toLowerCase();return Ew.has(o)?n.slice(0,-1).join("::"):t}function $y(e){var t;return Xi((t=e==null?void 0:e.effect)==null?void 0:t.type)}function $w(e){return Xi(e==null?void 0:e.status)||"unknown"}function Pp(e){return Xi(e==null?void 0:e.step_id)}function Mw(e){return Xi(e==null?void 0:e.ended_at)||Xi(e==null?void 0:e.started_at)}function Aw(e){const t=new Map,n=new Map;for(const a of e){const c=u_(c_(a));if(!c)continue;const d=$y(a);d==="llm_call"?t.set(c,(t.get(c)||0)+1):d==="tool_calls"&&n.set(c,(n.get(c)||0)+1)}const o=a=>{let c="",d=-1;for(const[u,m]of a)m>d&&(c=u,d=m);return c};return o(t)||o(n)||""}function Tw(e,t){const n=Xi(t.run_id);if(!n)return{run_id:"",node_id:"",items:[]};const o=(Array.isArray(e)?e:[]).filter(b=>b&&b.record&&Cw(b)===n).map(b=>({cursor:b.cursor,record:b.record})).sort((b,C)=>(b.cursor||0)-(C.cursor||0)),a=o.map(b=>b.record),c=u_(Xi(t.node_id)),d=c||Aw(a),u=new Set(["llm_call","tool_calls","ask_user","answer_user"]);let m=o.filter(b=>u.has($y(b.record)));c&&(m=m.filter(b=>u_(c_(b.record))===c));const y=new Map,g=[];for(const b of m){const C=Pp(b.record);if(!C){g.push(b);continue}const S=y.get(C);(!S||(b.cursor||0)>(S.cursor||0))&&y.set(C,b)}const x=[...g,...Array.from(y.values())].sort((b,C)=>(b.cursor||0)-(C.cursor||0)).map(b=>{const C=b.record,S=c_(C)||"(node?)",L=Mw(C),M=Pp(C);return{id:`ledger:${n}:${b.cursor}:${M||""}`,runId:n,nodeId:S,ts:L||void 0,status:$w(C),step:C}});return{run_id:n,node_id:d,items:x}}function zm(e){const t=String(e??"").trim();if(!t||!(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))return null;try{return JSON.parse(t)}catch{return null}}function Lw(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Rw(e){const t=String(e.role||"message").trim()||"message",n=String(e.title||"").trim(),o=String(e.ts||"").trim(),a=[t];return n&&a.push(n),o&&a.push(o),a.join(" · ")}function Pw(e){return e.endsWith(`
46
+ `)?e:`${e}
47
+ `}function Ow(e){return String(e||"").trimStart().startsWith("```")}function zw(e,t){const o=[`# ${String((t==null?void 0:t.heading)||"Chat").trim()||"Chat"}`,""];for(const a of e){const c=Rw(a);o.push(`## ${c}`,"");const d=String(a.content||""),u=zm(d);u!==null&&!Ow(d)?o.push("```json",Lw(u).trimEnd(),"```",""):o.push(Pw(d).trimEnd(),""),o.push("---","")}for(;o.length&&!o[o.length-1].trim();)o.pop();return o.length&&o[o.length-1]==="---"&&o.pop(),`${o.join(`
48
+ `).trimEnd()}
49
+ `}async function Vl(e){const t=String(e||"");if(!t)return!1;try{return await navigator.clipboard.writeText(t),!0}catch{try{const n=document.createElement("textarea");return n.value=t,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),!0}catch{return!1}}}function Iw(e){const t=String(e.filename||"").trim()||"export.txt",n=String(e.text||""),o=String(e.mime),a=new Blob([n],{type:o}),c=URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=t,document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Dw=3,Fw=Number.MAX_SAFE_INTEGER;function My(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ay(e){return Array.isArray(e)}function Bw(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xc({kind:e,children:t}){return s.jsx("span",{className:`pc-json-token ${e}`,children:t})}function Uw(e){const t=JSON.stringify(e.value),n=t.length>96||t.includes("\\n")||t.includes("\\r")||t.includes("\\t"),[o,a]=h.useState(!n||e.expansionMode==="unfolded");return h.useEffect(()=>{n&&a(e.expansionMode==="unfolded")},[n,e.expansionMode,e.expansionVersion]),n?s.jsxs("span",{className:`pc-json-string ${o?"open":"collapsed"}`,children:[s.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>a(c=>!c),"aria-label":o?"Collapse string value":"Expand string value","aria-expanded":o,children:o?"▾":"▸"}),o?s.jsx("span",{className:"pc-json-token string pc-json-string__value",children:t}):s.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>a(!0),"aria-label":"Expand string value",children:[s.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:t}),s.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):s.jsx(Xc,{kind:"string",children:t})}function Hw(e,t,n){return e===null?s.jsx(Xc,{kind:"null",children:"null"}):typeof e=="string"?s.jsx(Uw,{value:e,expansionMode:t,expansionVersion:n}):typeof e=="number"?s.jsx(Xc,{kind:"number",children:String(e)}):typeof e=="boolean"?s.jsx(Xc,{kind:"boolean",children:e?"true":"false"}):s.jsx(Xc,{kind:"string",children:JSON.stringify(String(e))})}function Ww(e){return Ay(e)?e.length===1?"1 item":`${e.length} items`:My(e)?Object.keys(e).length===1?"1 key":`${Object.keys(e).length} keys`:""}function Ty(e){const{label:t,value:n,depth:o,collapseAfterDepth:a,expansionMode:c,expansionVersion:d,trailingComma:u}=e,m=o*14,y=My(n),g=Ay(n),v=y||g,x=o<a,[b,C]=h.useState(x);h.useEffect(()=>{C(x)},[x,d]);const S=t?s.jsxs(s.Fragment,{children:[s.jsx(Xc,{kind:"key",children:JSON.stringify(t)}),": "]}):null;if(!v)return s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[S,Hw(n,c,d),u?",":""]});const L=g?"[":"{",M=g?"]":"}",W=Ww(n),q=b?`${L}`:`${L}…${M}${W?` (${W})`:""}`,z=g?n.map((Y,Q)=>({key:String(Q),label:void 0,value:Y})):Object.entries(n).map(([Y,Q])=>({key:Y,label:Y,value:Q}));return s.jsxs("details",{className:"pc-json-viewer__details",open:b,onToggle:Y=>C(Y.currentTarget.open),children:[s.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:m},children:[S,s.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:b?"▾":"▸"}),s.jsx("span",{className:"pc-json-viewer__punct",children:q}),!b&&u?s.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),b?s.jsx("div",{className:"pc-json-viewer__children",children:z.length===0?s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:M}),u?",":""]}):s.jsxs(s.Fragment,{children:[z.map((Y,Q)=>{const Z=Q===z.length-1;return s.jsx(Ty,{label:Y.label,value:Y.value,depth:o+1,collapseAfterDepth:a,expansionMode:c,expansionVersion:d,trailingComma:!Z},`${o}:${t||"root"}:${Y.key}`)}),s.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:m},children:[s.jsx("span",{className:"pc-json-viewer__punct",children:M}),u?",":""]})]})}):null]})}function qw(e){const t=e.trim();if(!t)return e;if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function os(e){const{value:t,className:n,showCopy:o=!0}=e,[a,c]=h.useState({mode:"folded",version:0}),d=typeof e.collapseAfterDepth=="number"&&(Number.isFinite(e.collapseAfterDepth)||e.collapseAfterDepth===1/0)&&e.collapseAfterDepth>=0?e.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(e.collapseAfterDepth):Dw,u=a.mode==="unfolded"?Fw:d,m=h.useMemo(()=>typeof t=="string"?qw(t):t,[t]),y=h.useMemo(()=>Bw(t),[t]),g=["pc-json-viewer",n].filter(Boolean).join(" ");h.useEffect(()=>{c(x=>({mode:"folded",version:x.version+1}))},[m]);const v=()=>{c(x=>({mode:x.mode==="unfolded"?"folded":"unfolded",version:x.version+1}))};return s.jsxs("div",{className:g,children:[s.jsxs("div",{className:"pc-json-viewer__toolbar",children:[s.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:v,"aria-expanded":a.mode==="unfolded",children:a.mode==="unfolded"?"Fold all":"Unfold all"}),o?s.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void Vl(y),children:"Copy JSON"}):null]}),s.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:s.jsx(Ty,{value:m,depth:0,collapseAfterDepth:u,expansionMode:a.mode,expansionVersion:a.version,trailingComma:!1})})]})}function gd(e,t){const n=String(e??"");if(!t||!t.needles.length)return[n];const o=[],a=n.toLowerCase();let c=0;for(;c<n.length;){let d=-1,u="";for(let g=0;g<t.needlesLower.length;g++){const v=t.needlesLower[g];if(!v)continue;const x=a.indexOf(v,c);if(x===-1)continue;const b=t.needles[g]||"";b&&(d===-1||x<d||x===d&&b.length>u.length)&&(d=x,u=b)}if(d===-1||!u){o.push(n.slice(c));break}d>c&&o.push(n.slice(c,d));const m=t.hits===0&&t.id?t.id:void 0,y=n.slice(d,d+u.length);o.push(s.jsx("span",{id:m,className:t.className,children:y},`hl:${t.hits}`)),t.hits+=1,c=d+u.length}return o}function d_(e){const t=String(e||"").trim();if(t&&/^(https?:|mailto:|tel:|#|\/)/i.test(t))return t}function Ua(e,t){const n=[],o=String(e??"");let a=0,c="";const d=()=>{if(c){for(const u of gd(c,t))n.push(u);c=""}};for(;a<o.length;){const u=o[a];if(u==="!"&&o[a+1]==="["){const m=o.indexOf("]",a+2);if(m!==-1&&o[m+1]==="("){const y=o.indexOf(")",m+2);if(y!==-1){const g=o.slice(a+2,m),v=d_(o.slice(m+2,y));if(v){d(),n.push(s.jsxs("span",{className:"pc-md_image_inline",children:[s.jsx("img",{className:"pc-md_img",src:v,alt:g,loading:"lazy"}),g?s.jsx("span",{className:"pc-md_img_caption",children:t?gd(g,t):g}):null]},`img:${a}`)),a=y+1;continue}}}}if(u==="["){const m=o.indexOf("]",a+1);if(m!==-1&&o[m+1]==="("){const y=o.indexOf(")",m+2);if(y!==-1){const g=o.slice(a+1,m),v=d_(o.slice(m+2,y));if(v){d(),n.push(s.jsx("a",{className:"pc-md_link",href:v,target:v.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Ua(g,t)},`link:${a}`)),a=y+1;continue}}}}if(u==="`"){const m=o.indexOf("`",a+1);if(m!==-1){d();const y=o.slice(a+1,m);n.push(s.jsx("code",{children:t?gd(y,t):y},`code:${a}`)),a=m+1;continue}}if(u==="*"&&o[a+1]==="*"){const m=o.indexOf("**",a+2);if(m!==-1){d();const y=o.slice(a+2,m);n.push(s.jsx("strong",{children:t?gd(y,t):y},`bold:${a}`)),a=m+2;continue}}if(u==="*"&&o[a+1]!=="*"){const m=o.indexOf("*",a+1);if(m!==-1){d();const y=o.slice(a+1,m);n.push(s.jsx("em",{children:t?gd(y,t):y},`em:${a}`)),a=m+1;continue}}c+=u,a+=1}return d(),n}function Vw(e){return String(e??"").replace(/\r\n/g,`
50
+ `).replace(/\r/g,`
51
+ `).split(`
52
+ `)}function um(e){const n=String(e??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return n?{indent:n[1].replace(/\t/g," ").length,ordered:!!n[3],start:n[3]?Math.max(1,parseInt(n[3],10)||1):1,content:n[4]??""}:null}function Gw(e){const t=[];for(const a of e){const c=um(a);c?t.push(c):t.length>0&&a.trim()&&(t[t.length-1].content+=` ${a.trim()}`)}const n=[],o=[];for(const a of t){for(;o.length>0&&a.indent<o[o.length-1].indent;)o.pop();let c=o.length>0?o[o.length-1]:null;if(c&&a.indent>c.indent){const d=c.node.items,u=d[d.length-1];if(u){const m={ordered:a.ordered,start:a.start,items:[]};u.children.push(m),o.push({indent:a.indent,node:m}),c=o[o.length-1]}}else if(c&&c.node.ordered!==a.ordered){o.pop();const d=o.length>0?o[o.length-1]:null,u={ordered:a.ordered,start:a.start,items:[]};if(d){const m=d.node.items,y=m[m.length-1];y?y.children.push(u):d.node.items.push({content:"",children:[u]})}else n.push(u);o.push({indent:a.indent,node:u}),c=o[o.length-1]}if(!c){const d={ordered:a.ordered,start:a.start,items:[]};n.push(d),o.push({indent:a.indent,node:d}),c=o[o.length-1]}c.node.items.push({content:a.content,children:[]})}return n}function Ly(e,t,n){const o=e.items.map((a,c)=>s.jsxs("li",{children:[Ua(a.content,t),a.children.map((d,u)=>Ly(d,t,`${n}:${c}:${u}`))]},`${n}:li:${c}`));return e.ordered?s.jsx("ol",{className:"pc-md_ol",start:e.start!==1?e.start:void 0,children:o},n):s.jsx("ul",{className:"pc-md_ul",children:o},n)}function Yw(e,t,n){return Gw(e).map((o,a)=>Ly(o,t,`${n}:${a}`))}function Op(e){let t=String(e??"").trim();return t?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>String(n??"").trim())):[]}function zp(e){let t=String(e??"").trim();if(!t)return!1;t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));const n=t.split("|").map(o=>String(o??"").trim());return n.length<2?!1:n.every(o=>/^:?-{3,}:?$/.test(o))}function gi({text:e,className:t,highlight:n,highlights:o,highlightClassName:a,highlightId:c}){const d=Vw(e),u=[],m=[];Array.isArray(o)&&m.push(...o),typeof n=="string"&&n.trim()&&m.push(n);const y=Array.from(new Set(m.map(b=>String(b??"").trim()).filter(Boolean))).filter(b=>b.length>=4),g=y.length?{needles:y,needlesLower:y.map(b=>b.toLowerCase()),className:a||"pc-md_hl",id:c,hits:0}:null;let v=0;for(;v<d.length;){const b=String(d[v]??"");if(!b.trim()){v+=1;continue}const C=b.trim();if(/^([-_*])(\s*\1){2,}$/.test(C)){u.push(s.jsx("hr",{className:"pc-md_hr"},`hr:${v}`)),v+=1;continue}const S=b.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(S){const W=d_(S[2]||"");if(W){const q=S[1]||"";u.push(s.jsxs("figure",{className:"pc-md_figure",children:[s.jsx("img",{className:"pc-md_img",src:W,alt:q,loading:"lazy"}),q?s.jsx("figcaption",{children:Ua(q,g)}):null]},`figure:${v}`)),v+=1;continue}}if(b.trim().startsWith("```")){const q=b.trim().replace(/```/g,"").trim(),z=[];for(v+=1;v<d.length&&!String(d[v]??"").trim().startsWith("```");)z.push(String(d[v]??"")),v+=1;v<d.length&&(v+=1);const Y=z.join(`
53
+ `);u.push(s.jsx("pre",{className:"pc-md_pre",children:s.jsx("code",{className:q?`language-${q}`:void 0,children:Y})},`pre:${v}`));continue}const L=b.match(/^(#{1,5})\s+(.*)$/);if(L){const W=L[1].length,q=L[2]||"",z=Ua(q,g);W===1?u.push(s.jsx("h1",{children:z},`h1:${v}`)):W===2?u.push(s.jsx("h2",{children:z},`h2:${v}`)):W===3?u.push(s.jsx("h3",{children:z},`h3:${v}`)):W===4?u.push(s.jsx("h4",{children:z},`h4:${v}`)):u.push(s.jsx("h5",{children:z},`h5:${v}`)),v+=1;continue}if(b.trimStart().startsWith(">")){const W=[];for(;v<d.length&&String(d[v]??"").trimStart().startsWith(">");){const z=String(d[v]??"").trimStart();W.push(z.replace(/^>\s?/,"")),v+=1}u.push(s.jsx("blockquote",{className:"pc-md_quote",children:W.map((q,z)=>s.jsxs(ye.Fragment,{children:[Ua(q,g),z<W.length-1?s.jsx("br",{}):null]},`q:${v}:${z}`))},`quote:${v}`));continue}if(b.includes("|")&&v+1<d.length&&zp(String(d[v+1]??""))){const W=Op(b),q=Math.max(1,W.length),z=[];for(v+=2;v<d.length;){const Y=String(d[v]??"");if(!Y.trim()||!Y.includes("|"))break;const Q=Op(Y),Z=[];for(let ne=0;ne<q;ne++)Z.push(Q[ne]??"");z.push(Z),v+=1}u.push(s.jsx("div",{className:"pc-md_table_wrap",children:s.jsxs("table",{className:"pc-md_table",children:[s.jsx("thead",{children:s.jsx("tr",{children:W.slice(0,q).map((Y,Q)=>s.jsx("th",{children:Ua(Y,g)},`th:${v}:${Q}`))})}),s.jsx("tbody",{children:z.map((Y,Q)=>s.jsx("tr",{children:Y.map((Z,ne)=>s.jsx("td",{children:Ua(Z,g)},`td:${v}:${Q}:${ne}`))},`tr:${v}:${Q}`))})]})},`table:${v}`));continue}if(um(b)){const W=[];for(;v<d.length;){const q=String(d[v]??"");if(!q.trim()||q.trimStart().startsWith("```"))break;if(um(q)||/^\s{2,}\S/.test(q)){W.push(q),v+=1;continue}break}u.push(s.jsx(ye.Fragment,{children:Yw(W,g,`list:${v}`)},`list:${v}`));continue}const M=[];for(;v<d.length&&String(d[v]??"").trim()&&!(M.length>0&&um(String(d[v]??"")));){const W=String(d[v]??"");if(M.length>0&&W.includes("|")&&v+1<d.length&&zp(String(d[v+1]??"")))break;M.push(W),v+=1}u.push(s.jsx("p",{className:"pc-md_p",children:M.map((W,q)=>s.jsxs(ye.Fragment,{children:[Ua(W,g),q<M.length-1?s.jsx("br",{}):null]},`pl:${v}:${q}`))},`p:${v}`))}const x=["pc-md",t].filter(Boolean).join(" ");return s.jsx("div",{className:x,children:u})}function Kw(e){const t=String(e.text??""),n=h.useMemo(()=>zm(t),[t]),o=["pc-chat-content",e.className].filter(Boolean).join(" ");return n!==null?s.jsx("div",{className:o,children:s.jsx(os,{value:n,collapseAfterDepth:e.jsonCollapseAfterDepth})}):e.renderMarkdown?s.jsx("div",{className:o,children:e.renderMarkdown(t)}):s.jsx("div",{className:o,children:s.jsx(gi,{text:t})})}const Ry=[{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"]}];Ry.map(e=>({id:e.id,label:e.label}));function Xw(e){return`theme-${String(e||"").trim()||"dark"}`}function Ip(e){try{const t=document.documentElement,n=Array.from(t.classList).filter(o=>o.startsWith("theme-"));for(const o of n)t.classList.remove(o);t.classList.add(Xw(e))}catch{}}const f_=[{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}],m_=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Jw(e){const t=String(e).trim();return f_.find(n=>n.id===t)||f_[1]}function Zw(e){const t=String(e).trim();return m_.find(n=>n.id===t)||m_[1]}function Dp(e){try{const t=document.documentElement,n=Jw(e.font_scale||"md"),o=Zw(e.header_density||"standard");t.style.setProperty("--font-scale",String(n.scale)),t.style.setProperty("--header-density",String(o.density))}catch{}}var Py=py();function Uc(...e){return e.filter(Boolean).join(" ")}function iu({value:e,options:t,placeholder:n="Select…",disabled:o=!1,loading:a=!1,searchable:c=!0,searchPlaceholder:d="Search…",allowCustom:u=!1,clearable:m=!1,minPopoverWidth:y=240,variant:g="panel",className:v,triggerClassName:x,ariaLabel:b,id:C,includeValueOption:S=!1,onOpen:L,customOptionLabel:M,validateCustomValue:W,onChange:q,renderOption:z,renderValue:Y}){const Q=h.useRef(null),Z=h.useRef(null),ne=h.useRef(null),ue=h.useRef(L),de=h.useId(),pe=C||`af-select-${de.replace(/[^a-zA-Z0-9_-]/g,"")}`,D=`${pe}-listbox`,[E,j]=h.useState(!1),[R,O]=h.useState(""),[ee,I]=h.useState(0),[P,G]=h.useState("bottom"),[$,K]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{ue.current=L},[L]);const se=h.useMemo(()=>{if(!S)return t;const ve=String(e??"").trim();return!ve||t.some(Ie=>Ie.value===ve)?t:[...t,{value:ve,label:ve}]},[S,t,e]),le=h.useMemo(()=>{const ve=String(e??"");return se.find(Ie=>Ie.value===ve)||null},[se,e]),he=h.useMemo(()=>(le==null?void 0:le.label)||String(e||"").trim()||"",[le,e]),be=h.useMemo(()=>{const ve=R.trim().toLowerCase();return ve?se.filter(Ie=>Ie.label.toLowerCase().includes(ve)||Ie.value.toLowerCase().includes(ve)):se},[se,R]),je=h.useMemo(()=>{if(!u)return null;const ve=R.trim();if(!ve||se.some(At=>At.value===ve))return null;const Ge=(W==null?void 0:W(ve,{options:se}))||"";return{value:ve,label:M?M(ve):`Use "${ve}"`,disabled:!!Ge,reason:Ge}},[u,M,se,R,W]),Ee=h.useMemo(()=>{const ve=je?[je,...be]:be;if(ve.length>0)return ve;const Ie=String(e??"").trim();return a&&Ie?[{value:Ie,label:he||Ie}]:ve},[je,be,a,he,e]),Fe=h.useCallback(()=>{const ve=Q.current;if(!ve)return;const Ie=ve.getBoundingClientRect(),Ge=Math.max(Ie.width,y),At=Math.max(8,Math.min(Ie.left,window.innerWidth-Ge-8)),Ft=window.innerHeight-Ie.bottom,fn=Ie.top,Dt=Ft>=220||Ft>=fn?"bottom":"top";G(Dt);const Tt=Dt==="bottom"?Ie.bottom+6:Ie.top-6;K({left:At,top:Tt,width:Ge})},[y]),Ye=h.useCallback(()=>{j(!1),O("")},[]);h.useEffect(()=>{var ve;E&&((ve=ue.current)==null||ve.call(ue))},[E]),h.useEffect(()=>{if(!E)return;Fe();const ve=()=>Fe();return window.addEventListener("resize",ve),window.addEventListener("scroll",ve,!0),()=>{window.removeEventListener("resize",ve),window.removeEventListener("scroll",ve,!0)}},[E,Fe]),h.useEffect(()=>{if(!E)return;const ve=Ie=>{var At,Ft;const Ge=Ie.target;Ge&&((At=Q.current)!=null&&At.contains(Ge)||(Ft=Z.current)!=null&&Ft.contains(Ge)||Ye())};return document.addEventListener("mousedown",ve,!0),()=>document.removeEventListener("mousedown",ve,!0)},[E,Ye]),h.useEffect(()=>{if(!E)return;const ve=Math.max(0,Ee.findIndex(Ie=>Ie.value===e));I(ve===-1?0:ve),c&&setTimeout(()=>{var Ie;return(Ie=ne.current)==null?void 0:Ie.focus()},0)},[E,c,e,Ee]);const Ke=ve=>{var Ge;const Ie=Ee.find(At=>At.value===ve);Ie!=null&&Ie.disabled||(q(ve),Ye(),(Ge=Q.current)==null||Ge.focus())},Ct=ve=>{var Ie,Ge;if(ve.key==="Escape")return ve.preventDefault(),Ye(),(Ie=Q.current)==null||Ie.focus(),!0;if(ve.key==="Tab")return Ye(),(Ge=Q.current)==null||Ge.focus(),!1;if(ve.key==="ArrowDown")return ve.preventDefault(),I(At=>Math.min(At+1,Math.max(0,Ee.length-1))),!0;if(ve.key==="ArrowUp")return ve.preventDefault(),I(At=>Math.max(At-1,0)),!0;if(ve.key==="Home")return ve.preventDefault(),I(0),!0;if(ve.key==="End")return ve.preventDefault(),I(Math.max(0,Ee.length-1)),!0;if(ve.key==="Enter"){ve.preventDefault();const At=Ee[ee];return At&&Ke(At.value),!0}return!1},wt=ve=>{if(!o){if(E){if(Ct(ve))return;if(ve.key===" "&&!c){ve.preventDefault();const Ie=Ee[ee];Ie&&Ke(Ie.value)}return}(ve.key==="Enter"||ve.key===" "||ve.key==="ArrowDown"||ve.key==="ArrowUp")&&(ve.preventDefault(),j(!0))}},at=!!String(e||"").trim(),yt=at?he:n,nt=je!=null&&je.disabled?je.reason||"Unavailable":"",Ne=E&&Ee.length>0?`${pe}-opt-${ee}`:void 0,Oe=s.jsx("span",{className:Uc("af-select-value",!at&&"af-select-value--placeholder"),children:a&&!at?"Loading…":yt}),st=Y?Y(le,String(e||"")):Oe;return s.jsxs("span",{className:Uc("af-select",g==="pin"?"af-select--pin":"af-select--panel",v),children:[s.jsxs("button",{ref:Q,id:pe,type:"button",className:Uc("af-select-trigger",m&&at&&"af-select-trigger--clearable",x),disabled:o,onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>{ve.stopPropagation(),!o&&j(Ie=>!Ie)},onKeyDown:wt,role:c?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":E,"aria-controls":E?D:void 0,"aria-activedescendant":c?void 0:Ne,"aria-label":b,children:[st,s.jsx("span",{className:Uc("af-select-caret",E&&"af-select-caret--open"),children:"▾"})]}),m&&at?s.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:o,onMouseDown:ve=>{ve.preventDefault(),ve.stopPropagation()},onClick:ve=>{var Ie;ve.preventDefault(),ve.stopPropagation(),q(""),Ye(),(Ie=Q.current)==null||Ie.focus()},title:"Clear",children:"×"}):null,E?Py.createPortal(s.jsxs("div",{ref:Z,className:Uc("af-select-popover",P==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${$.left}px`,top:`${$.top}px`,width:`${$.width}px`},onMouseDown:ve=>ve.stopPropagation(),onClick:ve=>ve.stopPropagation(),onWheel:ve=>ve.stopPropagation(),onKeyDown:Ct,tabIndex:-1,children:[c?s.jsxs("div",{className:"af-select-search",children:[s.jsx("input",{ref:ne,className:"af-select-search-input",value:R,onChange:ve=>O(ve.target.value),placeholder:d,onKeyDown:Ct,role:"combobox","aria-expanded":!0,"aria-controls":D,"aria-activedescendant":Ne,"aria-invalid":!!nt,"aria-describedby":nt?`${pe}-custom-error`:void 0}),nt?s.jsx("div",{id:`${pe}-custom-error`,className:"af-select-custom-error",role:"alert",children:nt}):null]}):null,s.jsx("div",{className:"af-select-options",role:"listbox",id:D,"aria-label":b,children:a&&Ee.length===0?s.jsx("div",{className:"af-select-empty",children:"Loading…"}):Ee.length===0?s.jsx("div",{className:"af-select-empty",children:"No results"}):Ee.map((ve,Ie)=>{var Tt;const Ge=ve.value===e,At=Ie===ee,Ft=String(ve.group||"").trim(),fn=Ie>0?String(((Tt=Ee[Ie-1])==null?void 0:Tt.group)||"").trim():"",Dt=!!Ft&&Ft!==fn;return s.jsxs(ye.Fragment,{children:[Dt?s.jsx("div",{className:"af-select-group",role:"presentation",children:Ft}):null,s.jsx("div",{id:`${pe}-opt-${Ie}`,role:"option","aria-selected":Ge,className:Uc("af-select-option",Ge&&"af-select-option--selected",At&&"af-select-option--highlighted",ve.disabled&&"af-select-option--disabled"),title:ve.disabled?ve.reason||"Unavailable":void 0,onMouseEnter:()=>I(Ie),onMouseDown:mn=>{mn.preventDefault(),mn.stopPropagation()},onClick:()=>Ke(ve.value),"aria-disabled":ve.disabled?!0:void 0,children:z?z(ve,{selected:Ge,highlighted:At}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"af-select-option-label",children:[s.jsx("span",{children:ve.label}),ve.reason?s.jsx("small",{className:"af-select-option-reason",children:ve.reason}):null]}),Ge?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},ve.value)})})]}),document.body):null]})}function Qw(e){const t=new Set,n=[];for(const o of e||[]){if(!o||typeof o!="object")continue;const a=String(o.name||"").trim();!a||t.has(a)||(t.add(a),n.push({name:a,display_name:typeof o.display_name=="string"?o.display_name:void 0}))}return n.sort((o,a)=>o.name.localeCompare(a.name)),n}function e0(e){const t=new Set,n=[];for(const o of e||[]){const a=String(o||"").trim();!a||t.has(a)||(t.add(a),n.push(a))}return n.sort(),n}function t0(e){const t=e.disabled===!0,n=e.layout||"stack",o=e.allowGatewayDefault!==!1,a=String(e.gatewayDefaultLabel||"(gateway default)"),c=String(e.providerLabel||"Provider"),d=String(e.modelLabel||"Model"),u=String(e.providerPlaceholder||"(select)"),m=String(e.modelPlaceholder||"(select)"),y=String(e.provider||"").trim(),g=String(e.model||"").trim(),v=Qw(e.providers),x=e0(e.models),b=t||!!e.loadingProviders,C=t||!!e.loadingModels,S=[...o?[{value:"",label:a}]:[],...v.map(M=>({value:M.name,label:M.display_name?`${M.display_name} (${M.name})`:M.name}))],L=[...o?[{value:"",label:a}]:[],...x.map(M=>({value:M,label:M}))];return s.jsxs("div",{className:e.className,style:n==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[s.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:c}),s.jsx(iu,{value:y,options:S,placeholder:o?a:u,disabled:b,loading:!!e.loadingProviders,searchable:!0,allowCustom:e.allowCustomProvider===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:c,onChange:M=>e.onChange({provider:String(M||"").trim(),model:""})}),e.loadingProviders?s.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,e.providerError?s.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.providerError}):null]}),s.jsxs("div",{style:n==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[s.jsx("label",{children:d}),s.jsx(iu,{value:g,options:L,placeholder:o?a:m,disabled:C,loading:!!e.loadingModels,searchable:!0,allowCustom:e.allowCustomModel===!0,clearable:o,variant:"panel",triggerClassName:e.selectClassName,ariaLabel:d,onChange:M=>e.onChange({provider:y,model:String(M||"").trim()})}),e.loadingModels?s.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,e.modelError?s.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:e.modelError}):null]})]})}function Fp(...e){return e.filter(Boolean).join(" ")}function n0({kicker:e="AbstractGateway connection",title:t="Connect to AbstractGateway",description:n="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:o="Gateway token missing",statusTone:a="warn",tokenSourceLabel:c="token: missing",showGatewayUrl:d=!1,gatewayUrl:u="",gatewayUrlPlaceholder:m="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:g,userPlaceholder:v="admin",onUserIdChange:x,token:b,tokenPlaceholder:C="Paste Gateway user token",showToken:S=!1,onTokenChange:L,onShowTokenChange:M,remember:W=!1,rememberLabel:q="Remember this browser",onRememberChange:z,loading:Y=!1,submitting:Q=!1,submitDisabled:Z=!1,submitLabel:ne="Sign in",submittingLabel:ue="Signing in...",closeLabel:de="Close",signOutLabel:pe="Sign out",showClose:D=!1,showSignOut:E=!1,error:j,message:R,className:O,onSubmit:ee,onClose:I,onSignOut:P}){const G=Y||Q,$=G||Z||!String(g||"").trim()||!String(b||"").trim(),K=se=>{se.preventDefault(),!$&&ee()};return s.jsxs("form",{className:Fp("af-gateway-signin",O),onSubmit:K,children:[s.jsxs("div",{className:"af-gateway-signin__hero",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-gateway-signin__kicker",children:e}),s.jsx("h2",{children:t}),n?s.jsx("p",{children:n}):null]}),s.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),s.jsxs("div",{className:"af-gateway-signin__status-row",children:[s.jsx("span",{className:Fp("af-gateway-signin__status",`af-gateway-signin__status--${a}`),children:o}),c?s.jsx("span",{className:"af-gateway-signin__source",children:c}):null]}),s.jsxs("div",{className:"af-gateway-signin__form",children:[d?s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),s.jsx("input",{id:"gateway-session-url",value:u,onChange:se=>y==null?void 0:y(se.target.value),placeholder:m,autoComplete:"url",disabled:G})]}):null,s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),s.jsx("input",{id:"gateway-session-user",value:g,onChange:se=>x(se.target.value),placeholder:v,autoComplete:"username",disabled:G}),s.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),s.jsxs("div",{className:"af-gateway-signin__token-input",children:[s.jsx("input",{id:"gateway-session-token",type:S?"text":"password",value:b,onChange:se=>L(se.target.value),placeholder:C,autoComplete:"current-password",disabled:G}),s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>M==null?void 0:M(!S),disabled:G,children:S?"Hide":"Show"})]}),s.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),s.jsxs("label",{className:"af-gateway-signin__checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!W,onChange:se=>z==null?void 0:z(se.target.checked),disabled:G}),q]})]}),j?s.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:j}):null,!j&&R?s.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:R}):null,s.jsxs("div",{className:"af-gateway-signin__actions",children:[D?s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:I,disabled:G,children:de}):null,E?s.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(P==null?void 0:P()),disabled:G,children:pe}):null,s.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:$,children:Q?ue:ne})]})]})}function r0(e){return e==="light"?"Light":"Dark"}function s0(e){const t=e.themes&&e.themes.length?e.themes:Ry,n=e.showSwatches!==!1,o=e.variant||"panel",a=h.useMemo(()=>{const d={};for(const u of t)d[u.id]=u;return d},[t]),c=h.useMemo(()=>t.map(d=>({value:d.id,label:d.label,group:r0(d.group)})),[t]);return s.jsx(iu,{value:e.value,options:c,placeholder:e.placeholder||"Select theme…",disabled:e.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:o,className:e.className,triggerClassName:e.triggerClassName,onChange:d=>e.onChange(String(d||"").trim()),renderValue:(d,u)=>{const m=String(u||"").trim(),y=a[m],g=(y==null?void 0:y.label)||m||e.placeholder||"Select theme…",v=(y==null?void 0:y.swatches)||null,x=!m;return s.jsxs("span",{className:"af-theme-value",children:[s.jsx("span",{className:`af-theme-label ${x?"af-theme-label--placeholder":""}`.trim(),children:g}),n&&v?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((b,C)=>s.jsx("span",{className:"af-theme-swatch",style:{background:b}},`${m}:${C}`))}):null]})},renderOption:(d,u)=>{const m=String(d.value||"").trim(),y=a[m],g=(y==null?void 0:y.swatches)||null;return s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"af-theme-option-label",children:d.label}),s.jsxs("span",{className:"af-theme-option-right",children:[n&&g?s.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:g.map((v,x)=>s.jsx("span",{className:"af-theme-swatch",style:{background:v}},`${m}:${x}`))}):null,u.selected?s.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function i0(e){const t=e.scales&&e.scales.length?e.scales:f_,n=e.variant||"panel",o=h.useMemo(()=>t.map(a=>({value:a.id,label:a.label})),[t]);return s.jsx(iu,{value:e.value,options:o,placeholder:e.placeholder||"Font size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:a=>e.onChange(String(a||"").trim())})}function o0(e){const t=e.densities&&e.densities.length?e.densities:m_,n=e.variant||"panel",o=h.useMemo(()=>t.map(a=>({value:a.id,label:a.label})),[t]);return s.jsx(iu,{value:e.value,options:o,placeholder:e.placeholder||"Header size…",disabled:e.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:n,className:e.className,triggerClassName:e.triggerClassName,onChange:a=>e.onChange(String(a||"").trim())})}const a0=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function l0(e){switch(e){case"chat":return s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]});case"history":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),s.jsx("path",{d:"M3 3v5h5"}),s.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),s.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 6h16"}),s.jsx("circle",{cx:"8",cy:"6",r:"2"}),s.jsx("path",{d:"M4 12h16"}),s.jsx("circle",{cx:"16",cy:"12",r:"2"}),s.jsx("path",{d:"M4 18h16"}),s.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"8",r:"4"}),s.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2v3"}),s.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M9 17h6"})]});case"paperclip":return s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),s.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),s.jsx("path",{d:"M12 18v4"}),s.jsx("path",{d:"M8 22h8"})]});case"speaker":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),s.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),s.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M12 15h5"})]});case"edit":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("path",{d:"M7 10l5 5 5-5"}),s.jsx("path",{d:"M12 15V3"})]});case"loader":return s.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4"}),s.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 3l10 18H2L12 3z"}),s.jsx("path",{d:"M12 9v4"}),s.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M15 9l-6 6"}),s.jsx("path",{d:"M9 9l6 6"})]});case"copy":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return s.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return s.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return s.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),s.jsx("path",{d:"M6 6l1 16h10l1-16"}),s.jsx("path",{d:"M10 11v6"}),s.jsx("path",{d:"M14 11v6"})]});case"send":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M22 2L11 13"}),s.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7 10v11"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 14V3"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7 10v11"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M17 14V3"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),s.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),s.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),s.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),s.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),s.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),s.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),s.jsx("path",{d:"M8 4.5V2.2"}),s.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),s.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M2.5 4h11"}),s.jsx("path",{d:"M2.5 8h11"}),s.jsx("path",{d:"M2.5 12h7"})]});case"gear":return s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),s.jsx("path",{d:"M8 1.6v2"}),s.jsx("path",{d:"M8 12.4v2"}),s.jsx("path",{d:"M1.6 8h2"}),s.jsx("path",{d:"M12.4 8h2"}),s.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),s.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),s.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),s.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),s.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 s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),s.jsx("path",{d:"M16 17l5-5-5-5"}),s.jsx("path",{d:"M21 12H9"})]});default:return null}}function zn({name:e,size:t=16,className:n,title:o,...a}){const c=o?void 0:!0,d=a0.has(e);return s.jsxs("svg",{width:t,height:t,viewBox:d?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:d?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":c,role:o?"img":"presentation",...a,children:[o?s.jsx("title",{children:o}):null,l0(e)]})}async function h_(e="/api/connection/gateway"){const t=await fetch(e),n=await t.json().catch(()=>null);if(!t.ok){const o=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(o)}return n}async function c0(e,t="/api/connection/gateway"){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),o=await n.json().catch(()=>null);if(!n.ok){const a=o&&typeof o=="object"&&o.detail?String(o.detail):`HTTP ${n.status}`;throw new Error(a)}return o}async function Oy(e="/api/connection/gateway"){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.json().catch(()=>({})),o=n&&typeof n=="object"&&n.detail?String(n.detail):`HTTP ${t.status}`;throw new Error(o)}}function Nh(e){let t=String(e||"").trim();for(let n=0;n<2&&t;n+=1){try{const c=JSON.parse(t);if(typeof c=="string"&&c!==t){t=c.trim();continue}}catch{}const o=t[0],a=t[t.length-1];if(o==='"'&&a==='"'||o==="'"&&a==="'"){t=t.slice(1,-1).trim();continue}break}return t.replace(/\/+$/,"")}function zy(e){var c,d;if(!e)return{label:"Signed out",tone:"warn"};if(!e.has_session)return{label:"Signed out",tone:"warn"};const t=e.gateway||{},n=(c=t.principal)==null?void 0:c.user_id,o=(d=t.principal)==null?void 0:d.runtime_id;if(t.ok&&n)return{label:`Signed in as ${n}${o?` · runtime ${o}`:""}`,tone:"ok"};if(t.ok)return{label:"Signed in",tone:"ok"};const a=t.error||t.detail;return typeof a=="string"&&a.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function u0(e){const t=e.connectionPath||"/api/connection/gateway",[n,o]=h.useState(!1),[a,c]=h.useState(!1),[d,u]=h.useState(null),[m,y]=h.useState(!1);h.useEffect(()=>{e.isOpen||y(!1)},[e.isOpen]);const[g,v]=h.useState(e.defaultGatewayUrl||"http://127.0.0.1:8080"),[x,b]=h.useState("admin"),[C,S]=h.useState(""),[L,M]=h.useState(!1),[W,q]=h.useState(!0),[z,Y]=h.useState(""),[Q,Z]=h.useState(""),ne=h.useMemo(()=>zy(d),[d]),ue=E=>{var j;u(E),(j=e.onStatusChange)==null||j.call(e,E)},de=h.useRef(!1);if(h.useEffect(()=>{var j;if(!e.isOpen)return;const E=!de.current;if(de.current=!0,E&&e.initialStatus!==void 0&&e.initialStatus!==null){const R=e.initialStatus;ue(R),typeof R.gateway_url=="string"&&R.gateway_url.trim()&&v(Nh(R.gateway_url));const O=(j=R.gateway)==null?void 0:j.principal;O!=null&&O.user_id&&b(O.user_id);return}o(!0),Y(""),h_(t).then(R=>{var ee;ue(R),typeof R.gateway_url=="string"&&R.gateway_url.trim()&&v(Nh(R.gateway_url));const O=(ee=R.gateway)==null?void 0:ee.principal;O!=null&&O.user_id&&b(O.user_id)}).catch(R=>Y(`Failed to load connection status: ${String((R==null?void 0:R.message)||R)}`)).finally(()=>o(!1))},[e.isOpen]),h.useEffect(()=>{if(!e.isOpen)return;const E=j=>{j.key==="Escape"&&!j.defaultPrevented&&!e.blocking&&(j.preventDefault(),e.onClose())};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e.isOpen,e.blocking,e.onClose]),!e.isOpen||m)return null;const pe=async()=>{c(!0),Y(""),Z("");try{const E=Nh(g);v(E);const j=await c0({gateway_url:E,gateway_user_id:x,gateway_token:C,persist:W},t);ue(j),S(""),y(!0),e.onClose()}catch(E){Y(String((E==null?void 0:E.message)||E))}finally{c(!1)}},D=async()=>{c(!0),Y(""),Z("");try{await Oy(t),S("");const E=await h_(t).catch(()=>null);ue(E),Z("Signed out. This browser no longer holds a gateway session.")}catch(E){Y(String((E==null?void 0:E.message)||E))}finally{c(!1)}};return s.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:E=>{!e.blocking&&E.target===E.currentTarget&&e.onClose()},children:s.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:s.jsx(n0,{kicker:`${e.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:ne.label,statusTone:ne.tone,tokenSourceLabel:d!=null&&d.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:g,onGatewayUrlChange:E=>v(E),userId:x,onUserIdChange:b,token:C,tokenPlaceholder:d!=null&&d.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:L,onTokenChange:S,onShowTokenChange:M,remember:W,rememberLabel:"Keep this browser signed in",onRememberChange:q,loading:n,submitting:a,submittingLabel:"Signing in...",showClose:!e.blocking,onClose:e.onClose,showSignOut:!e.blocking&&!!(d!=null&&d.has_session),onSignOut:D,error:z,message:Q,onSubmit:pe})})})}function d0(e){return!!(e&&e.ok===!0&&e.has_session===!0)}function f0(e){const t=e||{},n=t.connectionPath||"/api/connection/gateway",o=t.variant||"dismissable",a=h.useRef(t.onStatusChange);a.current=t.onStatusChange;const c=h.useRef(o);c.current=o;const d=h.useRef(!!t.autoOpenMidSession);d.current=!!t.autoOpenMidSession;const[u,m]=h.useState(null),[y,g]=h.useState("loading"),[v,x]=h.useState(!1),b=h.useRef(!1),C=h.useRef(!1),S=h.useRef("loading"),L=h.useRef("none"),M=h.useRef(!1),W=h.useRef(0),q=h.useCallback(j=>{var O;W.current+=1,m(j),(O=a.current)==null||O.call(a,j);const R=d0(j);if(R)g("connected"),S.current="connected",b.current=!1,L.current="none",C.current||x(!1);else if(j!==null){const ee=S.current;g("disconnected"),S.current="disconnected",ee!=="disconnected"&&(L.current=M.current?"signout":ee==="connected"?"mid":"boot");const I=c.current==="blocking"||L.current!=="mid"||d.current;!b.current&&I&&x(!0)}j!==null&&(C.current=R)},[]),z=h.useCallback(async()=>{const j=W.current;try{const R=await h_(n);if(W.current!==j)return;q(R)}catch{if(W.current!==j)return;q(null)}},[n,q]),[Y,Q]=h.useState(!1),[Z,ne]=h.useState(null),ue=h.useCallback(async()=>{Q(!0),ne(null),W.current+=1;let j=null;try{await Oy(n)}catch(R){j=String((R==null?void 0:R.message)||R||"Sign-out request failed")}M.current=!0;try{await z()}finally{M.current=!1}ne(j),Q(!1)},[n,z]),de=h.useRef(!1);h.useEffect(()=>{de.current||(de.current=!0,z())},[z]);const pe=h.useCallback(()=>{x(!0)},[]),D=h.useCallback(()=>{const j=S.current;o==="blocking"&&j==="disconnected"||(j==="disconnected"&&(b.current=!0),x(!1))},[o]),E=h.useMemo(()=>({isOpen:v,onClose:D,blocking:o==="blocking"&&y!=="connected",appName:t.appName,connectionPath:n,defaultGatewayUrl:t.defaultGatewayUrl,initialStatus:u,onStatusChange:q}),[v,D,o,y,t.appName,n,t.defaultGatewayUrl,u,q]);return{status:u,phase:y,connected:y==="connected",modalOpen:v,signingOut:Y,signOutError:Z,openModal:pe,refresh:z,signOut:ue,modalProps:E}}function m0(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`steer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function h0(){const e=[];try{if(typeof document>"u")return e;for(const t of String(document.cookie||"").split(";")){const n=t.indexOf("=");if(n<0||!t.slice(0,n).trim().endsWith("_gateway_csrf"))continue;const a=t.slice(n+1).trim();let c=a;try{c=decodeURIComponent(a)}catch{}c&&!e.includes(c)&&e.push(c)}}catch{}return e}async function _0(e){const t=e.commandsPath||"/api/gateway/commands",n=m0(),o=JSON.stringify({command_id:n,run_id:e.runId,type:"inject_guidance",payload:{guidance:e.guidance}}),a=e.csrfToken!==void 0?[e.csrfToken]:h0();a.length===0&&a.push("");let c=null;for(const d of a){const u=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-abstract-csrf":d}:{}},body:o}),m=await u.json().catch(()=>null);if(!u.ok){const y=m&&typeof m=="object"&&m.detail?String(m.detail):`HTTP ${u.status}`;if(c=new Error(y),u.status===403&&m&&typeof m=="object"&&m.reason_code==="csrf_required")continue;throw c}return{accepted:!!(m!=null&&m.accepted),duplicate:!!(m!=null&&m.duplicate),seq:Number((m==null?void 0:m.seq)??0)}}throw c||new Error("Steer submit failed")}function p0(e){const[t,n]=h.useState(""),[o,a]=h.useState({kind:"idle"}),c=h.useRef(!1),d=h.useRef(0);h.useEffect(()=>{d.current+=1,a({kind:"idle"})},[e.runId]);const u=!e.disabled&&t.trim().length>0&&o.kind!=="sending",m=h.useMemo(()=>e.parked?"Run is waiting — your guidance delivers at its next wake (steers do not wake runs).":"Delivers at the run's next loop boundary.",[e.parked]),y=async()=>{var b;const v=t.trim();if(!v||c.current||e.disabled)return;c.current=!0;const x=d.current;a({kind:"sending"});try{const C=e.submit?await e.submit(e.runId,v):await _0({runId:e.runId,guidance:v,commandsPath:e.commandsPath});if(d.current!==x)return;if(!C.accepted&&!C.duplicate){a({kind:"error",detail:"The gateway did not accept this steer (accepted=false)."});return}a({kind:"queued",seq:C.seq,duplicate:C.duplicate}),n(""),(b=e.onSent)==null||b.call(e,{...C,guidance:v})}catch(C){d.current===x&&a({kind:"error",detail:String((C==null?void 0:C.message)||C)})}finally{c.current=!1}},g=v=>{v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),y())};return s.jsxs("div",{className:`af-steer${e.className?` ${e.className}`:""}`,children:[s.jsxs("div",{className:"af-steer__row",children:[s.jsx("textarea",{className:"af-steer__input",value:t,rows:2,placeholder:e.placeholder||"Steer this run…","aria-label":e.ariaLabel||"Steer message",disabled:e.disabled||o.kind==="sending",onChange:v=>{n(v.target.value),(o.kind==="error"||o.kind==="queued")&&a({kind:"idle"})},onKeyDown:g}),s.jsx("button",{type:"button",className:"af-steer__send",disabled:!u,onClick:()=>void y(),title:"Send guidance (Cmd/Ctrl+Enter)",children:o.kind==="sending"?"Sending…":"Steer"})]}),s.jsx("div",{className:"af-steer__status",role:"status","aria-live":"polite",children:o.kind==="queued"?s.jsxs("span",{className:"af-steer__ok",children:[o.duplicate?`Already queued (seq ${o.seq}).`:`Queued (seq ${o.seq}).`," ",m," ","Watch for the steer_seen ack in the run ledger."]}):o.kind==="error"?s.jsx("span",{className:"af-steer__err",children:o.detail}):s.jsx("span",{className:"af-steer__hint",children:m})})]})}function g0(e){const t=e.closeOnEscape!==!1,n=h.useRef(null);return h.useEffect(()=>{if(!e.open||!t)return;const o=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),e.onClose())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e.open,t,e.onClose]),h.useEffect(()=>{const o=n.current;o&&(e.open?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.open]),s.jsxs("div",{ref:n,className:`af-drawer${e.open?" af-drawer--open":""}${e.className?` ${e.className}`:""}`,style:{width:e.width||420,top:e.topOffset||0,display:e.open?void 0:"none"},role:"complementary","aria-label":e.label,"aria-hidden":e.open?void 0:!0,children:[e.title!==void 0?s.jsxs("div",{className:"af-drawer__header",children:[s.jsx("div",{className:"af-drawer__title",children:e.title}),s.jsxs("div",{className:"af-drawer__header-actions",children:[e.headerActions,s.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:e.onClose,children:"×"})]})]}):null,s.jsx("div",{className:"af-drawer__body",children:e.children})]})}function y0(e){const{connection:t}=e,n=t.phase,o=t.signingOut===!0,a=o?"Signing out…":n==="connected"?"Disconnect":n==="loading"?"Connecting…":"Connect",c=n==="connected"?"Disconnect from gateway":n==="loading"?"Checking gateway session…":"Connect to gateway";return s.jsxs("div",{className:`af-topbar${e.className?` ${e.className}`:""}`,role:"group","aria-label":"App actions",children:[e.assistant?s.jsx("button",{type:"button",className:`af-topbar__btn${e.assistant.open?" is-active":""}`,"aria-pressed":e.assistant.open,"aria-label":e.assistant.label||"Open assistant",title:e.assistant.label||"Assistant",onClick:e.assistant.onToggle,children:s.jsx(zn,{name:"sparkle",size:16})}):null,e.appearance?s.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":e.appearance.label||"Appearance (theme and typography)",title:e.appearance.label||"Appearance",onClick:e.appearance.onOpen,children:s.jsx(zn,{name:"contrast",size:16})}):null,e.extraActions,s.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${n}`,onClick:n==="connected"?t.onDisconnect:t.onConnect,disabled:o,title:c,"aria-label":c,children:[s.jsx("span",{className:`af-topbar__dot af-topbar__dot--${n}`,"aria-hidden":"true"}),s.jsx("span",{className:"af-topbar__pill-label",children:a})]})]})}const dm={theme:"dark",font_scale:"md",header_density:"standard"};function v0(e){const t=e&&typeof e=="object"?e:{};return{theme:typeof t.theme=="string"&&t.theme?t.theme:dm.theme,font_scale:typeof t.font_scale=="string"&&t.font_scale?t.font_scale:dm.font_scale,header_density:typeof t.header_density=="string"&&t.header_density?t.header_density:dm.header_density}}function x0(e){return`af_appearance_${e}_v1`}function w0(e,t){const n=x0(e),o=h.useMemo(()=>({...dm,...(t==null?void 0:t.defaults)||{}}),[JSON.stringify((t==null?void 0:t.defaults)||{})]),[a,c]=h.useState(()=>{let d=o;try{const u=localStorage.getItem(n)??(t!=null&&t.legacyKey?localStorage.getItem(t.legacyKey):null);u&&(d=v0({...o,...JSON.parse(u)}))}catch{}try{Ip(d.theme),Dp({font_scale:d.font_scale,header_density:d.header_density})}catch{}return d});return h.useEffect(()=>{Ip(a.theme),Dp({font_scale:a.font_scale,header_density:a.header_density});try{localStorage.setItem(n,JSON.stringify(a))}catch{}},[n,a]),[a,c]}function b0(e){return h.useEffect(()=>{if(!e.open)return;const t=n=>{n.key!=="Escape"||n.defaultPrevented||(n.preventDefault(),e.onClose())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e.open,e.onClose]),e.open?s.jsx("div",{className:"af-appearance-overlay",onClick:e.onClose,role:"presentation",children:s.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":e.title||"Appearance",onClick:t=>t.stopPropagation(),children:[s.jsx("div",{className:"af-appearance__title",children:e.title||"Appearance"}),s.jsx("div",{className:"af-appearance__note",children:e.note||"Stored locally in this browser, per app."}),s.jsxs("div",{className:"af-appearance__grid",children:[s.jsx("label",{className:"af-appearance__label",children:"Theme"}),s.jsx(s0,{value:e.value.theme,onChange:t=>e.onChange({...e.value,theme:t})}),s.jsx("label",{className:"af-appearance__label",children:"Font size"}),s.jsx(i0,{value:e.value.font_scale,onChange:t=>e.onChange({...e.value,font_scale:t})}),s.jsx("label",{className:"af-appearance__label",children:"Header size"}),s.jsx(o0,{value:e.value.header_density,onChange:t=>e.onChange({...e.value,header_density:t})})]}),s.jsx("div",{className:"af-appearance__actions",children:s.jsx("button",{type:"button",className:"af-appearance__close",onClick:e.onClose,children:"Close"})})]})}):null}const S0={diary:"var(--accent)",question:"#e7b45a",dream:"#c084dd",interest:"#7bd88a",lesson:"#6ea8d8",world_model:"#5eead4"};function Bp(e){const t=String(e||"");return t.length>14?`${t.slice(0,10)}…${t.slice(-4)}`:t}function Ch(e){const[t,n]=h.useState(!1),[o,a]=h.useState(null),c=h.useRef(!1),d=typeof e.entryId=="string"&&e.entryId.trim()?e.entryId.trim():null,u=e.kind&&S0[e.kind]||"var(--text-muted)",m=h.useCallback(async()=>{if(!(!d||!e.onOpen||c.current)){c.current=!0,n(!0),a(null);try{await e.onOpen(d)}catch(y){a(String((y==null?void 0:y.message)||y||"could not open"))}finally{c.current=!1,n(!1)}}},[d,e.onOpen]);return!d||!e.onOpen?s.jsxs("span",{className:["af-memory-hint","af-memory-hint--text",e.className||""].filter(Boolean).join(" "),title:e.title,children:[s.jsx("span",{className:"af-memory-hint__dot",style:{background:u},"aria-hidden":"true"}),s.jsx("span",{className:"af-memory-hint__label",children:e.label}),d&&e.showId!==!1?s.jsx("code",{className:"af-memory-hint__id",children:Bp(d)}):null]}):s.jsxs("span",{className:["af-memory-hint",e.className||""].filter(Boolean).join(" "),children:[s.jsxs("button",{type:"button",className:"af-memory-hint__btn",onClick:()=>void m(),disabled:t,title:e.title||(e.command?e.command:`open ${d}`),"aria-label":`Open ${e.kind||"memory"} entry: ${e.label}`,children:[s.jsx("span",{className:"af-memory-hint__dot",style:{background:u},"aria-hidden":"true"}),s.jsx("span",{className:"af-memory-hint__label",children:e.label}),e.showId!==!1?s.jsx("code",{className:"af-memory-hint__id",children:Bp(d)}):null,s.jsx("span",{className:"af-memory-hint__act","aria-hidden":"true",children:t?"…":"↗"})]}),e.command?s.jsx("code",{className:"af-memory-hint__cmd",children:e.command}):null,o?s.jsx("span",{className:"af-memory-hint__err",role:"alert",children:o}):null]})}function Iy(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function j0(e){const t=Iy(e);if(!t||typeof t!="object"||Array.isArray(t))return{label:"input",value:t==null?"":String(t)};const n=Object.entries(t),a=["command","query","url","file_path","path","pattern","name"].map(c=>n.find(([d])=>d===c)).find(Boolean)||n[0];return a?{label:a[0].replace(/_/g," "),value:typeof a[1]=="string"?a[1]:JSON.stringify(a[1])??""}:{label:"",value:""}}function Dy({tool:e,showCopy:t=!0}){const[n,o]=h.useState(!1),a=Iy(e.arguments),c=j0(e.arguments),d=["file path","path"].includes(c.label)&&c.value.length>60?`${c.value.split(/[\\/]/).pop()} · ${c.value.slice(0,24)}…`:c.value,u=e.error&&/^File ['"].+['"] does not exist\.?$/.test(e.error)?"File not found. Expand for the exact path.":e.error&&e.error.length>180?`${e.error.slice(0,100)}…${e.error.slice(-70)}`:e.error,m={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},y=e.startedAt&&e.endedAt?Date.parse(e.endedAt)-Date.parse(e.startedAt):NaN,g=a&&typeof a=="object"&&!Array.isArray(a)?Object.entries(a):null;return s.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${e.status}`,children:[s.jsxs("summary",{className:"pc-tool-activity__summary",children:[s.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:s.jsx(zn,{name:e.status==="completed"?"check":e.status==="failed"?"x":e.status==="waiting"?"warning":"loader",size:15})}),s.jsx("strong",{children:e.name}),s.jsx("span",{className:"pc-tool-activity__preview",title:c.value,children:c.value?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pc-tool-activity__key",children:c.label}),d]}):"No parameters"}),s.jsx("span",{className:"pc-tool-activity__status",children:m[e.status]}),Number.isFinite(y)&&y>=0?s.jsxs("span",{className:"pc-tool-activity__duration",children:[(y/1e3).toFixed(1),"s"]}):null,s.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:s.jsx(zn,{name:"chevronRight",size:13})}),e.error?s.jsx("span",{className:"pc-tool-activity__error",title:e.error,children:u}):null]}),s.jsxs("div",{className:"pc-tool-activity__detail",children:[e.error?s.jsxs(s.Fragment,{children:[s.jsx("h4",{children:"Error"}),s.jsx("pre",{className:"pc-tool-activity__output",children:e.error})]}):null,s.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[s.jsx("h4",{children:"Parameters"}),t?s.jsxs("button",{type:"button",onClick:async()=>o(await Vl(JSON.stringify(e,null,2))),children:[s.jsx(zn,{name:"copy",size:13}),n?"Copied":"Copy details"]}):null]}),g?s.jsx("dl",{className:"pc-tool-activity__parameters",children:g.map(([v,x])=>s.jsxs(ye.Fragment,{children:[s.jsx("dt",{children:v}),s.jsx("dd",{children:x&&typeof x=="object"?s.jsx(os,{value:x}):s.jsx("code",{children:typeof x=="string"?x:JSON.stringify(x)})})]},v))}):e.arguments===void 0?s.jsx("p",{children:"Arguments are unavailable in this ledger."}):s.jsx(os,{value:a}),e.output!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("h4",{children:"Result"}),typeof e.output=="string"?s.jsx("pre",{className:"pc-tool-activity__output",children:e.output}):s.jsx("div",{className:"pc-tool-activity__output",children:s.jsx(os,{value:e.output})})]}):null]})]})}function k0({tools:e,showCopy:t}){const n=o=>e.filter(a=>a.status===o).length;return s.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[s.jsxs("div",{className:"pc-tool-group__heading",children:[s.jsx(zn,{name:"terminal",size:14}),s.jsx("strong",{children:"Tools"}),s.jsxs("span",{children:[e.length," ",e.length===1?"call":"calls"]}),s.jsx("div",{}),n("running")?s.jsxs("span",{className:"pc-tool-group__running",children:[n("running")," running"]}):null,n("waiting")?s.jsxs("span",{className:"pc-tool-group__waiting",children:[n("waiting")," need approval"]}):null,n("failed")?s.jsxs("span",{className:"pc-tool-group__failed",children:[n("failed")," failed"]}):null,n("completed")?s.jsxs("span",{className:"pc-tool-group__completed",children:[n("completed")," done"]}):null]}),e.map(o=>s.jsx(Dy,{tool:o,showCopy:t},o.id))]})}const Rr="not reported",rs=e=>e===void 0?Rr:Math.round(e).toLocaleString(),Cs=e=>{if(e===void 0)return Rr;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.round(e/1e3);return`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`},Fy=e=>e===void 0?Rr:`${Math.round(e).toLocaleString()} tok/s`,N0=(e,t)=>t>0?`${Math.round(e/t*100)}%`:"",Hl=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`,C0=e=>{const t=e.split("#")[0].replace(/\/+$/,"");return t.slice(t.lastIndexOf("/")+1)||e};function E0(e){const t=new Map;for(const n of e)n&&t.set(n,(t.get(n)||0)+1);return[...t].map(([n,o])=>o>1?`${n} ×${o}`:n).join(" · ")}function vm(e){const t=[],n=(e.models||[]).map(C0),o=e.providers||[];return(n.length||o.length)&&t.push([n.join(", ")||"model not reported",o.join(", ")].filter(Boolean).join(" · ")),t.push("From the run ledger; summed across this turn and its child runs."),t}function $0(e){const t=e.modelCalls||[],n=[],o=[{label:"Input",value:rs(e.inputTokens)},{label:"Output",value:rs(e.outputTokens)}];if(e.reasoningTokens!==void 0&&o.push({label:"Reasoning",value:rs(e.reasoningTokens),hint:"part of output"}),o.push({label:"Total",value:rs(e.totalTokens)}),n.push({heading:`Usage · ${Hl(e.llmCalls,"model call")}`,rows:o}),e.measuredCacheCalls){const c=e.cachedTokens||0,d=e.fedTokens||0,u=[{label:"Reused from cache",value:`${rs(c)}${c+d?` (${N0(c,c+d)})`:""}`},{label:"Newly processed",value:rs(e.fedTokens)},{label:"Outcome",value:E0(t.map(m=>m.cacheOutcome))||(e.cacheOutcomes||[]).join(" · ")||Rr},{label:"Backend",value:(e.cacheBackends||[]).join(", ")||Rr}];e.measuredCacheCalls!==e.llmCalls&&u.push({label:"Measured on",value:`${e.measuredCacheCalls} of ${e.llmCalls} calls`}),n.push({heading:"Prompt cache",rows:u})}else e.llmCalls&&n.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:Rr}]});const a=t.filter(c=>c.inputTokens!==void 0);return a.length===1&&t.length===1?n.push({heading:"Context",rows:[{label:"Prompt size",value:`${rs(a[0].inputTokens)} tokens`}]}):a.length>1&&n.push({heading:"Context",rows:[{label:"First → last call",value:`${rs(a[0].inputTokens)} → ${rs(a[a.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:t.map((c,d)=>[String(d+1),rs(c.inputTokens),c.cachedTokens===void 0?"—":rs(c.cachedTokens),c.fedTokens===void 0?"—":rs(c.fedTokens),rs(c.outputTokens),c.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:e.totalTokens===void 0?Rr:`${e.totalTokens.toLocaleString()} total`,sections:n,footer:vm(e)}}function Yf(e,t,n,o){if(e===void 0)return Rr;const a=[Cs(e)];return t!==void 0&&a.push(`${t.toLocaleString()} ${o}${n!==void 0?` at ${Fy(n)}`:""}`),a.join(" · ")}function M0(e){var y,g,v;const t=e.modelCalls||[],n=[],o=e.durationMs,a=[{label:"Wall clock",value:Cs(o)}];if(a.push({label:"Model",value:e.genTimeMs===void 0?Rr:`${Cs(e.genTimeMs)} · ${Hl(e.timedCalls||0,"call")}${e.timedCalls!==e.llmCalls?` (of ${e.llmCalls})`:""}`}),a.push({label:"Tools",value:e.toolTimeMs!==void 0?`${Cs(e.toolTimeMs)} · ${Hl(e.toolBatches||0,"batch","batches")}`:e.toolCalls?Rr:"none",hint:e.toolTimeIncludesApproval?"includes approval wait":void 0}),o!==void 0&&e.genTimeMs!==void 0){const x=o-e.genTimeMs-(e.toolTimeMs||0);a.push({label:"Orchestration",value:x>=0?Cs(x):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}n.push({heading:"Turn",rows:a});const c=[],d=e.ttftCalls||0,u=e.promptPhaseCalls||0;e.promptPhaseMs!==void 0?c.push({label:d&&d===u?"Prefill (TTFT)":"Prefill",value:Yf(e.promptPhaseMs,e.promptPhaseNewTokens,e.promptPhaseTokensPerSecond,"new tok"),hint:d===u?"measured time to first token":d?`TTFT measured on ${d} of ${u}; rest from provider rate`:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0&&e.prefillNewTokensPerSecond!==void 0?c.push({label:"Prefill",value:Yf(e.prefillMs,e.prefillNewTokens,e.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):e.prefillMs!==void 0?c.push({label:"Prefill",value:`${Cs(e.prefillMs)}${e.promptTokensPerSecond!==void 0?` at ${Fy(e.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):c.push({label:"Prefill",value:Rr}),e.cachedTokens&&(e.promptPhaseMs??e.prefillMs)!==void 0&&c.push({label:"Restored",value:`${e.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),c.push({label:"Generation",value:e.generationPhaseMs!==void 0?Yf(e.generationPhaseMs,e.generationPhaseTokens,e.generationPhaseTokensPerSecond,"tok"):Yf(e.decodeMs,e.outputTokens,e.generationTokensPerSecond,"tok")}),e.measuredSpeedCalls&&e.measuredSpeedCalls!==e.llmCalls&&c.push({label:"Speeds from",value:`${e.measuredSpeedCalls} of ${e.llmCalls} calls`}),n.push({heading:"Model",rows:c});const m=e.speculation;if(m){const x=(m.draftKinds||[]).map(C=>C.toUpperCase()).join(", "),b=[{label:"Mode",value:`${m.used?"on":"off"}${x?` · ${x}`:""}${(y=m.modes)!=null&&y.length?` (${m.modes.join(", ")})`:""}`,hint:m.calls!==e.llmCalls||m.used!==m.calls?`used on ${m.used} of ${e.llmCalls} calls`:void 0},{label:"Acceptance",value:m.acceptanceRate===void 0?Rr:`${Math.round(m.acceptanceRate*100)}% · ${rs(m.acceptedTokens)} of ${rs(m.draftedTokens)} drafted`}];((g=m.draftLengths)!=null&&g.length||m.rounds!==void 0)&&b.push({label:"Draft length",value:`${(v=m.draftLengths)!=null&&v.length?`${m.draftLengths.join("/")} tok/round`:Rr}${m.rounds!==void 0?` · ${m.rounds.toLocaleString()} rounds`:""}`}),n.push({heading:"Speculation",rows:b})}return e.slowestToolBatch&&n.push({heading:"Tools",rows:[{label:"Total",value:`${Cs(e.toolTimeMs)} · ${Hl(e.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Cs(e.slowestToolBatch.ms)} · ${By(e.slowestToolBatch)}`}],note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),t.length>1&&n.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:t.map((x,b)=>[String(b+1),x.promptMs===void 0?"—":`${Cs(x.promptMs)}${x.promptSource==="rate"?"*":""}`,x.promptNewTokensPerSecond===void 0?"—":Math.round(x.promptNewTokensPerSecond).toLocaleString(),x.generationMs===void 0?"—":Cs(x.generationMs),x.generationTokensPerSecond===void 0?"—":Math.round(x.generationTokensPerSecond).toLocaleString(),x.cacheOutcome||"—"])},note:t.some(x=>x.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:o===void 0?Rr:`${Cs(o)} wall clock`,sections:n,footer:vm(e)}}function By(e){return e.tools.length===1?`${e.tools[0]} ×${e.calls}`:`${Hl(e.calls,"call")} (${e.tools.join(", ")})`}function A0(e){const t=[],n=(e.toolsWaiting||0)+(e.toolsRunning||0);if(!e.toolCalls&&!n)return t.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:t,footer:vm(e)};const o=[{label:"Succeeded",value:(e.toolCalls-(e.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(e.toolsFailed||0).toLocaleString()}];e.toolsRunning&&o.push({label:"Running",value:e.toolsRunning.toLocaleString()}),e.toolsWaiting&&o.push({label:"Awaiting approval",value:e.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),t.push({heading:"Outcome",rows:o});const a=Object.entries(e.toolBreakdown||{}).sort((u,m)=>m[1].calls-u[1].calls||u[0].localeCompare(m[0]));a.length&&t.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:a.map(([u,m])=>[u,m.calls.toLocaleString(),m.failed.toLocaleString(),m.ms!==void 0?`${Cs(m.ms)}${m.sharedBatches?" +shared":""}`:m.sharedBatches?"shared":Rr])},note:a.some(([,u])=>u.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const c=a.filter(([,u])=>u.errors&&Object.keys(u.errors).length);c.length&&t.push({heading:"Failures",rows:c.map(([u,m])=>({label:u,value:Object.entries(m.errors).sort((y,g)=>g[1]-y[1]).map(([y,g])=>g>1?`${y} ×${g}`:y).join(" · ")}))});const d=[{label:"Tool time",value:e.toolTimeMs===void 0?Rr:`${Cs(e.toolTimeMs)} · ${Hl(e.toolBatches||0,"batch","batches")}`}];return e.slowestToolBatch&&d.push({label:"Slowest batch",value:`${Cs(e.slowestToolBatch.ms)} · ${By(e.slowestToolBatch)}`}),t.push({heading:"Timing",rows:d,note:e.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Hl(e.toolCalls,"call")}${e.toolsFailed?` · ${e.toolsFailed} failed`:""}`,sections:t,footer:vm(e)}}function Eh(e,t){return e==="tokens"?$0(t):e==="time"?M0(t):A0(t)}function T0(e){const t=e.detail;return s.jsxs("div",{ref:e.panelRef,id:e.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${t.kind}`,style:e.style,onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,children:[s.jsxs("div",{className:"pc-stat-detail-head",children:[s.jsx("span",{className:"pc-stat-detail-title",children:t.title}),s.jsx("span",{className:"pc-stat-detail-headline",children:t.headline})]}),t.sections.map(n=>{var o;return s.jsxs("div",{className:"pc-stat-detail-section",children:[s.jsx("div",{className:"pc-stat-detail-heading",children:n.heading}),(o=n.rows)!=null&&o.length?s.jsx("dl",{className:"pc-stat-detail-rows",children:n.rows.map(a=>s.jsxs(ye.Fragment,{children:[s.jsx("dt",{children:a.label}),s.jsxs("dd",{children:[s.jsx("span",{className:a.value===Rr?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:a.value}),a.hint?s.jsx("span",{className:"pc-stat-detail-hint",children:a.hint}):null]})]},a.label))}):null,n.table?s.jsxs("table",{className:"pc-stat-detail-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:n.table.columns.map(a=>s.jsx("th",{scope:"col",children:a},a))})}),s.jsx("tbody",{children:n.table.rows.map((a,c)=>s.jsx("tr",{children:a.map((d,u)=>s.jsx("td",{children:d},u))},c))})]}):null,n.note?s.jsx("p",{className:"pc-stat-detail-note",children:n.note}):null]},n.heading)}),s.jsx("div",{className:"pc-stat-detail-foot",children:t.footer.map(n=>s.jsx("div",{children:n},n))})]})}const Ko=8;function L0(e){const[t,n]=h.useState(!!e.defaultOpen),[o,a]=h.useState(null),c=h.useRef(null),d=h.useRef(null),u=h.useRef(null),m=`pc-stat-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=h.useCallback(()=>{u.current!==null&&window.clearTimeout(u.current),u.current=null},[]),g=h.useCallback(()=>{y(),n(!0)},[y]),v=h.useCallback(()=>{y(),u.current=window.setTimeout(()=>n(!1),120)},[y]);h.useEffect(()=>y,[y]),h.useLayoutEffect(()=>{if(!t){a(null);return}const S=()=>{const L=c.current,M=d.current;if(!L||!M)return;const W=L.getBoundingClientRect(),q=M.offsetWidth,z=M.offsetHeight,Y=window.innerWidth,Q=window.innerHeight,Z=W.top-Ko-z,ne=W.bottom+Ko,ue=Z>=Ko?Z:ne+z<=Q-Ko?ne:Math.max(Ko,Q-Ko-z),de=Math.min(Math.max(Ko,W.left),Math.max(Ko,Y-Ko-q));a({top:ue,left:de})};return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[t]),h.useEffect(()=>{if(!t)return;const S=L=>{L.key==="Escape"&&n(!1)};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t]);const x=typeof e.onClick=="function",b=x?"button":"span",C=t?s.jsx(T0,{detail:e.detail,id:m,panelRef:d,onMouseEnter:y,onMouseLeave:v,style:{position:"fixed",top:(o==null?void 0:o.top)??0,left:(o==null?void 0:o.left)??0,visibility:o?"visible":"hidden"}}):null;return s.jsxs(s.Fragment,{children:[s.jsxs(b,{ref:c,...x?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",x?"pc-chat-stat--clickable":"",e.className].filter(Boolean).join(" "),"aria-label":`${e.label} — ${e.detail.title.toLowerCase()} details`,"aria-describedby":t?m:void 0,"data-stat-kind":e.detail.kind,onMouseEnter:g,onMouseLeave:v,onFocus:g,onBlur:()=>n(!1),onKeyDown:S=>{S.key==="Escape"&&n(!1)},onClick:x?()=>{var S;return(S=e.onClick)==null?void 0:S.call(e)}:void 0,children:[e.icon?s.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:e.icon}):null,s.jsx("span",{className:"pc-chat-stat-label",children:e.label})]}),C&&typeof document<"u"?Py.createPortal(C,document.body):C]})}function R0(e){const t=e.totalTokens!==void 0?Eh("tokens",e):null,n=Eh("tools",e),o=e.durationMs!==void 0?Eh("time",e):null;return[...t?[{label:`${e.totalTokens.toLocaleString()} tokens`,detail:t}]:[],{label:`${e.toolCalls} ${e.toolCalls===1?"tool":"tools"}`,detail:n},...e.changedFiles.length?[{label:`${e.changedFiles.length} ${e.changedFiles.length===1?"file":"files"} changed`,title:e.changedFiles.join(`
54
+ `)}]:[],...o?[{label:`${(e.durationMs/1e3).toFixed(e.durationMs<1e4?1:0)}s`,detail:o}]:[]]}function P0(e){const t=String(e.role||"").trim().toLowerCase()||"system",n=String(e.kind||"").trim().toLowerCase(),o=String(e.level||"").trim().toLowerCase();return t==="system"&&n==="report_bug"?{label:String(e.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:t==="system"&&n==="report_feature"?{label:String(e.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:t==="user"?{label:String(e.title||"").trim()||"You",icon:"user",variant:"user"}:t==="assistant"?{label:String(e.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(e.title||"").trim()||(o==="error"?"Error":o==="warn"?"Warning":"System"),icon:o==="error"?"error":o==="warn"?"warning":"info",variant:o==="error"?"error":o==="warn"?"warn":"status"}}function O0(e){var L;const t=e.message,n=h.useMemo(()=>P0(t),[t.kind,t.level,t.role,t.title]),o=String(t.ts||"").trim(),a=h.useMemo(()=>{if(!o)return"";const M=new Date(o);return Number.isFinite(M.getTime())?M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[o]),[c,d]=h.useState("idle"),u=h.useRef(null);h.useEffect(()=>()=>{u.current!==null&&window.clearTimeout(u.current)},[]);const m=typeof e.onSpeakToggle=="function"&&n.variant==="assistant"&&!!String(t.content||"").trim(),y=m&&((L=e.getSpeakState)==null?void 0:L.call(e,t))||"idle",g=y==="loading"?"loader":y==="playing"?"pause":"speaker",v=y==="loading"?"Generating audio…":y==="playing"?"Pause":y==="paused"?"Resume":"Speak (TTS)",x=e.showCopy!==!1,b=Array.isArray(e.attachments)?e.attachments:[],C=t.statistics,S=h.useMemo(()=>Array.isArray(e.stats)?e.stats:C?R0(C):[],[e.stats,C]);return t.toolActivity?s.jsx(Dy,{tool:t.toolActivity,showCopy:e.showCopy}):s.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${n.variant}`,e.className].filter(Boolean).join(" "),children:[s.jsxs("div",{className:"pc-chat-header",children:[s.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:s.jsx(zn,{name:n.icon,size:14})}),s.jsx("span",{className:"pc-chat-role",children:n.label}),s.jsx("span",{className:"pc-chat-header-spacer"}),a?s.jsx("span",{className:"pc-chat-time",children:a}):null,s.jsxs("div",{className:"pc-chat-header-actions",children:[m?s.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":v,title:v,onClick:()=>{var M;return(M=e.onSpeakToggle)==null?void 0:M.call(e,t)},children:s.jsx(zn,{name:g,size:22})}):null,x?s.jsx("button",{className:`pc-chat-icon-btn ${c!=="idle"?`pc-chat-icon-btn--${c}`:""}`.trim(),type:"button","aria-label":"Copy message",title:c==="idle"?"Copy":c==="copied"?"Copied":"Copy failed",onClick:async()=>{const M=await Vl(String(t.content||""));d(M?"copied":"failed"),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>d("idle"),900)},children:s.jsx(zn,{name:"copy",size:22})}):null]})]}),s.jsx("div",{className:"pc-chat-body",children:s.jsx(Kw,{text:String(t.content||""),renderMarkdown:e.renderMarkdown,jsonCollapseAfterDepth:e.jsonCollapseAfterDepth})}),b.length?s.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:b.slice(0,24).map((M,W)=>{const q=String(M.label||"").trim()||"attachment",z=String(M.target||"").trim(),Y=String(M.title||"").trim(),Q=!!M.disabled||typeof M.onClick!="function";return s.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:Y||q,onClick:Q?void 0:M.onClick,disabled:Q,children:[s.jsx(zn,{name:"paperclip",size:14}),z?s.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${z}`,children:z}):null,s.jsx("span",{className:"pc-chat-attachment-name",children:q})]},M.id||`${q}:${W}`)})}):null,S.length?s.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:S.slice(0,12).map((M,W)=>{const q=String(M.label||"").trim();if(!q)return null;if(M.detail)return s.jsx(L0,{label:q,detail:M.detail,icon:M.icon,onClick:M.onClick},M.id||`${q}:${W}`);const z=String(M.title||"").trim(),Y=typeof M.onClick=="function",Q=Y?"button":"span";return s.jsxs(Q,{...Y?{type:"button"}:{},className:["pc-chat-stat",Y?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:z||void 0,onClick:Y?()=>{var Z;return(Z=M.onClick)==null?void 0:Z.call(M)}:void 0,children:[M.icon?s.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:M.icon}):null,s.jsx("span",{className:"pc-chat-stat-label",children:q})]},M.id||`${q}:${W}`)})}):null]})}function z0(e,t){const n=Math.max(0,Math.trunc(t));return e.scrollHeight-e.scrollTop-e.clientHeight<=n}function Uy(e){const t=typeof e.autoScrollThresholdPx=="number"&&Number.isFinite(e.autoScrollThresholdPx)?e.autoScrollThresholdPx:120,n=e.autoScroll!==!1,o=h.useRef(null),a=h.useRef(null),[c,d]=h.useState(!0),u=h.useMemo(()=>Array.isArray(e.messages)?e.messages:[],[e.messages]),m=h.useMemo(()=>{var v;const g=[];for(const x of u){const b=g[g.length-1];x.toolActivity&&((v=b==null?void 0:b[0])!=null&&v.toolActivity)&&b[0].runId===x.runId?b.push(x):g.push([x])}return g},[u]);h.useEffect(()=>{if(!n)return;const g=o.current;if(!g)return;const v=()=>{d(z0(g,t))};return g.addEventListener("scroll",v,{passive:!0}),v(),()=>g.removeEventListener("scroll",v)},[n,t]);const y=h.useMemo(()=>{let g=0;for(const v of u)g+=String(v.content??"").length;return`${u.length}:${g}:${String(e.afterKey??"")}`},[u,e.afterKey]);return h.useEffect(()=>{if(!n||!c)return;const g=o.current;g&&(g.scrollTop=g.scrollHeight)},[n,c,y]),s.jsxs("div",{ref:o,className:["pc-chat-thread",e.className].filter(Boolean).join(" "),children:[u.length?null:e.empty||null,m.map((g,v)=>{var C;const x=g[0],b=String(x.id||"")||String(x.ts||"")+":"+String(x.role||"")+":"+v;return x.toolActivity?s.jsx(k0,{tools:g.map(S=>S.toolActivity),showCopy:(C=e.messageProps)==null?void 0:C.showCopy},b):s.jsx(O0,{message:x,...e.messageProps||{}},b)}),e.after,s.jsx("div",{ref:a})]})}const Hy=ye.forwardRef(function(t,n){const o=typeof t.rows=="number"&&Number.isFinite(t.rows)?Math.max(1,Math.trunc(t.rows)):3,a=!!t.disabled,c=!!t.busy,d=!a&&!c&&!!String(t.value||"").trim();return s.jsxs("div",{className:["pc-composer",t.className].filter(Boolean).join(" "),children:[t.leading,s.jsx("textarea",{ref:n,className:["pc-composer__textarea",t.textareaClassName].filter(Boolean).join(" "),value:t.value,onChange:u=>t.onChange(u.target.value),rows:o,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:t.placeholder||"","aria-label":t.ariaLabel||t.placeholder||"Message",disabled:a,autoFocus:!!t.autoFocus,onPaste:t.onPaste,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),d&&t.onSubmit())}}),s.jsxs("div",{className:"pc-composer__row",children:[s.jsx("div",{className:"pc-composer__actions",children:t.actions}),s.jsx("button",{type:"button",className:t.sendButtonClassName||"pc-btn",disabled:!d,onClick:()=>t.onSubmit(),children:c?t.busyLabel||"Thinking…":t.sendLabel||"Send"})]}),t.overlay]})});function I0(e){return!!(e&&typeof e[Symbol.asyncIterator]=="function")}function D0(e){const[t,n]=h.useState([]),o=e.messages??t,a=S=>{e.onMessagesChange&&e.onMessagesChange(S),e.messages===void 0&&n(S)},c=h.useRef(o);c.current=o;const[d,u]=h.useState(""),[m,y]=h.useState(!1),g=h.useRef(null),v=e.assistantName||"Assistant",x=!!e.blockedNotice,b=async S=>{const L=String(S||"").trim();if(!L||m||x)return;u("");const M=c.current,W=[...M,{role:"user",content:L,ts:new Date().toISOString()}];a(W),y(!0);const q=new AbortController;g.current=q;try{const z=e.ask(L,{signal:q.signal,history:M});if(I0(z)){let Y="";const Q=[...W,{role:"assistant",title:v,content:"",ts:new Date().toISOString()}];a(Q);for await(const Z of z){if(q.signal.aborted)break;Y+=String(Z??""),a([...W,{role:"assistant",title:v,content:Y,ts:new Date().toISOString()}])}!Y.trim()&&!q.signal.aborted&&a([...W,{role:"assistant",title:v,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const Y=String(await z??"").trim();a([...W,Y?{role:"assistant",title:v,content:Y,ts:new Date().toISOString()}:{role:"assistant",title:v,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(z){q.signal.aborted||a([...c.current,{role:"assistant",title:v,content:`#FALLBACK assistant request failed: ${String((z==null?void 0:z.message)||z||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{g.current===q&&(g.current=null),y(!1)}},C=h.useMemo(()=>o.length>0?null:s.jsxs("div",{className:"pc-assistant__empty",children:[s.jsx("div",{className:"pc-assistant__empty-text",children:e.emptyState||"Ask about this app — answers are grounded in its documentation."}),e.suggestions&&e.suggestions.length>0?s.jsx("div",{className:"pc-assistant__suggestions",children:e.suggestions.map(S=>s.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void b(S),disabled:m||x,children:S},S))}):null]}),[o.length,e.emptyState,e.suggestions,m,x]);return s.jsxs("div",{className:`pc-assistant${e.className?` ${e.className}`:""}`,children:[s.jsxs("div",{className:"pc-assistant__thread",children:[C,s.jsx(Uy,{messages:o,autoScroll:!0}),x?s.jsx("div",{className:"pc-assistant__blocked",children:e.blockedNotice}):null]}),s.jsx("div",{className:"pc-assistant__composer",children:s.jsx(Hy,{value:d,onChange:u,onSubmit:()=>void b(d),placeholder:e.placeholder||"Ask about this app…",disabled:x,busy:m,rows:2,actions:m?s.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var S;(S=g.current)==null||S.abort()},children:"Stop"}):null})})]})}const F0="# AbstractObserver\n\n> Gateway-only observability UI (Web/PWA) for AbstractFramework runs: a browser SPA + tiny Node.js CLI that connects to an AbstractGateway HTTP API (HTTP fetch + SSE ledger streaming) and submits durable commands.\n\nThis repository is UI-only:\n- The packaged CLI (`bin/cli.js`) serves static assets from `dist/` (SPA fallback) and proxies `/api` to Gateway after hosted browser-session sign-in, using the shared session proxy from the `@abstractframework/app-server` runtime dependency.\n- The browser talks to same-origin `/api` in hosted mode; direct Gateway URLs remain available for local development via `src/lib/gateway_client.ts` (treat this file as the source of truth for HTTP endpoints and request shapes).\n- Hosted sign-in uses Gateway URL + user + token only to create an app-scoped browser session. Settings persistence strips Gateway bearer tokens.\n- On non-local hosted UI hostnames, the server-configured Gateway URL is authoritative; browser-supplied Gateway URL changes are rejected unless `ABSTRACTOBSERVER_ALLOW_REMOTE_BROWSER_GATEWAY_CONFIG=1` is enabled behind access control. Forwarded host headers are trusted only when `ABSTRACTOBSERVER_TRUST_PROXY_HEADERS=1` or `ABSTRACTGATEWAY_TRUST_PROXY_HEADERS=1`.\n\n## Quickstart\n- Run packaged UI server (no build step): `npx --yes --package @abstractframework/observer -- abstractobserver`\n- Dev server (Vite; proxies `/api` in dev): `npm install && npm run dev`\n- Unit tests (Vitest): `npm test`\n- Production build (writes `dist/`): `npm run build`\n- Regenerate `llms-full.txt`: `npm run llms:full`\n\nNotes:\n- Build output lives in `dist/` and is served by `bin/cli.js` (don’t edit `dist/` manually).\n- Dev/build uses Vite aliases to sibling workspace packages under `../abstractuic/*/src` (see `vite.config.ts` and `docs/development.md`).\n- `llms.txt` format reference: https://llmstxt.org/\n\n## Documentation (start here)\n- [README](README.md): Install and quickstart\n- [Getting started](docs/getting-started.md): Run the UI and connect to a gateway\n- [FAQ](docs/faq.md): Common questions (grounded in code)\n- [Docs index](docs/README.md): What to read next\n- [Architecture](docs/architecture.md): Components, data flow, diagrams\n- [Configuration](docs/configuration.md): CLI env vars, UI settings, deployment patterns\n- [API](docs/api.md): Gateway endpoints used by the UI, including Runtime Activity run pages and canonical artifact envelope search/stats for Runtime Artifact Explorer\n- [Development](docs/development.md): Local dev, workspace deps, tests, build\n- [Security](docs/security.md): Trust boundaries and operational guidance\n- [Troubleshooting](docs/troubleshooting.md): Common issues and fixes\n\n## Key entrypoints (code)\n- [CLI server](bin/cli.js): static server (`PORT`, `HOST`, `ABSTRACTOBSERVER_GATEWAY_URL`), SPA fallback, `@abstractframework/app-server` session proxy, optional GPU widget config injection\n- [App shell + pages](src/ui/app.tsx): settings, page routing, observe/launch flows, durable commands\n- [Gateway client](src/lib/gateway_client.ts): HTTP client + SSE ledger streaming (API source of truth)\n- [Vite config](vite.config.ts): workspace aliases + dev session proxy and `/api` fallback proxy\n- [Package metadata](package.json): npm name/version, scripts, Node engine\n- [llms-full generator](scripts/generate-llms-full.mjs): defines which files are embedded into `llms-full.txt`\n\n## Ecosystem context\n- [AbstractFramework](https://github.com/lpalbou/AbstractFramework): ecosystem entrypoint and component map\n- [AbstractRuntime](https://github.com/lpalbou/abstractruntime): durable workflow runtime behind the gateway ledger\n- [AbstractCore](https://github.com/lpalbou/abstractcore): unified LLM + tools layer commonly used by workflows\n\n## Common tasks\n- Add/change a gateway capability: update `src/lib/gateway_client.ts` (source of truth) → update `docs/api.md` → run `npm test` + `npm run build`.\n- Change CLI behavior/config: update `bin/cli.js` → update `docs/configuration.md` → run `npm run build`.\n- Update docs for agents: edit docs → regenerate `llms-full.txt` with `npm run llms:full`.\n\n## Optional (project meta)\n- [Changelog](CHANGELOG.md): Release notes\n- [Contributing](CONTRIBUTING.md): How to develop and submit changes\n- [Security policy](SECURITY.md): Responsible vulnerability reporting\n- [Acknowledgments](ACKNOWLEDGMENTS.md): Credits\n- [License](LICENSE): MIT license\n",B0="observer-docs-assistant",U0=1500,H0=12e4;function W0(e,t){return new Promise((n,o)=>{const a=setTimeout(n,e);t.addEventListener("abort",()=>{clearTimeout(a),o(new DOMException("aborted","AbortError"))},{once:!0})})}const $h=1200;function q0(e,t){const n=t.slice(-6),o=t.length-n.length,a=n.map(d=>{const u=d.role==="assistant"?"Assistant":"User",m=String(d.content||""),y=m.length>$h?`${m.slice(0,$h)}… [#TRUNCATION: ${$h} of ${m.length} chars of this turn]`:m;return`${u}: ${y}`}).join(`
55
+ `),c=o>0?`[#TRUNCATION: showing the last ${n.length} turns; ${o} earlier turn(s) omitted]
56
+ `:"";return["You are the AbstractObserver in-app assistant. Answer questions about","using and understanding the AbstractObserver web app (pages: Board,","Observe/run page with Story/Ledger/Flow/Ask tabs, System with","Activity/Artifacts/Memory/Logs, Launch, Settings). Ground every answer","in the documentation index below; when the docs don't cover something,","say so plainly instead of guessing. Be concise and concrete.","","=== DOCUMENTATION INDEX (llms.txt) ===",F0,"=== END DOCUMENTATION ===",a?`
57
+ Conversation so far:
58
+ `+c+a:"",`
59
+ User question: ${e}`].join(`
60
+ `)}function V0(e){var t,n;for(let o=e.length-1;o>=0;o--){const a=e[o],c=a!=null&&a.result&&typeof a.result=="object"?a.result:null,d=[(t=c==null?void 0:c.response)==null?void 0:t.content,(n=c==null?void 0:c.response)==null?void 0:n.text,c==null?void 0:c.output,c==null?void 0:c.content,c==null?void 0:c.text];for(const u of d){const m=typeof u=="string"?u.trim():"";if(m)return m}}return""}function G0(e){return async(t,n)=>{var u;const o=e(),a=n.history.map(m=>({role:m.role,content:String(m.content??"")})),c=await o.start_run(null,{prompt:q0(t,a)},{bundle_id:"basic-agent",session_id:B0}),d=Date.now();for(;;){if(await W0(U0,n.signal),Date.now()-d>H0)throw new Error("The assistant run timed out (120s). The run is still visible on the Observe page.");const m=await o.get_run(c),y=String((m==null?void 0:m.status)||"").trim().toLowerCase();if(y==="failed"||y==="cancelled"){const g=String(((u=m==null?void 0:m.error)==null?void 0:u.message)||(m==null?void 0:m.error)||"run "+y).slice(0,400);throw new Error(`The assistant run ${y}: ${g}`)}if(y==="completed"){const g=await o.get_ledger(c,{after:0,limit:500,signal:n.signal});return V0(g.items)||"(the run completed but produced no readable answer — inspect it on the Observe page)"}}}}function Y0(e){const t=h.useRef(e.gateway);t.current=e.gateway;const n=h.useMemo(()=>G0(()=>t.current),[]),[o]=h.useState(void 0);return s.jsx(g0,{open:e.open,onClose:e.onClose,label:"Observer assistant",title:"Assistant",width:420,topOffset:e.topOffset,children:s.jsx(D0,{ask:n,assistantName:"Observer",placeholder:"Ask about the observer…",blockedNotice:e.connected?o:"Connect to the gateway to use the assistant.",suggestions:["How do I see why a run failed?","Where do I find the artifacts a run produced?","What does the Board's Review column mean?","How do I launch a workflow on a schedule?"],emptyState:s.jsx("div",{children:"Answers are grounded in this app's documentation. Each question runs once through the connected gateway's basic agent."})})})}class xm{constructor(t){this._maxSize=xm._normalizeMaxSize(t),this._values=[]}get maxSize(){return this._maxSize}get size(){return this._values.length}static _normalizeMaxSize(t){const n=Number(t);return!Number.isFinite(n)||n<=0?1:Math.min(1e3,Math.floor(n))}setMaxSize(t){const n=xm._normalizeMaxSize(t);this._maxSize=n,this._values.length>n&&(this._values=this._values.slice(this._values.length-n))}clear(){this._values=[]}push(t){const n=Number(t),o=Number.isFinite(n)?n:null;this._values.push(o),this._values.length>this._maxSize&&this._values.splice(0,this._values.length-this._maxSize)}values(){return this._values.slice()}last(){return this._values.length?this._values[this._values.length-1]:null}}function K0(e){try{return new URL(String(e)),!0}catch{return!1}}function X0({baseUrl:e,endpoint:t}){const n=String(t||"/api/gateway/host/metrics/gpu");return K0(n)?n:e&&String(e).trim()?new URL(n,String(e)).toString():n}async function J0({token:e,getToken:t}){if(typeof t=="function"){const n=await t();return n==null?"":String(n)}return e==null?"":String(e)}function Z0({token:e}){const t=String(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}function Q0(e){if(!e||typeof e!="object")return null;const t=Number(e.utilization_gpu_pct);if(Number.isFinite(t))return t;const n=e.gpus;if(Array.isArray(n)&&n.length){const o=n.map(c=>Number(c&&c.utilization_gpu_pct)).filter(c=>Number.isFinite(c));return o.length?o.reduce((c,d)=>c+d,0)/o.length:null}return null}async function eb({baseUrl:e,endpoint:t,token:n,getToken:o,signal:a,fetchImpl:c}={}){const d=X0({baseUrl:e,endpoint:t}),u=await J0({token:n,getToken:o}),m=c||globalThis.fetch;if(typeof m!="function")return{ok:!1,status:0,error:"fetch_unavailable",payload:null};let y;try{y=await m(d,{method:"GET",headers:{Accept:"application/json",...Z0({token:u})},signal:a})}catch(v){return{ok:!1,status:0,error:"network_error",detail:v instanceof Error?v.message:String(v),payload:null}}let g=null;try{g=await y.json()}catch{g=null}return{ok:y.ok,status:y.status,error:y.ok?null:"http_error",payload:g}}const yd=Object.freeze({tickMs:1500,historySize:20,endpoint:"/api/gateway/host/metrics/gpu",baseUrl:"",mode:"full"});function tb(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Up(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}function Hp(e,t){const n=Number(e);return Number.isFinite(n)?Math.floor(n):t}function Mh(e,t=1){const n=Up(Number(e)/100,0,1),o=Math.round(140-140*n),a=Up(Number(t),0,1);return a>=1?`hsl(${o} 85% 55%)`:`hsl(${o} 85% 55% / ${a})`}function Wp(e){const t={...yd,...e||{}};return t.tickMs=Math.max(250,Hp(t.tickMs,yd.tickMs)),t.historySize=Math.max(1,Math.min(200,Hp(t.historySize,yd.historySize))),t.endpoint=String(t.endpoint||yd.endpoint),t.baseUrl=String(t.baseUrl||""),t.mode=String(t.mode||yd.mode).trim().toLowerCase(),t.mode!=="icon"&&(t.mode="full"),t}function nb(){return`
61
+ :host{display:inline-block;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";line-height:1}
62
+ .wrap{box-sizing:border-box;display:flex;flex-direction:column;gap:6px;padding:var(--monitor-gpu-padding,8px 10px);border:1px solid var(--monitor-gpu-border,#2a2f3a);border-radius:var(--monitor-gpu-radius,10px);background:var(--monitor-gpu-bg,#0b1020);color:var(--monitor-gpu-fg,#e7eaf0);width:var(--monitor-gpu-width,180px)}
63
+ .wrap.icon{gap:var(--monitor-gpu-gap,4px);padding:var(--monitor-gpu-padding,4px);border-radius:var(--monitor-gpu-radius,999px);width:var(--monitor-gpu-width,30px);background:linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.02)),var(--monitor-gpu-bg,#0b1020);box-shadow:0 0 14px var(--monitor-gpu-accent-glow, rgba(76,195,255,0.18))}
64
+ .wrap.icon .top{display:none}
65
+ .wrap.icon .bars{height:var(--monitor-gpu-bars-height,18px)}
66
+ .top{display:flex;align-items:baseline;justify-content:space-between;gap:10px}
67
+ .label{font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.9}
68
+ .value{font-variant-numeric:tabular-nums;font-size:var(--monitor-gpu-font-size,var(--font-size-sm,12px));opacity:.95}
69
+ .bars{display:flex;align-items:flex-end;gap:2px;height:var(--monitor-gpu-bars-height,34px);overflow:hidden}
70
+ .bar{flex:1;min-width:0;border-radius:2px;background:var(--monitor-gpu-bar,#4cc3ff);height:2px;opacity:.9;transition:height .25s ease, background .25s ease, opacity .25s ease}
71
+ .bar.missing{background:var(--monitor-gpu-bar-missing,#62708a);opacity:.35}
72
+ .bar.error{background:var(--monitor-gpu-bar-error,#ff6b6b);opacity:.7}
73
+ .muted{opacity:.6}
74
+ `}class rb{constructor(t,n={}){if(!t||typeof t!="object")throw new TypeError("target element is required");this._target=t,this._opts=Wp(n),this._buffer=new xm(this._opts.historySize),this._timer=null,this._timer_gen=0,this._running=!1,this._abort=null,this._resumeTimer=null,this._mounted=!1,this._els=null,this._token=n.token,this._getToken=n.getToken,this._stoppedForAuth=!1}get options(){return{...this._opts}}set token(t){this._token=t,String(this._token||"").trim()&&this._stoppedForAuth&&(this._stoppedForAuth=!1,this.start())}get token(){return this._token}set getToken(t){this._getToken=t}get getToken(){return this._getToken}mount(){if(this._mounted)return;if(typeof document>"u")throw new Error("MonitorGpuWidget requires a browser DOM");const t=this._target;t.textContent="";const n=document.createElement("style");n.textContent=nb();const o=document.createElement("div");o.className=this._opts.mode==="icon"?"wrap icon":"wrap";const a=document.createElement("div");a.className="top";const c=document.createElement("div");c.className="label",c.textContent="GPU";const d=document.createElement("div");d.className="value muted",d.textContent="—",a.appendChild(c),a.appendChild(d);const u=document.createElement("div");u.className="bars",o.appendChild(a),o.appendChild(u),t.appendChild(n),t.appendChild(o),this._els={wrap:o,value:d,bars:u},this._mounted=!0,this._rebuildBars(),this._render()}start(){this.mount(),!this._running&&(this._running=!0,this._timer_gen+=1,this._poll_loop(this._timer_gen))}stop(){this._running=!1,this._timer_gen+=1,this._timer&&(clearTimeout(this._timer),this._timer=null),this._resumeTimer&&(clearTimeout(this._resumeTimer),this._resumeTimer=null),this._abort&&(this._abort.abort(),this._abort=null)}destroy(){this.stop(),this._target&&this._mounted&&(this._target.textContent=""),this._mounted=!1,this._els=null}setOptions(t){const n=Wp({...this._opts,...t||{}}),o=n.historySize!==this._opts.historySize,a=n.tickMs!==this._opts.tickMs,c=n.mode!==this._opts.mode;this._opts=n,c&&this._mounted&&this._els&&this._els.wrap&&(this._els.wrap.className=n.mode==="icon"?"wrap icon":"wrap"),o&&(this._buffer.setMaxSize(n.historySize),this._mounted&&this._rebuildBars()),a&&this._running?(this.stop(),this.start()):this._mounted&&this._render()}push(t){this._buffer.push(t),this._render()}_rebuildBars(){if(!this._els)return;const{bars:t}=this._els;t.textContent="";for(let n=0;n<this._opts.historySize;n+=1){const o=document.createElement("div");o.className="bar missing",o.style.height="2px",t.appendChild(o)}}_render({error:t=!1}={}){if(!this._els)return;const{wrap:n,value:o,bars:a}=this._els,c=this._buffer.values(),d=this._buffer.last(),u=Number.isFinite(d)?Math.max(0,Math.min(100,d)):null;u==null?(o.textContent=t?"N/A":"—",o.classList.add("muted")):(o.textContent=`${u.toFixed(0)}%`,o.classList.remove("muted")),n&&(n.title=u==null?"GPU —":`GPU ${u.toFixed(0)}%`,u==null?(n.style.removeProperty("--monitor-gpu-accent"),n.style.removeProperty("--monitor-gpu-accent-glow")):(n.style.setProperty("--monitor-gpu-accent",Mh(u,.95)),n.style.setProperty("--monitor-gpu-accent-glow",Mh(u,.35))));const m=Array.from(a.children),y=Math.max(0,m.length-c.length),g=Math.max(2,a&&typeof a.clientHeight=="number"&&a.clientHeight>0?a.clientHeight:34);for(let v=0;v<m.length;v+=1){const x=m[v],b=v-y,C=b>=0?c[b]:null,S=Number.isFinite(C)?C:null,L=S==null?0:tb(S/100),M=Math.max(2,Math.min(g,Math.round(L*g)));x.style.height=`${M}px`,x.style.background=S==null?"":Mh(S),x.className="bar",S==null&&x.classList.add("missing"),t&&x.classList.add("error")}}async _tick(){const t=String(this._token||"").trim(),n=this._getToken,o=!!t||typeof n=="function";this._abort&&this._abort.abort(),this._abort=new AbortController;const a=await eb({baseUrl:this._opts.baseUrl,endpoint:this._opts.endpoint,token:t,getToken:n,signal:this._abort.signal}),c=a&&a.payload,d=c&&typeof c=="object"?c.supported!==!1:!0,u=Q0(c);if(!a.ok){if(this._buffer.push(null),this._render({error:!0}),a.status===401||a.status===403){const m=String(this._token||"").trim(),y=typeof this._getToken=="function";if(!o&&(!!m||y))return;this._stoppedForAuth=!0,this.stop()}else a.status===429&&(this.stop(),this._resumeTimer=setTimeout(()=>{this._resumeTimer=null,this._mounted&&this.start()},3e4));return}if(!d||u==null){this._buffer.push(null),this._render();return}this._buffer.push(u),this._render()}async _poll_loop(t){!this._running||t!==this._timer_gen||(await this._tick(),!(!this._running||t!==this._timer_gen)&&(this._timer=setTimeout(()=>{this._timer=null,this._poll_loop(t)},this._opts.tickMs)))}}function sb(e="monitor-gpu"){if(typeof globalThis>"u"||typeof globalThis.customElements>"u"||globalThis.customElements.get(e))return;const t=globalThis.HTMLElement||class{};class n extends t{static get observedAttributes(){return["tick-ms","history-size","endpoint","base-url","mode"]}constructor(){super(),this._shadow=this.attachShadow?this.attachShadow({mode:"open"}):null;const a=this._shadow||this;this._controller=new rb(a,{}),this._upgradeProperty("token"),this._upgradeProperty("getToken"),this._upgradeProperty("mode")}_upgradeProperty(a){if(!Object.prototype.hasOwnProperty.call(this,a))return;const c=this[a];try{delete this[a]}catch{}this[a]=c}connectedCallback(){this._controller.setOptions(this._readAttrs());const a=()=>{this.isConnected&&this._controller.start()};typeof queueMicrotask=="function"?queueMicrotask(a):Promise.resolve().then(a)}disconnectedCallback(){this._controller.destroy()}attributeChangedCallback(){this._controller.setOptions(this._readAttrs())}_readAttrs(){const a=this.getAttribute("tick-ms"),c=this.getAttribute("history-size"),d=this.getAttribute("endpoint"),u=this.getAttribute("base-url"),m=this.getAttribute("mode");return{...a!=null?{tickMs:a}:{},...c!=null?{historySize:c}:{},...d!=null?{endpoint:d}:{},...u!=null?{baseUrl:u}:{},...m!=null?{mode:m}:{}}}set token(a){this._controller.token=a}get token(){return this._controller.token}set getToken(a){this._controller.getToken=a}get getToken(){return this._controller.getToken}set tickMs(a){this._controller.setOptions({tickMs:a})}get tickMs(){return this._controller.options.tickMs}set historySize(a){this._controller.setOptions({historySize:a})}get historySize(){return this._controller.options.historySize}set endpoint(a){this._controller.setOptions({endpoint:a})}get endpoint(){return this._controller.options.endpoint}set baseUrl(a){this._controller.setOptions({baseUrl:a})}get baseUrl(){return this._controller.options.baseUrl}set mode(a){this._controller.setOptions({mode:a})}get mode(){return this._controller.options.mode}}globalThis.customElements.define(e,n)}function Nt(){return new Date().toISOString()}function ib(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function jr(e,t){try{const n=JSON.stringify(e);return typeof n!="string"?String(e):n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}catch{const n=String(e);return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}}function _t(e,t){const n=typeof(t==null?void 0:t.max_chars)=="number"?t.max_chars:360,o=typeof(t==null?void 0:t.max_lines)=="number"?t.max_lines:2,c=String(e||"").replace(/\r\n/g,`
75
+ `).replace(/\r/g,`
76
+ `).split(`
77
+ `),d=c.slice(0,Math.max(1,o)).join(`
78
+ `),u=c.length>o,m=d.length>n?`${d.slice(0,Math.max(0,n-1))}…`:d;return u&&m===d?`${d}…`:m}function Mt(e,t){const n=String(e||"");return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}function Ah(e){const t=String(e||"").trim();return t&&t.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")||"untitled"}function Sn(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function ob(e){const t=Date.now()-e,n=Math.floor(t/1e3),o=Math.floor(n/60),a=Math.floor(o/60),c=Math.floor(a/24);return n<60?"just now":o<60?`${o}m ago`:a<24?`${a}h ago`:c<=3?`${c}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Zo(e){const t=Sn(e);return t===null?"—":ob(t)}function qp(e){if(!Number.isFinite(e))return"";const t=Math.floor(e/1e3);if(t<=0)return"now";const n=Math.floor(t/60),o=Math.floor(n/60),a=Math.floor(o/24),c=t%60,d=n%60,u=o%24;return a>0?`${a}d ${u}h`:o>0?`${o}h ${d}m`:n>0?`${n}m ${c}s`:`${t}s`}function H_(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"—";const t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60),a=o%60,c=Math.floor(o/60),d=c%24,u=Math.floor(c/24);return u>0?`${u}d ${d}h`:c>0?`${c}h ${a}m`:o>0?`${o}m ${n}s`:`${Math.max(0,t)}s`}function ea(e){const t=Sn(e);return t===null?"—":new Date(t).toLocaleString()}function on(...e){for(const t of e){const n=String(t??"").trim();if(n)return n}return""}function ab(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return null}function yi(e){const t=String(e||"").trim().toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}function Qc(e){const t=String(e||"").trim().toLowerCase();return t==="running"||t==="waiting"}function Dl(e){return String((e==null?void 0:e.started_at)||(e==null?void 0:e.created_at)||"").trim()}function Wy(e){const t=String((e==null?void 0:e.status)||"").trim();return yi(t)?String((e==null?void 0:e.finished_at)||(e==null?void 0:e.updated_at)||"").trim():""}function W_(e,t=Date.now()){const n=Sn(Dl(e));if(n===null)return-1;const o=Sn(Wy(e));return Math.max(0,(o!==null?o:t)-n)}function Gl(e,t=Date.now()){return H_(W_(e,t))}function ou(e){return String(e||"").trim().toLowerCase()}function Im(e){return`${(e==null?void 0:e.filename)||""} ${(e==null?void 0:e.source_path)||""}`.trim().toLowerCase()}function Td(e,t){return t.some(n=>e.endsWith(n))}function lb(e){const t=(e==null?void 0:e.tags)||{};return[e==null?void 0:e.content_type,e==null?void 0:e.filename,e==null?void 0:e.source_path,e==null?void 0:e.modality,t.kind,t.type,t.source,t.format,t.content_format,t.name].map(n=>String(n||"").trim()).filter(Boolean).join(" ").toLowerCase()}function cb(e){const t=(e==null?void 0:e.tags)||{};return[e==null?void 0:e.content_type,e==null?void 0:e.filename,e==null?void 0:e.source_path,e==null?void 0:e.modality,e==null?void 0:e.semantic_kind,e==null?void 0:e.render_kind,e==null?void 0:e.task,t.semantic_kind,t.render_kind,t.kind,t.type,t.task,t.provider_task,t.source,t.format,t.content_format,t.name].map(n=>String(n||"").trim()).filter(Boolean).join(" ").toLowerCase()}function ub(e){const t=String(e||"").trimStart().slice(0,4096).toLowerCase();return t?!!(/^<!doctype\s+html\b/.test(t)||/^<html[\s>]/.test(t)||/<head[\s>][\s\S]*<\/head>/.test(t)||/<body[\s>][\s\S]*<\/body>/.test(t)||/<(?:article|main|section|div|p|h[1-6]|meta|title|script|style)\b[\s\S]*>/.test(t)&&/<\/(?:article|main|section|div|p|h[1-6]|title|script|style)>/.test(t)):!1}function qy(e,t){var d,u,m,y,g;const n=ou(e==null?void 0:e.content_type),o=Im(e),a=[e==null?void 0:e.semantic_kind,e==null?void 0:e.render_kind,e==null?void 0:e.task,(d=e==null?void 0:e.tags)==null?void 0:d.semantic_kind,(u=e==null?void 0:e.tags)==null?void 0:u.render_kind,(m=e==null?void 0:e.tags)==null?void 0:m.task,(y=e==null?void 0:e.tags)==null?void 0:y.kind,(g=e==null?void 0:e.tags)==null?void 0:g.type].map(v=>String(v||"").trim().toLowerCase()).filter(Boolean).join(" ");if(/(^|[^a-z0-9])(code|source_code|script|program|executable)([^a-z0-9]|$)/i.test(a)||n.includes("javascript")||n.includes("typescript")||n.includes("x-python")||n.includes("x-shellscript")||n.includes("x-rust")||n.includes("x-go")||n.includes("x-java")||n.includes("x-csrc")||n.includes("x-c++src")||Td(o,[".py",".js",".jsx",".ts",".tsx",".mjs",".cjs",".sh",".bash",".zsh",".go",".rs",".java",".c",".cc",".cpp",".h",".hpp",".cs",".php",".rb",".swift",".kt",".sql"]))return!0;const c=String(t||"").replace(/\r\n/g,`
79
+ `).replace(/\r/g,`
80
+ `).split(`
81
+ `);return Vy(c)}function db(e){const n=String(e||"").replace(/\r\n/g,`
82
+ `).replace(/\r/g,`
83
+ `).split(`
84
+ `),o=n.findIndex(d=>/^Markdown Content:\s*$/i.test(d.trim()));if(o===-1)return null;const a=[];for(const d of n.slice(0,o)){const u=d.match(/^\s*([A-Za-z][A-Za-z0-9 /_-]{1,40}):\s*(.+?)\s*$/);u&&a.push({label:u[1].trim(),value:u[2].trim()})}const c=n.slice(o+1).join(`
85
+ `).trim();return!a.length&&!c?null:{metadata:a,body:c}}function fb(e){const t=e.map(n=>n.trim()).filter(Boolean).slice(0,8);if(t.length<2)return!1;for(const n of[","," ",";"]){const o=t.map(a=>a.split(n).length);if(o[0]>=3&&o.every(a=>Math.abs(a-o[0])<=1))return!0}return!1}function mb(e){const t=e.map(o=>o.trimEnd()).filter(Boolean).slice(0,20);if(!t.length)return!1;const n=t.filter(o=>/^(\[[^\]]+\]|\d{4}-\d{2}-\d{2}[t\s]|\w+:\s|traceback\b|error\b|warn\b|info\b)/i.test(o.trim())).length;return t.length>=4&&n/t.length>=.55?!0:Vy(e)}function Vy(e){const t=e.map(o=>o.trimEnd()).filter(Boolean).slice(0,20);if(!t.length)return!1;const n=t.filter(o=>/[{};]\s*$/.test(o)||/^\s*(import|export|const|let|var|function|class|def|if|for|while|return)\b/.test(o)).length;return t.length>=4&&n/t.length>=.55}function hb(e){const t=String(e||"");if(!t.trim())return!1;const n=t.match(/\\[A-Za-z]{2,}\b/g)||[];if(n.length>=1&&/\\(?:setcctype|sectctype|documentclass|begin|end|maketitle|geq|leq|cite|ref|label)\b/.test(t)||n.length>=4)return!0;const a=t.replace(/\r\n/g,`
86
+ `).replace(/\r/g,`
87
+ `).split(`
88
+ `).map(m=>m.trim()).filter(Boolean).slice(0,80);if(a.length<12)return!1;const c=a.filter(m=>m.length<=28).length,d=a.filter(m=>/^[,.;:()†]+$/.test(m)).length;return a.filter(m=>/^(abstract\.?|introduction|references|appendix|figure\s+\d+|table\s+\d+)\b/i.test(m)).length>=2&&(c/a.length>=.45||d>=2)}function _b(e,t){var y;const n=String(t||""),o=lb(e);if(/(^|[^a-z0-9])(markdown|mdown)([^a-z0-9]|$)/i.test(o))return!0;if(!n.trim())return!1;if(/(^|\n)\s*Markdown Content:\s*(\n|$)/i.test(n)||n.includes("```")||/(^|\n)\s*#{1,6}\s+\S/.test(n)||/(^|\n)[ \t]*[-*][ \t]+\S/.test(n)||/(^|\n)[ \t]*\d+[\.)][ \t]+\S/.test(n)||/\*\*[^*\n][\s\S]*?\*\*/.test(n)||/\[[^\]\n]+\]\([^)]+\)/.test(n)||/(^|\n)\s*\|.+\|\s*(\n|$)/.test(n)&&/(^|\n)\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*(\n|$)/.test(n))return!0;const a=n.replace(/\r\n/g,`
89
+ `).replace(/\r/g,`
90
+ `).split(`
91
+ `),c=a.map(g=>g.trim()).filter(Boolean);if(c.length<2||hb(n)||fb(a)||mb(a))return!1;const d=((y=n.match(/[A-Za-z][A-Za-z'-]+/g))==null?void 0:y.length)||0,u=a.filter(g=>!g.trim()).length,m=c.filter(g=>/[A-Za-z]{3,}/.test(g)&&g.length>=12).length;return d>=24&&m>=2&&(u>=1||c[0].length<=140)}function Ld(e){const t=ou(e==null?void 0:e.modality),n=ou(e==null?void 0:e.content_type),o=Im(e),a=cb(e);return t==="image"||n.startsWith("image/")||Td(o,[".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg",".tif",".tiff",".heic"])?"image":t==="audio"||t==="voice"||t==="music"||t==="sound"||n.startsWith("audio/")||/(tts|stt|voice|music|sound|speech|audio)/i.test(a)||Td(o,[".wav",".mp3",".m4a",".aac",".flac",".ogg",".opus",".aiff",".mid",".midi"])?"audio":t==="video"||n.startsWith("video/")||Td(o,[".mp4",".mov",".webm",".mkv",".avi",".m4v"])?"video":!n||t==="text"||n.startsWith("text/")||n.includes("json")||n.includes("yaml")||n.includes("toml")||n.includes("xml")||n.includes("html")||n.includes("markdown")||n.includes("csv")||qy(e,"")?"text":"binary"}function Rd(e,t){const n=ou(e==null?void 0:e.content_type),o=Im(e),a=String(t||"").trim();return n.includes("html")||o.endsWith(".html")||o.endsWith(".htm")||ub(t)?"html":qy(e,t)?"code":n.includes("markdown")||o.endsWith(".md")||o.endsWith(".markdown")?"markdown":n.includes("json")||o.endsWith(".json")||o.endsWith(".jsonl")||(a.startsWith("{")||a.startsWith("["))&&zm(a)!==null?"json":_b(e,t)?"markdown":"text"}function q_(e,t=""){const n=Ld(e);if(n==="image"||n==="video")return n;if(n==="audio"){const o=(e==null?void 0:e.tags)||{},a=[e==null?void 0:e.semantic_kind,e==null?void 0:e.modality,e==null?void 0:e.task,o.semantic_kind,o.modality,o.kind,o.task,o.source,e==null?void 0:e.filename,e==null?void 0:e.source_path].map(c=>String(c||"").trim().toLowerCase()).filter(Boolean).join(" ");return/(^|[^a-z0-9])(voice|tts|speech)([^a-z0-9]|$)/i.test(a)?"voice":/(^|[^a-z0-9])(music|song|instrumental|t2m)([^a-z0-9]|$)/i.test(a)?"music":/(^|[^a-z0-9])(sound|sfx|recording)([^a-z0-9]|$)/i.test(a)?"sound":"audio"}if(n==="binary"){const o=ou(e==null?void 0:e.modality),a=ou(e==null?void 0:e.content_type),c=Im(e);return o==="document"||a.includes("pdf")||Td(c,[".pdf",".doc",".docx",".ppt",".pptx",".xls",".xlsx"])?"document":"other"}return Rd(e,t)}function Th(e){var y,g;const t=String(e||"").replace(/\r\n/g,`
92
+ `).replace(/\r/g,`
93
+ `).trim();if(!t)return"";const n=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),o=t.match(/<!--[\s\S]*?-->|<!doctype\b[^>]*>|<!\[CDATA\[[\s\S]*?\]\]>|<\/?[A-Za-z][^>]*>|[^<]+/gi)||[t],a=[];let c=0,d="";const u=v=>" ".repeat(Math.max(0,v)),m=(v,x)=>{const b=v.match(/^(<\/?|<!)([^\s/>]+)([\s\S]*?)(\/?>)$/);if(!b||v.length<=120||v.startsWith("</")||v.startsWith("<!"))return[`${u(x)}${v.trim()}`];const C=(b[3]||"").trim();if(!C)return[`${u(x)}${v.trim()}`];const S=C.match(/[^\s="'<>`]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'<>`]+))?/g)||[C];return[`${u(x)}${b[1]}${b[2]}`,...S.map(L=>`${u(x+1)}${L.trim()}`),`${u(x)}${b[4]}`]};for(const v of o){const x=String(v||"");if(!x.trim())continue;const b=x.trim().toLowerCase();if(b.startsWith("</")){const S=((y=b.match(/^<\/\s*([a-z0-9:-]+)/))==null?void 0:y[1])||"";d&&S===d&&(d=""),c=Math.max(0,c-1),a.push(`${u(c)}${x.trim()}`);continue}if(x.trimStart().startsWith("<")){a.push(...m(x,c));const S=((g=b.match(/^<\s*([a-z0-9:-]+)/))==null?void 0:g[1])||"";/\/>\s*$/.test(x)||b.startsWith("<!")||n.has(S)||(c+=1,(S==="script"||S==="style")&&(d=S));continue}if(d){const S=x.trim();S&&a.push(...S.split(`
94
+ `).map(L=>`${u(c)}${L.trimEnd()}`));continue}const C=x.replace(/\s+/g," ").trim();C&&a.push(`${u(c)}${C}`)}return a.join(`
95
+ `)}function pb(e){var n;const t=((n=e==null?void 0:e.output)==null?void 0:n.stop_reason)??(e==null?void 0:e.stop_reason)??null;return t&&typeof t=="object"?t:null}function wm(e){const t=String((e==null?void 0:e.status)??"").trim().toLowerCase(),n=t==="completed"||t==="failed"||t==="cancelled";return e!=null&&e.paused&&!n?"paused":t==="completed"&&(e!=null&&e.stop_reason)&&e.stop_reason.finished===!1?"stopped":t||"unknown"}function Ka(e,t){const n=String(e??"").trim().toLowerCase();return n==="stopped"?"warn":n==="completed"?t&&t.finished===!1?"warn":"ok":n==="failed"||n==="cancelled"?"danger":n==="waiting"||n==="paused"||n==="suspended"?"warn":n==="running"||n==="scheduled"?"info":"muted"}const gb=/^\s*<runtime_metadata>\s*([\s\S]*?)\s*<\/runtime_metadata>\s*/i;function V_(e){const t=typeof e=="string"?e:String(e??""),n=gb.exec(t);if(!n)return{text:t.trim(),metadata:null,stripped:!1};let o=null;try{const a=JSON.parse(String(n[1]||"").trim());a&&typeof a=="object"&&!Array.isArray(a)&&(o=a)}catch{o=null}return{text:t.slice(n[0].length).trim(),metadata:o,stripped:!0}}function Gy(...e){const t={};for(const n of e)if(!(!n||typeof n!="object"||Array.isArray(n)))for(const[o,a]of Object.entries(n))a==null||String(a).trim()===""||(t[o]=a);return Object.keys(t).length?t:null}function __(e){if(e==null)return"";if(typeof e=="string")return e.trim();if(Array.isArray(e))return e.map(t=>__(t)).filter(Boolean).join(`
96
+ `).trim();if(typeof e=="object"){const t=e.text??e.content??e.message??e.value;if(t!==e){const n=__(t);if(n)return n}}return""}function Yy(e){const t=V_(__(e));return{text:t.text,runtime_metadata:t.metadata}}function yb(e){var o,a;if(!e)return{text:"",runtime_metadata:null};const t=typeof e.prompt=="string"?String(e.prompt).trim():"";if(t){const c=V_(t);return{text:c.text,runtime_metadata:c.metadata}}const n=[(o=e.context)==null?void 0:o.messages,e.messages,e.conversation,e.history].filter(Array.isArray);for(const c of n)for(let d=c.length-1;d>=0;d-=1){const u=c[d],m=String((u==null?void 0:u.role)||(u==null?void 0:u.speaker)||"").trim().toLowerCase();if(m&&m!=="user"&&m!=="human")continue;const y=Yy((u==null?void 0:u.content)??(u==null?void 0:u.text)??u);if(y.text)return{text:y.text,runtime_metadata:Gy(y.runtime_metadata,u!=null&&u.runtime_metadata&&typeof u.runtime_metadata=="object"?u.runtime_metadata:null,(a=u==null?void 0:u.metadata)!=null&&a.runtime_metadata&&typeof u.metadata.runtime_metadata=="object"?u.metadata.runtime_metadata:null)}}return{text:"",runtime_metadata:null}}function vb(e,t=6){var c,d;if(!e)return[];const o=[(c=e.context)==null?void 0:c.messages,e.messages,e.conversation,e.history].filter(Array.isArray).find(u=>u.length)||[],a=[];for(const u of o){const m=String((u==null?void 0:u.role)||(u==null?void 0:u.speaker)||(u==null?void 0:u.author)||"").trim().toLowerCase()||"message",y=Yy((u==null?void 0:u.content)??(u==null?void 0:u.text)??(u==null?void 0:u.message)??u),g=y.text;if(!g)continue;const v=String((u==null?void 0:u.ts)||(u==null?void 0:u.timestamp)||(u==null?void 0:u.created_at)||(u==null?void 0:u.time)||"").trim(),x=Gy(y.runtime_metadata,u!=null&&u.runtime_metadata&&typeof u.runtime_metadata=="object"?u.runtime_metadata:null,(d=u==null?void 0:u.metadata)!=null&&d.runtime_metadata&&typeof u.metadata.runtime_metadata=="object"?u.metadata.runtime_metadata:null);a.push({role:m,text:g,ts:v,runtime_metadata:x})}return a.slice(Math.max(0,a.length-Math.max(1,t)))}function Ky(e){const t=String(e||"").trim().toLowerCase().replace(/\s+/g," ");return t==="please respond:"||t==="please respond"||t==="type response..."||t==="type response"}function xb(e){const t=e.map(n=>String((n==null?void 0:n.name)||"tool").trim()).filter(Boolean);return t.length?`${t.slice(0,3).join(", ")}${t.length>3?` +${t.length-3}`:""}`:""}const Xy="inferred from the call's arguments (regex heuristic) — not a declared risk tier; declared tiers replace this when the grant API ships";function Jy(e){const t=String((e==null?void 0:e.name)||"").trim().toLowerCase(),n=e!=null&&e.arguments&&typeof e.arguments=="object"?e.arguments:{},o=String((n==null?void 0:n.command)||(n==null?void 0:n.cmd)||(n==null?void 0:n.shell)||"").trim().toLowerCase(),a=[];return(t.includes("execute_command")||t.includes("terminal")||o)&&a.push("Shell"),/[;&|]?\s*(rm|rmdir|mv|chmod|chown|sudo)\b/.test(o)&&a.push("Destructive risk"),/(^|\s)(curl|wget|scp|ssh|nc|ncat|ftp)\b/.test(o)&&a.push("Network"),/(^|\s)(cat|sed|rg|grep|ls|find|pwd)\b/.test(o)&&!/[>|]\s*\S/.test(o)&&a.push("Read path"),/[>|]\s*\S|(^|\s)(tee|touch|mkdir|cp)\b/.test(o)&&a.push("Filesystem write"),a.length||a.push("Tool call"),Array.from(new Set(a)).slice(0,4)}function G_(e,t){const n=String((e==null?void 0:e.reason)||"").trim().toLowerCase(),o=xb(t);return t.length?`Approval required: ${o||"tool call"}`:n==="user"?"Waiting for your answer":n==="event"?"Waiting for a user response event":n==="subworkflow"?"Waiting for a subworkflow":n==="until"?"Scheduled wait":n?`Waiting: ${n}`:"Waiting for input"}function Zy(e,t){return t.length?"Review the requested tool call, then approve and execute it, approve without local execution, reject it, or cancel the whole run.":(Array.isArray(e==null?void 0:e.choices)?(e==null?void 0:e.choices)||[]:[]).length?"Select one of the allowed responses, then submit it to resume this run.":(e==null?void 0:e.allow_free_text)===!1?"This wait does not allow free text. Use the available response control or inspect the ledger.":String((e==null?void 0:e.prompt)||"").trim()?"Answer the workflow question below. Submitting resumes only this wait.":"No explicit question was emitted. Inspect the original request and recent ledger context before responding."}function Qy(e,t){const n=String((e==null?void 0:e.prompt)||"").trim(),o=V_(n),a=yb(t);return o.text&&!Ky(o.text)?{text:o.text,runtime_metadata:o.metadata}:a.text?a:{text:o.text||n,runtime_metadata:o.metadata}}function wb(e,t){return Qy(e,t).text}function bb(e,t){return e||String(t||"").trim()||{}}function qs(e,t){const n=String((e==null?void 0:e.schedule_target_workflow_id)||(e==null?void 0:e.workflow_id)||"").trim();return n?t[n]||n:"(workflow unknown)"}function Xa(e){const t=String(e.status||"unknown").trim()||"unknown";return s.jsx("span",{className:`run_status_pill ${Ka(t)}`,children:t})}function Sb(e){var c;const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(yi(t))return"";const n=e!=null&&e.waiting&&typeof e.waiting=="object"?e.waiting:null,o=String((n==null?void 0:n.reason)||(e==null?void 0:e.waiting_reason)||"").trim().toLowerCase(),a=Array.isArray((c=n==null?void 0:n.details)==null?void 0:c.tool_calls)?n.details.tool_calls:[];return a.length?G_(n,a):o==="user"?"Waiting for your answer":o==="event"?"Waiting for a response event":o==="subworkflow"?"Waiting for subworkflow":o==="until"?"Scheduled wait":o?`Waiting: ${o}`:t==="waiting"?"Waiting, reason unknown":""}function bm(e){const t=e==null?void 0:e.error;return t?typeof t=="string"?_t(t,{max_chars:220,max_lines:2}):_t(jr(t,400),{max_chars:220,max_lines:2}):""}function jb(e){const t=Sb(e);if(t)return t;const n=bm(e);if(n)return n;const o=String((e==null?void 0:e.current_node)||"").trim();if(o)return`Current node: ${o}`;const a=String((e==null?void 0:e.status)||"").trim().toLowerCase();return a==="running"?"Running":yi(a)?"Terminal":"No current activity reported"}function ev(e){return e!=null&&e.ref&&typeof e.ref=="object"?e.ref:e!=null&&e.artifact_ref&&typeof e.artifact_ref=="object"?e.artifact_ref:e!=null&&e.artifact&&typeof e.artifact=="object"?e.artifact:{}}function Vp(e){const t=ev(e),n=e!=null&&e.metadata&&typeof e.metadata=="object"?e.metadata:e!=null&&e.meta&&typeof e.meta=="object"?e.meta:{},o=e!=null&&e.tags&&typeof e.tags=="object"?e.tags:{},a=on(e==null?void 0:e.modality,t==null?void 0:t.modality,n==null?void 0:n.modality,o.modality).toLowerCase();if(a)return a;const c=on(e==null?void 0:e.content_type,e==null?void 0:e.mime_type,e==null?void 0:e.mime,t==null?void 0:t.content_type,t==null?void 0:t.mime_type,t==null?void 0:t.mime,n==null?void 0:n.content_type,o.content_type).toLowerCase();return c.startsWith("image/")?"image":c.startsWith("audio/")?"audio":c.startsWith("video/")?"video":c.includes("pdf")?"document":c.startsWith("text/")||c.includes("json")||c.includes("markdown")||c.includes("csv")?"text":"artifact"}function kb(e){return!e||typeof e!="object"?{}:e.artifact_envelope_v1&&typeof e.artifact_envelope_v1=="object"?e.artifact_envelope_v1:e.envelope&&typeof e.envelope=="object"?e.envelope:e}function Nb(e,t){if(!e||typeof e!="object")return null;const n=kb(e),o=ev(e),a=e!=null&&e.metadata&&typeof e.metadata=="object"?e.metadata:e!=null&&e.meta&&typeof e.meta=="object"?e.meta:{},c=n!=null&&n.descriptor&&typeof n.descriptor=="object"?n.descriptor:e!=null&&e.descriptor&&typeof e.descriptor=="object"?e.descriptor:{},d=on(n.artifact_id,e.artifact_id,e.$artifact,e.id,o.artifact_id,o.$artifact,o.id,a.artifact_id,a.$artifact);if(!d)return null;const u={...o.tags&&typeof o.tags=="object"?o.tags:{},...a.tags&&typeof a.tags=="object"?a.tags:{},...n.tags&&typeof n.tags=="object"?n.tags:{},...e.tags&&typeof e.tags=="object"?e.tags:{}},m={};for(const[z,Y]of Object.entries(u)){const Q=String(z||"").trim();Q&&(m[Q]=String(Y??""))}const y=on(n.filename,e.filename,o.filename,a.filename,m.filename,m.name,e.name,o.name),g=on(n.source_path,e.source_path,o.source_path,a.source_path,e.path,o.path,m.path,m.source_path,m.file_path),v=on(n.content_type,e.content_type,e.mime_type,e.mime,o.content_type,o.mime_type,o.mime,a.content_type,m.content_type),x=on(n.render_kind,c.render_kind,e.render_kind,m.render_kind),b=on(n.semantic_kind,c.semantic_kind,e.semantic_kind,m.semantic_kind,m.artifact_type),C=n.access&&typeof n.access=="object"?n.access:e.access&&typeof e.access=="object"?e.access:{},S=n.producer&&typeof n.producer=="object"?n.producer:e.producer&&typeof e.producer=="object"?e.producer:c.producer&&typeof c.producer=="object"?c.producer:{},L=n.provenance&&typeof n.provenance=="object"?n.provenance:e.provenance&&typeof e.provenance=="object"?e.provenance:c.provenance&&typeof c.provenance=="object"?c.provenance:{},M=n.generation&&typeof n.generation=="object"?n.generation:e.generation&&typeof e.generation=="object"?e.generation:c.generation&&typeof c.generation=="object"?c.generation:{},W=n.media&&typeof n.media=="object"?n.media:e.media&&typeof e.media=="object"?e.media:c.media&&typeof c.media=="object"?c.media:{},q=n.links&&typeof n.links=="object"?n.links:e.links&&typeof e.links=="object"?e.links:c.links&&typeof c.links=="object"?c.links:{};return{artifact_id:d,run_id:on(n.run_id,e.run_id,o.run_id,a.run_id,m.run_id,L.run_id),content_type:v,modality:on(n.modality,e.modality,c.modality,m.modality)||Vp({...e,ref:o,metadata:a,tags:m}),semantic_kind:b||Vp({...e,ref:o,metadata:a,tags:m}),render_kind:x||q_({content_type:v,filename:y,source_path:g,modality:on(n.modality,e.modality,m.modality),tags:m}),task:on(n.task,c.task,e.task,m.task,m.provider_task),classification_source:on(n.classification_source,c.classification_source,e.classification_source),session_id:on(n.session_id,c.session_id,e.session_id,m.session_id),workflow_id:on(n.workflow_id,c.workflow_id,e.workflow_id,m.workflow_id,m.workflow),node_id:on(n.node_id,c.node_id,e.node_id,m.node_id,m.node),step_id:on(n.step_id,c.step_id,e.step_id,m.step_id),effect_id:on(n.effect_id,c.effect_id,e.effect_id,m.effect_id,m.effect_idempotency_key),turn_id:on(n.turn_id,c.turn_id,e.turn_id,m.turn_id,m.turn),ledger_cursor:on(n.ledger_cursor,c.ledger_cursor,e.ledger_cursor,m.ledger_cursor,m.step_cursor),parent_run_id:on(n.parent_run_id,c.parent_run_id,e.parent_run_id,m.parent_run_id),actor_id:on(n.actor_id,c.actor_id,e.actor_id,m.actor_id),title:on(n.title,e.title,m.title,m.label,m.name),created_at:on(n.created_at,e.created_at,o.created_at,a.created_at,m.created_at),size_bytes:ab(n.size_bytes,e.size_bytes,o.size_bytes,a.size_bytes,m.size_bytes),filename:y,source_path:g,sha256:on(n.sha256,e.sha256,o.sha256,a.sha256,m.sha256),tags:m,producer:S,provenance:L,generation:M,media:W,source_refs:Array.isArray(n.source_refs)?n.source_refs:Array.isArray(e.source_refs)?e.source_refs:[],access:C,links:q,available_actions:Array.isArray(n.available_actions)?n.available_actions.map(String):Array.isArray(e.available_actions)?e.available_actions.map(String):[],provider_trace_available:!!(n.provider_trace_available??e.provider_trace_available),audit_available:!!(n.audit_available??e.audit_available),legacy_inferred:!!((n.legacy_inferred??e.legacy_inferred)||/(?:legacy|inferred|runtime_tags|runtime_mime)/i.test(on(n.classification_source,c.classification_source,e.classification_source))),descriptor:c,source:t,raw:e}}function p_(e){return e.filename||e.title||(e.source_path?e.source_path.split("/").filter(Boolean).slice(-1)[0]:"")||Mt(e.artifact_id,16)}function Cb(e,t){if(t==="type")return tu(e);if(t==="run")return e.run_id||"(no run)";if(t==="turn")return g_(e);if(t==="node")return eu(e)||"(node unknown)";if(t==="workflow")return Y_(e)||"(workflow unknown)";if(t==="location"){const a=(e.source_path||e.filename||"").split("/").filter(Boolean);return a.length>1?a.slice(0,-1).join("/"):"(root)"}if(t==="source")return Pd(e)||e.source||"artifact";const n=Sn(e.created_at);return n===null?"(unknown time)":new Date(n).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Y_(e){const t=(e==null?void 0:e.tags)||{};return String((e==null?void 0:e.workflow_id)||t.workflow_id||t.workflow||"").trim()}function eu(e){const t=(e==null?void 0:e.tags)||{},n=String((e==null?void 0:e.node_id)||t.node_id||t.node||(e==null?void 0:e.step_id)||t.step_id||"").trim();if(n)return n;const a=String((e==null?void 0:e.source_path)||t.path||"").trim().match(/(?:^|[._:/-])(node-[A-Za-z0-9_-]+)/);return a!=null&&a[1]?String(a[1]):""}function g_(e){const t=(e==null?void 0:e.tags)||{},n=String((e==null?void 0:e.turn_id)||t.turn_id||t.turn||t.cycle||(e==null?void 0:e.ledger_cursor)||t.ledger_cursor||t.step_cursor||"").trim();if(n)return`turn ${n}`;const o=eu(e),a=Sn(e==null?void 0:e.created_at),c=a===null?"unknown time":new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),d=e!=null&&e.run_id?Mt(String(e.run_id),10):"unknown run";return o?`${d} · ${o} · ${c}`:`${d} · ${c}`}function Gp(e){if(!e)return"provenance unavailable";const t=[],n=Y_(e),o=eu(e),a=Pd(e),c=tv(e);return n&&t.push(n),o&&t.push(o),a&&t.push(a),c&&t.push(c),t.length?t.join(" · "):"provenance unavailable"}function Fl(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"—";const t=["B","KB","MB","GB","TB"];let n=e,o=0;for(;n>=1024&&o<t.length-1;)n/=1024,o+=1;const a=o===0?0:n>=10?1:2;return`${n.toFixed(a)} ${t[o]}`}function tu(e){const t=String((e==null?void 0:e.semantic_kind)||(e==null?void 0:e.modality)||"").trim().toLowerCase(),n=String((e==null?void 0:e.render_kind)||"").trim().toLowerCase(),o=t||n||"artifact";return{voice:"Voice",music:"Music",sound:"Sound",recording:"Recording",audio:"Unclassified audio",image:"Image",video:"Video",markdown:"Markdown",html:"HTML",json:"JSON",document:"Document",code:"Code",text:"Text",binary:"Other",artifact:"Other"}[o]||o.replace(/[_-]+/g," ").replace(/\b\w/g,c=>c.toUpperCase())}function Eb(e){return e==="html"?"HTML":e==="json"?"JSON":e==="audio"?"Unclassified audio":e==="code"?"Code":e.slice(0,1).toUpperCase()+e.slice(1)}function $b(e){const t=Date.now();if(e==="hour")return new Date(t-3600*1e3).toISOString();if(e==="week")return new Date(t-10080*60*1e3).toISOString();if(e==="month")return new Date(t-720*60*60*1e3).toISOString();if(e==="today"){const n=new Date(t);return new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString()}return""}function Mb(e){return e==="oldest"?{order_by:"created_at",order:"asc"}:e==="size_desc"?{order_by:"size_bytes",order:"desc"}:e==="size_asc"?{order_by:"size_bytes",order:"asc"}:e==="last_access"?{order_by:"last_accessed_at",order:"desc"}:e==="turn"?{order_by:"turn",order:"asc"}:e==="type"?{order_by:"semantic_kind",order:"asc"}:{order_by:"created_at",order:"desc"}}function Yp(e){const t=e!=null&&e.stats&&typeof e.stats=="object"?e.stats:{},n=t!=null&&t.facets&&typeof t.facets=="object"?t.facets:e!=null&&e.facets&&typeof e.facets=="object"?e.facets:{};return n&&typeof n=="object"?n:{}}function Ab(e){const t=ea(e.created_at),n=Zo(e.created_at);return t==="—"?"Created —":`${t}${n&&n!=="—"?` (${n})`:""}`}function Kp(e){var a;const t=e.tags||{},n=String(((a=e.access)==null?void 0:a.last_accessed_at)||t.last_accessed_at||t.accessed_at||t.updated_at||e.created_at||"").trim(),o=ea(n);return o==="—"?"—":o}function Xp(e){const t=e.tags||{},n=String(e.title||t.title||t.name||t.label||e.filename||"").trim();if(n)return n;const o=String(e.source_path||t.path||"").trim();if(o)return o.split("/").filter(Boolean).slice(-1)[0]||o;const a=Pd(e),c=tu(e);return a?`${c} ${a}`:`${c} artifact`}function Pd(e){var n;const t=e.tags||{};return String(e.task||((n=e.provenance)==null?void 0:n.source)||t.task||t.kind||t.source||e.source||"").trim()}function tv(e){var o,a,c,d,u,m,y,g;if(!e)return"";const t=on((o=e.producer)==null?void 0:o.provider,(a=e.producer)==null?void 0:a.provider_id,(c=e.provenance)==null?void 0:c.provider,(d=e.generation)==null?void 0:d.provider),n=on((u=e.producer)==null?void 0:u.model,(m=e.producer)==null?void 0:m.model_id,(y=e.provenance)==null?void 0:y.model,(g=e.generation)==null?void 0:g.model);return t&&n?`${t} / ${n}`:t||n}function Tb(e){var t,n,o,a;return e?on((t=e.generation)==null?void 0:t.prompt,(n=e.generation)==null?void 0:n.input,(o=e.generation)==null?void 0:o.text,(a=e.provenance)==null?void 0:a.prompt):""}function Jp(e){if(!e)return"";const t=e.media||{},n=Number(t.duration_s??t.duration_seconds??t.duration),o=Number(t.width??t.image_width??t.video_width),a=Number(t.height??t.image_height??t.video_height),c=Number(t.sample_rate??t.sample_rate_hz),d=Number(t.channels);if(Number.isFinite(n)&&n>0){const m=[`${n>=60?`${Math.floor(n/60)}m ${Math.round(n%60)}s`:`${n.toFixed(n>=10?1:2)}s`}`];return Number.isFinite(c)&&c>0&&m.push(`${Math.round(c/1e3)} kHz`),Number.isFinite(d)&&d>0&&m.push(`${d} ch`),m.join(" · ")}if(Number.isFinite(o)&&Number.isFinite(a)&&o>0&&a>0)return`${Math.round(o)} x ${Math.round(a)}`;const u=Number(t.page_count??t.pages);return Number.isFinite(u)&&u>0?`${Math.round(u)} pages`:""}function Zp(e){return e.source_path||e.filename||""}function Sm(e,t,n){const o=e.run_id&&t[e.run_id]||null;if(!o)return e;const a=qs(o,n),c={...e.tags||{}};return a&&!c.workflow&&(c.workflow=a),a&&!c.workflow_id&&(c.workflow_id=a),{...e,workflow_id:e.workflow_id||a,tags:c}}function y_(e,t,n,o=""){const a=Sm(e,t,n),c=q_(a,o);return{json:"JSON",html:"HTML",markdown:"Markdown",code:"Code",voice:"Voice",music:"Music",sound:"Sound",audio:"Unclassified audio",image:"Image",video:"Video",document:"Document",text:"Text",other:"Other"}[c]||tu(a)}function Vi(e){var o;const t=e,n=(o=t==null?void 0:t.result)==null?void 0:o.wait;return!n||typeof n!="object"?null:n}function Kf(e){var c,d,u;const t=e,n=t==null?void 0:t.effect;if(!n||typeof n!="object"||String(n.type||"")!=="emit_event")return null;const o=String(((c=n==null?void 0:n.payload)==null?void 0:c.name)||((d=n==null?void 0:n.payload)==null?void 0:d.event_name)||"").trim();if(!o)return null;const a=(u=n==null?void 0:n.payload)==null?void 0:u.payload;return{name:o,payload:a}}function uu(e){const t=e,n=t==null?void 0:t.details;if(!n||typeof n!="object")return[];const o=n==null?void 0:n.tool_calls;return Array.isArray(o)?o:[]}function Lb(e){var a,c;const t=String((e==null?void 0:e.status)||"").trim(),n=String(((a=e==null?void 0:e.effect)==null?void 0:a.type)||"").trim(),o=(c=e==null?void 0:e.effect)!=null&&c.payload&&typeof e.effect.payload=="object"?String(e.effect.payload.name||"").trim():"";return n==="emit_event"&&o?o:n||t||"record"}function nv(e){if(!e||typeof e!="object")return"Ledger record";const t=String(e.node_id||"").trim(),n=String(e.status||"").trim(),o=Lb(e),a=Vi(e);if(a){const c=String(a.reason||"").trim();if(String(a.prompt||"").trim())return`${t||"node"} is waiting for a response`;if(c)return`${t||"node"} is waiting (${c})`}return e.error?`${t||"node"} failed`:n==="completed"?`${t||"node"} completed ${o}`:n==="running"?`${t||"node"} started ${o}`:n==="waiting"?`${t||"node"} is waiting`:[t,n,o].filter(Boolean).join(" · ")||"Ledger record"}function Hc(e){if(typeof e=="string")return{text:e,duration:-1};if(e&&typeof e=="object"){const t=typeof e.text=="string"?String(e.text):typeof e.value=="string"?String(e.value):typeof e.message=="string"?String(e.message):jr(e,320),n=typeof e.duration=="number"?Number(e.duration):-1;return{text:t,duration:n}}return{text:jr(e,320),duration:-1}}function Yd(e){var d,u,m,y,g,v,x,b,C;if(!e||typeof e!="object")return"";const t=String(((d=e==null?void 0:e.effect)==null?void 0:d.type)||"").trim(),n=e==null?void 0:e.result,o=S=>typeof S=="string"?S.trim():S==null?"":typeof S=="number"||typeof S=="boolean"?String(S):"",a=S=>{if(!S||typeof S!="object")return"";const L=S,M=[L.response,L.answer,L.message,L.text,L.content];for(const W of M){const q=o(W);if(q)return q}return""};if(t==="answer_user"){const S=o(n==null?void 0:n.message)||o((u=n==null?void 0:n.output)==null?void 0:u.message)||o((m=n==null?void 0:n.output)==null?void 0:m.response)||o((g=(y=e==null?void 0:e.effect)==null?void 0:y.payload)==null?void 0:g.message)||o((x=(v=e==null?void 0:e.effect)==null?void 0:v.payload)==null?void 0:x.text)||o((C=(b=e==null?void 0:e.effect)==null?void 0:b.payload)==null?void 0:C.content);if(S)return S}if(t==="llm_call"){const S=a(n)||o(n==null?void 0:n.output)||a(n==null?void 0:n.output)||o(n==null?void 0:n.response);if(S)return S}return o(n==null?void 0:n.output)||a(n==null?void 0:n.output)||a(n)||o(n==null?void 0:n.response)}function fm(e){var a;const t=String((e==null?void 0:e.node_id)||""),n=String((e==null?void 0:e.status)||""),o=String(((a=e==null?void 0:e.effect)==null?void 0:a.type)||"");return`${t||"(node?)"} • ${n||"(status?)"} • ${o||"(effect?)"}`}function Rb(e){return!!(e&&String(e.status||"")==="waiting")}function rv(e){var n,o;const t=[];for(const a of e||[]){const c=a.record;if(String(((n=c==null?void 0:c.effect)==null?void 0:n.type)||"").trim()!=="llm_call")continue;const u=(o=c==null?void 0:c.effect)!=null&&o.payload&&typeof c.effect.payload=="object"?c.effect.payload:{},m=c!=null&&c.result&&typeof c.result=="object"?c.result:{},y=(m==null?void 0:m.usage)||(m==null?void 0:m.token_usage)||{},g=typeof u.prompt=="string"?u.prompt:Array.isArray(u.messages)?jr(u.messages,1800):"",v=typeof m.content=="string"?m.content:typeof m.response=="string"?m.response:typeof c.result=="string"?String(c.result):"",x=Sn(c.started_at),b=Sn(c.ended_at),C=Number(y.prompt_tokens??y.input_tokens??0)||0,S=Number(y.completion_tokens??y.output_tokens??0)||0;t.push({id:`${String(a.run_id||c.run_id||"")}:${a.cursor}`,cursor:Number(a.cursor||0),ts:String(c.ended_at||c.started_at||""),run_id:String(a.run_id||c.run_id||"").trim(),node_id:String(c.node_id||"").trim(),provider:String(u.provider||m.provider||m.runtime_provider||"").trim(),model:String(u.model||m.model||m.runtime_model||"").trim(),prompt_preview:_t(g,{max_chars:1200,max_lines:10}),response_preview:_t(v,{max_chars:1200,max_lines:10}),missing_response:!String(v||"").trim(),tokens:{prompt:C,completion:S,total:Number(y.total_tokens??C+S)||0},duration_ms:x!==null&&b!==null?Math.max(0,b-x):typeof m.gen_time=="number"?Number(m.gen_time)*1e3:null,status:String(c.status||"").trim(),error:c.error?jr(c.error,500):"",raw:c})}return t.sort((a,c)=>(Sn(c.ts)??0)-(Sn(a.ts)??0))}function Qp(e){const t=e.size||18,n=Ld(e.artifact),o=q_(e.artifact,""),a=`artifact_glyph ${o==="code"?"code":n}`,c={width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"};return n==="image"?s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M7 15l3-3 3 3 2-2 4 4"}),s.jsx("circle",{cx:"8",cy:"9",r:"1.4"})]})}):n==="audio"?s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("path",{d:"M4 12h2"}),s.jsx("path",{d:"M8 8v8"}),s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M16 8v8"}),s.jsx("path",{d:"M20 12h-2"})]})}):n==="video"?s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M9 9l6 3-6 3V9z",fill:"currentColor",stroke:"none"})]})}):o==="code"?s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("path",{d:"M8 8l-4 4 4 4"}),s.jsx("path",{d:"M16 8l4 4-4 4"}),s.jsx("path",{d:"M14 4l-4 16"})]})}):n==="text"?s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("path",{d:"M7 3h7l5 5v13H7z"}),s.jsx("path",{d:"M14 3v6h6"}),s.jsx("path",{d:"M10 13h7"}),s.jsx("path",{d:"M10 17h5"})]})}):s.jsx("span",{className:a,children:s.jsxs("svg",{...c,children:[s.jsx("path",{d:"M7 3h7l5 5v13H7z"}),s.jsx("path",{d:"M14 3v6h6"}),s.jsx("path",{d:"M9 14h8"})]})})}const Pb=2,Ob=Number.MAX_SAFE_INTEGER;function zb(e,t=120){const n=String(e||"").replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function Ib(e){const t=String(e||"");if(typeof DOMParser>"u")return[{kind:"text",text:Th(t)||t}];try{const n=new DOMParser().parseFromString(t,"text/html"),o=[];n.doctype&&o.push({kind:"doctype",name:n.doctype.name||"html"});const a=c=>{if(c.nodeType===Node.TEXT_NODE){const d=String(c.textContent||"").trim();return d?{kind:"text",text:d}:null}if(c.nodeType===Node.COMMENT_NODE)return{kind:"comment",text:String(c.textContent||"")};if(c.nodeType===Node.ELEMENT_NODE){const d=c,u=Array.from(d.attributes||[]).map(y=>({name:y.name,value:y.value})),m=Array.from(d.childNodes||[]).map(a).filter(Boolean);return{kind:"element",tag:d.tagName.toLowerCase(),attrs:u,children:m}}return null};if(n.documentElement){const c=a(n.documentElement);c&&o.push(c)}return o.length?o:[{kind:"text",text:Th(t)||t}]}catch{return[{kind:"text",text:Th(t)||t}]}}function Lh(e){return e.closing?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"runtime_html_punct",children:"</"}),s.jsx("span",{className:"runtime_html_tag",children:e.tag}),s.jsx("span",{className:"runtime_html_punct",children:">"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"runtime_html_punct",children:"<"}),s.jsx("span",{className:"runtime_html_tag",children:e.tag}),e.attrs.map(t=>s.jsxs(ye.Fragment,{children:[" ",s.jsx("span",{className:"runtime_html_attr",children:t.name}),s.jsx("span",{className:"runtime_html_punct",children:"="}),s.jsxs("span",{className:"runtime_html_value",children:['"',t.value,'"']})]},`${e.tag}:${t.name}:${t.value}`)),s.jsx("span",{className:"runtime_html_punct",children:e.selfClosing?" />":">"})]})}function sv(e){const t=e.node,n=e.depth*14,o=e.depth<e.collapseAfterDepth,[a,c]=h.useState(o);if(h.useEffect(()=>{c(o)},[o,e.expansionVersion]),t.kind==="doctype")return s.jsxs("div",{className:"html-tree__line",style:{paddingLeft:n},children:[s.jsx("span",{className:"runtime_html_punct",children:"<!DOCTYPE "}),s.jsx("span",{className:"runtime_html_tag",children:t.name}),s.jsx("span",{className:"runtime_html_punct",children:">"})]});if(t.kind==="comment")return s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx("span",{className:"runtime_html_comment",children:`<!-- ${t.text.trim()} -->`})});if(t.kind==="text")return s.jsx("div",{className:"html-tree__line html-tree__text",style:{paddingLeft:n},children:t.text});if(!t.children.length)return s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx(Lh,{tag:t.tag,attrs:t.attrs,selfClosing:!0})});const d=t.children.find(u=>u.kind==="text");return s.jsxs("details",{className:"html-tree__details",open:a,onToggle:u=>c(u.currentTarget.open),children:[s.jsxs("summary",{className:"html-tree__summary",style:{paddingLeft:n},children:[s.jsx("span",{className:"html-tree__caret","aria-hidden":"true",children:a?"▾":"▸"}),s.jsx(Lh,{tag:t.tag,attrs:t.attrs}),!a&&d?s.jsxs("span",{className:"html-tree__summary_text",children:[" ",zb(d.text)]}):null]}),a?s.jsxs("div",{className:"html-tree__children",children:[t.children.map((u,m)=>s.jsx(sv,{node:u,depth:e.depth+1,collapseAfterDepth:e.collapseAfterDepth,expansionMode:e.expansionMode,expansionVersion:e.expansionVersion},`${e.depth}:${t.kind}:${t.tag}:${m}`)),s.jsx("div",{className:"html-tree__line",style:{paddingLeft:n},children:s.jsx(Lh,{tag:t.tag,attrs:[],closing:!0})})]}):null]})}function Db(e){const t=h.useMemo(()=>Ib(e.text),[e.text]),[n,o]=h.useState({mode:"folded",version:0}),a=n.mode==="unfolded"?Ob:Pb;h.useEffect(()=>{o(d=>({mode:"folded",version:d.version+1}))},[e.text]);const c=()=>{o(d=>({mode:d.mode==="unfolded"?"folded":"unfolded",version:d.version+1}))};return s.jsxs("div",{className:`${e.className} structured html_source_preview`,children:[s.jsx("div",{className:"html-tree__toolbar",children:s.jsx("button",{type:"button",className:"btn html-tree__toggle",onClick:c,"aria-expanded":n.mode==="unfolded",children:n.mode==="unfolded"?"Fold all":"Unfold all"})}),s.jsx("div",{className:"html-tree__tree",role:"tree","aria-label":"HTML source tree",children:t.map((d,u)=>s.jsx(sv,{node:d,depth:0,collapseAfterDepth:a,expansionMode:n.mode,expansionVersion:n.version},`root:${u}`))})]})}function Fb(e){var o;const t=db(e.text);if(!t)return s.jsx("div",{className:`${e.className} structured markdown_preview`,children:s.jsx(gi,{text:e.text})});const n=((o=t.metadata.find(a=>a.label.toLowerCase()==="title"))==null?void 0:o.value)||"";return s.jsxs("div",{className:`${e.className} structured markdown_preview artifact_markdown_report`,children:[n?s.jsx("h1",{className:"artifact_markdown_title",children:n}):null,t.metadata.length?s.jsx("dl",{className:"artifact_markdown_meta",children:t.metadata.map(a=>{const c=/^https?:\/\//i.test(a.value);return s.jsxs("div",{children:[s.jsx("dt",{children:a.label}),s.jsx("dd",{children:c?s.jsx("a",{href:a.value,target:"_blank",rel:"noreferrer",children:a.value}):a.value})]},`${a.label}:${a.value}`)})}):null,s.jsx(gi,{text:t.body||e.text})]})}function iv(e){const t=String(e.text||""),n=Rd(e.artifact,t);if(n==="json"){const o=zm(t);if(o!==null)return s.jsx("div",{className:`${e.className} structured`,children:s.jsx(os,{value:o,collapseAfterDepth:4,showCopy:!1})})}return n==="markdown"?s.jsx(Fb,{text:t,className:e.className}):n==="html"?s.jsx(Db,{text:t,className:e.className}):s.jsx("pre",{className:`mono ${e.className}`,children:t})}function Bb(e){const t=e.preview,n=e.artifact;return n?t.loading?s.jsx("div",{className:"runtime_inline_preview empty",children:"Loading preview…"}):t.error?s.jsx("div",{className:"runtime_inline_preview empty danger",children:t.error}):t.kind==="image"&&t.url?s.jsx("img",{className:"runtime_inline_preview media",src:t.url,alt:p_(n)}):t.kind==="audio"&&t.url?s.jsx("audio",{className:"runtime_inline_preview audio",src:t.url,controls:!0}):t.kind==="video"&&t.url?s.jsx("video",{className:"runtime_inline_preview media",src:t.url,controls:!0}):s.jsx(iv,{artifact:n,text:t.text||"Preview unavailable. Use Preview or Download.",className:"runtime_inline_preview text"}):s.jsx("div",{className:"runtime_inline_preview empty",children:"Select an artifact to preview it here."})}function K_(e){const t=e==null?void 0:e.waiting;return t&&typeof t=="object"?t:null}function ov(e){const t=K_(e);return String((t==null?void 0:t.reason)||(e==null?void 0:e.waiting_reason)||"").trim().toLowerCase()}function eg(e){return e?String(e.prompt||"").trim()||Array.isArray(e.choices)&&e.choices.length>0?!0:e.allow_free_text!==!1&&String(e.reason||"").trim().toLowerCase()==="user":!1}function Ub(e){const t=e.map(n=>String((n==null?void 0:n.name)||"tool").trim()).filter(Boolean);return t.length?`${t.slice(0,3).join(", ")}${t.length>3?` +${t.length-3}`:""}`:""}function du(e){const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(yi(t)||t!=="waiting")return"none";const n=K_(e),o=ov(e);return uu(n).length?"tool_approval":o==="until"?"scheduled":o==="subworkflow"?"subworkflow":o==="event"?eg(n)?"user_response":"external_event":o==="user"||eg(n)?"user_response":"unknown_wait"}function av(e){const t=K_(e),n=uu(t),o=du(e);return o==="tool_approval"?`Tool approval: ${Ub(n)||"tool call"}`:o==="user_response"?Array.isArray(t==null?void 0:t.choices)&&t.choices.length>0?"Choice required":"User response needed":o==="scheduled"?"Scheduled wait":o==="subworkflow"?"Waiting for subworkflow":o==="external_event"?"Waiting for external event":o==="unknown_wait"?"Waiting, context unclear":""}function Hb(e){const t=du(e);if(t==="tool_approval")return"Review the tool request, then approve, reject, or cancel the whole run.";if(t==="user_response")return"Answer the workflow request. Submit resumes only this wait.";if(t==="scheduled")return"No response is needed. The run resumes when the scheduled time arrives or it is manually resumed.";if(t==="subworkflow")return"No direct response is needed. Inspect the child workflow or cancel the parent run.";if(t==="external_event")return"No direct response is available here. Inspect the ledger or the event source.";if(t==="unknown_wait")return"No clear prompt was provided. Review the input and recent ledger before taking action.";const n=String((e==null?void 0:e.status)||"").trim().toLowerCase();return n==="failed"?"Open the ledger, artifacts, or logs to inspect the failure.":n==="running"?"Watch the ledger/provider traces or cancel the workflow if it should stop.":yi(n)?"Open the ledger and artifacts for the final outcome.":"Open the run to inspect current activity."}function tg(e){const t=e==null?void 0:e.error;if(!t)return"";if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}function Wb(e,t={}){const n=t.now_ms??Date.now(),o=t.workflow_label??"",a=String(e.status||"unknown").trim().toLowerCase()||"unknown",c=du(e),d=yi(a),u=W_(e,n),m=Sn(e.updated_at||e.created_at)??0,y=a==="running"&&u>=14400*1e3,g=av(e)||tg(e)||(e.current_node?`Current node: ${e.current_node}`:a==="running"?"Running":d?"Terminal":"No current activity reported");let v="all";c==="tool_approval"?v="tool_approval":c==="user_response"?v="user_wait":c==="scheduled"||c==="subworkflow"||c==="external_event"?v="scheduled":a==="failed"?v="failed":a==="running"?v="running":d&&(v="finished");const x=c==="tool_approval"?0:c==="user_response"?1:c==="unknown_wait"?2:a==="failed"?3:y?4:a==="running"?5:c!=="none"?6:d?8:7,b=c==="tool_approval"||c==="user_response",C=c==="tool_approval"?"Open approval":c==="user_response"?"Open wait":"Open Observe",S=[e.run_id,e.workflow_id,o,e.session_id,e.parent_run_id,e.status,e.current_node,ov(e),g,tg(e)].join(" ").toLowerCase();return{run:e,run_id:String(e.run_id||"").trim(),status:a,wait_kind:c,queue:v,attention_rank:x,reason:g,expected_action:Hb(e),action_label:C,search_text:S,is_terminal:d,needs_user_action:b,is_stale:y,duration_ms:u,updated_ms:m}}function qb(e,t={}){const n=t.now_ms??Date.now(),o=t.workflow_label_by_id??{};return e.map(a=>Wb(a,{now_ms:n,workflow_label:o[String(a.workflow_id||"")]||String(a.workflow_id||"")}))}function Vb(e){const t={attention:0,user_wait:0,tool_approval:0,running:0,failed:0,scheduled:0,finished:0,all:e.length};for(const n of e)t[n.queue]+=1,n.queue!=="finished"&&(n.needs_user_action||n.status==="failed"||n.is_stale||n.wait_kind==="unknown_wait")&&(t.attention+=1);return t}function Gb(e,t){const n=t.queue,a=(t.query??"").trim().toLowerCase();return e.filter(c=>{if(n==="attention"){if(!(c.needs_user_action||c.status==="failed"||c.is_stale||c.wait_kind==="unknown_wait"))return!1}else if(n!=="all"&&c.queue!==n)return!1;return!a||c.search_text.includes(a)})}function Yb(e,t){const n=[...e];return n.sort((o,a)=>{if(t==="recent")return a.updated_ms-o.updated_ms;if(t==="oldest")return o.updated_ms-a.updated_ms;if(t==="duration")return a.duration_ms-o.duration_ms;if(t==="tokens")return(Number(a.run.tokens_total||0)||0)-(Number(o.run.tokens_total||0)||0);if(t==="workflow")return String(o.run.workflow_id||"").localeCompare(String(a.run.workflow_id||""));const c=o.attention_rank-a.attention_rank;return c!==0?c:a.updated_ms-o.updated_ms}),n}function Kb(e){const[t,n]=h.useState("attention"),[o,a]=h.useState(""),[c,d]=h.useState("attention"),[u,m]=h.useState(""),y=h.useMemo(()=>{const D={};for(const E of e.artifacts){const j=String(E.run_id||"").trim();j&&(D[j]=(D[j]||0)+1)}return D},[e.artifacts]),g=h.useMemo(()=>qb(e.runs,{workflow_label_by_id:e.workflow_label_by_id}),[e.runs,e.workflow_label_by_id]),v=h.useMemo(()=>Vb(g),[g]),x=h.useMemo(()=>{const D=Gb(g,{queue:t,query:o});return Yb(D,c)},[g,t,o,c]),b=x.find(D=>String(D.run_id||"")===u)||x.find(D=>String(D.run_id||"")===e.selected_run_id)||x[0]||null,C=(b==null?void 0:b.run)||null,S=String((C==null?void 0:C.run_id)||"").trim(),L=String((C==null?void 0:C.session_id)||"").trim(),M=h.useMemo(()=>L?new Set(e.runs.filter(D=>String(D.session_id||"").trim()===L).map(D=>String(D.run_id||"").trim()).filter(Boolean)):new Set,[e.runs,L]),W=L?M.size:0,q=h.useMemo(()=>L?e.artifacts.filter(D=>String(D.session_id||"").trim()===L||M.has(String(D.run_id||"").trim())).length:0,[e.artifacts,L,M]),z=C!=null&&C.waiting&&typeof C.waiting=="object"?C.waiting:null,Y=z?uu(z):[],Q=(b==null?void 0:b.reason)||(z?G_(z,Y):""),Z=(b==null?void 0:b.expected_action)||(z?Zy(z,Y):""),ne=z?wb(z,null):"",ue=S&&y[S]||0,de=yi(C==null?void 0:C.status),pe=[{key:"attention",label:"Needs attention",count:v.attention},{key:"user_wait",label:"Needs my response",count:v.user_wait},{key:"tool_approval",label:"Tool approvals",count:v.tool_approval},{key:"running",label:"Running",count:v.running},{key:"failed",label:"Failed",count:v.failed},{key:"scheduled",label:"Scheduled/subflows",count:v.scheduled},{key:"finished",label:"Finished",count:v.finished},{key:"all",label:"All loaded",count:v.all}];return s.jsxs("div",{className:"runtime_ops_layout",children:[s.jsxs("aside",{className:"pane runtime_ops_filters",children:[s.jsxs("div",{className:"pane_header runtime_ops_filter_header",children:[s.jsx("span",{className:"pane_title",children:"Queues"}),s.jsx("div",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.gateway_connected?e.on_refresh_runs:e.on_reconnect,children:[s.jsx(zn,{name:"refresh",size:14}),e.gateway_connected?"Refresh":"Reconnect"]})]}),s.jsxs("div",{className:"pane_body scroll runtime_ops_queue_list",children:[pe.map(D=>s.jsxs("button",{className:`runtime_ops_filter ${t===D.key?"selected":""}`,"aria-pressed":t===D.key,onClick:()=>n(D.key),children:[s.jsx("span",{children:D.label}),s.jsx("strong",{children:D.count.toLocaleString()})]},D.key)),s.jsx("div",{className:"runtime_ops_hint",children:"Counts are for the loaded runtime page. Refine search or refresh when supervising large runtimes."})]})]}),s.jsxs("section",{className:"pane runtime_ops_table_panel",children:[s.jsxs("div",{className:"pane_header runtime_ops_list_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsx("span",{className:"pane_count",children:x.length.toLocaleString()}),s.jsx("div",{className:"pane_spacer"}),s.jsx("input",{value:o,onChange:D=>a(D.target.value),placeholder:"Search workflow, run, node, status, error"}),s.jsxs("select",{className:"seg_select",value:c,onChange:D=>d(D.target.value),children:[s.jsx("option",{value:"attention",children:"Attention order"}),s.jsx("option",{value:"recent",children:"Latest event"}),s.jsx("option",{value:"oldest",children:"Oldest event"}),s.jsx("option",{value:"duration",children:"Longest duration"}),s.jsx("option",{value:"tokens",children:"Most tokens"}),s.jsx("option",{value:"workflow",children:"Workflow"})]})]}),s.jsxs("div",{className:"pane_body scroll runtime_ops_rows",children:[x.length?null:s.jsx("div",{className:"runtime_ops_empty",children:e.gateway_connected?"No runs match this queue.":"Gateway offline. Runtime activity cannot be loaded until the connection is restored."}),x.map(D=>{const E=D.run,j=String(E.run_id||"").trim(),R=y[j]||0;return s.jsxs("div",{className:`raised runtime_ops_row ${j===S?"selected":""}`,"aria-current":j===S?"true":void 0,tabIndex:0,onClick:()=>{m(j),e.on_select_run(j)},onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),m(j),e.on_select_run(j))},children:[s.jsxs("div",{className:"runtime_ops_row_top",children:[s.jsx("strong",{className:"runtime_ops_row_name",children:qs(E,e.workflow_label_by_id)}),D.is_stale?s.jsx("span",{className:"chip warn",children:"stale"}):null,s.jsx(Xa,{status:E.status})]}),s.jsxs("div",{className:"runtime_ops_row_sub",children:[s.jsx("span",{className:"mono",children:Mt(j,18)}),s.jsx("span",{children:Zo(E.updated_at||E.created_at)}),s.jsx("span",{children:Gl(E)}),s.jsx("span",{className:"runtime_ops_row_reason",title:D.reason,children:D.reason})]}),s.jsxs("div",{className:"runtime_ops_row_foot",children:[s.jsxs("span",{className:"runtime_ops_row_facts",children:[s.jsxs("span",{children:[Number(E.llm_calls||0).toLocaleString()," llm"]}),s.jsxs("span",{children:[Number(E.tool_calls||0).toLocaleString()," tools"]}),s.jsxs("span",{children:[Number(E.tokens_total||0).toLocaleString()," tok"]}),s.jsxs("span",{children:[R.toLocaleString()," artifacts"]})]}),s.jsxs("div",{className:"runtime_ops_actions",children:[D.needs_user_action?s.jsx("button",{className:"btn primary",onClick:O=>{O.stopPropagation(),e.on_open_run(j)},children:D.action_label}):s.jsx("button",{className:"btn",onClick:O=>{O.stopPropagation(),e.on_open_run(j)},children:"Open"}),s.jsx("button",{className:"btn",onClick:O=>{O.stopPropagation(),e.on_open_ledger(j)},children:"Ledger"}),s.jsx("button",{className:"btn",onClick:O=>{O.stopPropagation(),e.on_select_run(j),e.on_open_logs()},children:"Logs"}),s.jsx("button",{className:"btn",onClick:O=>{O.stopPropagation(),e.on_filter_artifacts(j)},children:"Artifacts"})]})]})]},j)})]})]}),s.jsxs("aside",{className:"pane runtime_ops_inspector",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Run inspector"}),C?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pane_spacer"}),s.jsx(Xa,{status:C.status})]}):null]}),s.jsx("div",{className:"pane_body scroll runtime_ops_inspector_body",children:C?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_ops_inspector_head",children:[s.jsx("h3",{children:qs(C,e.workflow_label_by_id)}),s.jsx("span",{className:"mono",children:Mt(S,28)})]}),s.jsxs("div",{className:"runtime_ops_decision",children:[s.jsx("strong",{children:(b==null?void 0:b.reason)||jb(C)}),s.jsx("span",{children:(b==null?void 0:b.expected_action)||(String(C.status||"").toLowerCase()==="waiting"?"This run is paused until the pending wait is resolved or the run is cancelled.":de?"This run is terminal. Open the ledger for the narrative and final error/output.":"This run is active or recently updated. Use ledger/provider logs to inspect live work.")})]}),s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Started"}),s.jsx("strong",{children:ea(Dl(C))})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Elapsed"}),s.jsx("strong",{children:Gl(C)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Last event"}),s.jsx("strong",{children:ea(C.updated_at||C.created_at)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:C.session_id?Mt(String(C.session_id),18):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:C.current_node||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Visible artifacts"}),s.jsx("strong",{children:ue.toLocaleString()})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:Number(C.llm_calls||0).toLocaleString()})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Tokens"}),s.jsx("strong",{children:Number(C.tokens_total||0).toLocaleString()})]})]}),L?s.jsxs("section",{className:"runtime_ops_session_context",children:[s.jsxs("div",{children:[s.jsx("span",{className:"run_hero_eyebrow",children:"Session context"}),s.jsx("strong",{className:"mono",children:Mt(L,30)})]}),s.jsxs("div",{className:"runtime_ops_session_facts",children:[s.jsxs("span",{children:[W.toLocaleString()," loaded run",W===1?"":"s"]}),s.jsxs("span",{children:[q.toLocaleString()," visible artifact",q===1?"":"s"]})]}),s.jsxs("div",{className:"runtime_detail_actions compact",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_filter_session_artifacts(L),children:"Open session artifacts"}),s.jsx("button",{className:"btn",onClick:()=>void Vl(L),children:"Copy session id"})]})]}):null,z?s.jsxs("div",{className:"runtime_ops_wait_summary",children:[s.jsxs("div",{className:"runtime_ops_wait_header",children:[s.jsx("span",{className:"run_hero_eyebrow",children:"Blocked on"}),s.jsx("strong",{children:Q})]}),s.jsx("p",{children:Z}),ne?s.jsxs("div",{className:"runtime_ops_wait_request",children:[s.jsx("span",{children:"Request"}),s.jsx(gi,{text:ne})]}):s.jsx("div",{className:"runtime_ops_wait_request muted",children:"No explicit prompt is attached to this wait. Open Observe or the ledger for full run context before responding."}),Y.length?s.jsx("div",{className:"runtime_ops_wait_tools",children:Y.map((D,E)=>s.jsxs(ye.Fragment,{children:[s.jsx("span",{className:"chip mono warn",children:String((D==null?void 0:D.name)||"tool")}),Jy(D).map(j=>s.jsxs("span",{className:"chip muted",title:Xy,children:[j,"~"]},`${E}:${j}`))]},`${String((D==null?void 0:D.name)||"tool")}:${E}`))}):null,s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"muted",children:"Raw wait payload"}),s.jsx(os,{value:z,collapseAfterDepth:3,showCopy:!0})]})]}):null,bm(C)?s.jsx("div",{className:"warn_callout",children:bm(C)}):null,s.jsxs("div",{className:"runtime_detail_actions",children:[s.jsx("button",{className:"btn primary",onClick:()=>e.on_open_run(S),children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_ledger(S),children:"Open ledger"}),s.jsx("button",{className:"btn",onClick:()=>e.on_filter_artifacts(S),children:"Open artifacts"}),s.jsx("button",{className:"btn",onClick:e.on_open_logs,children:"Open logs"}),s.jsx("button",{className:"btn",onClick:()=>void Vl(S),children:"Copy run id"})]})]}):s.jsx("div",{className:"empty_state_inline",children:"Select a run to inspect why it is active or blocked."})})]})]})}function Xb(e){const t=e.selected_artifact,n=["voice","music","sound","recording","audio","image","video","markdown","html","json","document","code","text","other"],o=[{value:"all",label:"Any time"},{value:"hour",label:"Last hour"},{value:"today",label:"Today"},{value:"week",label:"7 days"},{value:"month",label:"30 days"}],a=h.useMemo(()=>new Set(e.type_filters),[e.type_filters]),c=Math.max(0,Number(e.artifact_total_count||0)),d=!!e.query.trim()||e.type_filters.length>0||e.date_filter!=="all"||e.scope!=="all"||!!e.artifact_run_filter.trim(),u=Math.max(1,Number(e.artifact_page_size||500)),m=Math.max(1,Math.ceil(c/u)),y=Math.min(Math.max(0,Number(e.artifact_page||0)),m-1),g=c?y*u+1:0,v=Math.min(c,y*u+e.artifacts.length),x=h.useMemo(()=>{const E={},j=e.artifact_type_facets&&Object.keys(e.artifact_type_facets).length?e.artifact_type_facets:e.artifact_facets,R=(j==null?void 0:j.semantic_kind)||{},O=(j==null?void 0:j.render_kind)||{};for(const ee of n)E[ee]=Number(R[ee]||O[ee]||0);return E.audio=Number(R.audio||0),E.other=Number(R.other||0)+Number(R.artifact||0)+Number(R.binary||0)+Number(R["(none)"]||0),E},[e.artifact_facets,e.artifact_type_facets]),b=E=>{const j=new Set(a);j.has(E)?j.delete(E):j.add(E),e.on_type_filters_change(Array.from(j.values()))},C=h.useMemo(()=>{const E={waiting:[],running:[],failed:[],cancelled:[],completed:[],other:[]};for(const j of e.runs){const R=String(j.status||"").trim().toLowerCase();R==="waiting"?E.waiting.push(j):R==="running"?E.running.push(j):R==="failed"?E.failed.push(j):R==="cancelled"?E.cancelled.push(j):R==="completed"?E.completed.push(j):E.other.push(j)}return E},[e.runs]),S=t!=null&&t.run_id&&e.run_by_id[t.run_id]||null,L=e.artifact_run_filter?qs(e.run_by_id[e.artifact_run_filter],e.workflow_label_by_id):"",M=h.useMemo(()=>{var R;const E=new Set,j=((R=e.artifact_facets)==null?void 0:R.run_id)||{};for(const O of Object.keys(j))O&&O!=="(none)"&&E.add(O);for(const O of e.artifacts)O.run_id&&E.add(O.run_id);for(const O of e.active_runs)O.run_id&&E.add(String(O.run_id));return Array.from(E).map(O=>e.run_by_id[O]||{run_id:O,workflow_id:null,status:"",created_at:null,updated_at:null}).sort((O,ee)=>{const I=Qc(O.status)?0:1,P=Qc(ee.status)?0:1;if(I!==P)return I-P;const G=Sn(O.updated_at||O.created_at)??0;return(Sn(ee.updated_at||ee.created_at)??0)-G}).slice(0,160)},[e.artifacts,e.active_runs,e.run_by_id,e.artifact_facets]),W=E=>{e.on_artifact_run_filter_change(E),e.on_session_filter_change(""),e.on_scope_change(E?"run":"all")},q=E=>e.gateway_connected?Math.max(0,Number(E||0)).toLocaleString():"—",z=e.selected_run_id&&e.run_by_id[e.selected_run_id]||null,Y=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=e.runtime_ledger_log_items||[];return E?j.filter(R=>{var I,P;const O=R.record||{};return[R.cursor,O.run_id,O.node_id,O.status,(I=O.effect)==null?void 0:I.type,O.started_at,O.ended_at,jr(((P=O.effect)==null?void 0:P.payload)??{},900),jr(O.result??{},900)].join(" ").toLowerCase().includes(E)}):j},[e.runtime_ledger_log_items,e.runtime_log_query]),Q=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=rv(e.runtime_ledger_log_items);return E?j.filter(R=>[R.provider,R.model,R.run_id,R.node_id,R.status,R.error,R.prompt_preview,R.response_preview,R.tokens.prompt,R.tokens.completion,R.tokens.total].join(" ").toLowerCase().includes(E)):j},[e.runtime_ledger_log_items,e.runtime_log_query]),Z=Q.reduce((E,j)=>E+(Number(j.tokens.total)||0),0),ne=Q.filter(E=>E.missing_response||E.error).length,ue=h.useMemo(()=>{const E=e.runtime_log_query.trim().toLowerCase(),j=String(e.audit_log_text||"").replace(/\r\n/g,`
97
+ `).replace(/\r/g,`
98
+ `).split(`
99
+ `).filter(Boolean);return E?j.filter(R=>R.toLowerCase().includes(E)):j},[e.audit_log_text,e.runtime_log_query]),de=e.runtime_log_source==="run_ledger"||e.runtime_log_source==="provider_calls",pe=e.runtime_log_source==="run_ledger"?"Selected Run Ledger":e.runtime_log_source==="provider_calls"?"Provider Calls":"Gateway HTTP Audit",D=e.runtime_log_source==="run_ledger"?"Runtime execution records for the selected workflow run.":e.runtime_log_source==="provider_calls"?"Model/provider call records extracted from the selected run ledger.":"Global Gateway HTTP/audit tail. This is system activity, not artifact provenance.";return s.jsxs("div",{className:"page runtime_page",children:[s.jsxs("section",{className:"runtime_header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"run_hero_eyebrow",children:"System"}),s.jsx("h2",{children:e.tab==="activity"?"Activity monitor":e.tab==="artifacts"?"Artifact explorer":e.tab==="memory"?"Active memory":"Logs"}),s.jsxs("div",{className:"run_hero_meta",children:[s.jsx("span",{className:`status_pill ${e.gateway_connected?"ok":"warn"}`,children:e.gateway_connected?"gateway connected":"gateway offline"}),e.tab==="artifacts"&&e.artifact_run_filter?s.jsxs("span",{className:"chip muted",children:["filtered run ",s.jsx("span",{className:"mono",children:Mt(e.artifact_run_filter,18)})]}):null,e.session_id?s.jsxs("span",{className:"chip muted",children:["session ",s.jsx("span",{className:"mono",children:Mt(e.session_id,18)})]}):null]})]}),s.jsxs("div",{className:"metric_grid compact runtime_header_metrics",children:[s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Waiting"}),s.jsx("strong",{children:q(C.waiting.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Running"}),s.jsx("strong",{children:q(C.running.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Failed"}),s.jsx("strong",{children:q(C.failed.length)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsxs("span",{children:["Artifacts",d?" (filtered)":""]}),s.jsx("strong",{children:q(c)})]})]})]}),s.jsx("nav",{className:"runtime_mode_tabs",role:"tablist","aria-label":"System sections",children:["activity","artifacts","memory","logs"].map(E=>s.jsxs("button",{role:"tab","aria-selected":e.tab===E,className:`runtime_mode_tab ${e.tab===E?"active":""}`,onClick:()=>e.on_tab_change(E),children:[s.jsx(zn,{name:E==="activity"?"history":E==="artifacts"?"download":E==="memory"?"agent":"terminal",size:14}),s.jsx("span",{children:E==="activity"?"Activity":E==="artifacts"?"Artifacts":E==="memory"?"Memory":"Logs"})]},E))}),e.gateway_connected?null:s.jsxs("div",{className:"runtime_offline_banner",role:"status",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Gateway offline"}),s.jsx("span",{children:"Activity, artifacts, memory, and logs are unavailable until the gateway reconnects."})]}),s.jsxs("div",{children:[s.jsx("button",{className:"btn primary",onClick:e.on_reconnect,children:"Reconnect"}),s.jsx("button",{className:"btn",onClick:e.on_open_settings,children:"Settings"})]})]}),e.error?s.jsx("div",{className:"warn_callout",children:e.error}):null,e.tab==="activity"?s.jsx(Kb,{gateway_connected:e.gateway_connected,runs:e.runs,artifacts:e.artifacts,selected_run_id:e.selected_run_id,workflow_label_by_id:e.workflow_label_by_id,on_select_run:e.on_select_run,on_open_run:e.on_open_run,on_open_ledger:e.on_open_ledger,on_refresh_runs:e.on_refresh_runs,on_reconnect:e.on_reconnect,on_open_logs:()=>e.on_tab_change("logs"),on_filter_artifacts:E=>{W(E),e.on_select_run(E),e.on_tab_change("artifacts")},on_filter_session_artifacts:E=>{E&&(e.on_artifact_run_filter_change(""),e.on_session_filter_change(E),e.on_scope_change("session"),e.on_tab_change("artifacts"))}}):null,e.tab==="memory"?e.memory_panel?s.jsx("div",{className:"runtime_memory_panel",children:e.memory_panel}):s.jsx("div",{className:"empty_state_inline",children:"The memory explorer needs a gateway connection — sign in to browse knowledge-graph assertions."}):null,e.tab==="artifacts"?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"pane runtime_artifact_toolbar","aria-label":"Find artifacts",children:[s.jsxs("div",{className:"runtime_artifact_toolbar_top",children:[s.jsxs("label",{className:"artifact_filter_field artifact_filter_search",children:[s.jsx("span",{children:"Search"}),s.jsx("input",{value:e.query,onChange:E=>e.on_query_change(E.target.value),placeholder:"title, path, hash, run, workflow, tag"})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Scope"}),s.jsxs("select",{className:"seg_select",value:e.scope,onChange:E=>{const j=E.target.value;j!=="run"&&e.on_artifact_run_filter_change(""),j==="session"?e.on_session_filter_change(e.session_id):e.on_session_filter_change(""),e.on_scope_change(j)},children:[s.jsx("option",{value:"all",children:"All runtime"}),s.jsx("option",{value:"session",children:"This session"}),s.jsx("option",{value:"run",children:"Selected run"})]})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Group"}),s.jsxs("select",{className:"seg_select",value:e.group_by,onChange:E=>e.on_group_by_change(E.target.value),children:[s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"time",children:"Date"}),s.jsx("option",{value:"turn",children:"Turn"}),s.jsx("option",{value:"node",children:"Node"}),s.jsx("option",{value:"workflow",children:"Workflow"}),s.jsx("option",{value:"run",children:"Run"}),s.jsx("option",{value:"location",children:"Location"}),s.jsx("option",{value:"source",children:"Source"})]})]}),s.jsxs("label",{className:"artifact_filter_field",children:[s.jsx("span",{children:"Sort"}),s.jsxs("select",{className:"seg_select",value:e.sort_by,onChange:E=>e.on_sort_by_change(E.target.value),children:[s.jsx("option",{value:"newest",children:"Newest"}),s.jsx("option",{value:"oldest",children:"Oldest"}),s.jsx("option",{value:"last_access",children:"Last accessed"}),s.jsx("option",{value:"turn",children:"Turn order"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"size_desc",children:"Largest"}),s.jsx("option",{value:"size_asc",children:"Smallest"})]})]}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_refresh_artifacts,disabled:!e.gateway_connected||e.loading,children:[s.jsx(zn,{name:"refresh",size:14}),e.loading?"Loading…":"Refresh"]})]}),s.jsxs("div",{className:"artifact_filter_section",children:[s.jsxs("div",{className:"artifact_filter_label",children:["Type ",s.jsx("span",{className:"muted",children:"OR"})]}),s.jsxs("div",{className:"artifact_filter_chips",role:"group","aria-label":"Artifact type filters combine with OR",children:[n.map(E=>{const j=a.has(E),R=x[E]||0,O=Eb(E);return s.jsxs("button",{type:"button","aria-pressed":j,"aria-label":`${j?"Remove":"Add"} ${O} artifact type filter. Type filters combine with OR.`,title:`${j?"Remove":"Add"} ${O}. Type filters combine with OR.`,className:`artifact_filter_chip ${j?"active":""}`,onClick:()=>b(E),children:[s.jsx("span",{children:O}),s.jsx("span",{className:"artifact_chip_count",children:e.gateway_connected?R.toLocaleString():"—"})]},E)}),e.type_filters.length?s.jsx("button",{type:"button",className:"artifact_filter_chip clear",onClick:()=>e.on_type_filters_change([]),children:"Clear types"}):null]})]}),s.jsxs("div",{className:"artifact_filter_section",children:[s.jsx("div",{className:"artifact_filter_label",children:"Date"}),s.jsx("div",{className:"artifact_filter_chips",role:"group","aria-label":"Artifact date filters",children:o.map(E=>s.jsx("button",{type:"button","aria-pressed":e.date_filter===E.value,className:`artifact_filter_chip ${e.date_filter===E.value?"active":""}`,onClick:()=>e.on_date_filter_change(E.value),children:E.label},E.value))})]})]}),s.jsx("div",{className:"artifact_scope_banner",children:e.artifact_run_filter?s.jsxs(s.Fragment,{children:["Showing artifacts for ",s.jsx("strong",{children:L||Mt(e.artifact_run_filter,18)}),".",s.jsx("button",{className:"btn",onClick:()=>W(""),children:"Show all"})]}):s.jsxs(s.Fragment,{children:["Showing artifacts across the selected runtime scope. Select a run to filter the inventory. ",e.artifact_total_bytes?s.jsxs("span",{className:"mono muted",children:["Total size ",Fl(e.artifact_total_bytes)]}):null]})}),s.jsxs("div",{className:"runtime_artifacts_layout",children:[s.jsxs("aside",{className:"pane artifact_filter_rail",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsx("span",{className:"pane_count",children:M.length.toLocaleString()})]}),s.jsxs("div",{className:"pane_body scroll artifact_filter_rail_list",children:[s.jsxs("button",{className:`artifact_filter_run ${e.artifact_run_filter?"":"selected"}`,onClick:()=>W(""),children:[s.jsx("strong",{children:"All artifacts"}),s.jsx("span",{children:e.gateway_connected?`${c.toLocaleString()} match${c===1?"":"es"}`:"counts unavailable"})]}),M.map(E=>{const j=String(E.run_id||"").trim(),R=j===e.artifact_run_filter||j===(t==null?void 0:t.run_id);return s.jsxs("button",{className:`artifact_filter_run ${R?"selected":""}`,onClick:()=>W(j),title:j,children:[s.jsx("strong",{children:qs(E,e.workflow_label_by_id)}),s.jsx("span",{className:"mono",children:Mt(j,15)}),s.jsx("span",{children:Gl(E)})]},j)})]})]}),s.jsxs("section",{className:"pane runtime_artifact_browser",children:[s.jsxs("div",{className:"pane_header artifact_browser_header",children:[s.jsx("span",{className:"pane_title",children:"Artifacts"}),s.jsx("span",{className:"pane_count",children:c?`${g.toLocaleString()}-${v.toLocaleString()} of ${c.toLocaleString()}`:"0 items"}),s.jsx("div",{className:"pane_spacer"}),m>1?s.jsxs("div",{className:"artifact_pagination","aria-label":"Artifact pages",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(0),disabled:y<=0,children:"First"}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(y-1),disabled:y<=0,children:"Prev"}),s.jsxs("span",{className:"muted artifact_page_label",children:["Page ",(y+1).toLocaleString()," / ",m.toLocaleString()]}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(y+1),disabled:y>=m-1,children:"Next"}),s.jsx("button",{className:"btn",onClick:()=>e.on_artifact_page_change(m-1),disabled:y>=m-1,children:"Last"})]}):null]}),s.jsxs("div",{className:"pane_body scroll artifact_browser_body",children:[e.artifact_groups.length?null:s.jsx("div",{className:"empty_state_inline",children:e.gateway_connected?"No artifacts match the current filters.":"Gateway offline. Artifact inventory cannot be loaded until the connection is restored."}),s.jsx("div",{className:"artifact_group_list",children:e.artifact_groups.map(E=>s.jsxs("section",{className:"artifact_group",children:[s.jsxs("div",{className:"artifact_group_header",children:[s.jsx("span",{children:E.key}),s.jsx("span",{className:"artifact_group_count",children:E.items.length})]}),E.items.map(j=>{var P;const R=j.run_id&&e.run_by_id[j.run_id]||null,O=R?qs(R,e.workflow_label_by_id):Y_(j),ee=Jp(j),I=Number(((P=j.access)==null?void 0:P.access_count)||0)||0;return s.jsxs("button",{className:`artifact_row ${(t==null?void 0:t.artifact_id)===j.artifact_id?"selected":""}`,onClick:()=>{e.on_select_artifact(j.artifact_id),j.run_id&&e.on_select_run(j.run_id)},title:j.artifact_id,children:[s.jsx(Qp,{artifact:j,size:18}),s.jsxs("div",{className:"artifact_row_main",children:[s.jsxs("div",{className:"artifact_row_title",children:[s.jsx("strong",{children:Xp(Sm(j,e.run_by_id,e.workflow_label_by_id))}),s.jsx("span",{className:"artifact_type_badge",children:tu(j)}),j.render_kind&&j.render_kind!==j.semantic_kind?s.jsx("span",{className:"artifact_type_badge muted",children:j.render_kind}):null,j.legacy_inferred?s.jsx("span",{className:"artifact_type_badge inferred",children:"legacy inferred"}):null]}),s.jsxs("div",{className:"artifact_row_facts",children:[s.jsxs("span",{children:[s.jsx("b",{children:"Created"})," ",Ab(j)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Size"})," ",Fl(j.size_bytes)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Last seen"})," ",Kp(j)]}),I?s.jsxs("span",{children:[s.jsx("b",{children:"Accesses"})," ",I.toLocaleString()]}):null,ee?s.jsxs("span",{children:[s.jsx("b",{children:"Media"})," ",ee]}):null,j.content_type?s.jsxs("span",{children:[s.jsx("b",{children:"MIME"})," ",j.content_type]}):null]}),s.jsxs("div",{className:"artifact_row_facts secondary",children:[O?s.jsxs("span",{children:[s.jsx("b",{children:"Workflow"})," ",O]}):null,j.run_id?s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"Run"})," ",Mt(j.run_id,13)]}):null,s.jsxs("span",{children:[s.jsx("b",{children:"Turn"})," ",g_(j)]}),eu(j)?s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"Node"})," ",eu(j)]}):null,Pd(j)?s.jsxs("span",{children:[s.jsx("b",{children:"Source"})," ",Pd(j)]}):null]}),s.jsxs("div",{className:"artifact_row_facts tertiary",children:[s.jsxs("span",{className:"mono",children:[s.jsx("b",{children:"ID"})," ",Mt(j.artifact_id,22)]}),s.jsxs("span",{children:[s.jsx("b",{children:"Provenance"})," ",Gp(j)]})]}),Zp(j)?s.jsx("div",{className:"artifact_row_path mono",children:Zp(j)}):null]})]},j.artifact_id)})]},E.key))})]})]}),s.jsx("aside",{className:"runtime_detail",children:s.jsxs("section",{className:"overview_panel runtime_artifact_detail",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Artifact Detail"}),t?s.jsx("span",{className:"chip mono muted",children:e.embedded_preview.render_kind?y_(t,e.run_by_id,e.workflow_label_by_id,e.embedded_preview.text):y_(t,e.run_by_id,e.workflow_label_by_id)}):null]}),t?s.jsxs(s.Fragment,{children:[(()=>{var P,G,$,K,se,le,he;const E=Tb(t),j=tv(t),R=Jp(t),O=Number(((P=t.access)==null?void 0:P.access_count)||0)||0,ee=on((G=t.links)==null?void 0:G.provider_trace,($=t.links)==null?void 0:$.provider_trace_url,(K=t.links)==null?void 0:K.provider_trace_id),I=on((se=t.links)==null?void 0:se.audit,(le=t.links)==null?void 0:le.audit_tail,(he=t.links)==null?void 0:he.audit_url);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"artifact_detail_header",children:[s.jsx(Qp,{artifact:t,size:22}),s.jsxs("div",{children:[s.jsx("div",{className:"artifact_detail_title",children:Xp(Sm(t,e.run_by_id,e.workflow_label_by_id))}),s.jsxs("div",{className:"artifact_detail_subtitle",children:[tu(t)," • ",t.render_kind||e.embedded_preview.render_kind||t.modality||"artifact"," • ",t.content_type||"unknown MIME"," • ",Fl(t.size_bytes),t.legacy_inferred?" • legacy inferred":""]})]})]}),s.jsx(Bb,{artifact:t,preview:e.embedded_preview}),s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Semantic type"}),s.jsx("strong",{children:tu(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Render kind"}),s.jsx("strong",{children:t.render_kind||e.embedded_preview.render_kind||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Created"}),s.jsx("strong",{children:ea(t.created_at)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Size"}),s.jsx("strong",{children:Fl(t.size_bytes)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Last seen"}),s.jsx("strong",{children:Kp(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Accesses"}),s.jsx("strong",{children:O?O.toLocaleString():"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Run"}),s.jsx("strong",{className:"mono",children:t.run_id?Mt(t.run_id,24):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Workflow"}),s.jsx("strong",{children:S?qs(S,e.workflow_label_by_id):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Turn"}),s.jsx("strong",{children:g_(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:eu(t)||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider/model"}),s.jsx("strong",{children:j||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Media facts"}),s.jsx("strong",{children:R||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Trace"}),s.jsx("strong",{children:t.provider_trace_available?"available":"not recorded"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provenance"}),s.jsx("strong",{children:Gp(t)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Artifact id"}),s.jsx("strong",{className:"mono",children:Mt(t.artifact_id,30)})]}),t.sha256?s.jsxs("div",{children:[s.jsx("span",{children:"sha256"}),s.jsx("strong",{className:"mono",children:Mt(t.sha256,30)})]}):null]}),E?s.jsxs("div",{className:"artifact_provenance_panel",children:[s.jsx("div",{className:"artifact_filter_label",children:"Generation prompt / input"}),s.jsx("div",{className:"artifact_prompt_text",children:E})]}):s.jsxs("div",{className:"artifact_provenance_panel muted",children:[s.jsx("div",{className:"artifact_filter_label",children:"Generation prompt / input"}),s.jsx("div",{className:"artifact_prompt_text",children:"Generation prompt not recorded by the runtime artifact descriptor."})]}),Object.keys(t.generation||{}).length||Object.keys(t.producer||{}).length?s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Generation and producer metadata"}),s.jsx(os,{value:{generation:t.generation,producer:t.producer,source_refs:t.source_refs},collapseAfterDepth:3,showCopy:!0})]}):null,t.source_path?s.jsx("div",{className:"artifact_detail_path mono",children:t.source_path}):null,s.jsxs("div",{className:"runtime_detail_actions",children:[s.jsx("button",{className:"btn primary",onClick:()=>e.on_preview_artifact(t),disabled:!t.run_id,children:e.embedded_preview.render_kind==="html"?"Open as web page":"Open full preview"}),s.jsx("button",{className:"btn",onClick:()=>e.on_download_artifact(t),disabled:!t.run_id,children:"Download"}),s.jsx("button",{className:"btn",onClick:()=>W(t.run_id),disabled:!t.run_id,children:"Show run artifacts"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(t.run_id),disabled:!t.run_id,children:"Open in Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_open_ledger(t.run_id),disabled:!t.run_id,children:"Open run ledger"}),s.jsx("button",{className:"btn",onClick:()=>{ee&&window.open(ee,"_blank","noopener,noreferrer")},disabled:!ee,children:"Open provider trace"}),s.jsx("button",{className:"btn",onClick:()=>{I?window.open(I,"_blank","noopener,noreferrer"):e.on_tab_change("logs")},disabled:!I&&!t.audit_available,children:"Open audit trail"}),s.jsx("button",{className:"btn",onClick:()=>void Vl(t.artifact_id),disabled:!t.artifact_id,children:"Copy artifact id"})]})]})})(),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw metadata"}),s.jsx(os,{value:t.raw,collapseAfterDepth:3,showCopy:!0})]})]}):s.jsx("div",{className:"empty_state_inline",children:"Select an artifact to inspect metadata, preview, or download content."})]})})]})]}):null,e.tab==="logs"?s.jsxs("section",{className:"overview_panel runtime_logs_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:pe}),s.jsx("div",{className:"mono muted",children:D})]}),s.jsxs("div",{className:"actions",style:{marginTop:0},children:[de&&e.runtime_ledger_log_meta?s.jsx("span",{className:"mono muted",children:e.runtime_ledger_log_meta}):null,e.runtime_log_source==="gateway_audit"&&e.audit_log_meta?s.jsx("span",{className:"mono muted",children:e.audit_log_meta}):null,s.jsxs("button",{className:"btn btn_icon",onClick:()=>{de?e.on_refresh_runtime_ledger(e.selected_run_id):e.on_refresh_audit()},disabled:de?e.runtime_ledger_log_loading:e.audit_log_loading,children:[s.jsx(zn,{name:"refresh",size:14}),de?e.runtime_ledger_log_loading?"Loading…":"Refresh":e.audit_log_loading?"Loading…":"Refresh"]})]})]}),s.jsxs("div",{className:"runtime_log_toolbar",children:[s.jsxs("div",{className:"seg_toggle mono",children:[s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="run_ledger"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("run_ledger"),children:"Run ledger"}),s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="provider_calls"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("provider_calls"),children:"Provider calls"}),s.jsx("button",{className:`seg_btn ${e.runtime_log_source==="gateway_audit"?"active":""}`,onClick:()=>e.on_runtime_log_source_change("gateway_audit"),children:"Gateway audit"})]}),s.jsx("input",{className:"mono",value:e.runtime_log_query,onChange:E=>e.on_runtime_log_query_change(E.target.value),placeholder:"Search node, status, effect, payload, error"})]}),e.runtime_log_source==="run_ledger"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_log_context",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Selected run"}),s.jsx("strong",{children:z?qs(z,e.workflow_label_by_id):e.selected_run_id?Mt(e.selected_run_id,24):"No run selected"}),e.selected_run_id?s.jsx("em",{className:"mono",children:Mt(e.selected_run_id,34)}):null]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:z!=null&&z.session_id?Mt(String(z.session_id),28):e.session_id?Mt(e.session_id,28):"—"})]}),s.jsxs("div",{className:"runtime_log_context_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(e.selected_run_id),disabled:!e.selected_run_id,children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>W(e.selected_run_id),disabled:!e.selected_run_id,children:"Run artifacts"})]})]}),e.runtime_ledger_log_error?s.jsx("div",{className:"warn_callout",children:e.runtime_ledger_log_error}):null,e.selected_run_id?null:s.jsx("div",{className:"empty_state_inline",children:"Select a run in Activity or Artifact Explorer to inspect its runtime ledger."}),e.selected_run_id&&!Y.length&&!e.runtime_ledger_log_loading?s.jsx("div",{className:"empty_state_inline",children:"No ledger records match the current search."}):null,s.jsx("div",{className:"runtime_log_event_list","aria-label":"Selected run ledger records",children:Y.map(E=>{var se,le;const j=E.record||{},R=String(((se=j==null?void 0:j.effect)==null?void 0:se.type)||"").trim(),O=String((j==null?void 0:j.status)||"").trim(),ee=String((j==null?void 0:j.node_id)||"").trim(),I=on(j==null?void 0:j.ended_at,j==null?void 0:j.started_at,j==null?void 0:j.ts),P=Vi(j),G=nv(j),$=R?_t(jr(((le=j==null?void 0:j.effect)==null?void 0:le.payload)??{},1200),{max_chars:1200,max_lines:6}):"",K=Yd(j)||(P?`Waiting for ${String(P.reason||"input")}`:"")||((j==null?void 0:j.result)!==void 0?jr(j.result,700):"");return s.jsxs("article",{className:`runtime_log_event ${Ka(O)}`,children:[s.jsxs("div",{className:"runtime_log_event_header",children:[s.jsxs("span",{className:"mono",children:["#",E.cursor]}),s.jsx(Xa,{status:O||"record"}),R?s.jsx("span",{className:"chip mono muted",children:R}):null,ee?s.jsx("strong",{className:"mono",children:ee}):null,I?s.jsx("span",{className:"mono muted",children:ea(I)}):null]}),s.jsxs("div",{className:"runtime_log_event_body",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Request / activity"}),s.jsx("p",{children:[G||fm(j),$&&$!=="{}"?$:""].filter(Boolean).join(`
100
+ `)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Outcome"}),s.jsx("p",{children:_t(K||"—",{max_chars:1200,max_lines:6})})]})]}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw ledger record"}),s.jsx(os,{value:j,collapseAfterDepth:3,showCopy:!0})]})]},`${e.selected_run_id}:${E.cursor}`)})})]}):e.runtime_log_source==="provider_calls"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"runtime_log_context",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Selected run"}),s.jsx("strong",{children:z?qs(z,e.workflow_label_by_id):e.selected_run_id?Mt(e.selected_run_id,24):"No run selected"}),e.selected_run_id?s.jsx("em",{className:"mono",children:Mt(e.selected_run_id,34)}):null]}),s.jsxs("div",{children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:Q.length.toLocaleString()}),s.jsx("em",{className:"mono",children:Z?`${Z.toLocaleString()} tokens`:"tokens not recorded"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Issues"}),s.jsx("strong",{children:ne.toLocaleString()})]}),s.jsxs("div",{className:"runtime_log_context_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(e.selected_run_id),disabled:!e.selected_run_id,children:"Open Observe"}),s.jsx("button",{className:"btn",onClick:()=>e.on_runtime_log_source_change("run_ledger"),disabled:!e.selected_run_id,children:"Run ledger"})]})]}),e.runtime_ledger_log_error?s.jsx("div",{className:"warn_callout",children:e.runtime_ledger_log_error}):null,e.selected_run_id?null:s.jsx("div",{className:"empty_state_inline",children:"Select a run in Activity or Artifact Explorer to inspect provider calls."}),e.selected_run_id&&!Q.length&&!e.runtime_ledger_log_loading?s.jsx("div",{className:"empty_state_inline",children:"No provider calls are present in the selected run ledger, or none match the current search."}):null,s.jsx("div",{className:"provider_activity_list runtime_provider_log_list",children:Q.map(E=>s.jsxs("article",{className:`provider_activity ${E.error||E.missing_response?"danger":""}`,children:[s.jsxs("div",{className:"provider_activity_header",children:[s.jsxs("div",{children:[s.jsx("h4",{children:[E.provider||"provider unknown",E.model||"model unknown"].join(" / ")}),s.jsxs("div",{className:"timeline_subtitle",children:[E.node_id?s.jsx("span",{className:"mono",children:E.node_id}):null,E.run_id?s.jsx("span",{className:"mono",children:Mt(E.run_id,16)}):null,s.jsx("span",{children:H_(E.duration_ms)}),E.status?s.jsx(Xa,{status:E.status}):null]})]}),s.jsxs("div",{className:"provider_tokens mono",children:[E.tokens.total?E.tokens.total.toLocaleString():"—"," tokens"]})]}),s.jsxs("div",{className:"provider_preview_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Prompt / messages"}),s.jsx("p",{children:E.prompt_preview||"No prompt payload captured"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Response / error"}),s.jsx("p",{children:E.response_preview||E.error||"No response captured"})]})]}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Raw provider ledger record"}),s.jsx(os,{value:E.raw,collapseAfterDepth:3,showCopy:!0})]})]},E.id))})]}):s.jsxs(s.Fragment,{children:[e.audit_log_error?s.jsx("div",{className:"warn_callout",children:e.audit_log_error}):null,s.jsx("pre",{className:"mono audit_log_tail",children:ue.length?ue.join(`
101
+ `):"(audit tail not loaded or no lines match search)"})]})]}):null]})}const Xf=30;function Jb(e){const[t,n]=h.useState(""),o=Array.isArray(e.wait.choices)?e.wait.choices:[],a=e.wait.allow_free_text!==!1,c=e.disabled===!0,d=String(e.wait.prompt||"").trim();return s.jsxs(s.Fragment,{children:[o.length?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Expected response"}),s.jsxs("select",{className:"mono",value:t,onChange:u=>n(u.target.value),children:[s.jsx("option",{value:"",children:"(select)"}),o.map((u,m)=>s.jsx("option",{value:String(u),children:String(u)},m))]})]}):null,a?s.jsxs("div",{className:"field",children:[s.jsx("label",{children:o.length?"Or type a response":d?"Your answer":"Response to resume this wait"}),s.jsx("textarea",{className:"mono wait_response_input",value:t,onChange:u=>n(u.target.value),placeholder:d?"Type your answer to the request above…":"Type the response the workflow is waiting for…",rows:4})]}):null,s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn primary",disabled:c||!t.trim(),onClick:()=>e.on_submit(t.trim()),children:"Submit response"})})]})}function Zb(e){const t=e.selected_run_id.trim(),n=e.root_run_id.trim()||t,o=e.sections.reduce((a,c)=>a+c.rows.reduce((d,u)=>{const m=[u.run,...u.children];return d+m.filter(y=>Qc(y.status)).length},0),0);return s.jsxs("aside",{className:"observatory_sidebar pane",children:[s.jsxs("div",{className:"run_nav_header pane_header",children:[s.jsx("span",{className:"pane_title",children:"Runs"}),s.jsxs("span",{className:"pane_count",children:[e.total_runs.toLocaleString()," runs • ",o.toLocaleString()," active"]}),s.jsx("span",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_refresh,disabled:e.loading,title:"Refresh workflow runs",children:[s.jsx(zn,{name:"refresh",size:14}),e.loading?"…":""]})]}),s.jsxs("div",{className:"run_nav_controls",children:[s.jsx("input",{value:e.search,onChange:a=>e.on_search(a.target.value),placeholder:"Search runs, sessions, workflows"}),s.jsxs("div",{className:"run_nav_filter_row",children:[s.jsx("div",{className:"seg_toggle run_nav_segments",children:["active","waiting","terminal","failed","all"].map(a=>s.jsx("button",{className:`seg_btn ${e.filter===a?"active":""}`,onClick:()=>e.on_filter(a),children:a},a))}),s.jsxs("select",{className:"seg_select",value:e.group_by,onChange:a=>e.on_group_by(a.target.value),title:"Group workflow runs",children:[s.jsx("option",{value:"status",children:"Group by status"}),s.jsx("option",{value:"workflow",children:"Group by workflow"}),s.jsx("option",{value:"session",children:"Group by session"})]})]})]}),s.jsxs("div",{className:"run_tree",children:[e.sections.length?null:e.connected?s.jsx("div",{className:"run_tree_empty",children:"No runs match the current filters."}):s.jsxs("div",{className:"run_tree_empty",children:["Gateway offline — runs are unavailable."," ",s.jsx("button",{className:"btn btn_sm",onClick:e.on_sign_in,children:"Sign in"})]}),e.sections.map(a=>s.jsxs("section",{className:"run_tree_section",children:[s.jsxs("div",{className:"run_tree_section_header",children:[s.jsx("span",{children:a.label}),s.jsx("span",{className:"mono",children:a.rows.length})]}),a.rows.map(c=>{const d=c.run,u=String(d.run_id||"").trim(),m=u===t;return s.jsxs("div",{className:"run_tree_group",children:[s.jsxs("button",{className:`run_tree_item ${m?"selected":""} ${u===n?"root_context":""}`,onClick:()=>e.on_select(u,u),title:u,children:[s.jsxs("div",{className:"run_tree_item_top",children:[s.jsx("span",{className:"run_tree_label",children:qs(d,e.workflow_label_by_id)}),s.jsx(Xa,{status:wm(d)})]}),s.jsxs("div",{className:"run_tree_meta",children:[s.jsx("span",{className:"mono",children:Mt(u,13)}),s.jsx("span",{children:Dl(d)?Zo(Dl(d)):"no start"}),s.jsx("span",{children:Gl(d)})]})]}),c.children.length?s.jsx("div",{className:"run_tree_children",children:c.children.map(y=>{const g=String(y.run_id||"").trim();return s.jsxs("button",{className:`run_tree_item run_tree_child ${g===t?"selected":""}`,onClick:()=>e.on_select(g,u),title:g,children:[s.jsxs("div",{className:"run_tree_item_top",children:[s.jsx("span",{className:"run_tree_label",children:qs(y,e.workflow_label_by_id)}),s.jsx(Xa,{status:wm(y)})]}),s.jsxs("div",{className:"run_tree_meta",children:[s.jsx("span",{className:"mono",children:Mt(g,13)}),s.jsx("span",{children:Dl(y)?Zo(Dl(y)):"child"}),s.jsx("span",{children:Gl(y)})]})]},g)})}):null]},u)})]},a.key))]})]})}function ng(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9L9.2 3.9A2 2 0 0 0 7.5 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function Qb(e){var L,M,W,q,z,Y,Q;const t=e.run_id.trim(),[n,o]=h.useState(!1);if(!t)return s.jsx("div",{className:"run_overview",children:s.jsx("div",{className:"empty_state_inline",style:{padding:"48px 24px",textAlign:"center"},children:"Select a run on the left to inspect it — or start one from Launch."})});const a=qs(e.run,e.workflow_label_by_id),c=Dl(e.run)||String(((L=e.run_state)==null?void 0:L.started_at)||((M=e.run_state)==null?void 0:M.created_at)||"").trim(),d=Wy(e.run)||(yi(e.status_label)?String(((W=e.run_state)==null?void 0:W.updated_at)||"").trim():""),u=e.run?Gl(e.run):c?H_((Sn(d)??Date.now())-(Sn(c)??Date.now())):"—",m=e.provider_activities.length,y=e.provider_activities.reduce((Z,ne)=>Z+(Number(ne.tokens.total)||0),0),g=e.provider_activities.filter(Z=>Z.missing_response||Z.error).length,v=String(((q=e.latest_summary)==null?void 0:q.text)||"").trim(),x=e.wait_state,b=yi(e.status_label),C=bm(e.run)||String(((z=e.run_state)==null?void 0:z.error)||"").trim();let S="";for(let Z=e.records.length-1;Z>=0;Z--){const ne=Yd((Y=e.records[Z])==null?void 0:Y.record);if(ne){S=ne;break}}return s.jsxs("div",{className:"run_overview",children:[s.jsxs("section",{className:"run_hero run_hero_line",children:[s.jsx("h2",{className:"run_hero_title",title:a,children:a}),s.jsx(Xa,{status:e.status_label}),t?s.jsx("span",{className:"chip mono muted",title:t,children:Mt(t,18)}):null,e.root_run_id&&e.root_run_id!==t?s.jsxs("span",{className:"chip mono muted",title:e.root_run_id,children:["root ",Mt(e.root_run_id,12)]}):null,s.jsx("span",{className:"run_hero_spacer"}),e.workspace_root?s.jsxs("button",{className:"btn btn_icon",onClick:e.on_reveal_workspace,title:`Open the run's workspace folder
102
+ ${e.workspace_root}`,children:[s.jsx(ng,{}),"Folder"]}):null,s.jsx("button",{className:"btn",onClick:e.on_generate_summary,disabled:!t||e.summary_generating,children:e.summary_generating?"Summarizing…":v?"Refresh summary":"Summarize"}),s.jsx("button",{className:"btn",onClick:e.on_open_runtime,title:"Open this run's artifacts in the System explorer",children:"Run artifacts"})]}),b?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Outcome"}),s.jsx("span",{className:`chip mono ${Ka(e.status_label)}`,children:e.status_label||(C?"failed":"completed")})]}),C?s.jsx("div",{className:"error_callout",children:C}):null,S?s.jsx(gi,{text:_t(S,{max_chars:4e3,max_lines:60})}):null,!C&&!S?s.jsx("div",{className:"empty_state_inline",children:"No final text output was recorded for this run — produced files, if any, live under Run artifacts (above)."}):null]}):null,(()=>{const Z=Array.isArray(e.run_artifacts)?e.run_artifacts:[],ne=E=>{const j=String((E!=null&&E.tags&&typeof E.tags=="object"?E.tags.source:"")||"").trim();return j==="run_store_offload"||j==="node_trace_offload"},ue=E=>{const j=E!=null&&E.tags&&typeof E.tags=="object"?E.tags:{},R=String((E==null?void 0:E.filename)||j.filename||"").trim();if(R)return R;const O=String(j.path||(E==null?void 0:E.source_path)||"").trim();return O?O.split("/").pop()||O:String((E==null?void 0:E.title)||"").trim()||String((E==null?void 0:E.artifact_id)||"").slice(0,14)},de=E=>{var j;return s.jsxs("div",{className:"run_artifact_row",children:[s.jsx("span",{className:"run_artifact_name",title:String(((j=E==null?void 0:E.tags)==null?void 0:j.path)||(E==null?void 0:E.source_path)||(E==null?void 0:E.artifact_id)||""),children:ue(E)}),s.jsx("span",{className:"chip mono muted",children:String((E==null?void 0:E.content_type)||"?").replace(/^application\//,"").replace(/^text\//,"")}),s.jsx("span",{className:"run_artifact_size",children:typeof(E==null?void 0:E.size_bytes)=="number"?`${(E.size_bytes/1024).toFixed(E.size_bytes>1e5?0:1)} kB`:""}),s.jsxs("span",{className:"run_artifact_actions",children:[s.jsx("button",{className:"btn",onClick:()=>e.on_preview_run_artifact(E),children:"Preview"}),s.jsx("button",{className:"btn",onClick:()=>e.on_download_run_artifact(E),children:"Download"})]})]},String((E==null?void 0:E.artifact_id)||Math.random()))},pe=Z.filter(E=>!ne(E)),D=Z.filter(ne);return s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Artifacts"}),s.jsx("span",{className:"mono muted",children:Z.length?Z.length.toLocaleString():""}),e.workspace_root?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pane_spacer"}),s.jsxs("button",{className:"btn btn_icon",onClick:e.on_reveal_workspace,title:`Open the run's workspace folder
103
+ ${e.workspace_root}`,children:[s.jsx(ng,{}),"Workspace"]})]}):null]}),e.run_artifacts_error?s.jsx("div",{className:"warn_callout",children:e.run_artifacts_error}):null,e.run_artifacts_loading&&!Z.length?s.jsx("div",{className:"empty_state_inline",children:"Loading artifacts…"}):null,!e.run_artifacts_loading&&!Z.length&&!e.run_artifacts_error?s.jsxs("div",{className:"empty_state_inline",children:["The runtime recorded no durable artifacts for this run.",e.workspace_root?" Files written to the workspace folder (if any) are reachable via the Folder button.":""]}):null,pe.length?s.jsx("div",{className:"run_artifact_list",children:pe.map(de)}):null,!pe.length&&Z.length?s.jsxs("div",{className:"empty_state_inline",children:["No file products — this run's durable artifacts are internal state offloads (below).",e.workspace_root?" Report files written to the workspace are reachable via the Folder button.":""]}):null,D.length?s.jsxs("details",{className:"runtime_raw_details",children:[s.jsxs("summary",{className:"muted",children:["Internal state offloads (",D.length,")"]}),s.jsx("div",{className:"run_artifact_list",children:D.map(de)})]}):null]})})(),s.jsxs("div",{className:"metric_grid",children:[s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Started"}),s.jsx("strong",{children:ea(c)})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:d?"Finished":"Running for"}),s.jsx("strong",{children:d?ea(d):u})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Total duration"}),s.jsx("strong",{children:u})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Ledger"}),s.jsx("strong",{children:(e.records_count+e.child_records_count).toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Subworkflows"}),s.jsx("strong",{children:e.subrun_ids.length.toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Provider calls"}),s.jsx("strong",{children:m.toLocaleString()})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Tokens"}),s.jsx("strong",{children:y?y.toLocaleString():"—"})]}),s.jsxs("div",{className:"metric_tile",children:[s.jsx("span",{children:"Assets"}),s.jsx("strong",{children:e.attachments_count.toLocaleString()})]})]}),s.jsxs("div",{className:"overview_columns",children:[s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:b?"What happened":"What is happening"}),x?s.jsx("span",{className:"chip mono info",children:"waiting"}):null]}),x?s.jsxs("div",{className:"overview_fact_list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Reason"}),s.jsx("strong",{children:String(x.reason||"unknown")})]}),x.wait_key?s.jsxs("div",{children:[s.jsx("span",{children:"Wait key"}),s.jsx("strong",{className:"mono",children:Mt(String(x.wait_key),34)})]}):null,(Q=x==null?void 0:x.details)!=null&&Q.sub_run_id?s.jsxs("div",{children:[s.jsx("span",{children:"Subworkflow"}),s.jsx("strong",{className:"mono",children:Mt(String(x.details.sub_run_id),24)})]}):null,x.prompt?s.jsxs("div",{children:[s.jsx("span",{children:"Prompt"}),s.jsx("strong",{children:_t(String(x.prompt),{max_chars:260,max_lines:3})})]}):null,e.on_answer_wait&&x.wait_key&&String(x.reason||"")==="user"?s.jsx("div",{className:"overview_fact_actions",children:s.jsx("button",{className:"btn primary",onClick:e.on_answer_wait,children:"Review & answer…"})}):null]}):(()=>{var E;const Z=e.timeline_items.length?e.timeline_items[e.timeline_items.length-1]:null,ne=(Z==null?void 0:Z.record)||null,ue=String((ne==null?void 0:ne.node_id)||"").trim(),de=ue&&e.node_index?e.node_index[ue]:null,pe=String((de==null?void 0:de.label)||ue||"").trim(),D=String(((E=ne==null?void 0:ne.effect)==null?void 0:E.type)||"").trim();return pe||D?s.jsxs("div",{className:"overview_fact_list",children:[pe?s.jsxs("div",{children:[s.jsx("span",{children:b?"Ended at":"Last step"}),s.jsx("strong",{children:pe})]}):null,D?s.jsxs("div",{children:[s.jsx("span",{children:"Effect"}),s.jsx("strong",{className:"mono",children:D})]}):null]}):s.jsx("div",{className:"empty_state_inline",children:b?"Nothing in flight — the run is finished.":"No active wait is reported for this run."})})(),g?s.jsxs("div",{className:"warn_callout",children:[g," provider call(s) have missing responses or errors."]}):null]}),s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Summary"}),e.latest_summary?s.jsx("span",{className:"chip mono ok",children:"saved"}):s.jsx("span",{className:"chip mono muted",children:"none"})]}),e.summary_error?s.jsx("div",{className:"warn_callout",children:e.summary_error}):null,v?s.jsx(gi,{text:v}):s.jsx("div",{className:"empty_state_inline",children:"Generate a grounded summary from the root run and its subflows."})]})]}),e.subrun_ids.length?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Subworkflows"}),s.jsx("span",{className:"mono muted",children:e.subrun_ids.length})]}),s.jsx("div",{className:"subrun_chip_list",children:e.subrun_ids.map(Z=>s.jsx("button",{className:"subrun_chip mono",onClick:()=>e.on_open_subrun(Z),title:Z,children:Mt(Z,22)},Z))})]}):null,e.attachments.length||e.session_id?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Session files"}),s.jsx("span",{className:"mono muted",children:e.attachments.length?`${e.attachments.length} file${e.attachments.length===1?"":"s"}`:""}),s.jsx("button",{className:"btn btn_sm",onClick:e.on_refresh_attachments,disabled:e.attachments_loading||!e.session_id,children:e.attachments_loading?"Refreshing…":"Refresh"})]}),e.attachments_error?s.jsx("div",{className:"warn_callout",children:e.attachments_error}):null,e.attachments.length?s.jsx("div",{className:"produced_list",children:e.attachments.map(Z=>{const ne=String((Z==null?void 0:Z.artifact_id)||"").trim();if(!ne)return null;const ue=Z!=null&&Z.tags&&typeof Z.tags=="object"?Z.tags:{},de=String((ue==null?void 0:ue.path)||"").trim()?`@${String(ue.path).trim()}`:String((ue==null?void 0:ue.filename)||"").trim()||ne,pe=typeof(Z==null?void 0:Z.size_bytes)=="number"?Number(Z.size_bytes):null,D=e.attachments_loading||!e.attachments_ready;return s.jsxs("div",{className:"produced_row",children:[s.jsx("span",{className:"produced_name mono",title:ne,children:de}),s.jsx("span",{className:"mono muted",children:pe!==null?`${pe.toLocaleString()} B`:""}),s.jsxs("span",{className:"produced_actions",children:[s.jsx("button",{className:"btn btn_sm",onClick:()=>e.on_preview_attachment(Z),disabled:D,children:"Preview"}),s.jsx("button",{className:"btn btn_sm",onClick:()=>e.on_download_attachment(Z),disabled:D,children:"Download"})]})]},ne)})}):s.jsx("div",{className:"empty_state_inline",children:b?"No files were attached to this run's session.":"No files in this run's session yet."})]}):null,e.timeline_items.length?s.jsxs("section",{className:"overview_panel",children:[s.jsxs("div",{className:"overview_panel_header",children:[s.jsx("h3",{children:"Chronology"}),s.jsx("span",{className:"mono muted",children:n||e.timeline_items.length<=Xf?`${e.timeline_items.length} steps`:`last ${Xf} of ${e.timeline_items.length} steps`}),e.timeline_items.length>Xf?s.jsx("button",{className:"btn btn_sm",onClick:()=>o(Z=>!Z),children:n?"Show fewer":"Show all"}):null]}),s.jsx(eS,{items:n?e.timeline_items:e.timeline_items.slice(-Xf),node_index:e.node_index,workflow_label_by_id:e.workflow_label_by_id,on_copy:e.on_copy})]}):null]})}function eS(e){const t=n=>{var M,W;const o=n,a=n.record||{},c=String(((M=a==null?void 0:a.effect)==null?void 0:M.type)||o.effect_type||"").trim(),d=String((a==null?void 0:a.status)||o.status||"").trim(),u=String((a==null?void 0:a.node_id)||o.node_id||"").trim(),m=u&&e.node_index?e.node_index[u]:null,y=String((m==null?void 0:m.label)||u||o.title||"Step").trim(),g=Vi(a),v=(W=a==null?void 0:a.effect)==null?void 0:W.payload,x=a==null?void 0:a.result,b=Yd(a),C=c?jr(v??{},900):_t(String(o.preview||""),{max_chars:900,max_lines:8}),S=b||(g?`Waiting for ${String(g.reason||"input")}${g.wait_key?` (${Mt(String(g.wait_key),18)})`:""}`:"")||(x!==void 0?jr(x,900):"");return{title:c==="llm_call"?"Model call":c==="tool_calls"?"Tool execution":c==="answer_user"?"User-facing response":c==="start_subworkflow"?"Subworkflow launched":c==="ask_user"?"User input requested":c||o.title||"Ledger event",subtitle:y,request:_t(C,{max_chars:900,max_lines:7}),outcome:_t(S,{max_chars:1100,max_lines:9}),cls:Ka(d)}};return s.jsxs("div",{className:"human_timeline",children:[e.items.length?null:s.jsx("div",{className:"empty_state_inline",children:"No ledger records yet."}),e.items.map(n=>{const o=n.record||{},a=t(n),c=String(o.ended_at||o.started_at||n.ts||"").trim();return s.jsxs("article",{className:`timeline_event ${a.cls}`,children:[s.jsx("div",{className:"timeline_marker"}),s.jsxs("div",{className:"timeline_event_body",children:[s.jsxs("div",{className:"timeline_event_header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:a.title}),s.jsxs("div",{className:"timeline_subtitle",children:[s.jsx("span",{children:a.subtitle}),n.run_id?s.jsx("span",{className:"mono",children:Mt(String(n.run_id),13)}):null]})]}),s.jsxs("div",{className:"timeline_time",children:[s.jsx("span",{children:Zo(c)}),s.jsx("span",{className:"mono",title:c,children:ea(c)})]})]}),s.jsxs("div",{className:"timeline_payload_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Requested"}),s.jsx("p",{className:"mono",children:a.request||"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Outcome"}),s.jsx("p",{children:a.outcome||"—"})]})]}),s.jsx("div",{className:"timeline_actions",children:s.jsxs("button",{className:"btn btn_icon",onClick:()=>e.on_copy(JSON.stringify(o,null,2)),children:[s.jsx(zn,{name:"copy",size:14}),"JSON"]})})]})]},`${String(n.run_id||o.run_id||"")}:${n.cursor}`)})]})}function tS(e){const t=e.item,n=String(t.node_id||"").trim(),o=n&&e.node_index&&typeof e.node_index=="object"?e.node_index[n]:null,a=typeof(o==null?void 0:o.label)=="string"&&o.label.trim()?o.label.trim():n||t.title,c=typeof(o==null?void 0:o.type)=="string"&&o.type.trim()?o.type.trim():"",d=typeof(o==null?void 0:o.headerColor)=="string"&&o.headerColor.trim()?o.headerColor.trim():"",u=t.kind==="step"?a:t.title,m=d||(t.kind==="error"?"rgba(239, 68, 68, 0.85)":t.kind==="message"?"rgba(167, 139, 250, 0.85)":t.kind==="event"?"rgba(96, 165, 250, 0.85)":t.status==="waiting"?"rgba(96, 165, 250, 0.65)":t.status==="completed"?"rgba(34, 197, 94, 0.65)":"rgba(255, 255, 255, 0.14)"),y=String(t.status||"").trim(),g=y.toLowerCase(),v=Ka(g),x=Yd(t.data),b=!!(x&&x.trim()),C=Zo(t.ts);return s.jsxs("div",{className:`lc ${v}`,style:{"--lc-accent":m},children:[s.jsxs("div",{className:"lc_header",children:[s.jsx("span",{className:"lc_title",children:u}),s.jsxs("div",{className:"lc_header_right",children:[y?s.jsx("span",{className:`lc_status ${v}`,children:y}):null,s.jsx("span",{className:"lc_time",title:t.ts,children:C})]})]}),s.jsxs("div",{className:"lc_meta",children:[c?s.jsx("span",{className:"lc_chip",children:c}):null,t.effect_type?s.jsx("span",{className:"lc_chip",children:String(t.effect_type)}):null,t.cursor?s.jsxs("span",{className:"lc_chip",children:["#",t.cursor]}):null,t.run_id?s.jsx("span",{className:"lc_chip",children:Mt(String(t.run_id),10)}):null,t.kind!=="step"&&n?s.jsx("span",{className:"lc_chip",children:n}):null]}),t.preview?s.jsx("div",{className:"lc_preview",children:t.preview}):null,t.data?s.jsxs("div",{className:"lc_actions",children:[b?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"lc_btn",onClick:e.on_toggle_response,children:e.response_open?"Fold Response":"Unfold Response"}),s.jsx("button",{className:"lc_btn",onClick:()=>e.on_copy(String(x||"")),children:"Copy Response"})]}):null,s.jsx("button",{className:"lc_btn",onClick:e.on_toggle,children:e.open?"Fold JSON":"Unfold JSON"}),s.jsx("button",{className:"lc_btn",onClick:()=>{try{e.on_copy(JSON.stringify(t.data,null,2))}catch{e.on_copy(String(t.data))}},children:"Copy JSON"})]}):null,e.response_open&&b?s.jsx("div",{className:"lc_body",children:s.jsx(gi,{text:String(x||"")})}):null,e.open&&t.data?s.jsx("div",{className:"lc_body lc_body_json mono",children:s.jsx(os,{value:t.data,collapseAfterDepth:3,showCopy:!1})}):null]})}class nS{constructor(){Da(this,"_buffer","");Da(this,"_current",{data_lines:[]})}push(t,n){for(this._buffer+=t;;){const o=this._buffer.indexOf(`
104
+ `);if(o===-1)return;const a=this._buffer.slice(0,o);this._buffer=this._buffer.slice(o+1);const c=a.endsWith("\r")?a.slice(0,-1):a;if(c.startsWith(":"))continue;if(c===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const y={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
105
+ `)};n(y)}this._current={data_lines:[]};continue}const d=c.indexOf(":"),u=d===-1?c:c.slice(0,d),m=d===-1?"":c.slice(d+1).trimStart();if(u==="id"){this._current.id=m;continue}if(u==="event"){this._current.event=m;continue}if(u==="data"){this._current.data_lines.push(m);continue}}}}function zt(e,t){const n=(e||"").trim().replace(/\/+$/,"");return n?`${n}${t}`:t}function ho(e,t=3e4){const n=AbortSignal.timeout(t);if(!e)return n;const o=AbortSignal.any;return typeof o=="function"?o([e,n]):e}function It(e){var o;const t=(e||"").trim(),n={};t&&(n.Authorization=`Bearer ${t}`);try{const a=(o=document.cookie.split(";").map(c=>c.trim()).find(c=>c.startsWith("abstractobserver_gateway_csrf=")))==null?void 0:o.slice(30);a&&(n["X-AbstractObserver-CSRF"]=decodeURIComponent(a))}catch{}return n}async function qn(e){try{const t=await e.text();return t!=null&&t.trim()?t.trim():`${e.status}`}catch{return`${e.status}`}}class Rh{constructor(t){Da(this,"_cfg");this._cfg={...t,base_url:(t.base_url||"").trim()}}async start_run(t,n,o){const a=String((o==null?void 0:o.bundle_id)||"").trim(),c=(o==null?void 0:o.session_id)===null||(o==null?void 0:o.session_id)===void 0?"":String(o.session_id||"").trim(),d=String(t||"").trim(),u={input_data:n||{}};a&&(u.bundle_id=a),d&&(u.flow_id=d),c&&(u.session_id=c);const m=await fetch(zt(this._cfg.base_url,"/api/gateway/runs/start"),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(u)});if(!m.ok)throw new Error(`start_run failed: ${m.status}`);const y=await m.json(),g=y==null?void 0:y.run_id;if(typeof g!="string"||!g)throw new Error("start_run: missing run_id");return g}async schedule_run(t){const n=String((t==null?void 0:t.bundle_id)||"").trim(),o=String((t==null?void 0:t.flow_id)||"").trim();if(!n)throw new Error("schedule_run: bundle_id is required");if(!o)throw new Error("schedule_run: flow_id is required");const a={bundle_id:n,flow_id:o,input_data:(t==null?void 0:t.input_data)||{}},c=(t==null?void 0:t.start_at)===null||(t==null?void 0:t.start_at)===void 0?"":String(t.start_at||"").trim();c&&(a.start_at=c);const d=(t==null?void 0:t.interval)===null||(t==null?void 0:t.interval)===void 0?"":String(t.interval||"").trim();d&&(a.interval=d),typeof(t==null?void 0:t.repeat_count)=="number"&&Number.isFinite(t.repeat_count)&&(a.repeat_count=Number(t.repeat_count));const u=(t==null?void 0:t.repeat_until)===null||(t==null?void 0:t.repeat_until)===void 0?"":String(t.repeat_until||"").trim();u&&(a.repeat_until=u),typeof(t==null?void 0:t.share_context)=="boolean"&&(a.share_context=!!t.share_context);const m=(t==null?void 0:t.session_id)===null||(t==null?void 0:t.session_id)===void 0?"":String(t.session_id||"").trim();m&&(a.session_id=m);const y=await fetch(zt(this._cfg.base_url,"/api/gateway/runs/schedule"),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(a)});if(!y.ok)throw new Error(`schedule_run failed: ${y.status}`);const g=await y.json(),v=g==null?void 0:g.run_id;if(typeof v!="string"||!v)throw new Error("schedule_run: missing run_id");return v}async list_mcp_servers(){for(const t of["/api/gateway/mcp/servers","/api/gateway/mcp","/api/gateway/discovery/mcp"])try{const n=await fetch(zt(this._cfg.base_url,t),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(n.status===404||!n.ok)continue;const o=await n.json(),a=Array.isArray(o)?o:Array.isArray(o==null?void 0:o.servers)?o.servers:Array.isArray(o==null?void 0:o.items)?o.items:null;if(!a)continue;return a.map(c=>({name:String((c==null?void 0:c.name)||(c==null?void 0:c.id)||"").trim(),url:typeof(c==null?void 0:c.url)=="string"?c.url:void 0,description:typeof(c==null?void 0:c.description)=="string"?c.description:void 0,auth_required:typeof(c==null?void 0:c.auth_required)=="boolean"?c.auth_required:void 0})).filter(c=>c.name)}catch{return null}return null}async list_skills(){for(const t of["/api/gateway/skills","/api/gateway/skills/registry"])try{const n=await fetch(zt(this._cfg.base_url,t),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(n.status===404||!n.ok)continue;const o=await n.json(),a=Array.isArray(o)?o:Array.isArray(o==null?void 0:o.skills)?o.skills:Array.isArray(o==null?void 0:o.items)?o.items:null;if(!a)continue;return a.map(c=>({name:String((c==null?void 0:c.name)||(c==null?void 0:c.id)||"").trim(),description:typeof(c==null?void 0:c.description)=="string"?c.description:void 0,version:typeof(c==null?void 0:c.version)=="string"?c.version:void 0,trust_level:typeof(c==null?void 0:c.trust_level)=="string"?c.trust_level:void 0,blocked:typeof(c==null?void 0:c.blocked)=="boolean"?c.blocked:void 0,requires_review:typeof(c==null?void 0:c.requires_review)=="boolean"?c.requires_review:void 0,tree_hash:typeof(c==null?void 0:c.tree_hash)=="string"?c.tree_hash:void 0,reasons:Array.isArray(c==null?void 0:c.reasons)?c.reasons.map(d=>String(d||"")).filter(Boolean):void 0})).filter(c=>c.name)}catch{return null}return null}async get_run(t){const n=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}`),{headers:{...It(this._cfg.auth_token)}});if(!n.ok)throw new Error(`get_run failed: ${await qn(n)}`);return await n.json()}async get_run_history_bundle(t,n){const o=String(t||"").trim();if(!o)throw new Error("get_run_history_bundle: run_id is required");const a=new URLSearchParams;(n==null?void 0:n.include_subruns)===!1&&a.set("include_subruns","false"),(n==null?void 0:n.include_session)===!0&&a.set("include_session","true"),typeof(n==null?void 0:n.session_turn_limit)=="number"&&Number.isFinite(n.session_turn_limit)&&a.set("session_turn_limit",String(Math.max(1,Math.trunc(n.session_turn_limit)))),n!=null&&n.ledger_mode&&a.set("ledger_mode",String(n.ledger_mode)),typeof(n==null?void 0:n.ledger_max_items)=="number"&&Number.isFinite(n.ledger_max_items)&&a.set("ledger_max_items",String(Math.max(0,Math.trunc(n.ledger_max_items))));const c=zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/history_bundle?${a.toString()}`),d=await fetch(c,{headers:{...It(this._cfg.auth_token)}});if(!d.ok)throw new Error(`get_run_history_bundle failed: ${await qn(d)}`);return await d.json()}async list_runs(t){const n=typeof(t==null?void 0:t.limit)=="number"?t.limit:50,o=String((t==null?void 0:t.status)||"").trim(),a=String((t==null?void 0:t.workflow_id)||"").trim(),c=String((t==null?void 0:t.session_id)||"").trim(),d=(t==null?void 0:t.root_only)===!0,u=new URLSearchParams;u.set("limit",String(n)),o&&u.set("status",o),a&&u.set("workflow_id",a),c&&u.set("session_id",c),d&&u.set("root_only","true"),typeof(t==null?void 0:t.include_ledger_len)=="boolean"&&u.set("include_ledger_len",String(t.include_ledger_len)),typeof(t==null?void 0:t.include_metrics)=="boolean"&&u.set("include_metrics",String(t.include_metrics)),typeof(t==null?void 0:t.include_drafts)=="boolean"&&u.set("include_drafts",String(t.include_drafts));const m=zt(this._cfg.base_url,`/api/gateway/runs?${u.toString()}`),y=await fetch(m,{headers:{...It(this._cfg.auth_token)},signal:AbortSignal.timeout(3e4)});if(!y.ok)throw new Error(`list_runs failed: ${await qn(y)}`);return await y.json()}async audit_log_tail(t){const n=typeof(t==null?void 0:t.max_bytes)=="number"?Math.max(1024,Math.min(4e5,Math.floor(t.max_bytes))):8e4,o=zt(this._cfg.base_url,`/api/gateway/audit/tail?max_bytes=${encodeURIComponent(String(n))}`),a=await fetch(o,{headers:{...It(this._cfg.auth_token)}});if(!a.ok)throw new Error(`audit_log_tail failed: ${await qn(a)}`);return await a.json()}async get_run_input_data(t){const n=String(t||"").trim();if(!n)throw new Error("get_run_input_data: run_id is required");const o=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(n)}/input_data`),{headers:{...It(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_run_input_data failed: ${await qn(o)}`);return await o.json()}async list_run_artifacts(t,n){const o=String(t||"").trim();if(!o)throw new Error("list_run_artifacts: run_id is required");const a=typeof(n==null?void 0:n.limit)=="number"?n.limit:200,c=typeof(n==null?void 0:n.offset)=="number"?Math.max(0,Math.floor(n.offset)):0,d=zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/artifacts?limit=${encodeURIComponent(String(a))}&offset=${encodeURIComponent(String(c))}`),u=await fetch(d,{headers:{...It(this._cfg.auth_token)}});if(!u.ok)throw new Error(`list_run_artifacts failed: ${await qn(u)}`);return await u.json()}async list_session_artifacts(t,n){const o=String(t||"").trim();if(!o)throw new Error("list_session_artifacts: session_id is required");const a=typeof(n==null?void 0:n.limit)=="number"?n.limit:200,c=typeof(n==null?void 0:n.offset)=="number"?Math.max(0,Math.floor(n.offset)):0,d=zt(this._cfg.base_url,`/api/gateway/sessions/${encodeURIComponent(o)}/artifacts?limit=${encodeURIComponent(String(a))}&offset=${encodeURIComponent(String(c))}`),u=await fetch(d,{headers:{...It(this._cfg.auth_token)}});if(!u.ok)throw new Error(`list_session_artifacts failed: ${await qn(u)}`);return await u.json()}async search_artifacts(t){const n=new URLSearchParams;n.set("scope",String((t==null?void 0:t.scope)||"all").trim()||"all");const o=String((t==null?void 0:t.session_id)||"").trim(),a=String((t==null?void 0:t.run_id)||"").trim(),c=String((t==null?void 0:t.modality)||"").trim(),d=String((t==null?void 0:t.artifact_kind)||"").trim(),u=String((t==null?void 0:t.semantic_kind)||"").trim(),m=String((t==null?void 0:t.render_kind)||"").trim(),y=String((t==null?void 0:t.workflow_id)||"").trim(),g=String((t==null?void 0:t.node_id)||"").trim(),v=String((t==null?void 0:t.content_type)||"").trim(),x=String((t==null?void 0:t.query)||"").trim(),b=String((t==null?void 0:t.tags)||"").trim(),C=String((t==null?void 0:t.cursor)||"").trim(),S=String((t==null?void 0:t.order_by)||"").trim(),L=String((t==null?void 0:t.order)||"").trim(),M=String((t==null?void 0:t.created_after)||"").trim(),W=String((t==null?void 0:t.created_before)||"").trim(),q=typeof(t==null?void 0:t.limit)=="number"?t.limit:500,z=typeof(t==null?void 0:t.offset)=="number"?Math.max(0,Math.floor(t.offset)):0;o&&n.set("session_id",o),a&&n.set("run_id",a),c&&n.set("modality",c),d&&n.set("artifact_kind",d),u&&n.set("semantic_kind",u),m&&n.set("render_kind",m),y&&n.set("workflow_id",y),g&&n.set("node_id",g),v&&n.set("content_type",v),x&&n.set("query",x),b&&n.set("tags",b),C&&n.set("cursor",C),S&&n.set("order_by",S),L&&n.set("order",L),M&&n.set("created_after",M),W&&n.set("created_before",W),t!=null&&t.include_stats&&n.set("include_stats","true"),n.set("limit",String(q)),n.set("offset",String(z));const Y=await fetch(zt(this._cfg.base_url,`/api/gateway/artifacts/search?${n.toString()}`),{headers:{...It(this._cfg.auth_token)}});if(!Y.ok)throw new Error(`search_artifacts failed: ${await qn(Y)}`);return await Y.json()}async artifact_stats(t){const n=new URLSearchParams;n.set("scope",String((t==null?void 0:t.scope)||"all").trim()||"all");for(const a of["session_id","run_id","modality","semantic_kind","render_kind","workflow_id","node_id","content_type","query","tags","created_after","created_before"]){const c=String((t==null?void 0:t[a])||"").trim();c&&n.set(a,c)}const o=await fetch(zt(this._cfg.base_url,`/api/gateway/artifacts/stats?${n.toString()}`),{headers:{...It(this._cfg.auth_token)}});if(!o.ok)throw new Error(`artifact_stats failed: ${await qn(o)}`);return await o.json()}async download_run_artifact_content(t,n,o){const a=String(t||"").trim(),c=String(n||"").trim();if(!a)throw new Error("download_run_artifact_content: run_id is required");if(!c)throw new Error("download_run_artifact_content: artifact_id is required");const d=String((o==null?void 0:o.access)||"").trim(),u=d?`?access=${encodeURIComponent(d)}`:"",m=zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/artifacts/${encodeURIComponent(c)}/content${u}`),y=await fetch(m,{headers:{...It(this._cfg.auth_token)}});if(!y.ok)throw new Error(`download_run_artifact_content failed: ${await qn(y)}`);return await y.blob()}async list_entities(){const t=await fetch(zt(this._cfg.base_url,"/api/gateway/entities"),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!t.ok)throw new Error(`list_entities failed: ${await qn(t)}`);const n=await t.json();return{entities:Array.isArray(n==null?void 0:n.entities)?n.entities:[]}}async get_entity_phases_spec(){const t=await fetch(zt(this._cfg.base_url,"/api/gateway/entities/spec/phases"),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!t.ok)throw new Error(`get_entity_phases_spec failed: ${await qn(t)}`);return await t.json()}async get_entity_cognition(t){const n=await fetch(zt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(t)}/cognition`),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!n.ok)throw new Error(`get_entity_cognition failed: ${await qn(n)}`);return await n.json()}async get_entity_card(t){const n=String(t||"").trim();if(!n)throw new Error("get_entity_card: name is required");const o=await fetch(zt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(n)}/card`),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!o.ok)throw new Error(`get_entity_card failed: ${await qn(o)}`);return await o.json()}async read_entity_diary_entry(t,n){const o=String(t||"").trim(),a=String(n||"").trim();if(!o||!a)throw new Error("read_entity_diary_entry: name and entry_id are required");const c=zt(this._cfg.base_url,`/api/gateway/entities/${encodeURIComponent(o)}/diary/${encodeURIComponent(a)}?reason=${encodeURIComponent("observer board hint chip")}`),d=await fetch(c,{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!d.ok)throw new Error(`read_entity_diary_entry failed: ${await qn(d)}`);return await d.json()}async get_ledger(t,n){const o=Number((n==null?void 0:n.after)||0),a=Number((n==null?void 0:n.limit)||0),c=zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger?after=${encodeURIComponent(String(o))}&limit=${encodeURIComponent(String(a))}`),d=await fetch(c,{headers:{...It(this._cfg.auth_token)},signal:ho(n==null?void 0:n.signal)});if(!d.ok)throw new Error(`get_ledger failed: ${d.status}`);const u=await d.json(),m=Array.isArray(u==null?void 0:u.items)?u.items:[],y=typeof(u==null?void 0:u.next_after)=="number"?u.next_after:o;return{items:m,next_after:y}}async get_ledger_batch(t){const n=Array.isArray(t==null?void 0:t.runs)?t.runs:[],o=Number((t==null?void 0:t.limit)||0),a=await fetch(zt(this._cfg.base_url,"/api/gateway/runs/ledger/batch"),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify({runs:n,limit:o}),signal:ho()});if(!a.ok)throw new Error(`get_ledger_batch failed: ${a.status}`);const c=await a.json(),u=(c&&typeof c=="object"?c:{}).runs;return{runs:u&&typeof u=="object"?u:{}}}async generate_run_summary(t,n){const o=String(t||"").trim();if(!o)throw new Error("generate_run_summary: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1},c=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";c&&(a.provider=c);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/summary`),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(a)});if(!u.ok)throw new Error(`generate_run_summary failed: ${u.status}`);return await u.json()}async run_chat(t,n){const o=String(t||"").trim();if(!o)throw new Error("run_chat: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[],persist:!!(n!=null&&n.persist)},c=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";c&&(a.provider=c);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat`),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(a)});if(!u.ok)throw new Error(`run_chat failed: ${u.status}`);return await u.json()}async audio_transcribe(t,n){const o=String(t||"").trim();if(!o)throw new Error("audio_transcribe: run_id is required");const a=n==null?void 0:n.audio_artifact;if(!a||typeof a!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(a.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const d={audio_artifact:a},u=String((n==null?void 0:n.language)||"").trim();u&&(d.language=u);const m=String((n==null?void 0:n.request_id)||"").trim();m&&(d.request_id=m);const y=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/audio/transcribe`),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(d)});if(!y.ok)throw new Error(`audio_transcribe failed: ${await qn(y)}`);const g=await y.json(),v=String((g==null?void 0:g.text)||"");return{ok:!!(g!=null&&g.ok),run_id:String((g==null?void 0:g.run_id)||""),request_id:String((g==null?void 0:g.request_id)||""),text:v,transcript_artifact:g==null?void 0:g.transcript_artifact}}async voice_tts(t,n){const o=String(t||"").trim();if(!o)throw new Error("voice_tts: run_id is required");const a=String((n==null?void 0:n.text)||"").trim();if(!a)throw new Error("voice_tts: text is required");const c={text:a},d=String((n==null?void 0:n.voice)||"").trim();d&&(c.voice=d);const u=String((n==null?void 0:n.format)||"").trim();u&&(c.format=u);const m=String((n==null?void 0:n.request_id)||"").trim();m&&(c.request_id=m);const y=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/voice/tts`),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(c)});if(!y.ok)throw new Error(`voice_tts failed: ${await qn(y)}`);const g=await y.json();return{ok:!!(g!=null&&g.ok),run_id:String((g==null?void 0:g.run_id)||""),request_id:String((g==null?void 0:g.request_id)||""),audio_artifact:g==null?void 0:g.audio_artifact}}async save_chat_thread(t,n){const o=String(t||"").trim();if(!o)throw new Error("save_chat_thread: run_id is required");const a={include_subruns:(n==null?void 0:n.include_subruns)!==!1,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},c=typeof(n==null?void 0:n.provider)=="string"?String(n.provider).trim():"";c&&(a.provider=c);const d=typeof(n==null?void 0:n.model)=="string"?String(n.model).trim():"";d&&(a.model=d);const u=typeof(n==null?void 0:n.title)=="string"?String(n.title).trim():"";u&&(a.title=u);const m=await fetch(zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(o)}/chat_threads`),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(a)});if(!m.ok)throw new Error(`save_chat_thread failed: ${await qn(m)}`);return await m.json()}async list_bundles(){const t=await fetch(zt(this._cfg.base_url,"/api/gateway/bundles"),{headers:{...It(this._cfg.auth_token)},signal:ho()});if(!t.ok)throw new Error(`list_bundles failed: ${t.status}`);return await t.json()}async reload_bundles(){const t=await fetch(zt(this._cfg.base_url,"/api/gateway/bundles/reload"),{method:"POST",headers:{...It(this._cfg.auth_token)}});if(!t.ok)throw new Error(`reload_bundles failed: ${t.status}`);return await t.json()}async upload_bundle(t,n){const o=(n==null?void 0:n.overwrite)===!0,a=(n==null?void 0:n.reload)!==!1,c=new FormData;c.set("overwrite",o?"true":"false"),c.set("reload",a?"true":"false"),c.set("file",t,t.name||"upload.flow");const d=await fetch(zt(this._cfg.base_url,"/api/gateway/bundles/upload"),{method:"POST",headers:{...It(this._cfg.auth_token)},body:c});if(!d.ok)throw new Error(`upload_bundle failed: ${await qn(d)}`);return await d.json()}async attachments_upload(t,n,o){const a=String(t||"").trim();if(!a)throw new Error("attachments_upload: session_id is required");if(!n)throw new Error("attachments_upload: file is required");const c=String((o==null?void 0:o.filename)||"").trim()||String((n==null?void 0:n.name)||"").trim()||"upload.bin",d=String((o==null?void 0:o.content_type)||"").trim()||String((n==null?void 0:n.type)||"").trim(),u=new FormData;u.append("session_id",a),u.append("file",n,c),u.append("filename",c),d&&u.append("content_type",d);const m=await fetch(zt(this._cfg.base_url,"/api/gateway/attachments/upload"),{method:"POST",headers:{...It(this._cfg.auth_token)},body:u});if(!m.ok)throw new Error(`attachments_upload failed: ${await qn(m)}`);const y=await m.json(),g=y==null?void 0:y.attachment;if(!g||typeof g!="object")throw new Error("attachments_upload: missing attachment");if(!String(g.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return g}async remove_bundle(t,n){const o=String(t||"").trim();if(!o)throw new Error("remove_bundle: bundle_id is required");const a=new URLSearchParams,c=String((n==null?void 0:n.bundle_version)||"").trim();c&&a.set("bundle_version",c),a.set("reload",(n==null?void 0:n.reload)===!1?"false":"true");const d=zt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}?${a.toString()}`),u=await fetch(d,{method:"DELETE",headers:{...It(this._cfg.auth_token)}});if(!u.ok)throw new Error(`remove_bundle failed: ${await qn(u)}`);return await u.json()}async discovery_tools(){const t=await fetch(zt(this._cfg.base_url,"/api/gateway/discovery/tools"),{headers:{...It(this._cfg.auth_token)}});if(!t.ok)throw new Error(`discovery_tools failed: ${t.status}`);return await t.json()}async discovery_providers(t){const n=(t==null?void 0:t.include_models)===!0,o=zt(this._cfg.base_url,`/api/gateway/discovery/providers?include_models=${encodeURIComponent(String(n))}`),a=await fetch(o,{headers:{...It(this._cfg.auth_token)}});if(!a.ok)throw new Error(`discovery_providers failed: ${a.status}`);return await a.json()}async discovery_provider_models(t){const n=String(t||"").trim();if(!n)throw new Error("discovery_provider_models: provider_name is required");const o=await fetch(zt(this._cfg.base_url,`/api/gateway/discovery/providers/${encodeURIComponent(n)}/models`),{headers:{...It(this._cfg.auth_token)}});if(!o.ok)throw new Error(`discovery_provider_models failed: ${o.status}`);return await o.json()}async get_bundle(t){const n=String(t||"").trim();if(!n)throw new Error("get_bundle: bundle_id is required");const o=await fetch(zt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(n)}`),{headers:{...It(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_bundle failed: ${o.status}`);return await o.json()}async get_bundle_flow(t,n){const o=String(t||"").trim(),a=String(n||"").trim();if(!o)throw new Error("get_bundle_flow: bundle_id is required");if(!a)throw new Error("get_bundle_flow: flow_id is required");const c=await fetch(zt(this._cfg.base_url,`/api/gateway/bundles/${encodeURIComponent(o)}/flows/${encodeURIComponent(a)}`),{headers:{...It(this._cfg.auth_token)}});if(!c.ok)throw new Error(`get_bundle_flow failed: ${c.status}`);return await c.json()}async get_workflow_flow(t){const n=String(t||"").trim();if(!n)throw new Error("get_workflow_flow: workflow_id is required");const o=await fetch(zt(this._cfg.base_url,`/api/gateway/workflows/${encodeURIComponent(n)}/flow`),{headers:{...It(this._cfg.auth_token)}});if(!o.ok)throw new Error(`get_workflow_flow failed: ${o.status}`);return await o.json()}async submit_command(t){const n=await fetch(zt(this._cfg.base_url,"/api/gateway/commands"),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(t)});if(!n.ok)throw new Error(`submit_command failed: ${n.status}`);return await n.json()}async kg_query(t){const n=String((t==null?void 0:t.scope)||"session").trim().toLowerCase(),o=String((t==null?void 0:t.order)||"desc").trim().toLowerCase(),a=typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?Number(t.limit):500,c={scope:n,order:o,limit:a},d=String((t==null?void 0:t.run_id)||"").trim();d&&(c.run_id=d);const u=String((t==null?void 0:t.session_id)||"").trim();u&&(c.session_id=u);const m=String((t==null?void 0:t.owner_id)||"").trim();m&&(c.owner_id=m),t!=null&&t.all_owners&&(c.all_owners=!0);const y=String((t==null?void 0:t.subject)||"").trim();y&&(c.subject=y);const g=String((t==null?void 0:t.predicate)||"").trim();g&&(c.predicate=g);const v=String((t==null?void 0:t.object)||"").trim();v&&(c.object=v);const x=String((t==null?void 0:t.since)||"").trim();x&&(c.since=x);const b=String((t==null?void 0:t.until)||"").trim();b&&(c.until=b);const C=String((t==null?void 0:t.active_at)||"").trim();C&&(c.active_at=C);const S=String((t==null?void 0:t.query_text)||"").trim();S&&(c.query_text=S),typeof(t==null?void 0:t.min_score)=="number"&&Number.isFinite(t.min_score)&&(c.min_score=Number(t.min_score));const L=await fetch(zt(this._cfg.base_url,"/api/gateway/kg/query"),{method:"POST",headers:{"Content-Type":"application/json",...It(this._cfg.auth_token)},body:JSON.stringify(c)});if(!L.ok)throw new Error(`kg_query failed: ${await qn(L)}`);return await L.json()}async stream_ledger(t,n){const o=Number((n==null?void 0:n.after)||0),a=n.on_step,c=n.signal,d=zt(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(t)}/ledger/stream?after=${encodeURIComponent(String(o))}`),u=await fetch(d,{headers:{Accept:"text/event-stream",...It(this._cfg.auth_token)},signal:c});if(!u.ok)throw new Error(`stream_ledger failed: ${u.status}`);if(!u.body)throw new Error("stream_ledger: response body is missing");const m=u.body.getReader(),y=new TextDecoder("utf-8"),g=new nS;for(;;){const{value:v,done:x}=await m.read();if(x)return;const b=y.decode(v,{stream:!0});g.push(b,C=>{if(!(C.event!=="step"||!C.data))try{const S=JSON.parse(C.data);S&&typeof S.cursor=="number"&&S.record&&a(S)}catch{}})}}}function ss(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}function rS(e){const t=(e||"").trim();return t?{Authorization:`Bearer ${t}`}:{}}class sS{constructor(t){Da(this,"_cfg");this._cfg={...t,url:(t.url||"").trim()}}async call_tool(t){const n=String((t==null?void 0:t.name)||"").trim(),o=String((t==null?void 0:t.call_id)||(t==null?void 0:t.id)||ss()),a=t!=null&&t.arguments&&typeof t.arguments=="object"?t.arguments:{};if(!n)return{call_id:o,name:"",success:!1,output:null,error:"Missing tool name"};const c={jsonrpc:"2.0",id:ss(),method:"tools/call",params:{name:n,arguments:a}},d=await fetch(this._cfg.url,{method:"POST",headers:{"Content-Type":"application/json",...rS(this._cfg.auth_token)},body:JSON.stringify(c)});if(!d.ok)return{call_id:o,name:n,success:!1,output:null,error:`Worker HTTP ${d.status}`};const u=await d.json().catch(()=>null),m=u==null?void 0:u.result,y=!!(m!=null&&m.isError),v=(Array.isArray(m==null?void 0:m.content)?m.content:[]).find(b=>b&&b.type==="text"&&typeof b.text=="string"),x=(v==null?void 0:v.text)??"";return y?{call_id:o,name:n,success:!1,output:null,error:x||"Tool failed"}:{call_id:o,name:n,success:!0,output:x,error:null}}}class rg{constructor(t,n){Da(this,"pending",[]);Da(this,"scheduled",!1);Da(this,"generation",0);this.schedule=t,this.on_flush=n}push(t){if(this.pending.push(t),this.scheduled)return;this.scheduled=!0;const n=this.generation;this.schedule(()=>{if(n!==this.generation)return;this.scheduled=!1;const o=this.pending;this.pending=[],o.length&&this.on_flush(o)})}reset(){this.generation+=1,this.pending=[],this.scheduled=!1}pending_count(){return this.pending.length}}const iS={execution:"#FFFFFF",string:"#FF00FF",number:"#00FF00",boolean:"#FF0000",object:"#00FFFF",array:"#FF8800",tools:"#FF8800",provider:"#00D2FF",model:"#9D4EDD",provider_text:"#00D2FF",model_text:"#9D4EDD",provider_image:"#19D3B8",model_image:"#8B5CF6",provider_voice:"#22D3EE",model_voice:"#A855F7",agent:"#4488FF",any:"#888888"},oS=[{type:"execution",label:"Execution",shape:"▷",description:"Controls flow order"},{type:"string",label:"String",shape:"●",description:"Text data"},{type:"number",label:"Number",shape:"●",description:"Integer or float"},{type:"boolean",label:"Boolean",shape:"◇",description:"True/False"},{type:"object",label:"Object",shape:"●",description:"JSON objects"},{type:"array",label:"Array",shape:"■",description:"Collections"},{type:"tools",label:"Tools",shape:"■",description:"Tool allowlist (string[])"},{type:"provider_text",label:"Text Provider",shape:"●",description:"Text/LLM provider id/name"},{type:"provider_image",label:"Image Provider",shape:"●",description:"Image-generation provider id"},{type:"provider_voice",label:"Voice Provider",shape:"●",description:"Voice/TTS/STT provider id"},{type:"provider",label:"Provider (legacy)",shape:"●",description:"Legacy unscoped provider id/name"},{type:"model",label:"Model",shape:"●",description:"Model id/name scoped by the selected provider"},{type:"agent",label:"Agent",shape:"⬢",description:"Agent reference"},{type:"any",label:"Any",shape:"●",description:"Accepts any type"}];function aS(){const[e,t]=h.useState(!0);return s.jsxs("div",{className:"pin-legend",children:[s.jsxs("button",{className:"pin-legend-toggle mono",type:"button",onClick:()=>t(n=>!n),title:"Pin Type Legend",children:[e?"?":"×"," Pin Types"]}),e?null:s.jsxs("div",{className:"pin-legend-content",children:[oS.map(n=>s.jsxs("div",{className:"pin-legend-row",children:[s.jsx("span",{className:"pin-legend-shape",style:{color:iS[n.type]},children:n.shape}),s.jsx("span",{className:"pin-legend-label mono",children:n.label}),s.jsx("span",{className:"pin-legend-desc mono",children:n.description})]},n.type)),s.jsxs("div",{className:"pin-legend-rules mono",children:[s.jsx("strong",{children:"Connection Rules:"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Execution connects to Execution only"}),s.jsx("li",{children:'"Any" type accepts all data types'}),s.jsx("li",{children:"Same types always compatible"}),s.jsx("li",{children:"Array and Object are interchangeable"}),s.jsx("li",{children:'"Tools" is compatible with Array (specialized string[])'})]})]})]})]})}function tn(e){return typeof e=="string"?e:e==null?"":String(e)}function sg(e,t){const n=tn(e).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`}function lv(e){const t=tn(e==null?void 0:e.targetHandle),n=tn(e==null?void 0:e.sourceHandle);return!!(t==="exec-in"||n==="exec-out"||t.includes("exec")||n.includes("exec"))}function cv(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{};return tn((t==null?void 0:t.nodeType)||(e==null?void 0:e.type)||"").trim()}function uv(e){if(!e||typeof e!="object")return"";const t=e!=null&&e.data&&typeof e.data=="object"?e.data:{},n=(t==null?void 0:t.subflowId)||(t==null?void 0:t.flowId),o=tn(n).trim();if(!o)return"";if(o.includes(":")){const a=o.split(":",2);if(a.length===2&&a[1])return a[1].trim()}return o}function lS(e){const t=tn(e==null?void 0:e.entryNode).trim();if(t)return t;const n=Array.isArray(e==null?void 0:e.nodes)?e.nodes:[];for(const o of n)if(cv(o)==="on_flow_start"){const a=tn(o==null?void 0:o.id).trim();if(a)return a}return""}function Ph(e){const t=e!=null&&e.position&&typeof e.position=="object"?e.position:{},n=typeof t.x=="number"?t.x:0,o=typeof t.y=="number"?t.y:0;return{x:n,y:o}}function vd(e,t){const n=tn(e).trim(),o=tn(t).trim();return o?n?`${n}::${o}`:o:""}function cS(e){const t=e.root&&typeof e.root=="object"?e.root:{};if(!e.expand_subflows)return t;const n=[],o=[],a=new Set,c=(d,u,m,y)=>{if(!d||typeof d!="object"||n.length>=e.max_nodes||o.length>=e.max_edges)return;const g=Array.isArray(d.nodes)?d.nodes:[],v=Array.isArray(d.edges)?d.edges:[];for(const x of g){const b=tn(x==null?void 0:x.id).trim();if(!b)continue;const C=vd(u,b);if(!C||a.has(C))continue;const S=Ph(x),L={...x,id:C,position:{x:S.x+m.x,y:S.y+m.y}};if(n.push(L),a.add(C),n.length>=e.max_nodes)break}for(const x of v){if(!lv(x))continue;const b=tn(x==null?void 0:x.source).trim(),C=tn(x==null?void 0:x.target).trim();if(!b||!C)continue;const S=vd(u,b),L=vd(u,C);if(!S||!L)continue;const M=tn(x==null?void 0:x.id).trim(),W=M?`${S}->${L}::${M}`:`${S}->${L}`;if(o.push({...x,id:W,source:S,target:L}),o.length>=e.max_edges)break}if(!(y>=e.max_depth))for(const x of g){if(n.length>=e.max_nodes||o.length>=e.max_edges)return;if(cv(x)!=="subflow")continue;const b=uv(x);if(!b)continue;const C=e.flow_by_id[b];if(!C||typeof C!="object")continue;const S=vd(u,tn(x==null?void 0:x.id));if(!S)continue;const L=lS(C);if(!L)continue;const W=(Array.isArray(C.nodes)?C.nodes:[]).find(ue=>tn(ue==null?void 0:ue.id).trim()===L)||null;if(!W)continue;const q=Ph(x),z=Ph(W),Z={x:q.x+m.x+240-z.x,y:q.y+m.y+0-z.y},ne=vd(S,L);o.push({id:`${S}=>${ne}`,source:S,target:ne,sourceHandle:"exec-out",targetHandle:"exec-in"}),c(C,S,Z,y+1)}};return c(t,"",{x:0,y:0},0),{...t,id:tn(t.id),nodes:n,edges:o}}function uS(e){const t=tn(e).trim().toLowerCase();return t?!!(t.startsWith("literal")||t.includes("literal")||t==="concat"||t==="join"||t==="cast"||t==="parse_json"||t==="stringify_json"||t==="break_object"||t==="get_property"||t==="set_property"||t.includes("get_property")||t.includes("set_property")||t==="get_variable"||t==="set_variable"||t.includes("get_variable")||t.includes("set_variable")||t==="json_schema"):!1}function dS(e){const t=e.nodes.filter(c=>e.keep_id(c.id)),n=new Set(t.map(c=>c.id)),o={};for(const c of e.edges)o[c.source]||(o[c.source]=[]),o[c.source].push(c.target);const a=new Map;for(const c of t){const d=new Set,u=(o[c.id]||[]).slice();for(;u.length;){const m=u.pop();if(!m||d.has(m))continue;if(d.add(m),n.has(m)){const g=`${c.id}->${m}`;a.has(g)||a.set(g,{id:g,source:c.id,target:m});continue}const y=o[m]||[];for(const g of y)d.has(g)||u.push(g);if(a.size>=e.max_edges)break}if(a.size>=e.max_edges)break}return{nodes:t,edges:Array.from(a.values())}}function ig(e,t){const a=Math.max(t.w*8,160),c=Math.max(t.h*8,120),d=Math.max(160,Math.min(a,e.w)),u=Math.max(120,Math.min(c,e.h));return{x:e.x,y:e.y,w:d,h:u}}function fS(e){const t=typeof e.now_ms=="number"?e.now_ms:Date.now(),n=e.flow,o=tn(e.active_node_id),a=e.recent_nodes||{},c=e.visited_nodes||{},d=e.highlight_path===!0,u=typeof e.vertical_compact=="number"?Math.max(.4,Math.min(1,e.vertical_compact)):.78,{nodes:m,edges:y,bounds:g}=h.useMemo(()=>{const I=cS({root:n||{},flow_by_id:e.flow_by_id||{},expand_subflows:e.expand_subflows===!0,max_depth:3,max_nodes:700,max_edges:900}),P=Array.isArray(I.nodes)?I.nodes:[],G=Array.isArray(I.edges)?I.edges:[];let $=[];for(const Ne of P){const Oe=tn(Ne==null?void 0:Ne.id).trim();if(!Oe)continue;const st=Ne!=null&&Ne.position&&typeof Ne.position=="object"?Ne.position:{},ve=typeof st.x=="number"?st.x:0,Ie=typeof st.y=="number"?st.y:0,Ge=Ne!=null&&Ne.data&&typeof Ne.data=="object"?Ne.data:{},At=tn((Ge==null?void 0:Ge.label)||(Ne==null?void 0:Ne.label)||Oe)||Oe,Ft=tn((Ge==null?void 0:Ge.nodeType)||(Ne==null?void 0:Ne.type)||"unknown")||"unknown",fn=tn((Ge==null?void 0:Ge.headerColor)||(Ne==null?void 0:Ne.headerColor)||"")||"",Dt=Ge!=null&&Ge.eventConfig&&typeof Ge.eventConfig=="object"?Ge.eventConfig:null,Tt=Dt&&typeof Dt.schedule=="string"?tn(Dt.schedule).trim():"",mn=Dt&&typeof Dt.recurrent=="boolean"?!!Dt.recurrent:void 0,Vn=Ft==="subflow"?uv(Ne):"",jt=Tt||mn!==void 0||Vn?{schedule:Tt||void 0,recurrent:mn,subflow_id:Vn||void 0}:void 0;$.push({id:Oe,x:ve,y:Ie,label:At,type:Ft,color:fn,meta:jt})}const K={};for(const Ne of $)K[Ne.id]=Ne;let se=[];for(const Ne of G){if(!lv(Ne))continue;const Oe=tn(Ne==null?void 0:Ne.source).trim(),st=tn(Ne==null?void 0:Ne.target).trim();!Oe||!st||se.push({id:tn((Ne==null?void 0:Ne.id)||`${Oe}->${st}`),source:Oe,target:st})}const le=new Set($.map(Ne=>Ne.id));if(se=se.filter(Ne=>le.has(Ne.source)&&le.has(Ne.target)),e.simplify===!0){const Oe=dS({nodes:$,edges:se,keep_id:st=>{if(o&&st===o)return!0;const ve=K[st];if(!ve)return!1;const Ie=tn(ve.type).trim().toLowerCase();return Ie==="on_flow_start"||Ie==="on_flow_end"||Ie==="subflow"?!0:!uS(Ie)},max_edges:900});$=Oe.nodes,se=Oe.edges}if(e.prefer_vertical===!0&&$.length>=2){const Ne=$.map(Ge=>Ge.x),Oe=$.map(Ge=>Ge.y),st=Math.max(...Ne)-Math.min(...Ne),ve=Math.max(...Oe)-Math.min(...Oe);st>=ve&&($=$.map(Ge=>({...Ge,x:Ge.y,y:Ge.x})));const Ie=Math.min(...$.map(Ge=>Ge.y));$=$.map(Ge=>({...Ge,y:Ie+(Ge.y-Ie)*u}))}const he={};for(const Ne of $)he[Ne.id]=Ne;const be=160,je=56,Ee=be/2,Fe=je/2;let Ye=0,Ke=0,Ct=0,wt=0;$.length&&(Ye=Math.min(...$.map(Ne=>Ne.x)),Ke=Math.min(...$.map(Ne=>Ne.y)),Ct=Math.max(...$.map(Ne=>Ne.x+be)),wt=Math.max(...$.map(Ne=>Ne.y+je)));let at=0;if(se.length){const Ne=new Set(se.map(Oe=>`${Oe.source}->${Oe.target}`));for(const Oe of se){if(!Ne.has(`${Oe.target}->${Oe.source}`))continue;const st=he[Oe.source],ve=he[Oe.target];if(!st||!ve)continue;const Ie=st.x+Ee,Ge=st.y+Fe,At=ve.x+Ee,Ft=ve.y+Fe,fn=Math.max(1,Math.hypot(At-Ie,Ft-Ge)),Dt=Math.max(28,Math.min(72,fn*.14)),Tt=Math.min(200,Dt*3.5);Tt>at&&(at=Tt)}}const yt=60+at,nt={x:Ye-yt,y:Ke-yt,w:Ct-Ye+yt*2,h:wt-Ke+yt*2,node_w:be,node_h:je};return{nodes:$,edges:se,bounds:nt}},[n,e.flow_by_id,e.expand_subflows,e.simplify,e.prefer_vertical,o,u]);if(!n)return s.jsx("div",{className:"graph_empty mono",children:"(no graph loaded)"});const v=h.useRef(null),[x,b]=h.useState(()=>({x:g.x,y:g.y,w:g.w,h:g.h})),C=h.useRef(x);C.current=x,h.useEffect(()=>{b({x:g.x,y:g.y,w:g.w,h:g.h})},[g.x,g.y,g.w,g.h]);const S=h.useRef(new Map),L=h.useRef(null),M=`${x.x} ${x.y} ${x.w} ${x.h}`,W={};for(const I of m)W[I.id]=I;const q=I=>{let P=tn(I).trim();if(!P)return"";if(W[P])return P;for(;P.includes("::");)if(P=P.slice(0,Math.max(0,P.lastIndexOf("::"))),W[P])return P;return""},z=q(o),Y={};for(const[I,P]of Object.entries(a)){if(typeof P!="number")continue;const G=q(I);G&&(Y[G]=Math.max(Y[G]||0,P))}const Q={};if(d)for(const[I,P]of Object.entries(c)){if(typeof P!="number")continue;const G=q(I);G&&(Q[G]=typeof Q[G]=="number"?Math.min(Q[G],P):P)}const Z=tn(e.schedule_next_in).trim(),ne=tn(e.schedule_interval).trim(),ue=e.node_last_ms&&typeof e.node_last_ms=="object"?e.node_last_ms:{},de=I=>{try{const P=new Date(I),G=String(P.getHours()).padStart(2,"0"),$=String(P.getMinutes()).padStart(2,"0");return`${G}:${$}`}catch{return""}},pe=(I,P)=>{var se,le;const G=tn((se=I.meta)==null?void 0:se.schedule).trim();if(!(((le=I.meta)==null?void 0:le.recurrent)===!0))return P&&Z?`next ${Z}`:G&&G.length<=12&&!G.includes("T")?`in ${G}`:"scheduled";const K=G||ne;return K?P&&Z?`${K} • next ${Z}`:`every ${K}`:P&&Z?`next ${Z}`:"scheduled"},D=I=>{var be;const P=tn((be=I.meta)==null?void 0:be.subflow_id).trim(),G=P&&e.flow_by_id?e.flow_by_id[P]:null,K=tn(G==null?void 0:G.name).trim()||P||I.label||I.id,se=typeof ue[I.id]=="number"?Number(ue[I.id]):null,le=se!==null?de(se):"",he=le?`last ${le}`:"subflow";return{label:K,sub:he}},E=(I,P,G)=>{const $=G||C.current,K=v.current;if(!K)return{x:I,y:P};const se=K.getBoundingClientRect(),le=se.width>0?(I-se.left)/se.width:0,he=se.height>0?(P-se.top)/se.height:0;return{x:$.x+le*$.w,y:$.y+he*$.h}},j=(I,P,G)=>{const $=G||C.current,K=Math.max(.12,Math.min(8,P)),se=$.w*K,le=$.h*K,he=$.w>0?(I.x-$.x)/$.w:.5,be=$.h>0?(I.y-$.y)/$.h:.5,je=I.x-he*se,Ee=I.y-be*le;b(ig({x:je,y:Ee,w:se,h:le},g))},R=(I,P,G)=>{const $=G||C.current,K=v.current;if(!K)return;const se=K.getBoundingClientRect(),le=.88,he=se.width>0?I/se.width*$.w*le:0,be=se.height>0?P/se.height*$.h*le:0;b(je=>ig({x:(G||je).x-he,y:(G||je).y-be,w:(G||je).w,h:(G||je).h},g))},O=h.useMemo(()=>{const I=new Set;for(const P of y)I.add(`${P.source}->${P.target}`);return I},[y]),ee=(I,P,G,$)=>{const K=g.node_w,se=g.node_h,le=Math.abs(G),he=Math.abs($);if(le<1e-6&&he<1e-6)return{x:I,y:P};const be=le>1e-6?K/2/le:Number.POSITIVE_INFINITY,je=he>1e-6?se/2/he:Number.POSITIVE_INFINITY,Ee=Math.min(be,je);return{x:I+G*Ee,y:P+$*Ee}};return s.jsxs("div",{className:"graph_wrap",children:[s.jsxs("div",{className:"graph_corner",children:[s.jsxs("div",{className:"graph_corner_buttons",children:[s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>b({x:g.x,y:g.y,w:g.w,h:g.h}),title:"Recenter",children:"⤢"}),s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>{const I=v.current;if(!I)return;const P=I.getBoundingClientRect(),G=E(P.left+P.width/2,P.top+P.height/2);j(G,.84)},title:"Zoom in",children:"+"}),s.jsx("button",{className:"btn graph_corner_btn",type:"button",onClick:()=>{const I=v.current;if(!I)return;const P=I.getBoundingClientRect(),G=E(P.left+P.width/2,P.top+P.height/2);j(G,1.18)},title:"Zoom out",children:"−"})]}),s.jsx(aS,{})]}),s.jsxs("svg",{ref:v,className:"graph_svg",viewBox:M,role:"img","aria-label":"Workflow execution graph",onWheel:I=>{I.preventDefault();const P=E(I.clientX,I.clientY),G=typeof I.deltaY=="number"?I.deltaY:0,$=typeof I.deltaMode=="number"?Number(I.deltaMode):0,K=$===1?G*24:$===2?G*800:G,se=45e-5*1.15*1.1;let le=Math.exp(K*se);le=Math.max(.86,Math.min(1.16,le)),j(P,le)},onPointerDown:I=>{var G,$;($=(G=I.currentTarget).setPointerCapture)==null||$.call(G,I.pointerId),S.current.set(I.pointerId,{x:I.clientX,y:I.clientY});const P=Array.from(S.current.values());if(P.length===1)L.current={mode:"pan",start_view:C.current,start_client:{x:I.clientX,y:I.clientY},start_dist:0,anchor_svg:{x:0,y:0}};else if(P.length>=2){const K=P[0],se=P[1],le=K.x-se.x,he=K.y-se.y,be=Math.max(1,Math.hypot(le,he)),je={x:(K.x+se.x)/2,y:(K.y+se.y)/2},Ee=C.current;L.current={mode:"pinch",start_view:Ee,start_client:je,start_dist:be,anchor_svg:E(je.x,je.y,Ee)}}},onPointerMove:I=>{if(!S.current.has(I.pointerId))return;S.current.set(I.pointerId,{x:I.clientX,y:I.clientY});const P=L.current;if(!P)return;const G=Array.from(S.current.values());if(P.mode==="pan"&&G.length===1){const $=I.clientX-P.start_client.x,K=I.clientY-P.start_client.y;R($,K,P.start_view)}else if(P.mode==="pinch"&&G.length>=2){const $=G[0],K=G[1],se=$.x-K.x,le=$.y-K.y,he=Math.max(1,Math.hypot(se,le)),be=P.start_dist/he;j(P.anchor_svg,be,P.start_view)}},onPointerUp:I=>{S.current.delete(I.pointerId),S.current.size===0&&(L.current=null)},onPointerCancel:I=>{S.current.delete(I.pointerId),S.current.size===0&&(L.current=null)},children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"rgba(148,163,184,0.55)"})}),s.jsxs("filter",{id:"glow",children:[s.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),s.jsxs("feMerge",{children:[s.jsx("feMergeNode",{in:"coloredBlur"}),s.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),y.map(I=>{const P=W[I.source],G=W[I.target];if(!P||!G)return null;const $=P.x+g.node_w/2,K=P.y+g.node_h/2,se=G.x+g.node_w/2,le=G.y+g.node_h/2,he=se-$,be=le-K,je=ee($,K,he,be),Ee=ee(se,le,-he,-be),Fe=I.source!==I.target&&O.has(`${I.target}->${I.source}`),Ye=Math.max(1,Math.hypot(he,be)),Ke=-be/Ye,Ct=he/Ye,wt=String(I.source)<String(I.target)?1:-1,yt=Math.abs(he)>=Math.abs(be)?he>=0:be>=0,nt=!Fe||yt,Ne=Math.max(28,Math.min(72,Ye*.14)),Oe=Math.min(200,Ne*3.5),st=Fe&&!nt?Oe*wt:0,ve=(je.x+Ee.x)/2+Ke*st,Ie=(je.y+Ee.y)/2+Ct*st,Ge=Fe&&!nt?`M ${je.x} ${je.y} Q ${ve} ${Ie} ${Ee.x} ${Ee.y}`:`M ${je.x} ${je.y} L ${Ee.x} ${Ee.y}`,At=d&&Q&&Q[I.source]!==void 0&&Q[I.target]!==void 0;return s.jsx("path",{d:Ge,className:`graph_edge ${At?"visited":""}`,markerEnd:"url(#arrow)",fill:"none"},I.id)}),m.map(I=>{const G=(typeof Y[I.id]=="number"?Y[I.id]:0)>t,$=z&&I.id===z,K=d&&Q&&Q[I.id]!==void 0,se=`graph_node ${$?"active":G?"recent":""} ${K?"visited":""}`,le=I.color||"rgba(255,255,255,0.16)";let he=I.label||I.id,be=I.type;if(I.type==="on_schedule")be=pe(I,!!$);else if(I.type==="subflow"){const Fe=D(I);he=Fe.label,be=Fe.sub}const je=sg(he,22),Ee=sg(be,22);return s.jsxs("g",{className:se,transform:`translate(${I.x}, ${I.y})`,children:[s.jsx("rect",{className:"graph_node_bg",width:g.node_w,height:g.node_h,rx:12,ry:12}),s.jsx("rect",{className:"graph_node_bar",width:g.node_w,height:6,rx:12,ry:12,fill:le}),s.jsx("text",{className:"graph_node_label",x:12,y:28,children:je}),s.jsx("text",{className:"graph_node_type",x:12,y:46,children:Ee}),I.type==="on_schedule"?s.jsx("text",{className:"graph_node_icon",x:g.node_w-18,y:18,children:"⏰"}):null]},I.id)})]})]})}function Pr(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Pr(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Oh={exports:{}},zh={},Ih={exports:{}},Dh={};/**
106
+ * @license React
107
+ * use-sync-external-store-shim.production.js
108
+ *
109
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
110
+ *
111
+ * This source code is licensed under the MIT license found in the
112
+ * LICENSE file in the root directory of this source tree.
113
+ */var og;function mS(){if(og)return Dh;og=1;var e=Gd();function t(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,a=e.useEffect,c=e.useLayoutEffect,d=e.useDebugValue;function u(v,x){var b=x(),C=o({inst:{value:b,getSnapshot:x}}),S=C[0].inst,L=C[1];return c(function(){S.value=b,S.getSnapshot=x,m(S)&&L({inst:S})},[v,b,x]),a(function(){return m(S)&&L({inst:S}),v(function(){m(S)&&L({inst:S})})},[v]),d(b),b}function m(v){var x=v.getSnapshot;v=v.value;try{var b=x();return!n(v,b)}catch{return!0}}function y(v,x){return x()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:u;return Dh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Dh}var ag;function hS(){return ag||(ag=1,Ih.exports=mS()),Ih.exports}/**
114
+ * @license React
115
+ * use-sync-external-store-shim/with-selector.production.js
116
+ *
117
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
118
+ *
119
+ * This source code is licensed under the MIT license found in the
120
+ * LICENSE file in the root directory of this source tree.
121
+ */var lg;function _S(){if(lg)return zh;lg=1;var e=Gd(),t=hS();function n(y,g){return y===g&&(y!==0||1/y===1/g)||y!==y&&g!==g}var o=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,c=e.useRef,d=e.useEffect,u=e.useMemo,m=e.useDebugValue;return zh.useSyncExternalStoreWithSelector=function(y,g,v,x,b){var C=c(null);if(C.current===null){var S={hasValue:!1,value:null};C.current=S}else S=C.current;C=u(function(){function M(Q){if(!W){if(W=!0,q=Q,Q=x(Q),b!==void 0&&S.hasValue){var Z=S.value;if(b(Z,Q))return z=Z}return z=Q}if(Z=z,o(q,Q))return Z;var ne=x(Q);return b!==void 0&&b(Z,ne)?(q=Q,Z):(q=Q,z=ne)}var W=!1,q,z,Y=v===void 0?null:v;return[function(){return M(g())},Y===null?void 0:function(){return M(Y())}]},[g,v,x,b]);var L=a(y,C[0],C[1]);return d(function(){S.hasValue=!0,S.value=L},[L]),m(L),L},zh}var cg;function pS(){return cg||(cg=1,Oh.exports=_S()),Oh.exports}var gS=pS();const yS=B_(gS),vS={},ug=e=>{let t;const n=new Set,o=(g,v)=>{const x=typeof g=="function"?g(t):g;if(!Object.is(x,t)){const b=t;t=v??(typeof x!="object"||x===null)?x:Object.assign({},t,x),n.forEach(C=>C(t,b))}},a=()=>t,m={setState:o,getState:a,getInitialState:()=>y,subscribe:g=>(n.add(g),()=>n.delete(g)),destroy:()=>{(vS?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},y=t=e(o,a,m);return m},xS=e=>e?ug(e):ug,{useDebugValue:wS}=ye,{useSyncExternalStoreWithSelector:bS}=yS,SS=e=>e;function dv(e,t=SS,n){const o=bS(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wS(o),o}const dg=(e,t)=>{const n=xS(e),o=(a,c=t)=>dv(n,a,c);return Object.assign(o,n),o},jS=(e,t)=>e?dg(e,t):dg;function kr(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,a]of e)if(!Object.is(a,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var kS={value:()=>{}};function Dm(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new mm(n)}function mm(e){this._=e}function NS(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",a=n.indexOf(".");if(a>=0&&(o=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}mm.prototype=Dm.prototype={constructor:mm,on:function(e,t){var n=this._,o=NS(e+"",n),a,c=-1,d=o.length;if(arguments.length<2){for(;++c<d;)if((a=(e=o[c]).type)&&(a=CS(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++c<d;)if(a=(e=o[c]).type)n[a]=fg(n[a],e.name,t);else if(t==null)for(a in n)n[a]=fg(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new mm(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),o=0,a,c;o<a;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(c=this._[e],o=0,a=c.length;o<a;++o)c[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],a=0,c=o.length;a<c;++a)o[a].value.apply(t,n)}};function CS(e,t){for(var n=0,o=e.length,a;n<o;++n)if((a=e[n]).name===t)return a.value}function fg(e,t,n){for(var o=0,a=e.length;o<a;++o)if(e[o].name===t){e[o]=kS,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var v_="http://www.w3.org/1999/xhtml";const mg={svg:"http://www.w3.org/2000/svg",xhtml:v_,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),mg.hasOwnProperty(t)?{space:mg[t],local:e}:e}function ES(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===v_&&t.documentElement.namespaceURI===v_?t.createElement(e):t.createElementNS(n,e)}}function $S(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fv(e){var t=Fm(e);return(t.local?$S:ES)(t)}function MS(){}function X_(e){return e==null?MS:function(){return this.querySelector(e)}}function AS(e){typeof e!="function"&&(e=X_(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var c=t[a],d=c.length,u=o[a]=new Array(d),m,y,g=0;g<d;++g)(m=c[g])&&(y=e.call(m,m.__data__,g,c))&&("__data__"in m&&(y.__data__=m.__data__),u[g]=y);return new Vs(o,this._parents)}function TS(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function LS(){return[]}function mv(e){return e==null?LS:function(){return this.querySelectorAll(e)}}function RS(e){return function(){return TS(e.apply(this,arguments))}}function PS(e){typeof e=="function"?e=RS(e):e=mv(e);for(var t=this._groups,n=t.length,o=[],a=[],c=0;c<n;++c)for(var d=t[c],u=d.length,m,y=0;y<u;++y)(m=d[y])&&(o.push(e.call(m,m.__data__,y,d)),a.push(m));return new Vs(o,a)}function hv(e){return function(){return this.matches(e)}}function _v(e){return function(t){return t.matches(e)}}var OS=Array.prototype.find;function zS(e){return function(){return OS.call(this.children,e)}}function IS(){return this.firstElementChild}function DS(e){return this.select(e==null?IS:zS(typeof e=="function"?e:_v(e)))}var FS=Array.prototype.filter;function BS(){return Array.from(this.children)}function US(e){return function(){return FS.call(this.children,e)}}function HS(e){return this.selectAll(e==null?BS:US(typeof e=="function"?e:_v(e)))}function WS(e){typeof e!="function"&&(e=hv(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var c=t[a],d=c.length,u=o[a]=[],m,y=0;y<d;++y)(m=c[y])&&e.call(m,m.__data__,y,c)&&u.push(m);return new Vs(o,this._parents)}function pv(e){return new Array(e.length)}function qS(){return new Vs(this._enter||this._groups.map(pv),this._parents)}function jm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}jm.prototype={constructor:jm,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function VS(e){return function(){return e}}function GS(e,t,n,o,a,c){for(var d=0,u,m=t.length,y=c.length;d<y;++d)(u=t[d])?(u.__data__=c[d],o[d]=u):n[d]=new jm(e,c[d]);for(;d<m;++d)(u=t[d])&&(a[d]=u)}function YS(e,t,n,o,a,c,d){var u,m,y=new Map,g=t.length,v=c.length,x=new Array(g),b;for(u=0;u<g;++u)(m=t[u])&&(x[u]=b=d.call(m,m.__data__,u,t)+"",y.has(b)?a[u]=m:y.set(b,m));for(u=0;u<v;++u)b=d.call(e,c[u],u,c)+"",(m=y.get(b))?(o[u]=m,m.__data__=c[u],y.delete(b)):n[u]=new jm(e,c[u]);for(u=0;u<g;++u)(m=t[u])&&y.get(x[u])===m&&(a[u]=m)}function KS(e){return e.__data__}function XS(e,t){if(!arguments.length)return Array.from(this,KS);var n=t?YS:GS,o=this._parents,a=this._groups;typeof e!="function"&&(e=VS(e));for(var c=a.length,d=new Array(c),u=new Array(c),m=new Array(c),y=0;y<c;++y){var g=o[y],v=a[y],x=v.length,b=JS(e.call(g,g&&g.__data__,y,o)),C=b.length,S=u[y]=new Array(C),L=d[y]=new Array(C),M=m[y]=new Array(x);n(g,v,S,L,M,b,t);for(var W=0,q=0,z,Y;W<C;++W)if(z=S[W]){for(W>=q&&(q=W+1);!(Y=L[q])&&++q<C;);z._next=Y||null}}return d=new Vs(d,o),d._enter=u,d._exit=m,d}function JS(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ZS(){return new Vs(this._exit||this._groups.map(pv),this._parents)}function QS(e,t,n){var o=this.enter(),a=this,c=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?c.remove():n(c),o&&a?o.merge(a).order():a}function ej(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,a=n.length,c=o.length,d=Math.min(a,c),u=new Array(a),m=0;m<d;++m)for(var y=n[m],g=o[m],v=y.length,x=u[m]=new Array(v),b,C=0;C<v;++C)(b=y[C]||g[C])&&(x[C]=b);for(;m<a;++m)u[m]=n[m];return new Vs(u,this._parents)}function tj(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],a=o.length-1,c=o[a],d;--a>=0;)(d=o[a])&&(c&&d.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(d,c),c=d);return this}function nj(e){e||(e=rj);function t(v,x){return v&&x?e(v.__data__,x.__data__):!v-!x}for(var n=this._groups,o=n.length,a=new Array(o),c=0;c<o;++c){for(var d=n[c],u=d.length,m=a[c]=new Array(u),y,g=0;g<u;++g)(y=d[g])&&(m[g]=y);m.sort(t)}return new Vs(a,this._parents).order()}function rj(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function sj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ij(){return Array.from(this)}function oj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],a=0,c=o.length;a<c;++a){var d=o[a];if(d)return d}return null}function aj(){let e=0;for(const t of this)++e;return e}function lj(){return!this.node()}function cj(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var a=t[n],c=0,d=a.length,u;c<d;++c)(u=a[c])&&e.call(u,u.__data__,c,a);return this}function uj(e){return function(){this.removeAttribute(e)}}function dj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fj(e,t){return function(){this.setAttribute(e,t)}}function mj(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hj(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function _j(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function pj(e,t){var n=Fm(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?dj:uj:typeof t=="function"?n.local?_j:hj:n.local?mj:fj)(n,t))}function gv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function gj(e){return function(){this.style.removeProperty(e)}}function yj(e,t,n){return function(){this.style.setProperty(e,t,n)}}function vj(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function xj(e,t,n){return arguments.length>1?this.each((t==null?gj:typeof t=="function"?vj:yj)(e,t,n??"")):au(this.node(),e)}function au(e,t){return e.style.getPropertyValue(t)||gv(e).getComputedStyle(e,null).getPropertyValue(t)}function wj(e){return function(){delete this[e]}}function bj(e,t){return function(){this[e]=t}}function Sj(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jj(e,t){return arguments.length>1?this.each((t==null?wj:typeof t=="function"?Sj:bj)(e,t)):this.node()[e]}function yv(e){return e.trim().split(/^|\s+/)}function J_(e){return e.classList||new vv(e)}function vv(e){this._node=e,this._names=yv(e.getAttribute("class")||"")}vv.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xv(e,t){for(var n=J_(e),o=-1,a=t.length;++o<a;)n.add(t[o])}function wv(e,t){for(var n=J_(e),o=-1,a=t.length;++o<a;)n.remove(t[o])}function kj(e){return function(){xv(this,e)}}function Nj(e){return function(){wv(this,e)}}function Cj(e,t){return function(){(t.apply(this,arguments)?xv:wv)(this,e)}}function Ej(e,t){var n=yv(e+"");if(arguments.length<2){for(var o=J_(this.node()),a=-1,c=n.length;++a<c;)if(!o.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?Cj:t?kj:Nj)(n,t))}function $j(){this.textContent=""}function Mj(e){return function(){this.textContent=e}}function Aj(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Tj(e){return arguments.length?this.each(e==null?$j:(typeof e=="function"?Aj:Mj)(e)):this.node().textContent}function Lj(){this.innerHTML=""}function Rj(e){return function(){this.innerHTML=e}}function Pj(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Oj(e){return arguments.length?this.each(e==null?Lj:(typeof e=="function"?Pj:Rj)(e)):this.node().innerHTML}function zj(){this.nextSibling&&this.parentNode.appendChild(this)}function Ij(){return this.each(zj)}function Dj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Fj(){return this.each(Dj)}function Bj(e){var t=typeof e=="function"?e:fv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Uj(){return null}function Hj(e,t){var n=typeof e=="function"?e:fv(e),o=t==null?Uj:typeof t=="function"?t:X_(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Wj(){var e=this.parentNode;e&&e.removeChild(this)}function qj(){return this.each(Wj)}function Vj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gj(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yj(e){return this.select(e?Gj:Vj)}function Kj(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Xj(e){return function(t){e.call(this,t,this.__data__)}}function Jj(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Zj(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,a=t.length,c;n<a;++n)c=t[n],(!e.type||c.type===e.type)&&c.name===e.name?this.removeEventListener(c.type,c.listener,c.options):t[++o]=c;++o?t.length=o:delete this.__on}}}function Qj(e,t,n){return function(){var o=this.__on,a,c=Xj(t);if(o){for(var d=0,u=o.length;d<u;++d)if((a=o[d]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=c,a.options=n),a.value=t;return}}this.addEventListener(e.type,c,n),a={type:e.type,name:e.name,value:t,listener:c,options:n},o?o.push(a):this.__on=[a]}}function ek(e,t,n){var o=Jj(e+""),a,c=o.length,d;if(arguments.length<2){var u=this.node().__on;if(u){for(var m=0,y=u.length,g;m<y;++m)for(a=0,g=u[m];a<c;++a)if((d=o[a]).type===g.type&&d.name===g.name)return g.value}return}for(u=t?Qj:Zj,a=0;a<c;++a)this.each(u(o[a],t,n));return this}function bv(e,t,n){var o=gv(e),a=o.CustomEvent;typeof a=="function"?a=new a(t,n):(a=o.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function tk(e,t){return function(){return bv(this,e,t)}}function nk(e,t){return function(){return bv(this,e,t.apply(this,arguments))}}function rk(e,t){return this.each((typeof t=="function"?nk:tk)(e,t))}function*sk(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],a=0,c=o.length,d;a<c;++a)(d=o[a])&&(yield d)}var Sv=[null];function Vs(e,t){this._groups=e,this._parents=t}function Kd(){return new Vs([[document.documentElement]],Sv)}function ik(){return this}Vs.prototype=Kd.prototype={constructor:Vs,select:AS,selectAll:PS,selectChild:DS,selectChildren:HS,filter:WS,data:XS,enter:qS,exit:ZS,join:QS,merge:ej,selection:ik,order:tj,sort:nj,call:sj,nodes:ij,node:oj,size:aj,empty:lj,each:cj,attr:pj,style:xj,property:jj,classed:Ej,text:Tj,html:Oj,raise:Ij,lower:Fj,append:Bj,insert:Hj,remove:qj,clone:Yj,datum:Kj,on:ek,dispatch:rk,[Symbol.iterator]:sk};function _i(e){return typeof e=="string"?new Vs([[document.querySelector(e)]],[document.documentElement]):new Vs([[e]],Sv)}function ok(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Gi(e,t){if(e=ok(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const ak={passive:!1},Od={capture:!0,passive:!1};function Fh(e){e.stopImmediatePropagation()}function nu(e){e.preventDefault(),e.stopImmediatePropagation()}function jv(e){var t=e.document.documentElement,n=_i(e).on("dragstart.drag",nu,Od);"onselectstart"in t?n.on("selectstart.drag",nu,Od):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function kv(e,t){var n=e.document.documentElement,o=_i(e).on("dragstart.drag",null);t&&(o.on("click.drag",nu,Od),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Jf=e=>()=>e;function x_(e,{sourceEvent:t,subject:n,target:o,identifier:a,active:c,x:d,y:u,dx:m,dy:y,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:c,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:m,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:g}})}x_.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function lk(e){return!e.ctrlKey&&!e.button}function ck(){return this.parentNode}function uk(e,t){return t??{x:e.x,y:e.y}}function dk(){return navigator.maxTouchPoints||"ontouchstart"in this}function fk(){var e=lk,t=ck,n=uk,o=dk,a={},c=Dm("start","drag","end"),d=0,u,m,y,g,v=0;function x(z){z.on("mousedown.drag",b).filter(o).on("touchstart.drag",L).on("touchmove.drag",M,ak).on("touchend.drag touchcancel.drag",W).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(z,Y){if(!(g||!e.call(this,z,Y))){var Q=q(this,t.call(this,z,Y),z,Y,"mouse");Q&&(_i(z.view).on("mousemove.drag",C,Od).on("mouseup.drag",S,Od),jv(z.view),Fh(z),y=!1,u=z.clientX,m=z.clientY,Q("start",z))}}function C(z){if(nu(z),!y){var Y=z.clientX-u,Q=z.clientY-m;y=Y*Y+Q*Q>v}a.mouse("drag",z)}function S(z){_i(z.view).on("mousemove.drag mouseup.drag",null),kv(z.view,y),nu(z),a.mouse("end",z)}function L(z,Y){if(e.call(this,z,Y)){var Q=z.changedTouches,Z=t.call(this,z,Y),ne=Q.length,ue,de;for(ue=0;ue<ne;++ue)(de=q(this,Z,z,Y,Q[ue].identifier,Q[ue]))&&(Fh(z),de("start",z,Q[ue]))}}function M(z){var Y=z.changedTouches,Q=Y.length,Z,ne;for(Z=0;Z<Q;++Z)(ne=a[Y[Z].identifier])&&(nu(z),ne("drag",z,Y[Z]))}function W(z){var Y=z.changedTouches,Q=Y.length,Z,ne;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),Z=0;Z<Q;++Z)(ne=a[Y[Z].identifier])&&(Fh(z),ne("end",z,Y[Z]))}function q(z,Y,Q,Z,ne,ue){var de=c.copy(),pe=Gi(ue||Q,Y),D,E,j;if((j=n.call(z,new x_("beforestart",{sourceEvent:Q,target:x,identifier:ne,active:d,x:pe[0],y:pe[1],dx:0,dy:0,dispatch:de}),Z))!=null)return D=j.x-pe[0]||0,E=j.y-pe[1]||0,function R(O,ee,I){var P=pe,G;switch(O){case"start":a[ne]=R,G=d++;break;case"end":delete a[ne],--d;case"drag":pe=Gi(I||ee,Y),G=d;break}de.call(O,z,new x_(O,{sourceEvent:ee,subject:j,target:x,identifier:ne,active:G,x:pe[0]+D,y:pe[1]+E,dx:pe[0]-P[0],dy:pe[1]-P[1],dispatch:de}),Z)}}return x.filter=function(z){return arguments.length?(e=typeof z=="function"?z:Jf(!!z),x):e},x.container=function(z){return arguments.length?(t=typeof z=="function"?z:Jf(z),x):t},x.subject=function(z){return arguments.length?(n=typeof z=="function"?z:Jf(z),x):n},x.touchable=function(z){return arguments.length?(o=typeof z=="function"?z:Jf(!!z),x):o},x.on=function(){var z=c.on.apply(c,arguments);return z===c?x:z},x.clickDistance=function(z){return arguments.length?(v=(z=+z)*z,x):Math.sqrt(v)},x}function Z_(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Nv(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function Xd(){}var zd=.7,km=1/zd,ru="\\s*([+-]?\\d+)\\s*",Id="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_o="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",mk=/^#([0-9a-f]{3,8})$/,hk=new RegExp(`^rgb\\(${ru},${ru},${ru}\\)$`),_k=new RegExp(`^rgb\\(${_o},${_o},${_o}\\)$`),pk=new RegExp(`^rgba\\(${ru},${ru},${ru},${Id}\\)$`),gk=new RegExp(`^rgba\\(${_o},${_o},${_o},${Id}\\)$`),yk=new RegExp(`^hsl\\(${Id},${_o},${_o}\\)$`),vk=new RegExp(`^hsla\\(${Id},${_o},${_o},${Id}\\)$`),hg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Z_(Xd,Dd,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:_g,formatHex:_g,formatHex8:xk,formatHsl:wk,formatRgb:pg,toString:pg});function _g(){return this.rgb().formatHex()}function xk(){return this.rgb().formatHex8()}function wk(){return Cv(this).formatHsl()}function pg(){return this.rgb().formatRgb()}function Dd(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=mk.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?gg(t):n===3?new Es(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Zf(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Zf(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=hk.exec(e))?new Es(t[1],t[2],t[3],1):(t=_k.exec(e))?new Es(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=pk.exec(e))?Zf(t[1],t[2],t[3],t[4]):(t=gk.exec(e))?Zf(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=yk.exec(e))?xg(t[1],t[2]/100,t[3]/100,1):(t=vk.exec(e))?xg(t[1],t[2]/100,t[3]/100,t[4]):hg.hasOwnProperty(e)?gg(hg[e]):e==="transparent"?new Es(NaN,NaN,NaN,0):null}function gg(e){return new Es(e>>16&255,e>>8&255,e&255,1)}function Zf(e,t,n,o){return o<=0&&(e=t=n=NaN),new Es(e,t,n,o)}function bk(e){return e instanceof Xd||(e=Dd(e)),e?(e=e.rgb(),new Es(e.r,e.g,e.b,e.opacity)):new Es}function w_(e,t,n,o){return arguments.length===1?bk(e):new Es(e,t,n,o??1)}function Es(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Z_(Es,w_,Nv(Xd,{brighter(e){return e=e==null?km:Math.pow(km,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zd:Math.pow(zd,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Es(Wl(this.r),Wl(this.g),Wl(this.b),Nm(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:yg,formatHex:yg,formatHex8:Sk,formatRgb:vg,toString:vg}));function yg(){return`#${Bl(this.r)}${Bl(this.g)}${Bl(this.b)}`}function Sk(){return`#${Bl(this.r)}${Bl(this.g)}${Bl(this.b)}${Bl((isNaN(this.opacity)?1:this.opacity)*255)}`}function vg(){const e=Nm(this.opacity);return`${e===1?"rgb(":"rgba("}${Wl(this.r)}, ${Wl(this.g)}, ${Wl(this.b)}${e===1?")":`, ${e})`}`}function Nm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Bl(e){return e=Wl(e),(e<16?"0":"")+e.toString(16)}function xg(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Yi(e,t,n,o)}function Cv(e){if(e instanceof Yi)return new Yi(e.h,e.s,e.l,e.opacity);if(e instanceof Xd||(e=Dd(e)),!e)return new Yi;if(e instanceof Yi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,a=Math.min(t,n,o),c=Math.max(t,n,o),d=NaN,u=c-a,m=(c+a)/2;return u?(t===c?d=(n-o)/u+(n<o)*6:n===c?d=(o-t)/u+2:d=(t-n)/u+4,u/=m<.5?c+a:2-c-a,d*=60):u=m>0&&m<1?0:d,new Yi(d,u,m,e.opacity)}function jk(e,t,n,o){return arguments.length===1?Cv(e):new Yi(e,t,n,o??1)}function Yi(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Z_(Yi,jk,Nv(Xd,{brighter(e){return e=e==null?km:Math.pow(km,e),new Yi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?zd:Math.pow(zd,e),new Yi(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,a=2*n-o;return new Es(Bh(e>=240?e-240:e+120,a,o),Bh(e,a,o),Bh(e<120?e+240:e-120,a,o),this.opacity)},clamp(){return new Yi(wg(this.h),Qf(this.s),Qf(this.l),Nm(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Nm(this.opacity);return`${e===1?"hsl(":"hsla("}${wg(this.h)}, ${Qf(this.s)*100}%, ${Qf(this.l)*100}%${e===1?")":`, ${e})`}`}}));function wg(e){return e=(e||0)%360,e<0?e+360:e}function Qf(e){return Math.max(0,Math.min(1,e||0))}function Bh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ev=e=>()=>e;function kk(e,t){return function(n){return e+n*t}}function Nk(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Ck(e){return(e=+e)==1?$v:function(t,n){return n-t?Nk(t,n,e):Ev(isNaN(t)?n:t)}}function $v(e,t){var n=t-e;return n?kk(e,n):Ev(isNaN(e)?t:e)}const bg=(function e(t){var n=Ck(t);function o(a,c){var d=n((a=w_(a)).r,(c=w_(c)).r),u=n(a.g,c.g),m=n(a.b,c.b),y=$v(a.opacity,c.opacity);return function(g){return a.r=d(g),a.g=u(g),a.b=m(g),a.opacity=y(g),a+""}}return o.gamma=e,o})(1);function Ha(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var b_=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Uh=new RegExp(b_.source,"g");function Ek(e){return function(){return e}}function $k(e){return function(t){return e(t)+""}}function Mk(e,t){var n=b_.lastIndex=Uh.lastIndex=0,o,a,c,d=-1,u=[],m=[];for(e=e+"",t=t+"";(o=b_.exec(e))&&(a=Uh.exec(t));)(c=a.index)>n&&(c=t.slice(n,c),u[d]?u[d]+=c:u[++d]=c),(o=o[0])===(a=a[0])?u[d]?u[d]+=a:u[++d]=a:(u[++d]=null,m.push({i:d,x:Ha(o,a)})),n=Uh.lastIndex;return n<t.length&&(c=t.slice(n),u[d]?u[d]+=c:u[++d]=c),u.length<2?m[0]?$k(m[0].x):Ek(t):(t=m.length,function(y){for(var g=0,v;g<t;++g)u[(v=m[g]).i]=v.x(y);return u.join("")})}var Sg=180/Math.PI,S_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Mv(e,t,n,o,a,c){var d,u,m;return(d=Math.sqrt(e*e+t*t))&&(e/=d,t/=d),(m=e*n+t*o)&&(n-=e*m,o-=t*m),(u=Math.sqrt(n*n+o*o))&&(n/=u,o/=u,m/=u),e*o<t*n&&(e=-e,t=-t,m=-m,d=-d),{translateX:a,translateY:c,rotate:Math.atan2(t,e)*Sg,skewX:Math.atan(m)*Sg,scaleX:d,scaleY:u}}var em;function Ak(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?S_:Mv(t.a,t.b,t.c,t.d,t.e,t.f)}function Tk(e){return e==null||(em||(em=document.createElementNS("http://www.w3.org/2000/svg","g")),em.setAttribute("transform",e),!(e=em.transform.baseVal.consolidate()))?S_:(e=e.matrix,Mv(e.a,e.b,e.c,e.d,e.e,e.f))}function Av(e,t,n,o){function a(y){return y.length?y.pop()+" ":""}function c(y,g,v,x,b,C){if(y!==v||g!==x){var S=b.push("translate(",null,t,null,n);C.push({i:S-4,x:Ha(y,v)},{i:S-2,x:Ha(g,x)})}else(v||x)&&b.push("translate("+v+t+x+n)}function d(y,g,v,x){y!==g?(y-g>180?g+=360:g-y>180&&(y+=360),x.push({i:v.push(a(v)+"rotate(",null,o)-2,x:Ha(y,g)})):g&&v.push(a(v)+"rotate("+g+o)}function u(y,g,v,x){y!==g?x.push({i:v.push(a(v)+"skewX(",null,o)-2,x:Ha(y,g)}):g&&v.push(a(v)+"skewX("+g+o)}function m(y,g,v,x,b,C){if(y!==v||g!==x){var S=b.push(a(b)+"scale(",null,",",null,")");C.push({i:S-4,x:Ha(y,v)},{i:S-2,x:Ha(g,x)})}else(v!==1||x!==1)&&b.push(a(b)+"scale("+v+","+x+")")}return function(y,g){var v=[],x=[];return y=e(y),g=e(g),c(y.translateX,y.translateY,g.translateX,g.translateY,v,x),d(y.rotate,g.rotate,v,x),u(y.skewX,g.skewX,v,x),m(y.scaleX,y.scaleY,g.scaleX,g.scaleY,v,x),y=g=null,function(b){for(var C=-1,S=x.length,L;++C<S;)v[(L=x[C]).i]=L.x(b);return v.join("")}}}var Lk=Av(Ak,"px, ","px)","deg)"),Rk=Av(Tk,", ",")",")"),Pk=1e-12;function jg(e){return((e=Math.exp(e))+1/e)/2}function Ok(e){return((e=Math.exp(e))-1/e)/2}function zk(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ik=(function e(t,n,o){function a(c,d){var u=c[0],m=c[1],y=c[2],g=d[0],v=d[1],x=d[2],b=g-u,C=v-m,S=b*b+C*C,L,M;if(S<Pk)M=Math.log(x/y)/t,L=function(Z){return[u+Z*b,m+Z*C,y*Math.exp(t*Z*M)]};else{var W=Math.sqrt(S),q=(x*x-y*y+o*S)/(2*y*n*W),z=(x*x-y*y-o*S)/(2*x*n*W),Y=Math.log(Math.sqrt(q*q+1)-q),Q=Math.log(Math.sqrt(z*z+1)-z);M=(Q-Y)/t,L=function(Z){var ne=Z*M,ue=jg(Y),de=y/(n*W)*(ue*zk(t*ne+Y)-Ok(Y));return[u+de*b,m+de*C,y*ue/jg(t*ne+Y)]}}return L.duration=M*1e3*t/Math.SQRT2,L}return a.rho=function(c){var d=Math.max(.001,+c),u=d*d,m=u*u;return e(d,u,m)},a})(Math.SQRT2,2,4);var lu=0,Md=0,xd=0,Tv=1e3,Cm,Ad,Em=0,Yl=0,Bm=0,Fd=typeof performance=="object"&&performance.now?performance:Date,Lv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Q_(){return Yl||(Lv(Dk),Yl=Fd.now()+Bm)}function Dk(){Yl=0}function $m(){this._call=this._time=this._next=null}$m.prototype=Rv.prototype={constructor:$m,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Q_():+n)+(t==null?0:+t),!this._next&&Ad!==this&&(Ad?Ad._next=this:Cm=this,Ad=this),this._call=e,this._time=n,j_()},stop:function(){this._call&&(this._call=null,this._time=1/0,j_())}};function Rv(e,t,n){var o=new $m;return o.restart(e,t,n),o}function Fk(){Q_(),++lu;for(var e=Cm,t;e;)(t=Yl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--lu}function kg(){Yl=(Em=Fd.now())+Bm,lu=Md=0;try{Fk()}finally{lu=0,Uk(),Yl=0}}function Bk(){var e=Fd.now(),t=e-Em;t>Tv&&(Bm-=t,Em=e)}function Uk(){for(var e,t=Cm,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Cm=n);Ad=e,j_(o)}function j_(e){if(!lu){Md&&(Md=clearTimeout(Md));var t=e-Yl;t>24?(e<1/0&&(Md=setTimeout(kg,e-Fd.now()-Bm)),xd&&(xd=clearInterval(xd))):(xd||(Em=Fd.now(),xd=setInterval(Bk,Tv)),lu=1,Lv(kg))}}function Ng(e,t,n){var o=new $m;return t=t==null?0:+t,o.restart(a=>{o.stop(),e(a+t)},t,n),o}var Hk=Dm("start","end","cancel","interrupt"),Wk=[],Pv=0,Cg=1,k_=2,hm=3,Eg=4,N_=5,_m=6;function Um(e,t,n,o,a,c){var d=e.__transition;if(!d)e.__transition={};else if(n in d)return;qk(e,n,{name:t,index:o,group:a,on:Hk,tween:Wk,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Pv})}function ep(e,t){var n=Ji(e,t);if(n.state>Pv)throw new Error("too late; already scheduled");return n}function po(e,t){var n=Ji(e,t);if(n.state>hm)throw new Error("too late; already running");return n}function Ji(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function qk(e,t,n){var o=e.__transition,a;o[t]=n,n.timer=Rv(c,0,n.time);function c(y){n.state=Cg,n.timer.restart(d,n.delay,n.time),n.delay<=y&&d(y-n.delay)}function d(y){var g,v,x,b;if(n.state!==Cg)return m();for(g in o)if(b=o[g],b.name===n.name){if(b.state===hm)return Ng(d);b.state===Eg?(b.state=_m,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete o[g]):+g<t&&(b.state=_m,b.timer.stop(),b.on.call("cancel",e,e.__data__,b.index,b.group),delete o[g])}if(Ng(function(){n.state===hm&&(n.state=Eg,n.timer.restart(u,n.delay,n.time),u(y))}),n.state=k_,n.on.call("start",e,e.__data__,n.index,n.group),n.state===k_){for(n.state=hm,a=new Array(x=n.tween.length),g=0,v=-1;g<x;++g)(b=n.tween[g].value.call(e,e.__data__,n.index,n.group))&&(a[++v]=b);a.length=v+1}}function u(y){for(var g=y<n.duration?n.ease.call(null,y/n.duration):(n.timer.restart(m),n.state=N_,1),v=-1,x=a.length;++v<x;)a[v].call(e,g);n.state===N_&&(n.on.call("end",e,e.__data__,n.index,n.group),m())}function m(){n.state=_m,n.timer.stop(),delete o[t];for(var y in o)return;delete e.__transition}}function pm(e,t){var n=e.__transition,o,a,c=!0,d;if(n){t=t==null?null:t+"";for(d in n){if((o=n[d]).name!==t){c=!1;continue}a=o.state>k_&&o.state<N_,o.state=_m,o.timer.stop(),o.on.call(a?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[d]}c&&delete e.__transition}}function Vk(e){return this.each(function(){pm(this,e)})}function Gk(e,t){var n,o;return function(){var a=po(this,e),c=a.tween;if(c!==n){o=n=c;for(var d=0,u=o.length;d<u;++d)if(o[d].name===t){o=o.slice(),o.splice(d,1);break}}a.tween=o}}function Yk(e,t,n){var o,a;if(typeof n!="function")throw new Error;return function(){var c=po(this,e),d=c.tween;if(d!==o){a=(o=d).slice();for(var u={name:t,value:n},m=0,y=a.length;m<y;++m)if(a[m].name===t){a[m]=u;break}m===y&&a.push(u)}c.tween=a}}function Kk(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ji(this.node(),n).tween,a=0,c=o.length,d;a<c;++a)if((d=o[a]).name===e)return d.value;return null}return this.each((t==null?Gk:Yk)(n,e,t))}function tp(e,t,n){var o=e._id;return e.each(function(){var a=po(this,o);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Ji(a,o).value[t]}}function Ov(e,t){var n;return(typeof t=="number"?Ha:t instanceof Dd?bg:(n=Dd(t))?(t=n,bg):Mk)(e,t)}function Xk(e){return function(){this.removeAttribute(e)}}function Jk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zk(e,t,n){var o,a=n+"",c;return function(){var d=this.getAttribute(e);return d===a?null:d===o?c:c=t(o=d,n)}}function Qk(e,t,n){var o,a=n+"",c;return function(){var d=this.getAttributeNS(e.space,e.local);return d===a?null:d===o?c:c=t(o=d,n)}}function eN(e,t,n){var o,a,c;return function(){var d,u=n(this),m;return u==null?void this.removeAttribute(e):(d=this.getAttribute(e),m=u+"",d===m?null:d===o&&m===a?c:(a=m,c=t(o=d,u)))}}function tN(e,t,n){var o,a,c;return function(){var d,u=n(this),m;return u==null?void this.removeAttributeNS(e.space,e.local):(d=this.getAttributeNS(e.space,e.local),m=u+"",d===m?null:d===o&&m===a?c:(a=m,c=t(o=d,u)))}}function nN(e,t){var n=Fm(e),o=n==="transform"?Rk:Ov;return this.attrTween(e,typeof t=="function"?(n.local?tN:eN)(n,o,tp(this,"attr."+e,t)):t==null?(n.local?Jk:Xk)(n):(n.local?Qk:Zk)(n,o,t))}function rN(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function sN(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function iN(e,t){var n,o;function a(){var c=t.apply(this,arguments);return c!==o&&(n=(o=c)&&sN(e,c)),n}return a._value=t,a}function oN(e,t){var n,o;function a(){var c=t.apply(this,arguments);return c!==o&&(n=(o=c)&&rN(e,c)),n}return a._value=t,a}function aN(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Fm(e);return this.tween(n,(o.local?iN:oN)(o,t))}function lN(e,t){return function(){ep(this,e).delay=+t.apply(this,arguments)}}function cN(e,t){return t=+t,function(){ep(this,e).delay=t}}function uN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lN:cN)(t,e)):Ji(this.node(),t).delay}function dN(e,t){return function(){po(this,e).duration=+t.apply(this,arguments)}}function fN(e,t){return t=+t,function(){po(this,e).duration=t}}function mN(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dN:fN)(t,e)):Ji(this.node(),t).duration}function hN(e,t){if(typeof t!="function")throw new Error;return function(){po(this,e).ease=t}}function _N(e){var t=this._id;return arguments.length?this.each(hN(t,e)):Ji(this.node(),t).ease}function pN(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;po(this,e).ease=n}}function gN(e){if(typeof e!="function")throw new Error;return this.each(pN(this._id,e))}function yN(e){typeof e!="function"&&(e=hv(e));for(var t=this._groups,n=t.length,o=new Array(n),a=0;a<n;++a)for(var c=t[a],d=c.length,u=o[a]=[],m,y=0;y<d;++y)(m=c[y])&&e.call(m,m.__data__,y,c)&&u.push(m);return new ta(o,this._parents,this._name,this._id)}function vN(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,a=n.length,c=Math.min(o,a),d=new Array(o),u=0;u<c;++u)for(var m=t[u],y=n[u],g=m.length,v=d[u]=new Array(g),x,b=0;b<g;++b)(x=m[b]||y[b])&&(v[b]=x);for(;u<o;++u)d[u]=t[u];return new ta(d,this._parents,this._name,this._id)}function xN(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function wN(e,t,n){var o,a,c=xN(t)?ep:po;return function(){var d=c(this,e),u=d.on;u!==o&&(a=(o=u).copy()).on(t,n),d.on=a}}function bN(e,t){var n=this._id;return arguments.length<2?Ji(this.node(),n).on.on(e):this.each(wN(n,e,t))}function SN(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function jN(){return this.on("end.remove",SN(this._id))}function kN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=X_(e));for(var o=this._groups,a=o.length,c=new Array(a),d=0;d<a;++d)for(var u=o[d],m=u.length,y=c[d]=new Array(m),g,v,x=0;x<m;++x)(g=u[x])&&(v=e.call(g,g.__data__,x,u))&&("__data__"in g&&(v.__data__=g.__data__),y[x]=v,Um(y[x],t,n,x,y,Ji(g,n)));return new ta(c,this._parents,t,n)}function NN(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mv(e));for(var o=this._groups,a=o.length,c=[],d=[],u=0;u<a;++u)for(var m=o[u],y=m.length,g,v=0;v<y;++v)if(g=m[v]){for(var x=e.call(g,g.__data__,v,m),b,C=Ji(g,n),S=0,L=x.length;S<L;++S)(b=x[S])&&Um(b,t,n,S,x,C);c.push(x),d.push(g)}return new ta(c,d,t,n)}var CN=Kd.prototype.constructor;function EN(){return new CN(this._groups,this._parents)}function $N(e,t){var n,o,a;return function(){var c=au(this,e),d=(this.style.removeProperty(e),au(this,e));return c===d?null:c===n&&d===o?a:a=t(n=c,o=d)}}function zv(e){return function(){this.style.removeProperty(e)}}function MN(e,t,n){var o,a=n+"",c;return function(){var d=au(this,e);return d===a?null:d===o?c:c=t(o=d,n)}}function AN(e,t,n){var o,a,c;return function(){var d=au(this,e),u=n(this),m=u+"";return u==null&&(m=u=(this.style.removeProperty(e),au(this,e))),d===m?null:d===o&&m===a?c:(a=m,c=t(o=d,u))}}function TN(e,t){var n,o,a,c="style."+t,d="end."+c,u;return function(){var m=po(this,e),y=m.on,g=m.value[c]==null?u||(u=zv(t)):void 0;(y!==n||a!==g)&&(o=(n=y).copy()).on(d,a=g),m.on=o}}function LN(e,t,n){var o=(e+="")=="transform"?Lk:Ov;return t==null?this.styleTween(e,$N(e,o)).on("end.style."+e,zv(e)):typeof t=="function"?this.styleTween(e,AN(e,o,tp(this,"style."+e,t))).each(TN(this._id,e)):this.styleTween(e,MN(e,o,t),n).on("end.style."+e,null)}function RN(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function PN(e,t,n){var o,a;function c(){var d=t.apply(this,arguments);return d!==a&&(o=(a=d)&&RN(e,d,n)),o}return c._value=t,c}function ON(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,PN(e,t,n??""))}function zN(e){return function(){this.textContent=e}}function IN(e){return function(){var t=e(this);this.textContent=t??""}}function DN(e){return this.tween("text",typeof e=="function"?IN(tp(this,"text",e)):zN(e==null?"":e+""))}function FN(e){return function(t){this.textContent=e.call(this,t)}}function BN(e){var t,n;function o(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&FN(a)),t}return o._value=e,o}function UN(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,BN(e))}function HN(){for(var e=this._name,t=this._id,n=Iv(),o=this._groups,a=o.length,c=0;c<a;++c)for(var d=o[c],u=d.length,m,y=0;y<u;++y)if(m=d[y]){var g=Ji(m,t);Um(m,e,n,y,d,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new ta(o,this._parents,e,n)}function WN(){var e,t,n=this,o=n._id,a=n.size();return new Promise(function(c,d){var u={value:d},m={value:function(){--a===0&&c()}};n.each(function(){var y=po(this,o),g=y.on;g!==e&&(t=(e=g).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(m)),y.on=t}),a===0&&c()})}var qN=0;function ta(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Iv(){return++qN}var Xo=Kd.prototype;ta.prototype={constructor:ta,select:kN,selectAll:NN,selectChild:Xo.selectChild,selectChildren:Xo.selectChildren,filter:yN,merge:vN,selection:EN,transition:HN,call:Xo.call,nodes:Xo.nodes,node:Xo.node,size:Xo.size,empty:Xo.empty,each:Xo.each,on:bN,attr:nN,attrTween:aN,style:LN,styleTween:ON,text:DN,textTween:UN,remove:jN,tween:Kk,delay:uN,duration:mN,ease:_N,easeVarying:gN,end:WN,[Symbol.iterator]:Xo[Symbol.iterator]};function VN(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var GN={time:null,delay:0,duration:250,ease:VN};function YN(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function KN(e){var t,n;e instanceof ta?(t=e._id,e=e._name):(t=Iv(),(n=GN).time=Q_(),e=e==null?null:e+"");for(var o=this._groups,a=o.length,c=0;c<a;++c)for(var d=o[c],u=d.length,m,y=0;y<u;++y)(m=d[y])&&Um(m,e,t,y,d,n||YN(m,t));return new ta(o,this._parents,e,t)}Kd.prototype.interrupt=Vk;Kd.prototype.transition=KN;const tm=e=>()=>e;function XN(e,{sourceEvent:t,target:n,transform:o,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:a}})}function Jo(e,t,n){this.k=e,this.x=t,this.y=n}Jo.prototype={constructor:Jo,scale:function(e){return e===1?this:new Jo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Jo(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Qo=new Jo(1,0,0);Jo.prototype;function Hh(e){e.stopImmediatePropagation()}function wd(e){e.preventDefault(),e.stopImmediatePropagation()}function JN(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ZN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function $g(){return this.__zoom||Qo}function QN(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function e1(){return navigator.maxTouchPoints||"ontouchstart"in this}function t1(e,t,n){var o=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],c=e.invertY(t[0][1])-n[0][1],d=e.invertY(t[1][1])-n[1][1];return e.translate(a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a),d>c?(c+d)/2:Math.min(0,c)||Math.max(0,d))}function Dv(){var e=JN,t=ZN,n=t1,o=QN,a=e1,c=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],u=250,m=Ik,y=Dm("start","zoom","end"),g,v,x,b=500,C=150,S=0,L=10;function M(j){j.property("__zoom",$g).on("wheel.zoom",ne,{passive:!1}).on("mousedown.zoom",ue).on("dblclick.zoom",de).filter(a).on("touchstart.zoom",pe).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}M.transform=function(j,R,O,ee){var I=j.selection?j.selection():j;I.property("__zoom",$g),j!==I?Y(j,R,O,ee):I.interrupt().each(function(){Q(this,arguments).event(ee).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},M.scaleBy=function(j,R,O,ee){M.scaleTo(j,function(){var I=this.__zoom.k,P=typeof R=="function"?R.apply(this,arguments):R;return I*P},O,ee)},M.scaleTo=function(j,R,O,ee){M.transform(j,function(){var I=t.apply(this,arguments),P=this.__zoom,G=O==null?z(I):typeof O=="function"?O.apply(this,arguments):O,$=P.invert(G),K=typeof R=="function"?R.apply(this,arguments):R;return n(q(W(P,K),G,$),I,d)},O,ee)},M.translateBy=function(j,R,O,ee){M.transform(j,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof O=="function"?O.apply(this,arguments):O),t.apply(this,arguments),d)},null,ee)},M.translateTo=function(j,R,O,ee,I){M.transform(j,function(){var P=t.apply(this,arguments),G=this.__zoom,$=ee==null?z(P):typeof ee=="function"?ee.apply(this,arguments):ee;return n(Qo.translate($[0],$[1]).scale(G.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof O=="function"?-O.apply(this,arguments):-O),P,d)},ee,I)};function W(j,R){return R=Math.max(c[0],Math.min(c[1],R)),R===j.k?j:new Jo(R,j.x,j.y)}function q(j,R,O){var ee=R[0]-O[0]*j.k,I=R[1]-O[1]*j.k;return ee===j.x&&I===j.y?j:new Jo(j.k,ee,I)}function z(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function Y(j,R,O,ee){j.on("start.zoom",function(){Q(this,arguments).event(ee).start()}).on("interrupt.zoom end.zoom",function(){Q(this,arguments).event(ee).end()}).tween("zoom",function(){var I=this,P=arguments,G=Q(I,P).event(ee),$=t.apply(I,P),K=O==null?z($):typeof O=="function"?O.apply(I,P):O,se=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),le=I.__zoom,he=typeof R=="function"?R.apply(I,P):R,be=m(le.invert(K).concat(se/le.k),he.invert(K).concat(se/he.k));return function(je){if(je===1)je=he;else{var Ee=be(je),Fe=se/Ee[2];je=new Jo(Fe,K[0]-Ee[0]*Fe,K[1]-Ee[1]*Fe)}G.zoom(null,je)}})}function Q(j,R,O){return!O&&j.__zooming||new Z(j,R)}function Z(j,R){this.that=j,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,R),this.taps=0}Z.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,R){return this.mouse&&j!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var R=_i(this.that).datum();y.call(j,this.that,new XN(j,{sourceEvent:this.sourceEvent,target:M,transform:this.that.__zoom,dispatch:y}),R)}};function ne(j,...R){if(!e.apply(this,arguments))return;var O=Q(this,R).event(j),ee=this.__zoom,I=Math.max(c[0],Math.min(c[1],ee.k*Math.pow(2,o.apply(this,arguments)))),P=Gi(j);if(O.wheel)(O.mouse[0][0]!==P[0]||O.mouse[0][1]!==P[1])&&(O.mouse[1]=ee.invert(O.mouse[0]=P)),clearTimeout(O.wheel);else{if(ee.k===I)return;O.mouse=[P,ee.invert(P)],pm(this),O.start()}wd(j),O.wheel=setTimeout(G,C),O.zoom("mouse",n(q(W(ee,I),O.mouse[0],O.mouse[1]),O.extent,d));function G(){O.wheel=null,O.end()}}function ue(j,...R){if(x||!e.apply(this,arguments))return;var O=j.currentTarget,ee=Q(this,R,!0).event(j),I=_i(j.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",se,!0),P=Gi(j,O),G=j.clientX,$=j.clientY;jv(j.view),Hh(j),ee.mouse=[P,this.__zoom.invert(P)],pm(this),ee.start();function K(le){if(wd(le),!ee.moved){var he=le.clientX-G,be=le.clientY-$;ee.moved=he*he+be*be>S}ee.event(le).zoom("mouse",n(q(ee.that.__zoom,ee.mouse[0]=Gi(le,O),ee.mouse[1]),ee.extent,d))}function se(le){I.on("mousemove.zoom mouseup.zoom",null),kv(le.view,ee.moved),wd(le),ee.event(le).end()}}function de(j,...R){if(e.apply(this,arguments)){var O=this.__zoom,ee=Gi(j.changedTouches?j.changedTouches[0]:j,this),I=O.invert(ee),P=O.k*(j.shiftKey?.5:2),G=n(q(W(O,P),ee,I),t.apply(this,R),d);wd(j),u>0?_i(this).transition().duration(u).call(Y,G,ee,j):_i(this).call(M.transform,G,ee,j)}}function pe(j,...R){if(e.apply(this,arguments)){var O=j.touches,ee=O.length,I=Q(this,R,j.changedTouches.length===ee).event(j),P,G,$,K;for(Hh(j),G=0;G<ee;++G)$=O[G],K=Gi($,this),K=[K,this.__zoom.invert(K),$.identifier],I.touch0?!I.touch1&&I.touch0[2]!==K[2]&&(I.touch1=K,I.taps=0):(I.touch0=K,P=!0,I.taps=1+!!g);g&&(g=clearTimeout(g)),P&&(I.taps<2&&(v=K[0],g=setTimeout(function(){g=null},b)),pm(this),I.start())}}function D(j,...R){if(this.__zooming){var O=Q(this,R).event(j),ee=j.changedTouches,I=ee.length,P,G,$,K;for(wd(j),P=0;P<I;++P)G=ee[P],$=Gi(G,this),O.touch0&&O.touch0[2]===G.identifier?O.touch0[0]=$:O.touch1&&O.touch1[2]===G.identifier&&(O.touch1[0]=$);if(G=O.that.__zoom,O.touch1){var se=O.touch0[0],le=O.touch0[1],he=O.touch1[0],be=O.touch1[1],je=(je=he[0]-se[0])*je+(je=he[1]-se[1])*je,Ee=(Ee=be[0]-le[0])*Ee+(Ee=be[1]-le[1])*Ee;G=W(G,Math.sqrt(je/Ee)),$=[(se[0]+he[0])/2,(se[1]+he[1])/2],K=[(le[0]+be[0])/2,(le[1]+be[1])/2]}else if(O.touch0)$=O.touch0[0],K=O.touch0[1];else return;O.zoom("touch",n(q(G,$,K),O.extent,d))}}function E(j,...R){if(this.__zooming){var O=Q(this,R).event(j),ee=j.changedTouches,I=ee.length,P,G;for(Hh(j),x&&clearTimeout(x),x=setTimeout(function(){x=null},b),P=0;P<I;++P)G=ee[P],O.touch0&&O.touch0[2]===G.identifier?delete O.touch0:O.touch1&&O.touch1[2]===G.identifier&&delete O.touch1;if(O.touch1&&!O.touch0&&(O.touch0=O.touch1,delete O.touch1),O.touch0)O.touch0[1]=this.__zoom.invert(O.touch0[0]);else if(O.end(),O.taps===2&&(G=Gi(G,this),Math.hypot(v[0]-G[0],v[1]-G[1])<L)){var $=_i(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return M.wheelDelta=function(j){return arguments.length?(o=typeof j=="function"?j:tm(+j),M):o},M.filter=function(j){return arguments.length?(e=typeof j=="function"?j:tm(!!j),M):e},M.touchable=function(j){return arguments.length?(a=typeof j=="function"?j:tm(!!j),M):a},M.extent=function(j){return arguments.length?(t=typeof j=="function"?j:tm([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),M):t},M.scaleExtent=function(j){return arguments.length?(c[0]=+j[0],c[1]=+j[1],M):[c[0],c[1]]},M.translateExtent=function(j){return arguments.length?(d[0][0]=+j[0][0],d[1][0]=+j[1][0],d[0][1]=+j[0][1],d[1][1]=+j[1][1],M):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},M.constrain=function(j){return arguments.length?(n=j,M):n},M.duration=function(j){return arguments.length?(u=+j,M):u},M.interpolate=function(j){return arguments.length?(m=j,M):m},M.on=function(){var j=y.on.apply(y,arguments);return j===y?M:j},M.clickDistance=function(j){return arguments.length?(S=(j=+j)*j,M):Math.sqrt(S)},M.tapDistance=function(j){return arguments.length?(L=+j,M):L},M}const Hm=h.createContext(null),n1=Hm.Provider,na={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Fv=na.error001();function Rn(e,t){const n=h.useContext(Hm);if(n===null)throw new Error(Fv);return dv(n,e,t)}const hr=()=>{const e=h.useContext(Hm);if(e===null)throw new Error(Fv);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},r1=e=>e.userSelectionActive?"none":"all";function Bd({position:e,children:t,className:n,style:o,...a}){const c=Rn(r1),d=`${e}`.split("-");return ye.createElement("div",{className:Pr(["react-flow__panel",n,...d]),style:{...o,pointerEvents:c},...a},t)}function s1({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:ye.createElement(Bd,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ye.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const i1=({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:c={},labelBgPadding:d=[2,4],labelBgBorderRadius:u=2,children:m,className:y,...g})=>{const v=h.useRef(null),[x,b]=h.useState({x:0,y:0,width:0,height:0}),C=Pr(["react-flow__edge-textwrapper",y]);return h.useEffect(()=>{if(v.current){const S=v.current.getBBox();b({x:S.x,y:S.y,width:S.width,height:S.height})}},[n]),typeof n>"u"||!n?null:ye.createElement("g",{transform:`translate(${e-x.width/2} ${t-x.height/2})`,className:C,visibility:x.width?"visible":"hidden",...g},a&&ye.createElement("rect",{width:x.width+2*d[0],x:-d[0],y:-d[1],height:x.height+2*d[1],className:"react-flow__edge-textbg",style:c,rx:u,ry:u}),ye.createElement("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:v,style:o},n),m)};var o1=h.memo(i1);const np=e=>({width:e.offsetWidth,height:e.offsetHeight}),cu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rp=(e={x:0,y:0},t)=>({x:cu(e.x,t[0][0],t[1][0]),y:cu(e.y,t[0][1],t[1][1])}),Mg=(e,t,n)=>e<t?cu(Math.abs(e-t),1,50)/50:e>n?-cu(Math.abs(e-n),1,50)/50:0,Bv=(e,t)=>{const n=Mg(e.x,35,t.width-35)*20,o=Mg(e.y,35,t.height-35)*20;return[n,o]},Uv=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Hv=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ud=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Wv=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ag=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),a1=(e,t)=>Wv(Hv(Ud(e),Ud(t))),C_=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},l1=e=>pi(e.width)&&pi(e.height)&&pi(e.x)&&pi(e.y),pi=e=>!isNaN(e)&&isFinite(e),or=Symbol.for("internals"),qv=["Enter"," ","Escape"],c1=(e,t)=>{},u1=e=>"nativeEvent"in e;function E_(e){var a,c;const t=u1(e)?e.nativeEvent:e,n=((c=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:c[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Vv=e=>"clientX"in e,Ga=(e,t)=>{var c,d;const n=Vv(e),o=n?e.clientX:(c=e.touches)==null?void 0:c[0].clientX,a=n?e.clientY:(d=e.touches)==null?void 0:d[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Mm=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Jd=({id:e,path:t,labelX:n,labelY:o,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:x,interactionWidth:b=20})=>ye.createElement(ye.Fragment,null,ye.createElement("path",{id:e,style:g,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:v,markerStart:x}),b&&ye.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:b,className:"react-flow__edge-interaction"}),a&&pi(n)&&pi(o)?ye.createElement(o1,{x:n,y:o,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y}):null);Jd.displayName="BaseEdge";function bd(e,t,n){return n===void 0?n:o=>{const a=t().edges.find(c=>c.id===e);a&&n(o,{...a})}}function Gv({sourceX:e,sourceY:t,targetX:n,targetY:o}){const a=Math.abs(n-e)/2,c=n<e?n+a:n-a,d=Math.abs(o-t)/2,u=o<t?o+d:o-d;return[c,u,a,d]}function Yv({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:d,targetControlY:u}){const m=e*.125+a*.375+d*.375+n*.125,y=t*.125+c*.375+u*.375+o*.125,g=Math.abs(m-e),v=Math.abs(y-t);return[m,y,g,v]}var Kl;(function(e){e.Strict="strict",e.Loose="loose"})(Kl||(Kl={}));var Ul;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ul||(Ul={}));var Hd;(function(e){e.Partial="partial",e.Full="full"})(Hd||(Hd={}));var Va;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Va||(Va={}));var Wd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wd||(Wd={}));var ut;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ut||(ut={}));function Tg({pos:e,x1:t,y1:n,x2:o,y2:a}){return e===ut.Left||e===ut.Right?[.5*(t+o),n]:[t,.5*(n+a)]}function Kv({sourceX:e,sourceY:t,sourcePosition:n=ut.Bottom,targetX:o,targetY:a,targetPosition:c=ut.Top}){const[d,u]=Tg({pos:n,x1:e,y1:t,x2:o,y2:a}),[m,y]=Tg({pos:c,x1:o,y1:a,x2:e,y2:t}),[g,v,x,b]=Yv({sourceX:e,sourceY:t,targetX:o,targetY:a,sourceControlX:d,sourceControlY:u,targetControlX:m,targetControlY:y});return[`M${e},${t} C${d},${u} ${m},${y} ${o},${a}`,g,v,x,b]}const sp=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:a=ut.Bottom,targetPosition:c=ut.Top,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:x,markerEnd:b,markerStart:C,interactionWidth:S})=>{const[L,M,W]=Kv({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:c});return ye.createElement(Jd,{path:L,labelX:M,labelY:W,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:x,markerEnd:b,markerStart:C,interactionWidth:S})});sp.displayName="SimpleBezierEdge";const Lg={[ut.Left]:{x:-1,y:0},[ut.Right]:{x:1,y:0},[ut.Top]:{x:0,y:-1},[ut.Bottom]:{x:0,y:1}},d1=({source:e,sourcePosition:t=ut.Bottom,target:n})=>t===ut.Left||t===ut.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Rg=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function f1({source:e,sourcePosition:t=ut.Bottom,target:n,targetPosition:o=ut.Top,center:a,offset:c}){const d=Lg[t],u=Lg[o],m={x:e.x+d.x*c,y:e.y+d.y*c},y={x:n.x+u.x*c,y:n.y+u.y*c},g=d1({source:m,sourcePosition:t,target:y}),v=g.x!==0?"x":"y",x=g[v];let b=[],C,S;const L={x:0,y:0},M={x:0,y:0},[W,q,z,Y]=Gv({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(d[v]*u[v]===-1){C=a.x||W,S=a.y||q;const Z=[{x:C,y:m.y},{x:C,y:y.y}],ne=[{x:m.x,y:S},{x:y.x,y:S}];d[v]===x?b=v==="x"?Z:ne:b=v==="x"?ne:Z}else{const Z=[{x:m.x,y:y.y}],ne=[{x:y.x,y:m.y}];if(v==="x"?b=d.x===x?ne:Z:b=d.y===x?Z:ne,t===o){const E=Math.abs(e[v]-n[v]);if(E<=c){const j=Math.min(c-1,c-E);d[v]===x?L[v]=(m[v]>e[v]?-1:1)*j:M[v]=(y[v]>n[v]?-1:1)*j}}if(t!==o){const E=v==="x"?"y":"x",j=d[v]===u[E],R=m[E]>y[E],O=m[E]<y[E];(d[v]===1&&(!j&&R||j&&O)||d[v]!==1&&(!j&&O||j&&R))&&(b=v==="x"?Z:ne)}const ue={x:m.x+L.x,y:m.y+L.y},de={x:y.x+M.x,y:y.y+M.y},pe=Math.max(Math.abs(ue.x-b[0].x),Math.abs(de.x-b[0].x)),D=Math.max(Math.abs(ue.y-b[0].y),Math.abs(de.y-b[0].y));pe>=D?(C=(ue.x+de.x)/2,S=b[0].y):(C=b[0].x,S=(ue.y+de.y)/2)}return[[e,{x:m.x+L.x,y:m.y+L.y},...b,{x:y.x+M.x,y:y.y+M.y},n],C,S,z,Y]}function m1(e,t,n,o){const a=Math.min(Rg(e,t)/2,Rg(t,n)/2,o),{x:c,y:d}=t;if(e.x===c&&c===n.x||e.y===d&&d===n.y)return`L${c} ${d}`;if(e.y===d){const y=e.x<n.x?-1:1,g=e.y<n.y?1:-1;return`L ${c+a*y},${d}Q ${c},${d} ${c},${d+a*g}`}const u=e.x<n.x?1:-1,m=e.y<n.y?-1:1;return`L ${c},${d+a*m}Q ${c},${d} ${c+a*u},${d}`}function $_({sourceX:e,sourceY:t,sourcePosition:n=ut.Bottom,targetX:o,targetY:a,targetPosition:c=ut.Top,borderRadius:d=5,centerX:u,centerY:m,offset:y=20}){const[g,v,x,b,C]=f1({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:a},targetPosition:c,center:{x:u,y:m},offset:y});return[g.reduce((L,M,W)=>{let q="";return W>0&&W<g.length-1?q=m1(g[W-1],M,g[W+1],d):q=`${W===0?"M":"L"}${M.x} ${M.y}`,L+=q,L},""),v,x,b,C]}const Wm=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,sourcePosition:v=ut.Bottom,targetPosition:x=ut.Top,markerEnd:b,markerStart:C,pathOptions:S,interactionWidth:L})=>{const[M,W,q]=$_({sourceX:e,sourceY:t,sourcePosition:v,targetX:n,targetY:o,targetPosition:x,borderRadius:S==null?void 0:S.borderRadius,offset:S==null?void 0:S.offset});return ye.createElement(Jd,{path:M,labelX:W,labelY:q,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:b,markerStart:C,interactionWidth:L})});Wm.displayName="SmoothStepEdge";const ip=h.memo(e=>{var t;return ye.createElement(Wm,{...e,pathOptions:h.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});ip.displayName="StepEdge";function h1({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[a,c,d,u]=Gv({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,a,c,d,u]}const op=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:x,interactionWidth:b})=>{const[C,S,L]=h1({sourceX:e,sourceY:t,targetX:n,targetY:o});return ye.createElement(Jd,{path:C,labelX:S,labelY:L,label:a,labelStyle:c,labelShowBg:d,labelBgStyle:u,labelBgPadding:m,labelBgBorderRadius:y,style:g,markerEnd:v,markerStart:x,interactionWidth:b})});op.displayName="StraightEdge";function nm(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Pg({pos:e,x1:t,y1:n,x2:o,y2:a,c}){switch(e){case ut.Left:return[t-nm(t-o,c),n];case ut.Right:return[t+nm(o-t,c),n];case ut.Top:return[t,n-nm(n-a,c)];case ut.Bottom:return[t,n+nm(a-n,c)]}}function Xv({sourceX:e,sourceY:t,sourcePosition:n=ut.Bottom,targetX:o,targetY:a,targetPosition:c=ut.Top,curvature:d=.25}){const[u,m]=Pg({pos:n,x1:e,y1:t,x2:o,y2:a,c:d}),[y,g]=Pg({pos:c,x1:o,y1:a,x2:e,y2:t,c:d}),[v,x,b,C]=Yv({sourceX:e,sourceY:t,targetX:o,targetY:a,sourceControlX:u,sourceControlY:m,targetControlX:y,targetControlY:g});return[`M${e},${t} C${u},${m} ${y},${g} ${o},${a}`,v,x,b,C]}const Am=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:a=ut.Bottom,targetPosition:c=ut.Top,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:x,markerEnd:b,markerStart:C,pathOptions:S,interactionWidth:L})=>{const[M,W,q]=Xv({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:c,curvature:S==null?void 0:S.curvature});return ye.createElement(Jd,{path:M,labelX:W,labelY:q,label:d,labelStyle:u,labelShowBg:m,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:x,markerEnd:b,markerStart:C,interactionWidth:L})});Am.displayName="BezierEdge";const ap=h.createContext(null),_1=ap.Provider;ap.Consumer;const p1=()=>h.useContext(ap),g1=e=>"id"in e&&"source"in e&&"target"in e,y1=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,M_=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`,v1=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),x1=(e,t)=>{if(!e.source||!e.target)return t;let n;return g1(e)?n={...e}:n={...e,id:y1(e)},v1(n,t)?t:t.concat(n)},A_=({x:e,y:t},[n,o,a],c,[d,u])=>{const m={x:(e-n)/a,y:(t-o)/a};return c?{x:d*Math.round(m.x/d),y:u*Math.round(m.y/u)}:m},Jv=({x:e,y:t},[n,o,a])=>({x:e*a+n,y:t*a+o}),ql=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],a={x:e.position.x-n,y:e.position.y-o};return{...a,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:a}},qm=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,a)=>{const{x:c,y:d}=ql(a,t).positionAbsolute;return Hv(o,Ud({x:c,y:d,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Wv(n)},Zv=(e,t,[n,o,a]=[0,0,1],c=!1,d=!1,u=[0,0])=>{const m={x:(t.x-n)/a,y:(t.y-o)/a,width:t.width/a,height:t.height/a},y=[];return e.forEach(g=>{const{width:v,height:x,selectable:b=!0,hidden:C=!1}=g;if(d&&!b||C)return!1;const{positionAbsolute:S}=ql(g,u),L={x:S.x,y:S.y,width:v||0,height:x||0},M=C_(m,L),W=typeof v>"u"||typeof x>"u"||v===null||x===null,q=c&&M>0,z=(v||0)*(x||0);(W||q||M>=z||g.dragging)&&y.push(g)}),y},Qv=(e,t)=>{const n=e.map(o=>o.id);return t.filter(o=>n.includes(o.source)||n.includes(o.target))},ex=(e,t,n,o,a,c=.1)=>{const d=t/(e.width*(1+c)),u=n/(e.height*(1+c)),m=Math.min(d,u),y=cu(m,o,a),g=e.x+e.width/2,v=e.y+e.height/2,x=t/2-g*y,b=n/2-v*y;return{x,y:b,zoom:y}},zl=(e,t=0)=>e.transition().duration(t);function Og(e,t,n,o){return(t[n]||[]).reduce((a,c)=>{var d,u;return`${e.id}-${c.id}-${n}`!==o&&a.push({id:c.id||null,type:n,nodeId:e.id,x:(((d=e.positionAbsolute)==null?void 0:d.x)??0)+c.x+c.width/2,y:(((u=e.positionAbsolute)==null?void 0:u.y)??0)+c.y+c.height/2}),a},[])}function w1(e,t,n,o,a,c){const{x:d,y:u}=Ga(e),y=t.elementsFromPoint(d,u).find(C=>C.classList.contains("react-flow__handle"));if(y){const C=y.getAttribute("data-nodeid");if(C){const S=lp(void 0,y),L=y.getAttribute("data-handleid"),M=c({nodeId:C,id:L,type:S});if(M){const W=a.find(q=>q.nodeId===C&&q.type===S&&q.id===L);return{handle:{id:L,type:S,nodeId:C,x:(W==null?void 0:W.x)||n.x,y:(W==null?void 0:W.y)||n.y},validHandleResult:M}}}}let g=[],v=1/0;if(a.forEach(C=>{const S=Math.sqrt((C.x-n.x)**2+(C.y-n.y)**2);if(S<=o){const L=c(C);S<=v&&(S<v?g=[{handle:C,validHandleResult:L}]:S===v&&g.push({handle:C,validHandleResult:L}),v=S)}}),!g.length)return{handle:null,validHandleResult:tx()};if(g.length===1)return g[0];const x=g.some(({validHandleResult:C})=>C.isValid),b=g.some(({handle:C})=>C.type==="target");return g.find(({handle:C,validHandleResult:S})=>b?C.type==="target":x?S.isValid:!0)||g[0]}const b1={source:null,target:null,sourceHandle:null,targetHandle:null},tx=()=>({handleDomNode:null,isValid:!1,connection:b1,endHandle:null});function nx(e,t,n,o,a,c,d){const u=a==="target",m=d.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),y={...tx(),handleDomNode:m};if(m){const g=lp(void 0,m),v=m.getAttribute("data-nodeid"),x=m.getAttribute("data-handleid"),b=m.classList.contains("connectable"),C=m.classList.contains("connectableend"),S={source:u?v:n,sourceHandle:u?x:o,target:u?n:v,targetHandle:u?o:x};y.connection=S,b&&C&&(t===Kl.Strict?u&&g==="source"||!u&&g==="target":v!==n||x!==o)&&(y.endHandle={nodeId:v,handleId:x,type:g},y.isValid=c(S))}return y}function S1({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce((a,c)=>{if(c[or]){const{handleBounds:d}=c[or];let u=[],m=[];d&&(u=Og(c,d,"source",`${t}-${n}-${o}`),m=Og(c,d,"target",`${t}-${n}-${o}`)),a.push(...u,...m)}return a},[])}function lp(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Wh(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function j1(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function rx({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:a,getState:c,setState:d,isValidConnection:u,edgeUpdaterType:m,onEdgeUpdateEnd:y}){const g=Uv(e.target),{connectionMode:v,domNode:x,autoPanOnConnect:b,connectionRadius:C,onConnectStart:S,panBy:L,getNodes:M,cancelConnection:W}=c();let q=0,z;const{x:Y,y:Q}=Ga(e),Z=g==null?void 0:g.elementFromPoint(Y,Q),ne=lp(m,Z),ue=x==null?void 0:x.getBoundingClientRect();if(!ue||!ne)return;let de,pe=Ga(e,ue),D=!1,E=null,j=!1,R=null;const O=S1({nodes:M(),nodeId:n,handleId:t,handleType:ne}),ee=()=>{if(!b)return;const[G,$]=Bv(pe,ue);L({x:G,y:$}),q=requestAnimationFrame(ee)};d({connectionPosition:pe,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:ne,connectionStartHandle:{nodeId:n,handleId:t,type:ne},connectionEndHandle:null}),S==null||S(e,{nodeId:n,handleId:t,handleType:ne});function I(G){const{transform:$}=c();pe=Ga(G,ue);const{handle:K,validHandleResult:se}=w1(G,g,A_(pe,$,!1,[1,1]),C,O,le=>nx(le,v,n,t,a?"target":"source",u,g));if(z=K,D||(ee(),D=!0),R=se.handleDomNode,E=se.connection,j=se.isValid,d({connectionPosition:z&&j?Jv({x:z.x,y:z.y},$):pe,connectionStatus:j1(!!z,j),connectionEndHandle:se.endHandle}),!z&&!j&&!R)return Wh(de);E.source!==E.target&&R&&(Wh(de),de=R,R.classList.add("connecting","react-flow__handle-connecting"),R.classList.toggle("valid",j),R.classList.toggle("react-flow__handle-valid",j))}function P(G){var $,K;(z||R)&&E&&j&&(o==null||o(E)),(K=($=c()).onConnectEnd)==null||K.call($,G),m&&(y==null||y(G)),Wh(de),W(),cancelAnimationFrame(q),D=!1,j=!1,E=null,R=null,g.removeEventListener("mousemove",I),g.removeEventListener("mouseup",P),g.removeEventListener("touchmove",I),g.removeEventListener("touchend",P)}g.addEventListener("mousemove",I),g.addEventListener("mouseup",P),g.addEventListener("touchmove",I),g.addEventListener("touchend",P)}const zg=()=>!0,k1=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),N1=(e,t,n)=>o=>{const{connectionStartHandle:a,connectionEndHandle:c,connectionClickStartHandle:d}=o;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n||(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.handleId)===t&&(c==null?void 0:c.type)===n,clickConnecting:(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.handleId)===t&&(d==null?void 0:d.type)===n}},sx=h.forwardRef(({type:e="source",position:t=ut.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:c=!0,id:d,onConnect:u,children:m,className:y,onMouseDown:g,onTouchStart:v,...x},b)=>{var ue,de;const C=d||null,S=e==="target",L=hr(),M=p1(),{connectOnClick:W,noPanClassName:q}=Rn(k1,kr),{connecting:z,clickConnecting:Y}=Rn(N1(M,C,e),kr);M||(de=(ue=L.getState()).onError)==null||de.call(ue,"010",na.error010());const Q=pe=>{const{defaultEdgeOptions:D,onConnect:E,hasDefaultEdges:j}=L.getState(),R={...D,...pe};if(j){const{edges:O,setEdges:ee}=L.getState();ee(x1(R,O))}E==null||E(R),u==null||u(R)},Z=pe=>{if(!M)return;const D=Vv(pe);a&&(D&&pe.button===0||!D)&&rx({event:pe,handleId:C,nodeId:M,onConnect:Q,isTarget:S,getState:L.getState,setState:L.setState,isValidConnection:n||L.getState().isValidConnection||zg}),D?g==null||g(pe):v==null||v(pe)},ne=pe=>{const{onClickConnectStart:D,onClickConnectEnd:E,connectionClickStartHandle:j,connectionMode:R,isValidConnection:O}=L.getState();if(!M||!j&&!a)return;if(!j){D==null||D(pe,{nodeId:M,handleId:C,handleType:e}),L.setState({connectionClickStartHandle:{nodeId:M,type:e,handleId:C}});return}const ee=Uv(pe.target),I=n||O||zg,{connection:P,isValid:G}=nx({nodeId:M,id:C,type:e},R,j.nodeId,j.handleId||null,j.type,I,ee);G&&Q(P),E==null||E(pe),L.setState({connectionClickStartHandle:null})};return ye.createElement("div",{"data-handleid":C,"data-nodeid":M,"data-handlepos":t,"data-id":`${M}-${C}-${e}`,className:Pr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",q,y,{source:!S,target:S,connectable:o,connectablestart:a,connectableend:c,connecting:Y,connectionindicator:o&&(a&&!z||c&&z)}]),onMouseDown:Z,onTouchStart:Z,onClick:W?ne:void 0,ref:b,...x},m)});sx.displayName="Handle";var Tm=h.memo(sx);const ix=({data:e,isConnectable:t,targetPosition:n=ut.Top,sourcePosition:o=ut.Bottom})=>ye.createElement(ye.Fragment,null,ye.createElement(Tm,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,ye.createElement(Tm,{type:"source",position:o,isConnectable:t}));ix.displayName="DefaultNode";var T_=h.memo(ix);const ox=({data:e,isConnectable:t,sourcePosition:n=ut.Bottom})=>ye.createElement(ye.Fragment,null,e==null?void 0:e.label,ye.createElement(Tm,{type:"source",position:n,isConnectable:t}));ox.displayName="InputNode";var ax=h.memo(ox);const lx=({data:e,isConnectable:t,targetPosition:n=ut.Top})=>ye.createElement(ye.Fragment,null,ye.createElement(Tm,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);lx.displayName="OutputNode";var cx=h.memo(lx);const cp=()=>null;cp.displayName="GroupNode";const C1=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),rm=e=>e.id;function E1(e,t){return kr(e.selectedNodes.map(rm),t.selectedNodes.map(rm))&&kr(e.selectedEdges.map(rm),t.selectedEdges.map(rm))}const ux=h.memo(({onSelectionChange:e})=>{const t=hr(),{selectedNodes:n,selectedEdges:o}=Rn(C1,E1);return h.useEffect(()=>{const a={nodes:n,edges:o};e==null||e(a),t.getState().onSelectionChange.forEach(c=>c(a))},[n,o,e]),null});ux.displayName="SelectionListener";const $1=e=>!!e.onSelectionChange;function M1({onSelectionChange:e}){const t=Rn($1);return e||t?ye.createElement(ux,{onSelectionChange:e}):null}const A1=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Wc(e,t){h.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Ut(e,t,n){h.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const T1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:c,onConnectEnd:d,onClickConnectStart:u,onClickConnectEnd:m,nodesDraggable:y,nodesConnectable:g,nodesFocusable:v,edgesFocusable:x,edgesUpdatable:b,elevateNodesOnSelect:C,minZoom:S,maxZoom:L,nodeExtent:M,onNodesChange:W,onEdgesChange:q,elementsSelectable:z,connectionMode:Y,snapGrid:Q,snapToGrid:Z,translateExtent:ne,connectOnClick:ue,defaultEdgeOptions:de,fitView:pe,fitViewOptions:D,onNodesDelete:E,onEdgesDelete:j,onNodeDrag:R,onNodeDragStart:O,onNodeDragStop:ee,onSelectionDrag:I,onSelectionDragStart:P,onSelectionDragStop:G,noPanClassName:$,nodeOrigin:K,rfId:se,autoPanOnConnect:le,autoPanOnNodeDrag:he,onError:be,connectionRadius:je,isValidConnection:Ee,nodeDragThreshold:Fe})=>{const{setNodes:Ye,setEdges:Ke,setDefaultNodesAndEdges:Ct,setMinZoom:wt,setMaxZoom:at,setTranslateExtent:yt,setNodeExtent:nt,reset:Ne}=Rn(A1,kr),Oe=hr();return h.useEffect(()=>{const st=o==null?void 0:o.map(ve=>({...ve,...de}));return Ct(n,st),()=>{Ne()}},[]),Ut("defaultEdgeOptions",de,Oe.setState),Ut("connectionMode",Y,Oe.setState),Ut("onConnect",a,Oe.setState),Ut("onConnectStart",c,Oe.setState),Ut("onConnectEnd",d,Oe.setState),Ut("onClickConnectStart",u,Oe.setState),Ut("onClickConnectEnd",m,Oe.setState),Ut("nodesDraggable",y,Oe.setState),Ut("nodesConnectable",g,Oe.setState),Ut("nodesFocusable",v,Oe.setState),Ut("edgesFocusable",x,Oe.setState),Ut("edgesUpdatable",b,Oe.setState),Ut("elementsSelectable",z,Oe.setState),Ut("elevateNodesOnSelect",C,Oe.setState),Ut("snapToGrid",Z,Oe.setState),Ut("snapGrid",Q,Oe.setState),Ut("onNodesChange",W,Oe.setState),Ut("onEdgesChange",q,Oe.setState),Ut("connectOnClick",ue,Oe.setState),Ut("fitViewOnInit",pe,Oe.setState),Ut("fitViewOnInitOptions",D,Oe.setState),Ut("onNodesDelete",E,Oe.setState),Ut("onEdgesDelete",j,Oe.setState),Ut("onNodeDrag",R,Oe.setState),Ut("onNodeDragStart",O,Oe.setState),Ut("onNodeDragStop",ee,Oe.setState),Ut("onSelectionDrag",I,Oe.setState),Ut("onSelectionDragStart",P,Oe.setState),Ut("onSelectionDragStop",G,Oe.setState),Ut("noPanClassName",$,Oe.setState),Ut("nodeOrigin",K,Oe.setState),Ut("rfId",se,Oe.setState),Ut("autoPanOnConnect",le,Oe.setState),Ut("autoPanOnNodeDrag",he,Oe.setState),Ut("onError",be,Oe.setState),Ut("connectionRadius",je,Oe.setState),Ut("isValidConnection",Ee,Oe.setState),Ut("nodeDragThreshold",Fe,Oe.setState),Wc(e,Ye),Wc(t,Ke),Wc(S,wt),Wc(L,at),Wc(ne,yt),Wc(M,nt),null},Ig={display:"none"},L1={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},dx="react-flow__node-desc",fx="react-flow__edge-desc",R1="react-flow__aria-live",P1=e=>e.ariaLiveMessage;function O1({rfId:e}){const t=Rn(P1);return ye.createElement("div",{id:`${R1}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:L1},t)}function z1({rfId:e,disableKeyboardA11y:t}){return ye.createElement(ye.Fragment,null,ye.createElement("div",{id:`${dx}-${e}`,style:Ig},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ye.createElement("div",{id:`${fx}-${e}`,style:Ig},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&ye.createElement(O1,{rfId:e}))}var qd=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=h.useState(!1),a=h.useRef(!1),c=h.useRef(new Set([])),[d,u]=h.useMemo(()=>{if(e!==null){const y=(Array.isArray(e)?e:[e]).filter(v=>typeof v=="string").map(v=>v.split("+")),g=y.reduce((v,x)=>v.concat(...x),[]);return[y,g]}return[[],[]]},[e]);return h.useEffect(()=>{const m=typeof document<"u"?document:null,y=(t==null?void 0:t.target)||m;if(e!==null){const g=b=>{if(a.current=b.ctrlKey||b.metaKey||b.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&E_(b))return!1;const S=Fg(b.code,u);c.current.add(b[S]),Dg(d,c.current,!1)&&(b.preventDefault(),o(!0))},v=b=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&E_(b))return!1;const S=Fg(b.code,u);Dg(d,c.current,!0)?(o(!1),c.current.clear()):c.current.delete(b[S]),b.key==="Meta"&&c.current.clear(),a.current=!1},x=()=>{c.current.clear(),o(!1)};return y==null||y.addEventListener("keydown",g),y==null||y.addEventListener("keyup",v),window.addEventListener("blur",x),()=>{y==null||y.removeEventListener("keydown",g),y==null||y.removeEventListener("keyup",v),window.removeEventListener("blur",x)}}},[e,o]),n};function Dg(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(a=>t.has(a)))}function Fg(e,t){return t.includes(e)?"code":"key"}function mx(e,t,n,o){var d,u;if(!e.parentNode)return n;const a=t.get(e.parentNode),c=ql(a,o);return mx(a,t,{x:(n.x??0)+c.x,y:(n.y??0)+c.y,z:(((d=a[or])==null?void 0:d.z)??0)>(n.z??0)?((u=a[or])==null?void 0:u.z)??0:n.z??0},o)}function hx(e,t,n){e.forEach(o=>{var a;if(o.parentNode&&!e.has(o.parentNode))throw new Error(`Parent node ${o.parentNode} not found`);if(o.parentNode||n!=null&&n[o.id]){const{x:c,y:d,z:u}=mx(o,e,{...o.position,z:((a=o[or])==null?void 0:a.z)??0},t);o.positionAbsolute={x:c,y:d},o[or].z=u,n!=null&&n[o.id]&&(o[or].isParent=!0)}})}function qh(e,t,n,o){const a=new Map,c={},d=o?1e3:0;return e.forEach(u=>{var x;const m=(pi(u.zIndex)?u.zIndex:0)+(u.selected?d:0),y=t.get(u.id),g={...u,positionAbsolute:{x:u.position.x,y:u.position.y}};u.parentNode&&(c[u.parentNode]=!0);const v=(y==null?void 0:y.type)&&(y==null?void 0:y.type)!==u.type;Object.defineProperty(g,or,{enumerable:!1,value:{handleBounds:v||(x=y==null?void 0:y[or])==null?void 0:x.handleBounds,z:m}}),a.set(u.id,g)}),hx(a,n,c),a}function _x(e,t={}){const{getNodes:n,width:o,height:a,minZoom:c,maxZoom:d,d3Zoom:u,d3Selection:m,fitViewOnInitDone:y,fitViewOnInit:g,nodeOrigin:v}=e(),x=t.initial&&!y&&g;if(u&&m&&(x||!t.initial)){const C=n().filter(L=>{var W;const M=t.includeHiddenNodes?L.width&&L.height:!L.hidden;return(W=t.nodes)!=null&&W.length?M&&t.nodes.some(q=>q.id===L.id):M}),S=C.every(L=>L.width&&L.height);if(C.length>0&&S){const L=qm(C,v),{x:M,y:W,zoom:q}=ex(L,o,a,t.minZoom??c,t.maxZoom??d,t.padding??.1),z=Qo.translate(M,W).scale(q);return typeof t.duration=="number"&&t.duration>0?u.transform(zl(m,t.duration),z):u.transform(m,z),!0}}return!1}function I1(e,t){return e.forEach(n=>{const o=t.get(n.id);o&&t.set(o.id,{...o,[or]:o[or],selected:n.selected})}),new Map(t)}function D1(e,t){return t.map(n=>{const o=e.find(a=>a.id===n.id);return o&&(n.selected=o.selected),n})}function sm({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:a,edges:c,onNodesChange:d,onEdgesChange:u,hasDefaultNodes:m,hasDefaultEdges:y}=n();e!=null&&e.length&&(m&&o({nodeInternals:I1(e,a)}),d==null||d(e)),t!=null&&t.length&&(y&&o({edges:D1(t,c)}),u==null||u(t))}const qc=()=>{},F1={zoomIn:qc,zoomOut:qc,zoomTo:qc,getZoom:()=>1,setViewport:qc,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:qc,fitBounds:qc,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},B1=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),U1=()=>{const e=hr(),{d3Zoom:t,d3Selection:n}=Rn(B1,kr);return h.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(zl(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(zl(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,c)=>t.scaleTo(zl(n,c==null?void 0:c.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,c)=>{const[d,u,m]=e.getState().transform,y=Qo.translate(a.x??d,a.y??u).scale(a.zoom??m);t.transform(zl(n,c==null?void 0:c.duration),y)},getViewport:()=>{const[a,c,d]=e.getState().transform;return{x:a,y:c,zoom:d}},fitView:a=>_x(e.getState,a),setCenter:(a,c,d)=>{const{width:u,height:m,maxZoom:y}=e.getState(),g=typeof(d==null?void 0:d.zoom)<"u"?d.zoom:y,v=u/2-a*g,x=m/2-c*g,b=Qo.translate(v,x).scale(g);t.transform(zl(n,d==null?void 0:d.duration),b)},fitBounds:(a,c)=>{const{width:d,height:u,minZoom:m,maxZoom:y}=e.getState(),{x:g,y:v,zoom:x}=ex(a,d,u,m,y,(c==null?void 0:c.padding)??.1),b=Qo.translate(g,v).scale(x);t.transform(zl(n,c==null?void 0:c.duration),b)},project:a=>{const{transform:c,snapToGrid:d,snapGrid:u}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),A_(a,c,d,u)},screenToFlowPosition:a=>{const{transform:c,snapToGrid:d,snapGrid:u,domNode:m}=e.getState();if(!m)return a;const{x:y,y:g}=m.getBoundingClientRect(),v={x:a.x-y,y:a.y-g};return A_(v,c,d,u)},flowToScreenPosition:a=>{const{transform:c,domNode:d}=e.getState();if(!d)return a;const{x:u,y:m}=d.getBoundingClientRect(),y=Jv(a,c);return{x:y.x+u,y:y.y+m}},viewportInitialized:!0}:F1,[t,n])};function up(){const e=U1(),t=hr(),n=h.useCallback(()=>t.getState().getNodes().map(S=>({...S})),[]),o=h.useCallback(S=>t.getState().nodeInternals.get(S),[]),a=h.useCallback(()=>{const{edges:S=[]}=t.getState();return S.map(L=>({...L}))},[]),c=h.useCallback(S=>{const{edges:L=[]}=t.getState();return L.find(M=>M.id===S)},[]),d=h.useCallback(S=>{const{getNodes:L,setNodes:M,hasDefaultNodes:W,onNodesChange:q}=t.getState(),z=L(),Y=typeof S=="function"?S(z):S;if(W)M(Y);else if(q){const Q=Y.length===0?z.map(Z=>({type:"remove",id:Z.id})):Y.map(Z=>({item:Z,type:"reset"}));q(Q)}},[]),u=h.useCallback(S=>{const{edges:L=[],setEdges:M,hasDefaultEdges:W,onEdgesChange:q}=t.getState(),z=typeof S=="function"?S(L):S;if(W)M(z);else if(q){const Y=z.length===0?L.map(Q=>({type:"remove",id:Q.id})):z.map(Q=>({item:Q,type:"reset"}));q(Y)}},[]),m=h.useCallback(S=>{const L=Array.isArray(S)?S:[S],{getNodes:M,setNodes:W,hasDefaultNodes:q,onNodesChange:z}=t.getState();if(q){const Q=[...M(),...L];W(Q)}else if(z){const Y=L.map(Q=>({item:Q,type:"add"}));z(Y)}},[]),y=h.useCallback(S=>{const L=Array.isArray(S)?S:[S],{edges:M=[],setEdges:W,hasDefaultEdges:q,onEdgesChange:z}=t.getState();if(q)W([...M,...L]);else if(z){const Y=L.map(Q=>({item:Q,type:"add"}));z(Y)}},[]),g=h.useCallback(()=>{const{getNodes:S,edges:L=[],transform:M}=t.getState(),[W,q,z]=M;return{nodes:S().map(Y=>({...Y})),edges:L.map(Y=>({...Y})),viewport:{x:W,y:q,zoom:z}}},[]),v=h.useCallback(({nodes:S,edges:L})=>{const{nodeInternals:M,getNodes:W,edges:q,hasDefaultNodes:z,hasDefaultEdges:Y,onNodesDelete:Q,onEdgesDelete:Z,onNodesChange:ne,onEdgesChange:ue}=t.getState(),de=(S||[]).map(R=>R.id),pe=(L||[]).map(R=>R.id),D=W().reduce((R,O)=>{const ee=!de.includes(O.id)&&O.parentNode&&R.find(P=>P.id===O.parentNode);return(typeof O.deletable=="boolean"?O.deletable:!0)&&(de.includes(O.id)||ee)&&R.push(O),R},[]),E=q.filter(R=>typeof R.deletable=="boolean"?R.deletable:!0),j=E.filter(R=>pe.includes(R.id));if(D||j){const R=Qv(D,E),O=[...j,...R],ee=O.reduce((I,P)=>(I.includes(P.id)||I.push(P.id),I),[]);if((Y||z)&&(Y&&t.setState({edges:q.filter(I=>!ee.includes(I.id))}),z&&(D.forEach(I=>{M.delete(I.id)}),t.setState({nodeInternals:new Map(M)}))),ee.length>0&&(Z==null||Z(O),ue&&ue(ee.map(I=>({id:I,type:"remove"})))),D.length>0&&(Q==null||Q(D),ne)){const I=D.map(P=>({id:P.id,type:"remove"}));ne(I)}}},[]),x=h.useCallback(S=>{const L=l1(S),M=L?null:t.getState().nodeInternals.get(S.id);return!L&&!M?[null,null,L]:[L?S:Ag(M),M,L]},[]),b=h.useCallback((S,L=!0,M)=>{const[W,q,z]=x(S);return W?(M||t.getState().getNodes()).filter(Y=>{if(!z&&(Y.id===q.id||!Y.positionAbsolute))return!1;const Q=Ag(Y),Z=C_(Q,W);return L&&Z>0||Z>=W.width*W.height}):[]},[]),C=h.useCallback((S,L,M=!0)=>{const[W]=x(S);if(!W)return!1;const q=C_(W,L);return M&&q>0||q>=W.width*W.height},[]);return h.useMemo(()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:c,setNodes:d,setEdges:u,addNodes:m,addEdges:y,toObject:g,deleteElements:v,getIntersectingNodes:b,isNodeIntersecting:C}),[e,n,o,a,c,d,u,m,y,g,v,b,C])}const H1={actInsideInputWithModifier:!1};var W1=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=hr(),{deleteElements:o}=up(),a=qd(e,H1),c=qd(t);h.useEffect(()=>{if(a){const{edges:d,getNodes:u}=n.getState(),m=u().filter(g=>g.selected),y=d.filter(g=>g.selected);o({nodes:m,edges:y}),n.setState({nodesSelectionActive:!1})}},[a]),h.useEffect(()=>{n.setState({multiSelectionActive:c})},[c])};function q1(e){const t=hr();h.useEffect(()=>{let n;const o=()=>{var c,d;if(!e.current)return;const a=np(e.current);(a.height===0||a.width===0)&&((d=(c=t.getState()).onError)==null||d.call(c,"004",na.error004())),t.setState({width:a.width||500,height:a.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver(()=>o()),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}},[])}const dp={position:"absolute",width:"100%",height:"100%",top:0,left:0},V1=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,im=e=>({x:e.x,y:e.y,zoom:e.k}),Vc=(e,t)=>e.target.closest(`.${t}`),Bg=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ug=e=>{const t=e.ctrlKey&&Mm()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},G1=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),Y1=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:c=!0,panOnScroll:d=!1,panOnScrollSpeed:u=.5,panOnScrollMode:m=Ul.Free,zoomOnDoubleClick:y=!0,elementsSelectable:g,panOnDrag:v=!0,defaultViewport:x,translateExtent:b,minZoom:C,maxZoom:S,zoomActivationKeyCode:L,preventScrolling:M=!0,children:W,noWheelClassName:q,noPanClassName:z})=>{const Y=h.useRef(),Q=hr(),Z=h.useRef(!1),ne=h.useRef(!1),ue=h.useRef(null),de=h.useRef({x:0,y:0,zoom:0}),{d3Zoom:pe,d3Selection:D,d3ZoomHandler:E,userSelectionActive:j}=Rn(G1,kr),R=qd(L),O=h.useRef(0),ee=h.useRef(!1),I=h.useRef();return q1(ue),h.useEffect(()=>{if(ue.current){const P=ue.current.getBoundingClientRect(),G=Dv().scaleExtent([C,S]).translateExtent(b),$=_i(ue.current).call(G),K=Qo.translate(x.x,x.y).scale(cu(x.zoom,C,S)),se=[[0,0],[P.width,P.height]],le=G.constrain()(K,se,b);G.transform($,le),G.wheelDelta(Ug),Q.setState({d3Zoom:G,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[le.x,le.y,le.k],domNode:ue.current.closest(".react-flow")})}},[]),h.useEffect(()=>{D&&pe&&(d&&!R&&!j?D.on("wheel.zoom",P=>{if(Vc(P,q))return!1;P.preventDefault(),P.stopImmediatePropagation();const G=D.property("__zoom").k||1,$=Mm();if(P.ctrlKey&&c&&$){const Fe=Gi(P),Ye=Ug(P),Ke=G*Math.pow(2,Ye);pe.scaleTo(D,Ke,Fe,P);return}const K=P.deltaMode===1?20:1;let se=m===Ul.Vertical?0:P.deltaX*K,le=m===Ul.Horizontal?0:P.deltaY*K;!$&&P.shiftKey&&m!==Ul.Vertical&&(se=P.deltaY*K,le=0),pe.translateBy(D,-(se/G)*u,-(le/G)*u,{internal:!0});const he=im(D.property("__zoom")),{onViewportChangeStart:be,onViewportChange:je,onViewportChangeEnd:Ee}=Q.getState();clearTimeout(I.current),ee.current||(ee.current=!0,t==null||t(P,he),be==null||be(he)),ee.current&&(e==null||e(P,he),je==null||je(he),I.current=setTimeout(()=>{n==null||n(P,he),Ee==null||Ee(he),ee.current=!1},150))},{passive:!1}):typeof E<"u"&&D.on("wheel.zoom",function(P,G){if(!M||Vc(P,q))return null;P.preventDefault(),E.call(this,P,G)},{passive:!1}))},[j,d,m,D,pe,E,R,c,M,q,t,e,n]),h.useEffect(()=>{pe&&pe.on("start",P=>{var K,se;if(!P.sourceEvent||P.sourceEvent.internal)return null;O.current=(K=P.sourceEvent)==null?void 0:K.button;const{onViewportChangeStart:G}=Q.getState(),$=im(P.transform);Z.current=!0,de.current=$,((se=P.sourceEvent)==null?void 0:se.type)==="mousedown"&&Q.setState({paneDragging:!0}),G==null||G($),t==null||t(P.sourceEvent,$)})},[pe,t]),h.useEffect(()=>{pe&&(j&&!Z.current?pe.on("zoom",null):j||pe.on("zoom",P=>{var $;const{onViewportChange:G}=Q.getState();if(Q.setState({transform:[P.transform.x,P.transform.y,P.transform.k]}),ne.current=!!(o&&Bg(v,O.current??0)),(e||G)&&!(($=P.sourceEvent)!=null&&$.internal)){const K=im(P.transform);G==null||G(K),e==null||e(P.sourceEvent,K)}}))},[j,pe,e,v,o]),h.useEffect(()=>{pe&&pe.on("end",P=>{if(!P.sourceEvent||P.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=Q.getState();if(Z.current=!1,Q.setState({paneDragging:!1}),o&&Bg(v,O.current??0)&&!ne.current&&o(P.sourceEvent),ne.current=!1,(n||G)&&V1(de.current,P.transform)){const $=im(P.transform);de.current=$,clearTimeout(Y.current),Y.current=setTimeout(()=>{G==null||G($),n==null||n(P.sourceEvent,$)},d?150:0)}})},[pe,d,v,n,o]),h.useEffect(()=>{pe&&pe.filter(P=>{const G=R||a,$=c&&P.ctrlKey;if((v===!0||Array.isArray(v)&&v.includes(1))&&P.button===1&&P.type==="mousedown"&&(Vc(P,"react-flow__node")||Vc(P,"react-flow__edge")))return!0;if(!v&&!G&&!d&&!y&&!c||j||!y&&P.type==="dblclick"||Vc(P,q)&&P.type==="wheel"||Vc(P,z)&&(P.type!=="wheel"||d&&P.type==="wheel"&&!R)||!c&&P.ctrlKey&&P.type==="wheel"||!G&&!d&&!$&&P.type==="wheel"||!v&&(P.type==="mousedown"||P.type==="touchstart")||Array.isArray(v)&&!v.includes(P.button)&&(P.type==="mousedown"||P.type==="touchstart"))return!1;const K=Array.isArray(v)&&v.includes(P.button)||!P.button||P.button<=1;return(!P.ctrlKey||P.type==="wheel")&&K})},[j,pe,a,c,d,y,v,g,R]),ye.createElement("div",{className:"react-flow__renderer",ref:ue,style:dp},W)},K1=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function X1(){const{userSelectionActive:e,userSelectionRect:t}=Rn(K1,kr);return e&&t?ye.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Hg(e,t){const n=e.find(o=>o.id===t.parentNode);if(n){const o=t.position.x+t.width-n.width,a=t.position.y+t.height-n.height;if(o>0||a>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,o>0&&(n.style.width+=o),a>0&&(n.style.height+=a),t.position.x<0){const c=Math.abs(t.position.x);n.position.x=n.position.x-c,n.style.width+=c,t.position.x=0}if(t.position.y<0){const c=Math.abs(t.position.y);n.position.y=n.position.y-c,n.style.height+=c,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function J1(e,t){if(e.some(o=>o.type==="reset"))return e.filter(o=>o.type==="reset").map(o=>o.item);const n=e.filter(o=>o.type==="add").map(o=>o.item);return t.reduce((o,a)=>{const c=e.filter(u=>u.id===a.id);if(c.length===0)return o.push(a),o;const d={...a};for(const u of c)if(u)switch(u.type){case"select":{d.selected=u.selected;break}case"position":{typeof u.position<"u"&&(d.position=u.position),typeof u.positionAbsolute<"u"&&(d.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(d.dragging=u.dragging),d.expandParent&&Hg(o,d);break}case"dimensions":{typeof u.dimensions<"u"&&(d.width=u.dimensions.width,d.height=u.dimensions.height),typeof u.updateStyle<"u"&&(d.style={...d.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(d.resizing=u.resizing),d.expandParent&&Hg(o,d);break}case"remove":return o}return o.push(d),o},n)}function Z1(e,t){return J1(e,t)}const Wa=(e,t)=>({id:e,type:"select",selected:t});function Jc(e,t){return e.reduce((n,o)=>{const a=t.includes(o.id);return!o.selected&&a?(o.selected=!0,n.push(Wa(o.id,!0))):o.selected&&!a&&(o.selected=!1,n.push(Wa(o.id,!1))),n},[])}const Vh=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Q1=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),px=h.memo(({isSelecting:e,selectionMode:t=Hd.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:m,onPaneMouseMove:y,onPaneMouseLeave:g,children:v})=>{const x=h.useRef(null),b=hr(),C=h.useRef(0),S=h.useRef(0),L=h.useRef(),{userSelectionActive:M,elementsSelectable:W,dragging:q}=Rn(Q1,kr),z=()=>{b.setState({userSelectionActive:!1,userSelectionRect:null}),C.current=0,S.current=0},Y=E=>{c==null||c(E),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},Q=E=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){E.preventDefault();return}d==null||d(E)},Z=u?E=>u(E):void 0,ne=E=>{const{resetSelectedElements:j,domNode:R}=b.getState();if(L.current=R==null?void 0:R.getBoundingClientRect(),!W||!e||E.button!==0||E.target!==x.current||!L.current)return;const{x:O,y:ee}=Ga(E,L.current);j(),b.setState({userSelectionRect:{width:0,height:0,startX:O,startY:ee,x:O,y:ee}}),o==null||o(E)},ue=E=>{const{userSelectionRect:j,nodeInternals:R,edges:O,transform:ee,onNodesChange:I,onEdgesChange:P,nodeOrigin:G,getNodes:$}=b.getState();if(!e||!L.current||!j)return;b.setState({userSelectionActive:!0,nodesSelectionActive:!1});const K=Ga(E,L.current),se=j.startX??0,le=j.startY??0,he={...j,x:K.x<se?K.x:se,y:K.y<le?K.y:le,width:Math.abs(K.x-se),height:Math.abs(K.y-le)},be=$(),je=Zv(R,he,ee,t===Hd.Partial,!0,G),Ee=Qv(je,O).map(Ye=>Ye.id),Fe=je.map(Ye=>Ye.id);if(C.current!==Fe.length){C.current=Fe.length;const Ye=Jc(be,Fe);Ye.length&&(I==null||I(Ye))}if(S.current!==Ee.length){S.current=Ee.length;const Ye=Jc(O,Ee);Ye.length&&(P==null||P(Ye))}b.setState({userSelectionRect:he})},de=E=>{if(E.button!==0)return;const{userSelectionRect:j}=b.getState();!M&&j&&E.target===x.current&&(Y==null||Y(E)),b.setState({nodesSelectionActive:C.current>0}),z(),a==null||a(E)},pe=E=>{M&&(b.setState({nodesSelectionActive:C.current>0}),a==null||a(E)),z()},D=W&&(e||M);return ye.createElement("div",{className:Pr(["react-flow__pane",{dragging:q,selection:e}]),onClick:D?void 0:Vh(Y,x),onContextMenu:Vh(Q,x),onWheel:Vh(Z,x),onMouseEnter:D?void 0:m,onMouseDown:D?ne:void 0,onMouseMove:D?ue:y,onMouseUp:D?de:void 0,onMouseLeave:D?pe:g,ref:x,style:dp},v,ye.createElement(X1,null))});px.displayName="Pane";function gx(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:gx(n,t):!1}function Wg(e,t,n){let o=e;do{if(o!=null&&o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function e2(e,t,n,o){return Array.from(e.values()).filter(a=>(a.selected||a.id===o)&&(!a.parentNode||!gx(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var c,d;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((c=a.positionAbsolute)==null?void 0:c.x)??0),y:n.y-(((d=a.positionAbsolute)==null?void 0:d.y)??0)},delta:{x:0,y:0},extent:a.extent,parentNode:a.parentNode,width:a.width,height:a.height,expandParent:a.expandParent}})}function t2(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function yx(e,t,n,o,a=[0,0],c){const d=t2(e,e.extent||o);let u=d;if(e.extent==="parent"&&!e.expandParent)if(e.parentNode&&e.width&&e.height){const g=n.get(e.parentNode),{x:v,y:x}=ql(g,a).positionAbsolute;u=g&&pi(v)&&pi(x)&&pi(g.width)&&pi(g.height)?[[v+e.width*a[0],x+e.height*a[1]],[v+g.width-e.width+e.width*a[0],x+g.height-e.height+e.height*a[1]]]:u}else c==null||c("005",na.error005()),u=d;else if(e.extent&&e.parentNode&&e.extent!=="parent"){const g=n.get(e.parentNode),{x:v,y:x}=ql(g,a).positionAbsolute;u=[[e.extent[0][0]+v,e.extent[0][1]+x],[e.extent[1][0]+v,e.extent[1][1]+x]]}let m={x:0,y:0};if(e.parentNode){const g=n.get(e.parentNode);m=ql(g,a).positionAbsolute}const y=u&&u!=="parent"?rp(t,u):t;return{position:{x:y.x-m.x,y:y.y-m.y},positionAbsolute:y}}function Gh({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map(a=>({...n.get(a.id),position:a.position,positionAbsolute:a.positionAbsolute}));return[e?o.find(a=>a.id===e):o[0],o]}const qg=(e,t,n,o)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const c=Array.from(a),d=t.getBoundingClientRect(),u={x:d.width*o[0],y:d.height*o[1]};return c.map(m=>{const y=m.getBoundingClientRect();return{id:m.getAttribute("data-handleid"),position:m.getAttribute("data-handlepos"),x:(y.left-d.left-u.x)/n,y:(y.top-d.top-u.y)/n,...np(m)}})};function Sd(e,t,n){return n===void 0?n:o=>{const a=t().nodeInternals.get(e);a&&n(o,{...a})}}function L_({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:a,unselectNodesAndEdges:c,multiSelectionActive:d,nodeInternals:u,onError:m}=t.getState(),y=u.get(e);if(!y){m==null||m("012",na.error012(e));return}t.setState({nodesSelectionActive:!1}),y.selected?(n||y.selected&&d)&&(c({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var g;return(g=o==null?void 0:o.current)==null?void 0:g.blur()})):a([e])}function n2(){const e=hr();return h.useCallback(({sourceEvent:n})=>{const{transform:o,snapGrid:a,snapToGrid:c}=e.getState(),d=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,m={x:(d-o[0])/o[2],y:(u-o[1])/o[2]};return{xSnapped:c?a[0]*Math.round(m.x/a[0]):m.x,ySnapped:c?a[1]*Math.round(m.y/a[1]):m.y,...m}},[])}function Yh(e){return(t,n,o)=>e==null?void 0:e(t,o)}function vx({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:c,selectNodesOnDrag:d}){const u=hr(),[m,y]=h.useState(!1),g=h.useRef([]),v=h.useRef({x:null,y:null}),x=h.useRef(0),b=h.useRef(null),C=h.useRef({x:0,y:0}),S=h.useRef(null),L=h.useRef(!1),M=h.useRef(!1),W=n2();return h.useEffect(()=>{if(e!=null&&e.current){const q=_i(e.current),z=({x:Z,y:ne})=>{const{nodeInternals:ue,onNodeDrag:de,onSelectionDrag:pe,updateNodePositions:D,nodeExtent:E,snapGrid:j,snapToGrid:R,nodeOrigin:O,onError:ee}=u.getState();v.current={x:Z,y:ne};let I=!1,P={x:0,y:0,x2:0,y2:0};if(g.current.length>1&&E){const $=qm(g.current,O);P=Ud($)}if(g.current=g.current.map($=>{const K={x:Z-$.distance.x,y:ne-$.distance.y};R&&(K.x=j[0]*Math.round(K.x/j[0]),K.y=j[1]*Math.round(K.y/j[1]));const se=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];g.current.length>1&&E&&!$.extent&&(se[0][0]=$.positionAbsolute.x-P.x+E[0][0],se[1][0]=$.positionAbsolute.x+($.width??0)-P.x2+E[1][0],se[0][1]=$.positionAbsolute.y-P.y+E[0][1],se[1][1]=$.positionAbsolute.y+($.height??0)-P.y2+E[1][1]);const le=yx($,K,ue,se,O,ee);return I=I||$.position.x!==le.position.x||$.position.y!==le.position.y,$.position=le.position,$.positionAbsolute=le.positionAbsolute,$}),!I)return;D(g.current,!0,!0),y(!0);const G=a?de:Yh(pe);if(G&&S.current){const[$,K]=Gh({nodeId:a,dragItems:g.current,nodeInternals:ue});G(S.current,$,K)}},Y=()=>{if(!b.current)return;const[Z,ne]=Bv(C.current,b.current);if(Z!==0||ne!==0){const{transform:ue,panBy:de}=u.getState();v.current.x=(v.current.x??0)-Z/ue[2],v.current.y=(v.current.y??0)-ne/ue[2],de({x:Z,y:ne})&&z(v.current)}x.current=requestAnimationFrame(Y)},Q=Z=>{var O;const{nodeInternals:ne,multiSelectionActive:ue,nodesDraggable:de,unselectNodesAndEdges:pe,onNodeDragStart:D,onSelectionDragStart:E}=u.getState();M.current=!0;const j=a?D:Yh(E);(!d||!c)&&!ue&&a&&((O=ne.get(a))!=null&&O.selected||pe()),a&&c&&d&&L_({id:a,store:u,nodeRef:e});const R=W(Z);if(v.current=R,g.current=e2(ne,de,R,a),j&&g.current){const[ee,I]=Gh({nodeId:a,dragItems:g.current,nodeInternals:ne});j(Z.sourceEvent,ee,I)}};if(t)q.on(".drag",null);else{const Z=fk().on("start",ne=>{const{domNode:ue,nodeDragThreshold:de}=u.getState();de===0&&Q(ne);const pe=W(ne);v.current=pe,b.current=(ue==null?void 0:ue.getBoundingClientRect())||null,C.current=Ga(ne.sourceEvent,b.current)}).on("drag",ne=>{var D,E;const ue=W(ne),{autoPanOnNodeDrag:de,nodeDragThreshold:pe}=u.getState();if(!L.current&&M.current&&de&&(L.current=!0,Y()),!M.current){const j=ue.xSnapped-(((D=v==null?void 0:v.current)==null?void 0:D.x)??0),R=ue.ySnapped-(((E=v==null?void 0:v.current)==null?void 0:E.y)??0);Math.sqrt(j*j+R*R)>pe&&Q(ne)}(v.current.x!==ue.xSnapped||v.current.y!==ue.ySnapped)&&g.current&&M.current&&(S.current=ne.sourceEvent,C.current=Ga(ne.sourceEvent,b.current),z(ue))}).on("end",ne=>{if(M.current&&(y(!1),L.current=!1,M.current=!1,cancelAnimationFrame(x.current),g.current)){const{updateNodePositions:ue,nodeInternals:de,onNodeDragStop:pe,onSelectionDragStop:D}=u.getState(),E=a?pe:Yh(D);if(ue(g.current,!1,!1),E){const[j,R]=Gh({nodeId:a,dragItems:g.current,nodeInternals:de});E(ne.sourceEvent,j,R)}}}).filter(ne=>{const ue=ne.target;return!ne.button&&(!n||!Wg(ue,`.${n}`,e))&&(!o||Wg(ue,o,e))});return q.call(Z),()=>{q.on(".drag",null)}}}},[e,t,n,o,c,u,a,d,W]),m}function xx(){const e=hr();return h.useCallback(n=>{const{nodeInternals:o,nodeExtent:a,updateNodePositions:c,getNodes:d,snapToGrid:u,snapGrid:m,onError:y,nodesDraggable:g}=e.getState(),v=d().filter(W=>W.selected&&(W.draggable||g&&typeof W.draggable>"u")),x=u?m[0]:5,b=u?m[1]:5,C=n.isShiftPressed?4:1,S=n.x*x*C,L=n.y*b*C,M=v.map(W=>{if(W.positionAbsolute){const q={x:W.positionAbsolute.x+S,y:W.positionAbsolute.y+L};u&&(q.x=m[0]*Math.round(q.x/m[0]),q.y=m[1]*Math.round(q.y/m[1]));const{positionAbsolute:z,position:Y}=yx(W,q,o,a,void 0,y);W.position=Y,W.positionAbsolute=z}return W});c(M,!0,!1)},[])}const su={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var jd=e=>{const t=({id:n,type:o,data:a,xPos:c,yPos:d,xPosOrigin:u,yPosOrigin:m,selected:y,onClick:g,onMouseEnter:v,onMouseMove:x,onMouseLeave:b,onContextMenu:C,onDoubleClick:S,style:L,className:M,isDraggable:W,isSelectable:q,isConnectable:z,isFocusable:Y,selectNodesOnDrag:Q,sourcePosition:Z,targetPosition:ne,hidden:ue,resizeObserver:de,dragHandle:pe,zIndex:D,isParent:E,noDragClassName:j,noPanClassName:R,initialized:O,disableKeyboardA11y:ee,ariaLabel:I,rfId:P,hasHandleBounds:G})=>{const $=hr(),K=h.useRef(null),se=h.useRef(Z),le=h.useRef(ne),he=h.useRef(o),be=q||W||g||v||x||b,je=xx(),Ee=Sd(n,$.getState,v),Fe=Sd(n,$.getState,x),Ye=Sd(n,$.getState,b),Ke=Sd(n,$.getState,C),Ct=Sd(n,$.getState,S),wt=nt=>{const{nodeDragThreshold:Ne}=$.getState();if(q&&(!Q||!W||Ne>0)&&L_({id:n,store:$,nodeRef:K}),g){const Oe=$.getState().nodeInternals.get(n);Oe&&g(nt,{...Oe})}},at=nt=>{if(!E_(nt))if(qv.includes(nt.key)&&q){const Ne=nt.key==="Escape";L_({id:n,store:$,unselect:Ne,nodeRef:K})}else!ee&&W&&y&&Object.prototype.hasOwnProperty.call(su,nt.key)&&($.setState({ariaLiveMessage:`Moved selected node ${nt.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~c}, y: ${~~d}`}),je({x:su[nt.key].x,y:su[nt.key].y,isShiftPressed:nt.shiftKey}))};h.useEffect(()=>()=>{K.current&&(de==null||de.unobserve(K.current))},[]),h.useEffect(()=>{if(K.current&&!ue){const nt=K.current;(!O||!G)&&(de==null||de.unobserve(nt),de==null||de.observe(nt))}},[ue,O,G]),h.useEffect(()=>{const nt=he.current!==o,Ne=se.current!==Z,Oe=le.current!==ne;K.current&&(nt||Ne||Oe)&&(nt&&(he.current=o),Ne&&(se.current=Z),Oe&&(le.current=ne),$.getState().updateNodeDimensions([{id:n,nodeElement:K.current,forceUpdate:!0}]))},[n,o,Z,ne]);const yt=vx({nodeRef:K,disabled:ue||!W,noDragClassName:j,handleSelector:pe,nodeId:n,isSelectable:q,selectNodesOnDrag:Q});return ue?null:ye.createElement("div",{className:Pr(["react-flow__node",`react-flow__node-${o}`,{[R]:W},M,{selected:y,selectable:q,parent:E,dragging:yt}]),ref:K,style:{zIndex:D,transform:`translate(${u}px,${m}px)`,pointerEvents:be?"all":"none",visibility:O?"visible":"hidden",...L},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Ee,onMouseMove:Fe,onMouseLeave:Ye,onContextMenu:Ke,onClick:wt,onDoubleClick:Ct,onKeyDown:Y?at:void 0,tabIndex:Y?0:void 0,role:Y?"button":void 0,"aria-describedby":ee?void 0:`${dx}-${P}`,"aria-label":I},ye.createElement(_1,{value:n},ye.createElement(e,{id:n,data:a,type:o,xPos:c,yPos:d,selected:y,isConnectable:z,sourcePosition:Z,targetPosition:ne,dragging:yt,dragHandle:pe,zIndex:D})))};return t.displayName="NodeWrapper",h.memo(t)};const r2=e=>{const t=e.getNodes().filter(n=>n.selected);return{...qm(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function s2({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=hr(),{width:a,height:c,x:d,y:u,transformString:m,userSelectionActive:y}=Rn(r2,kr),g=xx(),v=h.useRef(null);if(h.useEffect(()=>{var C;n||(C=v.current)==null||C.focus({preventScroll:!0})},[n]),vx({nodeRef:v}),y||!a||!c)return null;const x=e?C=>{const S=o.getState().getNodes().filter(L=>L.selected);e(C,S)}:void 0,b=C=>{Object.prototype.hasOwnProperty.call(su,C.key)&&g({x:su[C.key].x,y:su[C.key].y,isShiftPressed:C.shiftKey})};return ye.createElement("div",{className:Pr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:m}},ye.createElement("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:n?void 0:-1,onKeyDown:n?void 0:b,style:{width:a,height:c,top:u,left:d}}))}var i2=h.memo(s2);const o2=e=>e.nodesSelectionActive,wx=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:c,onPaneScroll:d,deleteKeyCode:u,onMove:m,onMoveStart:y,onMoveEnd:g,selectionKeyCode:v,selectionOnDrag:x,selectionMode:b,onSelectionStart:C,onSelectionEnd:S,multiSelectionKeyCode:L,panActivationKeyCode:M,zoomActivationKeyCode:W,elementsSelectable:q,zoomOnScroll:z,zoomOnPinch:Y,panOnScroll:Q,panOnScrollSpeed:Z,panOnScrollMode:ne,zoomOnDoubleClick:ue,panOnDrag:de,defaultViewport:pe,translateExtent:D,minZoom:E,maxZoom:j,preventScrolling:R,onSelectionContextMenu:O,noWheelClassName:ee,noPanClassName:I,disableKeyboardA11y:P})=>{const G=Rn(o2),$=qd(v),K=qd(M),se=K||de,le=K||Q,he=$||x&&se!==!0;return W1({deleteKeyCode:u,multiSelectionKeyCode:L}),ye.createElement(Y1,{onMove:m,onMoveStart:y,onMoveEnd:g,onPaneContextMenu:c,elementsSelectable:q,zoomOnScroll:z,zoomOnPinch:Y,panOnScroll:le,panOnScrollSpeed:Z,panOnScrollMode:ne,zoomOnDoubleClick:ue,panOnDrag:!$&&se,defaultViewport:pe,translateExtent:D,minZoom:E,maxZoom:j,zoomActivationKeyCode:W,preventScrolling:R,noWheelClassName:ee,noPanClassName:I},ye.createElement(px,{onSelectionStart:C,onSelectionEnd:S,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:c,onPaneScroll:d,panOnDrag:se,isSelecting:!!he,selectionMode:b},e,G&&ye.createElement(i2,{onSelectionContextMenu:O,noPanClassName:I,disableKeyboardA11y:P})))};wx.displayName="FlowRenderer";var a2=h.memo(wx);function l2(e){return Rn(h.useCallback(n=>e?Zv(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function c2(e){const t={input:jd(e.input||ax),default:jd(e.default||T_),output:jd(e.output||cx),group:jd(e.group||cp)},n={},o=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,c)=>(a[c]=jd(e[c]||T_),a),n);return{...t,...o}}const u2=({x:e,y:t,width:n,height:o,origin:a})=>!n||!o?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-o*a[1]},d2=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),bx=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:c,onError:d}=Rn(d2,kr),u=l2(e.onlyRenderVisibleElements),m=h.useRef(),y=h.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const g=new ResizeObserver(v=>{const x=v.map(b=>({id:b.target.getAttribute("data-id"),nodeElement:b.target,forceUpdate:!0}));c(x)});return m.current=g,g},[]);return h.useEffect(()=>()=>{var g;(g=m==null?void 0:m.current)==null||g.disconnect()},[]),ye.createElement("div",{className:"react-flow__nodes",style:dp},u.map(g=>{var Y,Q,Z;let v=g.type||"default";e.nodeTypes[v]||(d==null||d("003",na.error003(v)),v="default");const x=e.nodeTypes[v]||e.nodeTypes.default,b=!!(g.draggable||t&&typeof g.draggable>"u"),C=!!(g.selectable||a&&typeof g.selectable>"u"),S=!!(g.connectable||n&&typeof g.connectable>"u"),L=!!(g.focusable||o&&typeof g.focusable>"u"),M=e.nodeExtent?rp(g.positionAbsolute,e.nodeExtent):g.positionAbsolute,W=(M==null?void 0:M.x)??0,q=(M==null?void 0:M.y)??0,z=u2({x:W,y:q,width:g.width??0,height:g.height??0,origin:e.nodeOrigin});return ye.createElement(x,{key:g.id,id:g.id,className:g.className,style:g.style,type:v,data:g.data,sourcePosition:g.sourcePosition||ut.Bottom,targetPosition:g.targetPosition||ut.Top,hidden:g.hidden,xPos:W,yPos:q,xPosOrigin:z.x,yPosOrigin:z.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!g.selected,isDraggable:b,isSelectable:C,isConnectable:S,isFocusable:L,resizeObserver:y,dragHandle:g.dragHandle,zIndex:((Y=g[or])==null?void 0:Y.z)??0,isParent:!!((Q=g[or])!=null&&Q.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!g.width&&!!g.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:g.ariaLabel,hasHandleBounds:!!((Z=g[or])!=null&&Z.handleBounds)})}))};bx.displayName="NodeRenderer";var f2=h.memo(bx);const m2=(e,t,n)=>n===ut.Left?e-t:n===ut.Right?e+t:e,h2=(e,t,n)=>n===ut.Top?e-t:n===ut.Bottom?e+t:e,Vg="react-flow__edgeupdater",Gg=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:a,onMouseEnter:c,onMouseOut:d,type:u})=>ye.createElement("circle",{onMouseDown:a,onMouseEnter:c,onMouseOut:d,className:Pr([Vg,`${Vg}-${u}`]),cx:m2(t,o,e),cy:h2(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),_2=()=>!0;var Gc=e=>{const t=({id:n,className:o,type:a,data:c,onClick:d,onEdgeDoubleClick:u,selected:m,animated:y,label:g,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:C,labelBgBorderRadius:S,style:L,source:M,target:W,sourceX:q,sourceY:z,targetX:Y,targetY:Q,sourcePosition:Z,targetPosition:ne,elementsSelectable:ue,hidden:de,sourceHandleId:pe,targetHandleId:D,onContextMenu:E,onMouseEnter:j,onMouseMove:R,onMouseLeave:O,edgeUpdaterRadius:ee,onEdgeUpdate:I,onEdgeUpdateStart:P,onEdgeUpdateEnd:G,markerEnd:$,markerStart:K,rfId:se,ariaLabel:le,isFocusable:he,isUpdatable:be,pathOptions:je,interactionWidth:Ee})=>{const Fe=h.useRef(null),[Ye,Ke]=h.useState(!1),[Ct,wt]=h.useState(!1),at=hr(),yt=h.useMemo(()=>`url('#${M_(K,se)}')`,[K,se]),nt=h.useMemo(()=>`url('#${M_($,se)}')`,[$,se]);if(de)return null;const Ne=jt=>{var Qt;const{edges:hn,addSelectedEdges:Un,unselectNodesAndEdges:Nn,multiSelectionActive:yn}=at.getState(),Cn=hn.find(ar=>ar.id===n);Cn&&(ue&&(at.setState({nodesSelectionActive:!1}),Cn.selected&&yn?(Nn({nodes:[],edges:[Cn]}),(Qt=Fe.current)==null||Qt.blur()):Un([n])),d&&d(jt,Cn))},Oe=bd(n,at.getState,u),st=bd(n,at.getState,E),ve=bd(n,at.getState,j),Ie=bd(n,at.getState,R),Ge=bd(n,at.getState,O),At=(jt,hn)=>{if(jt.button!==0)return;const{edges:Un,isValidConnection:Nn}=at.getState(),yn=hn?W:M,Cn=(hn?D:pe)||null,Qt=hn?"target":"source",ar=Nn||_2,_n=hn,Hn=Un.find(te=>te.id===n);wt(!0),P==null||P(jt,Hn,Qt);const vn=te=>{wt(!1),G==null||G(te,Hn,Qt)};rx({event:jt,handleId:Cn,nodeId:yn,onConnect:te=>I==null?void 0:I(Hn,te),isTarget:_n,getState:at.getState,setState:at.setState,isValidConnection:ar,edgeUpdaterType:Qt,onEdgeUpdateEnd:vn})},Ft=jt=>At(jt,!0),fn=jt=>At(jt,!1),Dt=()=>Ke(!0),Tt=()=>Ke(!1),mn=!ue&&!d,Vn=jt=>{var hn;if(qv.includes(jt.key)&&ue){const{unselectNodesAndEdges:Un,addSelectedEdges:Nn,edges:yn}=at.getState();jt.key==="Escape"?((hn=Fe.current)==null||hn.blur(),Un({edges:[yn.find(Qt=>Qt.id===n)]})):Nn([n])}};return ye.createElement("g",{className:Pr(["react-flow__edge",`react-flow__edge-${a}`,o,{selected:m,animated:y,inactive:mn,updating:Ye}]),onClick:Ne,onDoubleClick:Oe,onContextMenu:st,onMouseEnter:ve,onMouseMove:Ie,onMouseLeave:Ge,onKeyDown:he?Vn:void 0,tabIndex:he?0:void 0,role:he?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":le===null?void 0:le||`Edge from ${M} to ${W}`,"aria-describedby":he?`${fx}-${se}`:void 0,ref:Fe},!Ct&&ye.createElement(e,{id:n,source:M,target:W,selected:m,animated:y,label:g,labelStyle:v,labelShowBg:x,labelBgStyle:b,labelBgPadding:C,labelBgBorderRadius:S,data:c,style:L,sourceX:q,sourceY:z,targetX:Y,targetY:Q,sourcePosition:Z,targetPosition:ne,sourceHandleId:pe,targetHandleId:D,markerStart:yt,markerEnd:nt,pathOptions:je,interactionWidth:Ee}),be&&ye.createElement(ye.Fragment,null,(be==="source"||be===!0)&&ye.createElement(Gg,{position:Z,centerX:q,centerY:z,radius:ee,onMouseDown:Ft,onMouseEnter:Dt,onMouseOut:Tt,type:"source"}),(be==="target"||be===!0)&&ye.createElement(Gg,{position:ne,centerX:Y,centerY:Q,radius:ee,onMouseDown:fn,onMouseEnter:Dt,onMouseOut:Tt,type:"target"})))};return t.displayName="EdgeWrapper",h.memo(t)};function p2(e){const t={default:Gc(e.default||Am),straight:Gc(e.bezier||op),step:Gc(e.step||ip),smoothstep:Gc(e.step||Wm),simplebezier:Gc(e.simplebezier||sp)},n={},o=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,c)=>(a[c]=Gc(e[c]||Am),a),n);return{...t,...o}}function Yg(e,t,n=null){const o=((n==null?void 0:n.x)||0)+t.x,a=((n==null?void 0:n.y)||0)+t.y,c=(n==null?void 0:n.width)||t.width,d=(n==null?void 0:n.height)||t.height;switch(e){case ut.Top:return{x:o+c/2,y:a};case ut.Right:return{x:o+c,y:a+d/2};case ut.Bottom:return{x:o+c/2,y:a+d};case ut.Left:return{x:o,y:a+d/2}}}function Kg(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const g2=(e,t,n,o,a,c)=>{const d=Yg(n,e,t),u=Yg(c,o,a);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y}};function y2({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:a,targetHeight:c,width:d,height:u,transform:m}){const y={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+a),y2:Math.max(e.y+o,t.y+c)};y.x===y.x2&&(y.x2+=1),y.y===y.y2&&(y.y2+=1);const g=Ud({x:(0-m[0])/m[2],y:(0-m[1])/m[2],width:d/m[2],height:u/m[2]}),v=Math.max(0,Math.min(g.x2,y.x2)-Math.max(g.x,y.x)),x=Math.max(0,Math.min(g.y2,y.y2)-Math.max(g.y,y.y));return Math.ceil(v*x)>0}function Xg(e){var o,a,c,d,u;const t=((o=e==null?void 0:e[or])==null?void 0:o.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.x)<"u"&&typeof((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)<"u";return[{x:((d=e==null?void 0:e.positionAbsolute)==null?void 0:d.x)||0,y:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const v2=[{level:0,isMaxLevel:!0,edges:[]}];function x2(e,t,n=!1){let o=-1;const a=e.reduce((d,u)=>{var g,v;const m=pi(u.zIndex);let y=m?u.zIndex:0;if(n){const x=t.get(u.target),b=t.get(u.source),C=u.selected||(x==null?void 0:x.selected)||(b==null?void 0:b.selected),S=Math.max(((g=b==null?void 0:b[or])==null?void 0:g.z)||0,((v=x==null?void 0:x[or])==null?void 0:v.z)||0,1e3);y=(m?u.zIndex:0)+(C?S:0)}return d[y]?d[y].push(u):d[y]=[u],o=y>o?y:o,d},{}),c=Object.entries(a).map(([d,u])=>{const m=+d;return{edges:u,level:m,isMaxLevel:m===o}});return c.length===0?v2:c}function w2(e,t,n){const o=Rn(h.useCallback(a=>e?a.edges.filter(c=>{const d=t.get(c.source),u=t.get(c.target);return(d==null?void 0:d.width)&&(d==null?void 0:d.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&y2({sourcePos:d.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:d.width,sourceHeight:d.height,targetWidth:u.width,targetHeight:u.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return x2(o,t,n)}const b2=({color:e="none",strokeWidth:t=1})=>ye.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),S2=({color:e="none",strokeWidth:t=1})=>ye.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Jg={[Wd.Arrow]:b2,[Wd.ArrowClosed]:S2};function j2(e){const t=hr();return h.useMemo(()=>{var a,c;return Object.prototype.hasOwnProperty.call(Jg,e)?Jg[e]:((c=(a=t.getState()).onError)==null||c.call(a,"009",na.error009(e)),null)},[e])}const k2=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:c="strokeWidth",strokeWidth:d,orient:u="auto-start-reverse"})=>{const m=j2(t);return m?ye.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:u,refX:"0",refY:"0"},ye.createElement(m,{color:n,strokeWidth:d})):null},N2=({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce((a,c)=>([c.markerStart,c.markerEnd].forEach(d=>{if(d&&typeof d=="object"){const u=M_(d,t);o.includes(u)||(a.push({id:u,color:d.color||e,...d}),o.push(u))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))},Sx=({defaultColor:e,rfId:t})=>{const n=Rn(h.useCallback(N2({defaultColor:e,rfId:t}),[e,t]),(o,a)=>!(o.length!==a.length||o.some((c,d)=>c.id!==a[d].id)));return ye.createElement("defs",null,n.map(o=>ye.createElement(k2,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};Sx.displayName="MarkerDefinitions";var C2=h.memo(Sx);const E2=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),jx=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:a,noPanClassName:c,onEdgeUpdate:d,onEdgeContextMenu:u,onEdgeMouseEnter:m,onEdgeMouseMove:y,onEdgeMouseLeave:g,onEdgeClick:v,edgeUpdaterRadius:x,onEdgeDoubleClick:b,onEdgeUpdateStart:C,onEdgeUpdateEnd:S,children:L})=>{const{edgesFocusable:M,edgesUpdatable:W,elementsSelectable:q,width:z,height:Y,connectionMode:Q,nodeInternals:Z,onError:ne}=Rn(E2,kr),ue=w2(t,Z,n);return z?ye.createElement(ye.Fragment,null,ue.map(({level:de,edges:pe,isMaxLevel:D})=>ye.createElement("svg",{key:de,style:{zIndex:de},width:z,height:Y,className:"react-flow__edges react-flow__container"},D&&ye.createElement(C2,{defaultColor:e,rfId:o}),ye.createElement("g",null,pe.map(E=>{const[j,R,O]=Xg(Z.get(E.source)),[ee,I,P]=Xg(Z.get(E.target));if(!O||!P)return null;let G=E.type||"default";a[G]||(ne==null||ne("011",na.error011(G)),G="default");const $=a[G]||a.default,K=Q===Kl.Strict?I.target:(I.target??[]).concat(I.source??[]),se=Kg(R.source,E.sourceHandle),le=Kg(K,E.targetHandle),he=(se==null?void 0:se.position)||ut.Bottom,be=(le==null?void 0:le.position)||ut.Top,je=!!(E.focusable||M&&typeof E.focusable>"u"),Ee=typeof d<"u"&&(E.updatable||W&&typeof E.updatable>"u");if(!se||!le)return ne==null||ne("008",na.error008(se,E)),null;const{sourceX:Fe,sourceY:Ye,targetX:Ke,targetY:Ct}=g2(j,se,he,ee,le,be);return ye.createElement($,{key:E.id,id:E.id,className:Pr([E.className,c]),type:G,data:E.data,selected:!!E.selected,animated:!!E.animated,hidden:!!E.hidden,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,style:E.style,source:E.source,target:E.target,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerEnd:E.markerEnd,markerStart:E.markerStart,sourceX:Fe,sourceY:Ye,targetX:Ke,targetY:Ct,sourcePosition:he,targetPosition:be,elementsSelectable:q,onEdgeUpdate:d,onContextMenu:u,onMouseEnter:m,onMouseMove:y,onMouseLeave:g,onClick:v,edgeUpdaterRadius:x,onEdgeDoubleClick:b,onEdgeUpdateStart:C,onEdgeUpdateEnd:S,rfId:o,ariaLabel:E.ariaLabel,isFocusable:je,isUpdatable:Ee,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth})})))),L):null};jx.displayName="EdgeRenderer";var $2=h.memo(jx);const M2=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function A2({children:e}){const t=Rn(M2);return ye.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function T2(e){const t=up(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const L2={[ut.Left]:ut.Right,[ut.Right]:ut.Left,[ut.Top]:ut.Bottom,[ut.Bottom]:ut.Top},kx=({nodeId:e,handleType:t,style:n,type:o=Va.Bezier,CustomComponent:a,connectionStatus:c})=>{var Q,Z,ne;const{fromNode:d,handleId:u,toX:m,toY:y,connectionMode:g}=Rn(h.useCallback(ue=>({fromNode:ue.nodeInternals.get(e),handleId:ue.connectionHandleId,toX:(ue.connectionPosition.x-ue.transform[0])/ue.transform[2],toY:(ue.connectionPosition.y-ue.transform[1])/ue.transform[2],connectionMode:ue.connectionMode}),[e]),kr),v=(Q=d==null?void 0:d[or])==null?void 0:Q.handleBounds;let x=v==null?void 0:v[t];if(g===Kl.Loose&&(x=x||(v==null?void 0:v[t==="source"?"target":"source"])),!d||!x)return null;const b=u?x.find(ue=>ue.id===u):x[0],C=b?b.x+b.width/2:(d.width??0)/2,S=b?b.y+b.height/2:d.height??0,L=(((Z=d.positionAbsolute)==null?void 0:Z.x)??0)+C,M=(((ne=d.positionAbsolute)==null?void 0:ne.y)??0)+S,W=b==null?void 0:b.position,q=W?L2[W]:null;if(!W||!q)return null;if(a)return ye.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:b,fromX:L,fromY:M,toX:m,toY:y,fromPosition:W,toPosition:q,connectionStatus:c});let z="";const Y={sourceX:L,sourceY:M,sourcePosition:W,targetX:m,targetY:y,targetPosition:q};return o===Va.Bezier?[z]=Xv(Y):o===Va.Step?[z]=$_({...Y,borderRadius:0}):o===Va.SmoothStep?[z]=$_(Y):o===Va.SimpleBezier?[z]=Kv(Y):z=`M${L},${M} ${m},${y}`,ye.createElement("path",{d:z,fill:"none",className:"react-flow__connection-path",style:n})};kx.displayName="ConnectionLine";const R2=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function P2({containerStyle:e,style:t,type:n,component:o}){const{nodeId:a,handleType:c,nodesConnectable:d,width:u,height:m,connectionStatus:y}=Rn(R2,kr);return!(a&&c&&u&&d)?null:ye.createElement("svg",{style:e,width:u,height:m,className:"react-flow__edges react-flow__connectionline react-flow__container"},ye.createElement("g",{className:Pr(["react-flow__connection",y])},ye.createElement(kx,{nodeId:a,handleType:c,style:t,type:n,CustomComponent:o,connectionStatus:y})))}function Zg(e,t){return h.useRef(null),hr(),h.useMemo(()=>t(e),[e])}const Nx=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:c,onNodeClick:d,onEdgeClick:u,onNodeDoubleClick:m,onEdgeDoubleClick:y,onNodeMouseEnter:g,onNodeMouseMove:v,onNodeMouseLeave:x,onNodeContextMenu:b,onSelectionContextMenu:C,onSelectionStart:S,onSelectionEnd:L,connectionLineType:M,connectionLineStyle:W,connectionLineComponent:q,connectionLineContainerStyle:z,selectionKeyCode:Y,selectionOnDrag:Q,selectionMode:Z,multiSelectionKeyCode:ne,panActivationKeyCode:ue,zoomActivationKeyCode:de,deleteKeyCode:pe,onlyRenderVisibleElements:D,elementsSelectable:E,selectNodesOnDrag:j,defaultViewport:R,translateExtent:O,minZoom:ee,maxZoom:I,preventScrolling:P,defaultMarkerColor:G,zoomOnScroll:$,zoomOnPinch:K,panOnScroll:se,panOnScrollSpeed:le,panOnScrollMode:he,zoomOnDoubleClick:be,panOnDrag:je,onPaneClick:Ee,onPaneMouseEnter:Fe,onPaneMouseMove:Ye,onPaneMouseLeave:Ke,onPaneScroll:Ct,onPaneContextMenu:wt,onEdgeUpdate:at,onEdgeContextMenu:yt,onEdgeMouseEnter:nt,onEdgeMouseMove:Ne,onEdgeMouseLeave:Oe,edgeUpdaterRadius:st,onEdgeUpdateStart:ve,onEdgeUpdateEnd:Ie,noDragClassName:Ge,noWheelClassName:At,noPanClassName:Ft,elevateEdgesOnSelect:fn,disableKeyboardA11y:Dt,nodeOrigin:Tt,nodeExtent:mn,rfId:Vn})=>{const jt=Zg(e,c2),hn=Zg(t,p2);return T2(c),ye.createElement(a2,{onPaneClick:Ee,onPaneMouseEnter:Fe,onPaneMouseMove:Ye,onPaneMouseLeave:Ke,onPaneContextMenu:wt,onPaneScroll:Ct,deleteKeyCode:pe,selectionKeyCode:Y,selectionOnDrag:Q,selectionMode:Z,onSelectionStart:S,onSelectionEnd:L,multiSelectionKeyCode:ne,panActivationKeyCode:ue,zoomActivationKeyCode:de,elementsSelectable:E,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:$,zoomOnPinch:K,zoomOnDoubleClick:be,panOnScroll:se,panOnScrollSpeed:le,panOnScrollMode:he,panOnDrag:je,defaultViewport:R,translateExtent:O,minZoom:ee,maxZoom:I,onSelectionContextMenu:C,preventScrolling:P,noDragClassName:Ge,noWheelClassName:At,noPanClassName:Ft,disableKeyboardA11y:Dt},ye.createElement(A2,null,ye.createElement($2,{edgeTypes:hn,onEdgeClick:u,onEdgeDoubleClick:y,onEdgeUpdate:at,onlyRenderVisibleElements:D,onEdgeContextMenu:yt,onEdgeMouseEnter:nt,onEdgeMouseMove:Ne,onEdgeMouseLeave:Oe,onEdgeUpdateStart:ve,onEdgeUpdateEnd:Ie,edgeUpdaterRadius:st,defaultMarkerColor:G,noPanClassName:Ft,elevateEdgesOnSelect:!!fn,disableKeyboardA11y:Dt,rfId:Vn},ye.createElement(P2,{style:W,type:M,component:q,containerStyle:z})),ye.createElement("div",{className:"react-flow__edgelabel-renderer"}),ye.createElement(f2,{nodeTypes:jt,onNodeClick:d,onNodeDoubleClick:m,onNodeMouseEnter:g,onNodeMouseMove:v,onNodeMouseLeave:x,onNodeContextMenu:b,selectNodesOnDrag:j,onlyRenderVisibleElements:D,noPanClassName:Ft,noDragClassName:Ge,disableKeyboardA11y:Dt,nodeOrigin:Tt,nodeExtent:mn,rfId:Vn})))};Nx.displayName="GraphView";var O2=h.memo(Nx);const R_=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Fa={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:R_,nodeExtent:R_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Kl.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:c1,isValidConnection:void 0},z2=()=>jS((e,t)=>({...Fa,setNodes:n=>{const{nodeInternals:o,nodeOrigin:a,elevateNodesOnSelect:c}=t();e({nodeInternals:qh(n,o,a,c)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map(a=>({...o,...a}))})},setDefaultNodesAndEdges:(n,o)=>{const a=typeof n<"u",c=typeof o<"u",d=a?qh(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:d,edges:c?o:[],hasDefaultNodes:a,hasDefaultEdges:c})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:a,fitViewOnInit:c,fitViewOnInitDone:d,fitViewOnInitOptions:u,domNode:m,nodeOrigin:y}=t(),g=m==null?void 0:m.querySelector(".react-flow__viewport");if(!g)return;const v=window.getComputedStyle(g),{m22:x}=new window.DOMMatrixReadOnly(v.transform),b=n.reduce((S,L)=>{const M=a.get(L.id);if(M){const W=np(L.nodeElement);!!(W.width&&W.height&&(M.width!==W.width||M.height!==W.height||L.forceUpdate))&&(a.set(M.id,{...M,[or]:{...M[or],handleBounds:{source:qg(".source",L.nodeElement,x,y),target:qg(".target",L.nodeElement,x,y)}},...W}),S.push({id:M.id,type:"dimensions",dimensions:W}))}return S},[]);hx(a,y);const C=d||c&&!d&&_x(t,{initial:!0,...u});e({nodeInternals:new Map(a),fitViewOnInitDone:C}),(b==null?void 0:b.length)>0&&(o==null||o(b))},updateNodePositions:(n,o=!0,a=!1)=>{const{triggerNodeChanges:c}=t(),d=n.map(u=>{const m={id:u.id,type:"position",dragging:a};return o&&(m.positionAbsolute=u.positionAbsolute,m.position=u.position),m});c(d)},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:a,hasDefaultNodes:c,nodeOrigin:d,getNodes:u,elevateNodesOnSelect:m}=t();if(n!=null&&n.length){if(c){const y=Z1(n,u()),g=qh(y,a,d,m);e({nodeInternals:g})}o==null||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:a,getNodes:c}=t();let d,u=null;o?d=n.map(m=>Wa(m,!0)):(d=Jc(c(),n),u=Jc(a,[])),sm({changedNodes:d,changedEdges:u,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:a,getNodes:c}=t();let d,u=null;o?d=n.map(m=>Wa(m,!0)):(d=Jc(a,n),u=Jc(c(),[])),sm({changedNodes:u,changedEdges:d,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:a,getNodes:c}=t(),d=n||c(),u=o||a,m=d.map(g=>(g.selected=!1,Wa(g.id,!1))),y=u.map(g=>Wa(g.id,!1));sm({changedNodes:m,changedEdges:y,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:a}=t();o==null||o.scaleExtent([n,a]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:a}=t();o==null||o.scaleExtent([a,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;(o=t().d3Zoom)==null||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t(),c=o().filter(u=>u.selected).map(u=>Wa(u.id,!1)),d=n.filter(u=>u.selected).map(u=>Wa(u.id,!1));sm({changedNodes:c,changedEdges:d,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach(a=>{a.positionAbsolute=rp(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:n=>{const{transform:o,width:a,height:c,d3Zoom:d,d3Selection:u,translateExtent:m}=t();if(!d||!u||!n.x&&!n.y)return!1;const y=Qo.translate(o[0]+n.x,o[1]+n.y).scale(o[2]),g=[[0,0],[a,c]],v=d==null?void 0:d.constrain()(y,g,m);return d.transform(u,v),o[0]!==v.x||o[1]!==v.y||o[2]!==v.k},cancelConnection:()=>e({connectionNodeId:Fa.connectionNodeId,connectionHandleId:Fa.connectionHandleId,connectionHandleType:Fa.connectionHandleType,connectionStatus:Fa.connectionStatus,connectionStartHandle:Fa.connectionStartHandle,connectionEndHandle:Fa.connectionEndHandle}),reset:()=>e({...Fa})}),Object.is),fp=({children:e})=>{const t=h.useRef(null);return t.current||(t.current=z2()),ye.createElement(n1,{value:t.current},e)};fp.displayName="ReactFlowProvider";const Cx=({children:e})=>h.useContext(Hm)?ye.createElement(ye.Fragment,null,e):ye.createElement(fp,null,e);Cx.displayName="ReactFlowWrapper";const I2={input:ax,default:T_,output:cx,group:cp},D2={default:Am,straight:op,step:ip,smoothstep:Wm,simplebezier:sp},F2=[0,0],B2=[15,15],U2={x:0,y:0,zoom:1},H2={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Ex=h.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:a,nodeTypes:c=I2,edgeTypes:d=D2,onNodeClick:u,onEdgeClick:m,onInit:y,onMove:g,onMoveStart:v,onMoveEnd:x,onConnect:b,onConnectStart:C,onConnectEnd:S,onClickConnectStart:L,onClickConnectEnd:M,onNodeMouseEnter:W,onNodeMouseMove:q,onNodeMouseLeave:z,onNodeContextMenu:Y,onNodeDoubleClick:Q,onNodeDragStart:Z,onNodeDrag:ne,onNodeDragStop:ue,onNodesDelete:de,onEdgesDelete:pe,onSelectionChange:D,onSelectionDragStart:E,onSelectionDrag:j,onSelectionDragStop:R,onSelectionContextMenu:O,onSelectionStart:ee,onSelectionEnd:I,connectionMode:P=Kl.Strict,connectionLineType:G=Va.Bezier,connectionLineStyle:$,connectionLineComponent:K,connectionLineContainerStyle:se,deleteKeyCode:le="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:be=!1,selectionMode:je=Hd.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:Fe=Mm()?"Meta":"Control",zoomActivationKeyCode:Ye=Mm()?"Meta":"Control",snapToGrid:Ke=!1,snapGrid:Ct=B2,onlyRenderVisibleElements:wt=!1,selectNodesOnDrag:at=!0,nodesDraggable:yt,nodesConnectable:nt,nodesFocusable:Ne,nodeOrigin:Oe=F2,edgesFocusable:st,edgesUpdatable:ve,elementsSelectable:Ie,defaultViewport:Ge=U2,minZoom:At=.5,maxZoom:Ft=2,translateExtent:fn=R_,preventScrolling:Dt=!0,nodeExtent:Tt,defaultMarkerColor:mn="#b1b1b7",zoomOnScroll:Vn=!0,zoomOnPinch:jt=!0,panOnScroll:hn=!1,panOnScrollSpeed:Un=.5,panOnScrollMode:Nn=Ul.Free,zoomOnDoubleClick:yn=!0,panOnDrag:Cn=!0,onPaneClick:Qt,onPaneMouseEnter:ar,onPaneMouseMove:_n,onPaneMouseLeave:Hn,onPaneScroll:vn,onPaneContextMenu:Pn,children:te,onEdgeUpdate:ge,onEdgeContextMenu:Te,onEdgeDoubleClick:qe,onEdgeMouseEnter:He,onEdgeMouseMove:it,onEdgeMouseLeave:pt,onEdgeUpdateStart:vt,onEdgeUpdateEnd:Rt,edgeUpdaterRadius:lt=10,onNodesChange:Pt,onEdgesChange:Vt,noDragClassName:ce="nodrag",noWheelClassName:kt="nowheel",noPanClassName:Lt="nopan",fitView:Ve=!1,fitViewOptions:nn,connectOnClick:pn=!0,attributionPosition:cn,proOptions:gn,defaultEdgeOptions:er,elevateNodesOnSelect:Vr=!0,elevateEdgesOnSelect:Nr=!1,disableKeyboardA11y:Gr=!1,autoPanOnConnect:Gs=!0,autoPanOnNodeDrag:$s=!0,connectionRadius:vi=20,isValidConnection:Ys,onError:Or,style:an,id:ra,nodeDragThreshold:Yr,...Ms},As)=>{const Ks=ra||"1";return ye.createElement("div",{...Ms,style:{...an,...H2},ref:As,className:Pr(["react-flow",a]),"data-testid":"rf__wrapper",id:ra},ye.createElement(Cx,null,ye.createElement(O2,{onInit:y,onMove:g,onMoveStart:v,onMoveEnd:x,onNodeClick:u,onEdgeClick:m,onNodeMouseEnter:W,onNodeMouseMove:q,onNodeMouseLeave:z,onNodeContextMenu:Y,onNodeDoubleClick:Q,nodeTypes:c,edgeTypes:d,connectionLineType:G,connectionLineStyle:$,connectionLineComponent:K,connectionLineContainerStyle:se,selectionKeyCode:he,selectionOnDrag:be,selectionMode:je,deleteKeyCode:le,multiSelectionKeyCode:Fe,panActivationKeyCode:Ee,zoomActivationKeyCode:Ye,onlyRenderVisibleElements:wt,selectNodesOnDrag:at,defaultViewport:Ge,translateExtent:fn,minZoom:At,maxZoom:Ft,preventScrolling:Dt,zoomOnScroll:Vn,zoomOnPinch:jt,zoomOnDoubleClick:yn,panOnScroll:hn,panOnScrollSpeed:Un,panOnScrollMode:Nn,panOnDrag:Cn,onPaneClick:Qt,onPaneMouseEnter:ar,onPaneMouseMove:_n,onPaneMouseLeave:Hn,onPaneScroll:vn,onPaneContextMenu:Pn,onSelectionContextMenu:O,onSelectionStart:ee,onSelectionEnd:I,onEdgeUpdate:ge,onEdgeContextMenu:Te,onEdgeDoubleClick:qe,onEdgeMouseEnter:He,onEdgeMouseMove:it,onEdgeMouseLeave:pt,onEdgeUpdateStart:vt,onEdgeUpdateEnd:Rt,edgeUpdaterRadius:lt,defaultMarkerColor:mn,noDragClassName:ce,noWheelClassName:kt,noPanClassName:Lt,elevateEdgesOnSelect:Nr,rfId:Ks,disableKeyboardA11y:Gr,nodeOrigin:Oe,nodeExtent:Tt}),ye.createElement(T1,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:b,onConnectStart:C,onConnectEnd:S,onClickConnectStart:L,onClickConnectEnd:M,nodesDraggable:yt,nodesConnectable:nt,nodesFocusable:Ne,edgesFocusable:st,edgesUpdatable:ve,elementsSelectable:Ie,elevateNodesOnSelect:Vr,minZoom:At,maxZoom:Ft,nodeExtent:Tt,onNodesChange:Pt,onEdgesChange:Vt,snapToGrid:Ke,snapGrid:Ct,connectionMode:P,translateExtent:fn,connectOnClick:pn,defaultEdgeOptions:er,fitView:Ve,fitViewOptions:nn,onNodesDelete:de,onEdgesDelete:pe,onNodeDragStart:Z,onNodeDrag:ne,onNodeDragStop:ue,onSelectionDrag:j,onSelectionDragStart:E,onSelectionDragStop:R,noPanClassName:Lt,nodeOrigin:Oe,rfId:Ks,autoPanOnConnect:Gs,autoPanOnNodeDrag:$s,onError:Or,connectionRadius:vi,isValidConnection:Ys,nodeDragThreshold:Yr}),ye.createElement(M1,{onSelectionChange:D}),te,ye.createElement(s1,{proOptions:gn,position:cn}),ye.createElement(z1,{rfId:Ks,disableKeyboardA11y:Gr})))});Ex.displayName="ReactFlow";const $x=({id:e,x:t,y:n,width:o,height:a,style:c,color:d,strokeColor:u,strokeWidth:m,className:y,borderRadius:g,shapeRendering:v,onClick:x,selected:b})=>{const{background:C,backgroundColor:S}=c||{},L=d||C||S;return ye.createElement("rect",{className:Pr(["react-flow__minimap-node",{selected:b},y]),x:t,y:n,rx:g,ry:g,width:o,height:a,fill:L,stroke:u,strokeWidth:m,shapeRendering:v,onClick:x?M=>x(M,e):void 0})};$x.displayName="MiniMapNode";var W2=h.memo($x);const q2=e=>e.nodeOrigin,V2=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Kh=e=>e instanceof Function?e:()=>e;function G2({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:a=2,nodeComponent:c=W2,onClick:d}){const u=Rn(V2,kr),m=Rn(q2),y=Kh(t),g=Kh(e),v=Kh(n),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ye.createElement(ye.Fragment,null,u.map(b=>{const{x:C,y:S}=ql(b,m).positionAbsolute;return ye.createElement(c,{key:b.id,x:C,y:S,width:b.width,height:b.height,style:b.style,selected:b.selected,className:v(b),color:y(b),borderRadius:o,strokeColor:g(b),strokeWidth:a,shapeRendering:x,onClick:d,id:b.id})}))}var Y2=h.memo(G2);const K2=200,X2=150,J2=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?a1(qm(t,e.nodeOrigin),n):n,rfId:e.rfId}},Z2="react-flow__minimap-desc";function Mx({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:o="#e2e2e2",nodeClassName:a="",nodeBorderRadius:c=5,nodeStrokeWidth:d=2,nodeComponent:u,maskColor:m="rgb(240, 240, 240, 0.6)",maskStrokeColor:y="none",maskStrokeWidth:g=1,position:v="bottom-right",onClick:x,onNodeClick:b,pannable:C=!1,zoomable:S=!1,ariaLabel:L="React Flow mini map",inversePan:M=!1,zoomStep:W=10,offsetScale:q=5}){const z=hr(),Y=h.useRef(null),{boundingRect:Q,viewBB:Z,rfId:ne}=Rn(J2,kr),ue=(e==null?void 0:e.width)??K2,de=(e==null?void 0:e.height)??X2,pe=Q.width/ue,D=Q.height/de,E=Math.max(pe,D),j=E*ue,R=E*de,O=q*E,ee=Q.x-(j-Q.width)/2-O,I=Q.y-(R-Q.height)/2-O,P=j+O*2,G=R+O*2,$=`${Z2}-${ne}`,K=h.useRef(0);K.current=E,h.useEffect(()=>{if(Y.current){const he=_i(Y.current),be=Fe=>{const{transform:Ye,d3Selection:Ke,d3Zoom:Ct}=z.getState();if(Fe.sourceEvent.type!=="wheel"||!Ke||!Ct)return;const wt=-Fe.sourceEvent.deltaY*(Fe.sourceEvent.deltaMode===1?.05:Fe.sourceEvent.deltaMode?1:.002)*W,at=Ye[2]*Math.pow(2,wt);Ct.scaleTo(Ke,at)},je=Fe=>{const{transform:Ye,d3Selection:Ke,d3Zoom:Ct,translateExtent:wt,width:at,height:yt}=z.getState();if(Fe.sourceEvent.type!=="mousemove"||!Ke||!Ct)return;const nt=K.current*Math.max(1,Ye[2])*(M?-1:1),Ne={x:Ye[0]-Fe.sourceEvent.movementX*nt,y:Ye[1]-Fe.sourceEvent.movementY*nt},Oe=[[0,0],[at,yt]],st=Qo.translate(Ne.x,Ne.y).scale(Ye[2]),ve=Ct.constrain()(st,Oe,wt);Ct.transform(Ke,ve)},Ee=Dv().on("zoom",C?je:null).on("zoom.wheel",S?be:null);return he.call(Ee),()=>{he.on("zoom",null)}}},[C,S,M,W]);const se=x?he=>{const be=Gi(he);x(he,{x:be[0],y:be[1]})}:void 0,le=b?(he,be)=>{const je=z.getState().nodeInternals.get(be);b(he,je)}:void 0;return ye.createElement(Bd,{position:v,style:e,className:Pr(["react-flow__minimap",t]),"data-testid":"rf__minimap"},ye.createElement("svg",{width:ue,height:de,viewBox:`${ee} ${I} ${P} ${G}`,role:"img","aria-labelledby":$,ref:Y,onClick:se},L&&ye.createElement("title",{id:$},L),ye.createElement(Y2,{onClick:le,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:c,nodeClassName:a,nodeStrokeWidth:d,nodeComponent:u}),ye.createElement("path",{className:"react-flow__minimap-mask",d:`M${ee-O},${I-O}h${P+O*2}v${G+O*2}h${-P-O*2}z
122
+ M${Z.x},${Z.y}h${Z.width}v${Z.height}h${-Z.width}z`,fill:m,fillRule:"evenodd",stroke:y,strokeWidth:g,pointerEvents:"none"})))}Mx.displayName="MiniMap";var Q2=h.memo(Mx);function eC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ye.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function tC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ye.createElement("path",{d:"M0 0h32v4.2H0z"}))}function nC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ye.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function rC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ye.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function sC(){return ye.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ye.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Zc=({children:e,className:t,...n})=>ye.createElement("button",{type:"button",className:Pr(["react-flow__controls-button",t]),...n},e);Zc.displayName="ControlButton";const iC=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Ax=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:c,onZoomOut:d,onFitView:u,onInteractiveChange:m,className:y,children:g,position:v="bottom-left"})=>{const x=hr(),[b,C]=h.useState(!1),{isInteractive:S,minZoomReached:L,maxZoomReached:M}=Rn(iC,kr),{zoomIn:W,zoomOut:q,fitView:z}=up();if(h.useEffect(()=>{C(!0)},[]),!b)return null;const Y=()=>{W(),c==null||c()},Q=()=>{q(),d==null||d()},Z=()=>{z(a),u==null||u()},ne=()=>{x.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),m==null||m(!S)};return ye.createElement(Bd,{className:Pr(["react-flow__controls",y]),position:v,style:e,"data-testid":"rf__controls"},t&&ye.createElement(ye.Fragment,null,ye.createElement(Zc,{onClick:Y,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:M},ye.createElement(eC,null)),ye.createElement(Zc,{onClick:Q,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:L},ye.createElement(tC,null))),n&&ye.createElement(Zc,{className:"react-flow__controls-fitview",onClick:Z,title:"fit view","aria-label":"fit view"},ye.createElement(nC,null)),o&&ye.createElement(Zc,{className:"react-flow__controls-interactive",onClick:ne,title:"toggle interactivity","aria-label":"toggle interactivity"},S?ye.createElement(sC,null):ye.createElement(rC,null)),g)};Ax.displayName="Controls";var oC=h.memo(Ax),Ki;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ki||(Ki={}));function aC({color:e,dimensions:t,lineWidth:n}){return ye.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function lC({color:e,radius:t}){return ye.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const cC={[Ki.Dots]:"#91919a",[Ki.Lines]:"#eee",[Ki.Cross]:"#e2e2e2"},uC={[Ki.Dots]:1,[Ki.Lines]:1,[Ki.Cross]:6},dC=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Tx({id:e,variant:t=Ki.Dots,gap:n=20,size:o,lineWidth:a=1,offset:c=2,color:d,style:u,className:m}){const y=h.useRef(null),{transform:g,patternId:v}=Rn(dC,kr),x=d||cC[t],b=o||uC[t],C=t===Ki.Dots,S=t===Ki.Cross,L=Array.isArray(n)?n:[n,n],M=[L[0]*g[2]||1,L[1]*g[2]||1],W=b*g[2],q=S?[W,W]:M,z=C?[W/c,W/c]:[q[0]/c,q[1]/c];return ye.createElement("svg",{className:Pr(["react-flow__background",m]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:y,"data-testid":"rf__background"},ye.createElement("pattern",{id:v+e,x:g[0]%M[0],y:g[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`},C?ye.createElement(lC,{color:x,radius:W/c}):ye.createElement(aC,{dimensions:q,color:x,lineWidth:a})),ye.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${v+e})`}))}Tx.displayName="Background";var fC=h.memo(Tx);function Lx(e,t={}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!n)return null;const o=typeof n.x=="number"&&Number.isFinite(n.x)?n.x:null,a=typeof n.y=="number"&&Number.isFinite(n.y)?n.y:null,c=typeof n.zoom=="number"&&Number.isFinite(n.zoom)?n.zoom:null;if(o===null||a===null||c===null)return null;const d=typeof t.maxAbsTranslate=="number"&&Number.isFinite(t.maxAbsTranslate)?Math.abs(t.maxAbsTranslate):1e6;if(Math.abs(o)>d||Math.abs(a)>d)return null;const u=typeof t.minZoom=="number"&&Number.isFinite(t.minZoom)?t.minZoom:.025,m=typeof t.maxZoom=="number"&&Number.isFinite(t.maxZoom)?t.maxZoom:6,y=Math.min(u,m),g=Math.max(u,m);return{x:o,y:a,zoom:Math.min(g,Math.max(y,c))}}function Lm(e){const t=String(e||"").trim();if(!t)return"";const n=t.indexOf(":");return n!==-1&&n<t.length-1?t.slice(n+1):t}function mC(e){const t=String(e||"").trim();if(!t)return"entity";const n=t.indexOf(":");if(n<=0||n>=t.length-1)return"entity";const o=t.slice(0,n).toLowerCase(),a=t.slice(n+1).toLowerCase();if(o==="ex"){const c=a.indexOf("-"),d=c>0?a.slice(0,c):a;return d==="person"?"person":d==="org"?"org":d==="concept"?"concept":d==="claim"?"claim":d==="event"?"event":d==="doc"?"doc":d==="thing"?"thing":"entity"}return o==="schema"||o==="skos"||o==="dcterms"||o==="rdf"||o==="cito"?"vocab":"entity"}function hC(e){const t=String(e||"").trim();if(!t)return"";const n=t.indexOf(":");if(n<=0||n>=t.length-1)return Lm(t);const o=t.slice(0,n).toLowerCase(),a=t.slice(n+1);if(o==="ex"){const c=a.indexOf("-");if(c>0&&c<a.length-1)return a.slice(c+1)}return Lm(t)}function P_(e){const o=Math.max(1,Math.ceil(Math.sqrt(e.length))),a={};for(let c=0;c<e.length;c++){const d=Math.floor(c/o),u=c%o;a[e[c]]={x:u*240,y:d*120}}return a}function O_(e){const t=String(e??"");let n=2166136261;for(let o=0;o<t.length;o++)n^=t.charCodeAt(o),n=Math.imul(n,16777619);return n>>>0}function Rx(e){let t=e>>>0;return()=>{t+=1831565813;let n=Math.imul(t^t>>>15,1|t);return n^=n+Math.imul(n^n>>>7,61|n),((n^n>>>14)>>>0)/4294967296}}function _C(e,t){const n={},o=e.length;if(!o)return n;const a=Math.max(260,Math.sqrt(o)*150),c=t%360*Math.PI/180;for(let d=0;d<o;d++){const u=c+2*Math.PI*d/o;n[e[d]]={x:a*Math.cos(u),y:a*Math.sin(u)}}return n}function Qg(e,t,n){var C;const o={};if(!e.length)return o;const a=new Map;for(const S of e)a.set(S,new Set);for(const S of t){const L=String((S==null?void 0:S.source)||"").trim(),M=String((S==null?void 0:S.target)||"").trim();if(!L||!M||L===M)continue;const W=a.get(L),q=a.get(M);W&&W.add(M),q&&q.add(L)}let c=e[0],d=-1;for(const S of e){const L=((C=a.get(S))==null?void 0:C.size)??0;(L>d||L===d&&S.localeCompare(c)<0)&&(c=S,d=L)}const u=new Map,m=[];for(u.set(c,0),m.push(c);m.length;){const S=m.shift(),L=u.get(S)??0,M=Array.from(a.get(S)??[]);M.sort((W,q)=>W.localeCompare(q));for(const W of M)u.has(W)||(u.set(W,L+1),m.push(W))}let y=0;for(const S of u.values())y=Math.max(y,S);for(const S of e)u.has(S)||u.set(S,y+1);const g=new Map;for(const S of e){const L=u.get(S)??0,M=g.get(L);M?M.push(S):g.set(L,[S])}const v=Array.from(g.keys()).sort((S,L)=>S-L),x=260,b=n%360*Math.PI/180;for(const S of v){const L=g.get(S)||[];if(L.sort((z,Y)=>z.localeCompare(Y)),S===0){if(L.length===1)o[L[0]]={x:0,y:0};else for(let Y=0;Y<L.length;Y++){const Q=b+2*Math.PI*Y/L.length;o[L[Y]]={x:80*Math.cos(Q),y:80*Math.sin(Q)}}continue}const M=x*S,W=L.length;if(W===1){o[L[0]]={x:M,y:0};continue}const q=b+S*.35;for(let z=0;z<W;z++){const Y=q+2*Math.PI*z/W;o[L[z]]={x:M*Math.cos(Y),y:M*Math.sin(Y)}}}return o}function Yc(e,t={}){const n=t.kind??"grid",o=typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):0,a=e.nodes.map(c=>c.id);if(n==="grid")return P_(a);if(n==="circle")return _C(a,o);if(n==="radial")return Qg(a,e.edges,o);if(n==="force"){const c=Qg(a,e.edges,o),d=Rx(o||1),u=Math.max(10,Math.min(42,Math.sqrt(a.length)*2.75)),m={};for(const y of a){const g=c[y]||{x:0,y:0};m[y]={x:g.x+(d()-.5)*u,y:g.y+(d()-.5)*u}}return m}return P_(a)}function pC(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&typeof t.subject=="string"&&typeof t.predicate=="string"&&typeof t.object=="string"):[]}function gC(e,t={}){const n=!!(t.groupEdges??!0),o=Math.max(1,t.maxEdgeLabelPredicates??3),a=pC(e),c=new Set;for(const x of a){const b=String(x.subject||"").trim(),C=String(x.object||"").trim();b&&c.add(b),C&&c.add(C)}const d=Array.from(c);d.sort((x,b)=>x.localeCompare(b));const u=P_(d),m=d.map(x=>({id:x,type:"default",data:{label:hC(x),kind:mC(x)},position:u[x]||{x:0,y:0}})),y=new Map,g=(x,b)=>{const C=String(x.subject||"").trim(),S=String(x.object||"").trim(),L=String(x.predicate||"").trim();return n?`edge:${C}:${S}`:`edge:${b}:${C}:${L}:${S}`};for(let x=0;x<a.length;x++){const b=a[x],C=g(b,x),S=y.get(C);S?S.push(b):y.set(C,[b])}const v=[];for(const[x,b]of y.entries()){const C=b[0],S=String(C.subject||"").trim(),L=String(C.object||"").trim();if(!S||!L)continue;const M=new Map;for(const Z of b){const ne=String(Z.predicate||"").trim();ne&&M.set(ne,(M.get(ne)||0)+1)}const W=Array.from(M.entries());W.sort((Z,ne)=>ne[1]-Z[1]||Z[0].localeCompare(ne[0]));const z=W.slice(0,o).map(([Z,ne])=>ne>1?`${Lm(Z)}×${ne}`:Lm(Z)).join(" | "),Y=W.length>o?` +${W.length-o}`:"",Q=`${z}${Y}`.trim();v.push({id:x,source:S,target:L,label:Q,animated:!1,data:{assertions:b,predicateSummary:Q}})}return{nodes:m,edges:v}}function yC(e,t,n,o={}){const a=o.directed!==!1,c=String(t||"").trim(),d=String(n||"").trim();if(!c||!d)return null;if(c===d)return{nodeIds:[c],edgeIds:[]};const u=new Map,m=(S,L,M)=>{const W=u.get(S);W?W.push({to:L,edgeId:M}):u.set(S,[{to:L,edgeId:M}])};for(const S of e.edges)m(S.source,S.target,S.id),a||m(S.target,S.source,S.id);const y=[c],g=new Map,v=new Map;for(g.set(c,null),v.set(c,null);y.length;){const S=y.shift(),L=u.get(S)||[];for(const M of L)if(!g.has(M.to)){if(g.set(M.to,S),v.set(M.to,M.edgeId),M.to===d){y.length=0;break}y.push(M.to)}}if(!g.has(d))return null;const x=[],b=[];let C=d;for(;C;){x.push(C);const S=v.get(C);S&&b.push(S),C=g.get(C)||null}return x.reverse(),b.reverse(),{nodeIds:x,edgeIds:b}}const ey={seed:1,dt:1,springLength:240,springStrength:.03,repulsionStrength:9e3,centeringStrength:.003,damping:.85,maxSpeed:90,maxRepulsionNodes:320};function om(e,t={}){const n={...ey,...t,seed:typeof t.seed=="number"&&Number.isFinite(t.seed)?Math.trunc(t.seed):ey.seed},o=e.nodes.map(b=>b.id),a=o.length,c=new Float64Array(2*a),d=new Float64Array(2*a),u=new Float64Array(2*a),m=new Map;for(let b=0;b<a;b++)m.set(o[b],b);const y=t.positions??Yc(e,{kind:"force",seed:n.seed}),g=Rx(n.seed||1),v=Math.max(8,Math.min(38,Math.sqrt(a)*2.25));for(let b=0;b<a;b++){const C=o[b],S=y[C],L=typeof(S==null?void 0:S.x)=="number"&&Number.isFinite(S.x)?S.x:(g()-.5)*500,M=typeof(S==null?void 0:S.y)=="number"&&Number.isFinite(S.y)?S.y:(g()-.5)*500;c[2*b]=L+(g()-.5)*v,c[2*b+1]=M+(g()-.5)*v,d[2*b]=0,d[2*b+1]=0}const x=[];for(const b of e.edges){const C=m.get(String((b==null?void 0:b.source)||"").trim()),S=m.get(String((b==null?void 0:b.target)||"").trim());typeof C!="number"||typeof S!="number"||C===S||x.push(C,S)}return{nodeIds:o,pos:c,vel:d,acc:u,edges:new Uint32Array(x),options:n,tick:0}}function vC(e,t=1){const n=e.nodeIds.length;if(!n)return;const o=e.options,a=o.dt;for(let c=0;c<Math.max(1,Math.trunc(t));c++){if(e.acc.fill(0),n<=o.maxRepulsionNodes){const b=o.repulsionStrength;for(let C=0;C<n;C++){const S=e.pos[2*C],L=e.pos[2*C+1];for(let M=C+1;M<n;M++){const W=e.pos[2*M]-S,q=e.pos[2*M+1]-L,z=W*W+q*q+1e-6,Y=1/Math.sqrt(z),Q=b/z,Z=Q*W*Y,ne=Q*q*Y;e.acc[2*C]-=Z,e.acc[2*C+1]-=ne,e.acc[2*M]+=Z,e.acc[2*M+1]+=ne}}}const u=o.springLength,m=o.springStrength,y=e.edges;for(let b=0;b<y.length;b+=2){const C=y[b],S=y[b+1],L=e.pos[2*C],M=e.pos[2*C+1],W=e.pos[2*S],q=e.pos[2*S+1],z=W-L,Y=q-M,Q=z*z+Y*Y+1e-6,Z=Math.sqrt(Q),ne=m*(Z-u),ue=ne*z/Z,de=ne*Y/Z;e.acc[2*C]+=ue,e.acc[2*C+1]+=de,e.acc[2*S]-=ue,e.acc[2*S+1]-=de}const g=o.centeringStrength;for(let b=0;b<n;b++)e.acc[2*b]+=-g*e.pos[2*b],e.acc[2*b+1]+=-g*e.pos[2*b+1];const v=o.damping,x=o.maxSpeed;for(let b=0;b<n;b++){let C=(e.vel[2*b]+e.acc[2*b]*a)*v,S=(e.vel[2*b+1]+e.acc[2*b+1]*a)*v;const L=Math.sqrt(C*C+S*S);if(L>x){const M=x/L;C*=M,S*=M}e.vel[2*b]=C,e.vel[2*b+1]=S,e.pos[2*b]+=C*a,e.pos[2*b+1]+=S*a}e.tick+=1}}function xC(e){const t=e.nodeIds.length;if(!t)return 0;let n=0;for(let o=0;o<t;o++){const a=e.vel[2*o],c=e.vel[2*o+1];n+=Math.sqrt(a*a+c*c)}return n/t}function wC(e){const t={},n=e.nodeIds.length;for(let o=0;o<n;o++)t[e.nodeIds[o]]={x:e.pos[2*o],y:e.pos[2*o+1]};return t}function ty(e,t="session"){const n=String(e??"").trim().toLowerCase();return n==="run"||n==="session"||n==="global"||n==="all"?n:t}function bC(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(max-width: 720px)").matches}catch{return!1}}function SC(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[s.jsx("rect",{x:"3",y:"3",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"3",y:"7",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"3",y:"11",width:"3",height:"3",rx:"1"}),s.jsx("rect",{x:"8",y:"3.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"}),s.jsx("rect",{x:"8",y:"7.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"}),s.jsx("rect",{x:"8",y:"11.5",width:"6",height:"2",rx:"1",fill:"none",strokeWidth:"1.4"})]})}function Px(e,t,n,o){const a=typeof e=="number"&&Number.isFinite(e)?e:o;return Math.min(n,Math.max(t,a))}function kd(e){const t=Px(e,.6,2.4,1),n=240*t,o=9e3*t*t;return{springLength:n,repulsionStrength:o}}const Vd="abstractuic_amx_saved_layouts_v1",z_=.025,I_=6,Ox=1e6;function mp(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function D_(e,t="grid"){const n=String(e??"").trim().toLowerCase();return n==="grid"||n==="circle"||n==="radial"||n==="force"?n:t}function jC(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:null;if(!t)return null;const n=typeof t.x=="number"&&Number.isFinite(t.x)?t.x:null,o=typeof t.y=="number"&&Number.isFinite(t.y)?t.y:null;return n===null||o===null?null:{x:n,y:o}}function ny(e){const t=mp();if(!t)return null;const n=String(e??"").trim();if(!n)return null;try{const o=t.getItem(Vd);if(!o)return null;const a=JSON.parse(o),c=a&&typeof a=="object"&&!Array.isArray(a)?a:null;if(!c)return null;const d=c[n],u=d&&typeof d=="object"&&!Array.isArray(d)?d:null;if(!u)return null;const m=u.version===1?1:null;if(m===null)return null;const y=D_(u.kind,"grid"),g=typeof u.seed=="number"&&Number.isFinite(u.seed)?Math.trunc(u.seed):O_(n),v=u.positions&&typeof u.positions=="object"&&!Array.isArray(u.positions)?u.positions:null,x={};if(v)for(const[S,L]of Object.entries(v)){const M=jC(L);M&&(x[String(S)]=M)}const b=Lx(u.viewport,{minZoom:z_,maxZoom:I_,maxAbsTranslate:Ox})??void 0,C=typeof u.saved_at=="string"&&u.saved_at.trim()?u.saved_at.trim():"";return{version:m,kind:y,seed:g,positions:x,viewport:b,saved_at:C}}catch{return null}}function kC(e,t){const n=mp();if(!n)return;const o=String(e??"").trim();if(o)try{const a=n.getItem(Vd),c=a?JSON.parse(a):null,d=c&&typeof c=="object"&&!Array.isArray(c)?{...c}:{};d[o]=t,n.setItem(Vd,JSON.stringify(d))}catch{}}function NC(e){const t=mp();if(!t)return;const n=String(e??"").trim();if(n)try{const o=t.getItem(Vd);if(!o)return;const a=JSON.parse(o),c=a&&typeof a=="object"&&!Array.isArray(a)?{...a}:null;if(!c||!(n in c))return;delete c[n],t.setItem(Vd,JSON.stringify(c))}catch{}}function CC(e){const t=String(e??"").trim();if(!t)return;const n=Number(t);if(Number.isFinite(n))return n}function Xh(e,t){const n=!!(t!=null&&t.allowZero),o=!!(t!=null&&t.allowNegativeOne),a=String(e??"").trim();if(!a)return;const c=Number(a);if(!Number.isFinite(c))return;const d=Math.trunc(c);if(o&&d===-1)return-1;if(!(!n&&d<=0)&&!(n&&d<0))return d}function EC(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=typeof t.recall_level=="string"?t.recall_level:"",o=t.applied&&typeof t.applied=="object"&&!Array.isArray(t.applied)?t.applied:null,a=[];return n&&a.push(`recall_level=${n}`),o&&(typeof o.limit=="number"&&a.push(`limit=${o.limit}`),typeof o.min_score=="number"&&a.push(`min_score=${o.min_score}`),typeof o.max_input_tokens=="number"&&a.push(`max_input_tokens=${o.max_input_tokens}`)),a.length?a.join(" · "):null}function $C(e){if(!e||typeof e!="object")return null;const t=[],n=typeof e.scope=="string"?e.scope.trim():"",o=typeof e.owner_id=="string"?e.owner_id.trim():"";n&&t.push(`scope=${n}`),o&&t.push(`owner_id=${o}`);const a=typeof e.confidence=="number"&&Number.isFinite(e.confidence)?e.confidence:null;a!==null&&t.push(`confidence=${a.toFixed(3)}`);const c=e.provenance&&typeof e.provenance=="object"&&!Array.isArray(e.provenance)?e.provenance:null;if(c){const y=typeof c.writer_run_id=="string"?c.writer_run_id.trim():"",g=typeof c.writer_workflow_id=="string"?c.writer_workflow_id.trim():"";y&&t.push(`writer_run_id=${y}`),g&&t.push(`writer_workflow_id=${g}`)}const d=e.attributes&&typeof e.attributes=="object"&&!Array.isArray(e.attributes)?e.attributes:null,u=d&&d._retrieval&&typeof d._retrieval=="object"&&!Array.isArray(d._retrieval)?d._retrieval:null,m=u&&typeof u.score=="number"&&Number.isFinite(u.score)?u.score:null;return m!==null&&t.push(`score=${m.toFixed(3)}`),t.length?t.join(" · "):null}function MC(e,t){const n=String(e??""),o=String(t??"").trim();if(!o)return n;const a=n.toLowerCase().indexOf(o.toLowerCase());if(a<0)return n;const c=n.slice(0,a),d=n.slice(a,a+o.length),u=n.slice(a+o.length);return s.jsxs(s.Fragment,{children:[c,s.jsx("span",{className:"amx-hl",children:d}),u]})}function Nd(e){const t=String(e??"").trim().toLowerCase();return t==="person"?{stroke:"rgba(96, 165, 250, 0.82)",bg:"rgba(96, 165, 250, 0.10)",minimap:"rgba(96, 165, 250, 0.85)"}:t==="org"?{stroke:"rgba(34, 197, 94, 0.78)",bg:"rgba(34, 197, 94, 0.10)",minimap:"rgba(34, 197, 94, 0.82)"}:t==="concept"?{stroke:"rgba(168, 85, 247, 0.78)",bg:"rgba(168, 85, 247, 0.10)",minimap:"rgba(168, 85, 247, 0.82)"}:t==="claim"?{stroke:"rgba(251, 191, 36, 0.78)",bg:"rgba(251, 191, 36, 0.10)",minimap:"rgba(251, 191, 36, 0.82)"}:t==="event"?{stroke:"rgba(239, 68, 68, 0.74)",bg:"rgba(239, 68, 68, 0.10)",minimap:"rgba(239, 68, 68, 0.80)"}:t==="doc"?{stroke:"rgba(14, 165, 233, 0.74)",bg:"rgba(14, 165, 233, 0.10)",minimap:"rgba(14, 165, 233, 0.80)"}:t==="vocab"?{stroke:"rgba(148, 163, 184, 0.55)",bg:"rgba(148, 163, 184, 0.06)",minimap:"rgba(148, 163, 184, 0.70)"}:t==="thing"?{stroke:"rgba(255, 255, 255, 0.20)",bg:"rgba(255, 255, 255, 0.04)",minimap:"rgba(255, 255, 255, 0.30)"}:{stroke:"rgba(255, 255, 255, 0.14)",bg:"rgba(0, 0, 0, 0.18)",minimap:"rgba(255, 255, 255, 0.24)"}}function AC(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function Cd(e){const t=AC(e);if(t===null)return"";const n=new Date(t),o=n.getUTCFullYear(),a=String(n.getUTCMonth()+1).padStart(2,"0"),c=String(n.getUTCDate()).padStart(2,"0"),d=String(n.getUTCHours()).padStart(2,"0"),u=String(n.getUTCMinutes()).padStart(2,"0");return`${o}/${a}/${c} ${d}:${u}`}function zx(e){const t=String(e??"").trim();if(!t)return"";const n=t.indexOf(":");return n!==-1&&n<t.length-1?t.slice(n+1):t}function Jh(e,t){const n=String(e??"").trim().toLowerCase();return!!(n&&t.has(n))}function TC(e,t={}){const n=Math.max(1,t.maxPredicates??3),o=new Map;for(const m of e){const y=String((m==null?void 0:m.predicate)||"").trim();y&&o.set(y,(o.get(y)||0)+1)}const a=Array.from(o.entries());a.sort((m,y)=>y[1]-m[1]||m[0].localeCompare(y[0]));const d=a.slice(0,n).map(([m,y])=>{const g=zx(m);return y>1?`${g}×${y}`:g}).join(" | "),u=a.length>n?` +${a.length-n}`:"";return`${d}${u}`.trim()}function LC({resetKey:e,queryMode:t,items:n,activeMemoryText:o,packets:a,packetsVersion:c,packedCount:d,dropped:u,estimatedTokens:m,effort:y,warnings:g,onQuery:v,onItemsReplace:x,onOpenSpan:b,onOpenTranscript:C}){var xo;const S=h.useRef(null),L=h.useMemo(()=>{const F=n==null?void 0:n[0],ae=n==null?void 0:n[n.length-1],we=F?`${F.subject}|${F.predicate}|${F.object}`:"",ke=ae?`${ae.subject}|${ae.predicate}|${ae.object}`:"";return`${(n==null?void 0:n.length)||0}:${we}:${ke}`},[n]),M=String(e??L),W=t==="replace"?"replace":"override",[q,z]=h.useState(null),[Y,Q]=h.useState(null),[Z,ne]=h.useState(!1),[ue,de]=h.useState(""),[pe,D]=h.useState(!1),[E,j]=h.useState("");h.useEffect(()=>{z(null),Q(null),de(""),ne(!1),j(""),D(!1)},[M]);const[R,O]=h.useState(""),[ee,I]=h.useState(!0),[P,G]=h.useState(!1),[$,K]=h.useState(!0),[se]=h.useState(()=>({compact:bC(),show:!1})),le=se.compact,[he,be]=h.useState(se.show),[je,Ee]=h.useState(!1),Fe=M,Ye=h.useMemo(()=>O_(Fe),[Fe]),[Ke,Ct]=h.useState("grid"),[wt,at]=h.useState(Ye),[yt,nt]=h.useState(!1),[Ne,Oe]=h.useState(1),st=h.useRef(null),ve=h.useRef(null),Ie=h.useRef(!1),[Ge,At]=h.useState(0),Ft=h.useRef(null),fn=h.useRef(0),Dt=h.useRef(0),Tt=h.useRef(0),mn=h.useRef(0),[Vn,jt]=h.useState(!1),[hn,Un]=h.useState(""),[Nn,yn]=h.useState({}),Cn=h.useRef({});h.useEffect(()=>{Cn.current=Nn},[Nn]);const[Qt,ar]=h.useState(""),[_n,Hn]=h.useState(""),vn=h.useMemo(()=>{var ae;const F=(ae=n==null?void 0:n[0])==null?void 0:ae.scope;return ty(F,"session")},[n]),[Pn,te]=h.useState(vn),[ge,Te]=h.useState("standard"),[qe,He]=h.useState(""),[it,pt]=h.useState(""),[vt,Rt]=h.useState(""),[lt,Pt]=h.useState(""),[Vt,ce]=h.useState(""),[kt,Lt]=h.useState(""),[Ve,nn]=h.useState(""),[pn,cn]=h.useState("qwen/qwen3-next-80b");h.useEffect(()=>{te(vn)},[M]);const gn=Array.isArray(n)?n:[],er=typeof o=="string"?o:"",Vr=Array.isArray(a)?a:[],Nr=typeof c=="number"?c:void 0,Gr=typeof d=="number"?d:void 0,Gs=typeof u=="number"?u:void 0,$s=typeof m=="number"?m:void 0,vi=y,Ys=g,Or=W==="override"&&(q!=null&&q.items)&&Array.isArray(q.items)?q.items:gn,an=typeof(q==null?void 0:q.active_memory_text)=="string"&&q.active_memory_text.trim()?q.active_memory_text:er,ra=(q==null?void 0:q.effort)??vi,Yr=(q==null?void 0:q.warnings)??Ys,Ms=h.useMemo(()=>new Set(["rdf:type","schema:name","skos:preflabel","skos:altlabel","dcterms:title","dcterms:identifier"]),[]),As=h.useMemo(()=>$?Or:(Or||[]).filter(F=>!Jh(F==null?void 0:F.predicate,Ms)),[Or,$,Ms]),Ks=h.useMemo(()=>gC(Or,{groupEdges:ee}),[Or,ee]),rt=h.useMemo(()=>{if($)return Ks;const F=[];for(const ae of Ks.edges){const ke=(ae&&ae.data&&Array.isArray(ae.data.assertions)?ae.data.assertions:[]).filter(We=>!Jh(We==null?void 0:We.predicate,Ms));if(!ke.length)continue;const $e=TC(ke);F.push({...ae,label:$e,data:{...ae.data,assertions:ke,predicateSummary:$e}})}return{nodes:Ks.nodes,edges:F}},[Ks,$,Ms]),rn=h.useMemo(()=>rt.nodes.map(F=>F.id),[rt.nodes]),Cr=h.useMemo(()=>{const F=rn[0]||"",ae=rn[rn.length-1]||"";return`${rn.length}:${F}:${ae}`},[rn]),xi=h.useMemo(()=>{var ae;const F=new Map;for(const we of rt.nodes)F.set(we.id,String(((ae=we.data)==null?void 0:ae.label)||we.id));return F},[rt.nodes]),_r=h.useMemo(()=>{var ae;const F=new Map;for(const we of rt.nodes)F.set(we.id,String(((ae=we.data)==null?void 0:ae.kind)||""));return F},[rt.nodes]),sa=R.trim().toLowerCase(),Ja=h.useMemo(()=>{var ae;if(!sa)return new Set;const F=new Set;for(const we of rt.nodes){const ke=String(we.id||"").toLowerCase(),$e=String(((ae=we.data)==null?void 0:ae.label)||"").toLowerCase();(ke.includes(sa)||$e.includes(sa))&&F.add(we.id)}return F},[rt.nodes,sa]),Za=h.useCallback((F,ae)=>{const we={};for(const ke of rn){const $e=F[ke]||ae[ke];we[ke]=$e?{x:$e.x,y:$e.y}:{x:0,y:0}}return we},[rn]);h.useEffect(()=>{yn(F=>{const ae=Yc(rt,{kind:Ke,seed:wt}),we={};for(const ke of rn){const $e=F[ke]||ae[ke];we[ke]=$e?{x:$e.x,y:$e.y}:{x:0,y:0}}return we})},[rt,Ke,wt,rn,Cr]),h.useEffect(()=>{if(!Ie.current)return;const F=S.current;if(!(!F||typeof F.fitView!="function")&&rn.length){Ie.current=!1;try{F.fitView({padding:.2,duration:0})}catch{try{F.fitView({padding:.2})}catch{}}}},[rn.length,Cr,Nn]),h.useEffect(()=>{nt(!1),st.current=null,ve.current=null,Ie.current=!1,fn.current=0,Dt.current=0,Tt.current=0;const F=ny(Fe);if(F&&Object.keys(F.positions||{}).length){if(Ct(F.kind),at(F.seed),jt(!0),Un(F.saved_at||""),F.viewport){ve.current=F.viewport;const $e=S.current;if($e&&typeof $e.setViewport=="function"){try{$e.setViewport(F.viewport,{duration:0})}catch{try{$e.setViewport(F.viewport)}catch{}}ve.current=null}}else Ie.current=!0;const ke=Yc(rt,{kind:F.kind,seed:F.seed});yn(Za(F.positions,ke));return}jt(!1),Un("");const ae=O_(Fe);at(ae);const we=Yc(rt,{kind:Ke,seed:ae});yn(we),Ke==="force"&&rt.nodes.length>0&&rt.nodes.length<=320&&(st.current=om(rt,{seed:ae,positions:we,...kd(Ne)}),nt(!0))},[Fe]);const Wn=h.useMemo(()=>{const F=String(Qt||"").trim(),ae=String(_n||"").trim();return!F||!ae?null:yC(rt,F,ae,{directed:P})},[rt,Qt,_n,P]),as=!!(Wn&&String(Qt||"").trim()&&String(_n||"").trim()),Gn=h.useMemo(()=>{const F=String(Qt||"").trim(),ae=String(_n||"").trim();if(!F||!ae)return null;const we=P,ke=new Map,$e=(tt,ct)=>{const Ot=ke.get(tt);Ot?Ot.push(ct):ke.set(tt,[ct])};for(const tt of rt.edges)$e(tt.source,tt.target),we||$e(tt.target,tt.source);const We=new Set,dt=[];for(We.add(F),dt.push(F);dt.length;){const tt=dt.shift(),ct=ke.get(tt)||[];for(const Ot of ct)We.has(Ot)||(We.add(Ot),dt.push(Ot))}return{reachableFromStart:We.size,endReachable:We.has(ae),nodes:rt.nodes.length,edges:rt.edges.length,assertions:As.length}},[P,rt.edges,rt.nodes.length,_n,Qt,As.length]),Xs=h.useMemo(()=>new Set((Wn==null?void 0:Wn.nodeIds)||[]),[Wn]),ia=h.useMemo(()=>new Set((Wn==null?void 0:Wn.edgeIds)||[]),[Wn]),[In,ls]=h.useState(""),[Yn,cs]=h.useState(""),Fn=!!(String(In||"").trim()||String(Yn||"").trim()),us=h.useMemo(()=>{const F=new Set,ae=new Set,we=String(In||"").trim(),ke=String(Yn||"").trim();if(we){F.add(we);for(const $e of rt.edges)($e.source===we||$e.target===we)&&(ae.add($e.id),F.add($e.source),F.add($e.target));return{nodes:F,edges:ae}}if(ke){const $e=rt.edges.find(We=>We.id===ke);$e&&(ae.add($e.id),F.add($e.source),F.add($e.target))}return{nodes:F,edges:ae}},[rt.edges,Yn,In]);h.useEffect(()=>{ls(""),cs(""),ar(""),Hn("")},[M]);const[Js,Yt]=h.useState(!1);h.useEffect(()=>{Yt(!1)},[M]),h.useEffect(()=>{yt||(st.current=null)},[yt]),h.useEffect(()=>{if(Ke!=="force")return;const F=st.current;if(!F)return;const ae=kd(Ne);F.options.springLength=ae.springLength,F.options.repulsionStrength=ae.repulsionStrength},[Ke,Ne]),h.useEffect(()=>{Ke!=="force"&&yt&&nt(!1)},[Ke,yt]),h.useEffect(()=>{if(!yt||Ke!=="force"||rt.nodes.length===0||typeof window>"u"||typeof window.requestAnimationFrame!="function")return;st.current||(st.current=om(rt,{seed:wt,positions:Cn.current,...kd(Ne)}));let F=0,ae=0,we=0;const ke=rt.nodes.length<=140?2:1,$e=1600,We=.08,dt=tt=>{if(F=window.requestAnimationFrame(dt),tt-ae<33)return;ae=tt;const ct=st.current;if(!ct){nt(!1);return}vC(ct,ke),we+=ke,yn(wC(ct)),(xC(ct)<=We||we>=$e)&&nt(!1)};return F=window.requestAnimationFrame(dt),()=>{window.cancelAnimationFrame(F)}},[rt,Ke,yt,wt]);const go=h.useMemo(()=>rt.nodes.map(F=>{var en;const ae=Xs.has(F.id),we=Ja.has(F.id),ke=In===F.id,$e=Fn&&us.nodes.has(F.id),We=Nd((en=F.data)==null?void 0:en.kind),dt="rgba(34, 211, 238, 0.88)",tt=we?"0 0 0 1px rgba(34, 211, 238, 0.34), 0 0 16px rgba(34, 211, 238, 0.26), 0 0 44px rgba(34, 211, 238, 0.14)":"",ct=ae?"rgba(168, 85, 247, 0.9)":we?dt:We.stroke,Ot=ke?"0 0 0 2px rgba(255,255,255,0.20), 0 18px 46px rgba(0,0,0,0.55)":$e?"0 0 0 1px rgba(96, 165, 250, 0.28), 0 12px 34px rgba(0,0,0,0.45)":void 0,Gt=tt&&Ot?`${tt}, ${Ot}`:Ot||tt||void 0,Kt=ae?"rgba(168, 85, 247, 0.10)":we?"rgba(34, 211, 238, 0.08)":We.bg,Et=as?ae||ke?1:.16:Fn?$e||ke?1:.1:1;return{...F,position:Nn[F.id]?{x:Nn[F.id].x,y:Nn[F.id].y}:F.position,style:{...F.style||{},border:`1px solid ${ct}`,borderRadius:10,background:Kt,color:"rgba(255,255,255,0.92)",opacity:Et,padding:8,fontSize:12,boxShadow:Gt,width:180,cursor:"pointer"}}}),[rt.nodes,as,Ja,Nn,In,Xs,Fn,us.nodes]),oa=h.useMemo(()=>rt.edges.map(F=>{const ae=ia.has(F.id),we=Yn===F.id,ke=Fn&&us.edges.has(F.id),$e=ae?"rgba(168, 85, 247, 0.9)":Fn?ke||we?"rgba(96, 165, 250, 0.55)":"rgba(255,255,255,0.14)":"rgba(255,255,255,0.18)",We=ae?2.75:Fn?ke||we?2.25:1.25:1.5,dt=we?"drop-shadow(0 0 10px rgba(168, 85, 247, 0.25))":void 0,tt=ae?"rgba(168, 85, 247, 0.9)":as?"rgba(255,255,255,0.10)":"rgba(255,255,255,0.28)",ct=as?ae||we?1:.1:Fn?ke||we?1:.08:1,Ot=as?ae||we?1:0:Fn?ke||we?1:0:1,Gt=as?ae||we?String(F.label||""):"":String(F.label||"");return{...F,label:Gt,style:{...F.style||{},stroke:$e,strokeWidth:We,filter:dt,opacity:ct},animated:!1,markerEnd:{type:Wd.ArrowClosed,color:tt,width:20,height:20},labelShowBg:!0,labelBgPadding:[6,3],labelBgBorderRadius:10,labelBgStyle:{fill:`rgba(0, 0, 0, ${.38*Ot})`,stroke:`rgba(255, 255, 255, ${.14*Ot})`,strokeWidth:1},labelStyle:{fill:`rgba(255, 255, 255, ${.92*Ot})`,fontSize:10,fontWeight:600,letterSpacing:.2,textTransform:"lowercase"}}}),[rt.edges,as,Yn,ia,Fn,us.edges]),aa=h.useMemo(()=>{if(!Yn)return[];const F=rt.edges.find(we=>we.id===Yn),ae=F&&F.data&&Array.isArray(F.data.assertions)?F.data.assertions:[];return Array.isArray(ae)?ae:[]},[rt.edges,Yn]),zr=h.useMemo(()=>Yn&&rt.edges.find(F=>F.id===Yn)||null,[rt.edges,Yn]),Qa=h.useMemo(()=>{const F=String(In||"").trim();return F?Or.filter(ae=>!ae||typeof ae!="object"||!(ae.subject===F||ae.object===F)?!1:$?!0:!Jh(ae.predicate,Ms)):[]},[Or,In,$,Ms]),Zs=h.useMemo(()=>Yn?aa:Qa,[aa,Yn,Qa]),yo=h.useMemo(()=>{const F=new Map;for(const ae of Zs){if(!ae||typeof ae!="object")continue;const we=ae.provenance&&typeof ae.provenance=="object"&&!Array.isArray(ae.provenance)?ae.provenance:null,ke=we&&typeof we.span_id=="string"?we.span_id.trim():"",$e=we&&typeof we.writer_run_id=="string"?we.writer_run_id.trim():"",We=typeof ae.owner_id=="string"?ae.owner_id.trim():"",dt=$e||We;if(!dt||!ke)continue;const tt=`${dt}|${ke}`,ct=F.get(tt),Ot=typeof ae.observed_at=="string"?ae.observed_at.trim():"";ct?(ct.count+=1,Ot&&(!ct.last_observed_at||Ot>ct.last_observed_at)&&(ct.last_observed_at=Ot,ct.last_observed_at_fmt=Cd(Ot),ct.assertion=ae)):F.set(tt,{span_run_id:dt,span_id:ke,writer_run_id:$e,count:1,last_observed_at:Ot,last_observed_at_fmt:Cd(Ot),assertion:ae})}return Array.from(F.values()).sort((ae,we)=>String(we.last_observed_at||"").localeCompare(String(ae.last_observed_at||"")))},[Zs]),wi=h.useMemo(()=>{const F=new Map;for(const ae of Zs){if(!ae||typeof ae!="object")continue;const we=ae.provenance&&typeof ae.provenance=="object"&&!Array.isArray(ae.provenance)?ae.provenance:null,ke=we&&typeof we.span_id=="string"?we.span_id.trim():"",$e=we&&typeof we.writer_run_id=="string"?we.writer_run_id.trim():"";if(!$e||ke)continue;const We=F.get($e),dt=typeof ae.observed_at=="string"?ae.observed_at.trim():"";We?(We.count+=1,dt&&(!We.last_observed_at||dt>We.last_observed_at)&&(We.last_observed_at=dt,We.last_observed_at_fmt=Cd(dt),We.assertion=ae)):F.set($e,{run_id:$e,count:1,last_observed_at:dt,last_observed_at_fmt:Cd(dt),assertion:ae})}return Array.from(F.values()).sort((ae,we)=>String(we.last_observed_at||"").localeCompare(String(ae.last_observed_at||"")))},[Zs]),tr=h.useCallback(F=>{const ae=String(F.run_id||"").trim(),we=typeof F.span_id=="string"?String(F.span_id).trim():"";if(ae){if(C){try{C({run_id:ae,span_id:we||void 0,assertion:F.assertion})}catch{}return}if(b&&we)try{b({run_id:ae,span_id:we,assertion:F.assertion})}catch{}}},[b,C]),nr=h.useCallback(async F=>{const ae=String(F??"");if(ae)try{await navigator.clipboard.writeText(ae)}catch{}},[]),Er=h.useCallback(()=>{const F=S.current;if(!(!F||typeof F.fitView!="function")){if(In&&typeof F.getNode=="function"){const ae=F.getNode(In);if(ae){F.fitView({nodes:[ae],padding:.55,duration:350});return}}F.fitView({padding:.2,duration:350})}},[In]),bi=h.useCallback(F=>{const ae=F.kind,we=Math.trunc(F.seed);nt(!1),st.current=null,ve.current=null,Ct(ae),at(we);const ke=Yc(rt,{kind:ae,seed:we});yn(ke),ae==="force"&&(F.autoPlay??!0)&&rt.nodes.length>0&&rt.nodes.length<=320&&(st.current=om(rt,{seed:we,positions:ke,...kd(Ne)}),nt(!0))},[rt,Ne]),ds=h.useCallback(()=>{if(Ke==="force"){if(yt){nt(!1);return}st.current=om(rt,{seed:wt,positions:Cn.current,...kd(Ne)}),nt(!0)}},[rt,Ke,yt,wt,Ne]);h.useEffect(()=>()=>{typeof window>"u"||typeof window.cancelAnimationFrame=="function"&&mn.current&&window.cancelAnimationFrame(mn.current)},[]);const Ir=h.useCallback(()=>{const F=S.current;if(!F||typeof F.getViewport!="function"||!rn.length)return null;const ae=Ft.current;if(!ae)return null;const we=ae.getBoundingClientRect();if(!Number.isFinite(we.width)||!Number.isFinite(we.height)||we.width<64||we.height<64)return null;const ke=F.getViewport(),$e=typeof(ke==null?void 0:ke.zoom)=="number"&&Number.isFinite(ke.zoom)?ke.zoom:null,We=typeof(ke==null?void 0:ke.x)=="number"&&Number.isFinite(ke.x)?ke.x:null,dt=typeof(ke==null?void 0:ke.y)=="number"&&Number.isFinite(ke.y)?ke.y:null;if($e===null||We===null||dt===null||$e<=0)return null;const tt=140,ct=Math.min(rn.length,180),Ot=Cn.current;let Gt=0,Kt=0;for(const Et of rn){const en=Ot[Et];if(!en||!Number.isFinite(en.x)||!Number.isFinite(en.y))continue;Kt+=1;const En=[{x:en.x,y:en.y},{x:en.x+90,y:en.y+24}];for(const un of En){const Dr=un.x*$e+We,Kn=un.y*$e+dt;if(Dr>-tt&&Dr<we.width+tt&&Kn>-tt&&Kn<we.height+tt)return!1}if(Gt++,Gt>=ct)break}return Kt?!0:null},[rn]),fs=h.useCallback(F=>{typeof window>"u"||typeof window.requestAnimationFrame!="function"||mn.current||(mn.current=window.requestAnimationFrame(()=>{mn.current=0;const ae=Ir();if(ae===null){if(Tt.current>=12)return;Tt.current+=1,window.setTimeout(()=>fs(`${F}:probe`),120);return}if(ae!==!0){Tt.current=0,Dt.current=0;return}Tt.current=0;const we=S.current;if(we&&typeof we.fitView=="function")try{we.fitView({padding:.2,duration:0})}catch{try{we.fitView({padding:.2})}catch{}}if(Dt.current+=1,Dt.current>=4&&fn.current<1){Dt.current=0,fn.current+=1,At(ke=>ke+1);return}Dt.current<8&&window.setTimeout(()=>fs(`${F}:retry`),220)}))},[Ir]);h.useEffect(()=>{Dt.current=0,fn.current=0,Tt.current=0,fs("mount")},[M,fs]),h.useEffect(()=>{fs("graph change")},[Cr,fs]),h.useEffect(()=>{const F=Ft.current;if(!F||typeof window>"u"||typeof ResizeObserver!="function")return;const ae=new ResizeObserver(()=>fs("resize"));return ae.observe(F),()=>ae.disconnect()},[fs]);const el=h.useCallback(()=>{const F=new Date().toISOString(),ae={};for(const dt of rn){const tt=Cn.current[dt];tt&&typeof tt.x=="number"&&typeof tt.y=="number"&&(ae[dt]={x:tt.x,y:tt.y})}const we=S.current,ke=we&&typeof we.toObject=="function"?we.toObject():null,$e=ke&&ke.viewport?ke.viewport:we&&typeof we.getViewport=="function"?we.getViewport():null,We=Lx($e,{minZoom:z_,maxZoom:I_,maxAbsTranslate:Ox})??void 0;kC(Fe,{version:1,kind:Ke,seed:wt,positions:ae,viewport:We,saved_at:F}),jt(!0),Un(F),nt(!1)},[Fe,Ke,wt,rn]),ms=h.useCallback(()=>{const F=ny(Fe);if(!F)return;nt(!1),st.current=null,Ct(F.kind),at(F.seed),jt(!0),Un(F.saved_at||""),ve.current=F.viewport||null,Ie.current=!F.viewport;const ae=Yc(rt,{kind:F.kind,seed:F.seed});if(yn(Za(F.positions,ae)),F.viewport){const we=S.current;if(we&&typeof we.setViewport=="function"){try{we.setViewport(F.viewport,{duration:0})}catch{try{we.setViewport(F.viewport)}catch{}}ve.current=null}}},[Za,rt,Fe]),Xl=h.useCallback(()=>{NC(Fe),jt(!1),Un("")},[Fe]),Qs=h.useCallback(F=>{if(!Array.isArray(F)||F.length===0)return;let ae=!1;yn(we=>{let ke=we,$e=!1;for(const We of F){const dt=We&&typeof We=="object"&&"id"in We&&typeof We.id=="string"?String(We.id):"",tt=(We==null?void 0:We.type)==="position"?We==null?void 0:We.position:null;dt&&tt&&typeof tt.x=="number"&&typeof tt.y=="number"&&($e||(ke={...we},$e=!0),ke[dt]={x:tt.x,y:tt.y},We!=null&&We.dragging&&(ae=!0))}return $e?ke:we}),ae&&yt&&nt(!1)},[yt]),Zi=h.useMemo(()=>{const F=new Map;for(const ae of rt.edges)F.set(ae.id,ae);return F},[rt.edges]),la=h.useMemo(()=>{var ke;if(!Wn)return[];const F=Wn.nodeIds||[],ae=Wn.edgeIds||[],we=[];for(let $e=0;$e<Math.min(F.length-1,ae.length);$e++){const We=F[$e],dt=F[$e+1],tt=ae[$e],ct=Zi.get(tt),Ot=String(((ke=ct==null?void 0:ct.data)==null?void 0:ke.predicateSummary)||(ct==null?void 0:ct.label)||"").trim(),Gt=ct&&ct.source===We&&ct.target===dt?"forward":ct&&ct.source===dt&&ct.target===We?"reverse":"unknown";we.push({from:We,to:dt,edgeId:tt,predicate:Ot,dir:Gt})}return we},[Zi,Wn]),Si=h.useCallback(async()=>{if(v){de(""),j(""),ne(!0);try{const F=CC(Vt),ae=Xh(kt,{allowZero:!0,allowNegativeOne:!0}),we=Xh(Ve,{allowZero:!0}),ke=await v({scope:Pn,owner_id:void 0,recall_level:ge,query_text:qe||void 0,subject:it||void 0,predicate:vt||void 0,object:lt||void 0,min_score:F,limit:ae,max_input_tokens:we,model:pn||void 0});z(ke),Q("live query"),W==="replace"&&x&&ke&&Array.isArray(ke.items)&&x(ke.items,{kind:"live query",result:ke})}catch(F){const ae=F instanceof Error?F.message:String(F);de(ae||"Query failed")}finally{ne(!1)}}},[kt,Ve,Vt,pn,lt,x,v,vt,W,qe,ge,Pn,it]),hs=h.useCallback(async()=>{if(!v)return;const F=String(Qt||"").trim(),ae=String(_n||"").trim();if(!F||!ae)return;const we=Math.max(200,Xh(kt)??80),ke=60;j(""),de(""),D(!0);try{const $e=[],We=new Set,dt=Et=>{if(!Et||typeof Et!="object"||typeof Et.subject!="string"||typeof Et.predicate!="string"||typeof Et.object!="string")return;const en=`${Et.subject}|${Et.predicate}|${Et.object}|${String(Et.observed_at||"")}|${String(Et.scope||"")}|${String(Et.owner_id||"")}`;We.has(en)||(We.add(en),$e.push(Et))};for(const Et of Or)dt(Et);const tt=P,ct=new Set,Ot=[F],Gt=new Set([F]),Kt=async Et=>{const en=await v({scope:Pn,recall_level:ge,min_score:0,limit:we,subject:Et,query_text:void 0,max_input_tokens:0,model:void 0});if(en&&Array.isArray(en.items)){for(const En of en.items)if(dt(En),typeof En.subject=="string"&&En.subject.trim()===Et&&typeof En.object=="string"){const un=En.object.trim();un&&!Gt.has(un)&&(Gt.add(un),Ot.push(un))}}if(!tt){const En=await v({scope:Pn,recall_level:ge,min_score:0,limit:we,object:Et,query_text:void 0,max_input_tokens:0,model:void 0});if(En&&Array.isArray(En.items)){for(const un of En.items)if(dt(un),typeof un.object=="string"&&un.object.trim()===Et&&typeof un.subject=="string"){const Dr=un.subject.trim();Dr&&!Gt.has(Dr)&&(Gt.add(Dr),Ot.push(Dr))}}}};for(;Ot.length&&ct.size<ke&&!Gt.has(ae);){const Et=Ot.shift();!Et||ct.has(Et)||(ct.add(Et),await Kt(Et))}z({ok:!0,count:$e.length,items:$e,active_memory_text:an,raw:{expanded_for_path:!0,expanded_nodes:ct.size,discovered_nodes:Gt.size,merged:$e.length,directed:tt}}),Q("expanded neighborhood"),W==="replace"&&x&&x($e,{kind:"expanded neighborhood",result:{ok:!0,count:$e.length,items:$e,active_memory_text:an,raw:{expanded_for_path:!0,expanded_nodes:ct.size,discovered_nodes:Gt.size,merged:$e.length,directed:tt}}})}catch($e){const We=$e instanceof Error?$e.message:String($e);j(We||"Expand neighborhood failed")}finally{D(!1)}},[P,an,Or,kt,x,v,_n,Qt,W,ge,Pn]),vo=h.useCallback(()=>{z(null),Q(null),de(""),ne(!1),j(""),D(!1),ar(""),Hn(""),ls(""),cs("")},[]),ei="Search KG",pr=rt.nodes.length,fu=rt.edges.length,Ts=As.length;return s.jsxs("div",{className:"amx-root",children:[s.jsxs("div",{className:"amx-left",children:[s.jsx("div",{className:"amx-graphbar",role:"toolbar","aria-label":"Graph layout controls",children:s.jsxs("div",{className:"amx-graphbar-row",children:[s.jsx("span",{className:"amx-graphbar-title",children:"layout"}),s.jsxs("select",{value:Ke,onChange:F=>Ct(D_(F.target.value,Ke)),disabled:!rn.length,children:[s.jsx("option",{value:"grid",children:"grid (deterministic)"}),s.jsx("option",{value:"radial",children:"radial (bfs)"}),s.jsx("option",{value:"circle",children:"circle"}),s.jsx("option",{value:"force",children:"force (simulation)"})]}),Ke==="force"?s.jsxs("label",{className:"amx-graphbar-spread",children:[s.jsx("span",{className:"amx-graphbar-title",children:"spread"}),s.jsx("input",{type:"range",min:"0.7",max:"2.2",step:"0.1",value:Ne,onChange:F=>Oe(Px(Number(F.target.value),.7,2.2,1))}),s.jsxs("span",{className:"amx-small",children:[Ne.toFixed(1),"×"]})]}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>bi({kind:Ke,seed:wt}),disabled:!rn.length,children:"Apply"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:ds,disabled:!rn.length||Ke!=="force",children:yt?"Pause simulation":"Play simulation"})]})}),s.jsxs("div",{className:"amx-graph","aria-label":"Knowledge graph",ref:Ft,children:[s.jsx(fp,{children:s.jsxs(Ex,{nodes:go,edges:oa,defaultViewport:{x:0,y:0,zoom:1},minZoom:z_,maxZoom:I_,onInit:F=>{S.current=F;const ae=ve.current;if(ae&&typeof F.setViewport=="function")try{F.setViewport(ae,{duration:0})}catch{try{F.setViewport(ae)}catch{}}if(Ie.current&&typeof F.fitView=="function")try{F.fitView({padding:.2,duration:0})}catch{try{F.fitView({padding:.2})}catch{}}ve.current=null,Ie.current=!1,fs("init")},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,onNodesChange:Qs,onNodeClick:(F,ae)=>{cs(""),ls(ae.id)},onEdgeClick:(F,ae)=>{ls(""),cs(ae.id)},onPaneClick:()=>{ls(""),cs("")},children:[s.jsx(oC,{className:"amx-flow-controls",children:s.jsx(Zc,{type:"button",className:`amx-control-legend ${je?"amx-control-legend-active":""}`,onClick:()=>Ee(F=>!F),title:je?"Hide node color legend":"Show node color legend","aria-label":je?"Hide node color legend":"Show node color legend",children:s.jsx(SC,{})})}),s.jsx(Bd,{position:"bottom-right",className:"amx-panel-bottom-right",children:s.jsx("div",{className:"amx-panel-toggles",children:s.jsx("button",{type:"button",className:"amx-minimap-toggle",onClick:()=>be(F=>!F),title:he?"Hide minimap preview":"Show minimap preview","aria-label":he?"Hide minimap preview":"Show minimap preview",children:he?"minimap on":"minimap off"})})}),he?s.jsx(Q2,{position:"bottom-right",pannable:!0,zoomable:!0,maskColor:"rgba(0,0,0,0.45)",style:{background:"rgba(12, 18, 34, 0.88)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:10,width:le?120:160,height:le?80:110,marginBottom:56},nodeColor:F=>{var ae;return Nd((ae=F.data)==null?void 0:ae.kind).minimap}}):null,je?s.jsxs(Bd,{position:"bottom-left",className:"amx-legend-panel",children:[s.jsx("div",{className:"amx-legend-title",children:"node colors"}),s.jsx("div",{className:"amx-legend",children:[{k:"person",label:"person"},{k:"org",label:"org"},{k:"concept",label:"concept"},{k:"claim",label:"claim"},{k:"event",label:"event"},{k:"doc",label:"doc"},{k:"vocab",label:"vocab"}].map(({k:F,label:ae})=>s.jsx("span",{className:"amx-legend-item",style:{borderColor:Nd(F).stroke},children:ae},F))})]}):null,s.jsx(fC,{gap:20,size:1,color:"rgba(255,255,255,0.06)"})]})},Ge),s.jsxs("details",{className:"amx-panel amx-controls",children:[s.jsxs("summary",{children:[s.jsx("span",{className:"amx-controls-title",children:ei}),s.jsxs("span",{className:"amx-small",children:[Ts," assertions · ",pr," nodes · ",fu," edges"]})]}),s.jsxs("div",{className:"amx-toolbar",style:{marginTop:10},children:[s.jsxs("div",{className:"amx-toolbar-grid",children:[s.jsxs("label",{children:["search / highlight",s.jsx("input",{value:R,onChange:F=>O(F.target.value),placeholder:"filter nodes by id/label"})]}),s.jsxs("label",{children:["group edges",s.jsxs("select",{value:String(ee),onChange:F=>I(F.target.value==="true"),children:[s.jsx("option",{value:"true",children:"group (subject→object)"}),s.jsx("option",{value:"false",children:"no grouping"})]})]}),s.jsxs("label",{children:["view",s.jsxs("select",{value:String($),onChange:F=>K(F.target.value==="true"),children:[s.jsx("option",{value:"true",children:"all assertions"}),s.jsx("option",{value:"false",children:"hide rdf:type / labels"})]})]}),s.jsxs("label",{children:["path mode",s.jsxs("select",{value:String(P),onChange:F=>G(F.target.value==="true"),children:[s.jsx("option",{value:"false",children:"undirected"}),s.jsx("option",{value:"true",children:"directed"})]})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"layout"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["layout",s.jsxs("select",{value:Ke,onChange:F=>Ct(D_(F.target.value,Ke)),children:[s.jsx("option",{value:"grid",children:"grid (deterministic)"}),s.jsx("option",{value:"radial",children:"radial (bfs)"}),s.jsx("option",{value:"circle",children:"circle"}),s.jsx("option",{value:"force",children:"force (simulation)"})]})]}),s.jsxs("label",{children:["seed",s.jsx("input",{type:"number",step:"1",value:wt,onChange:F=>at(Math.trunc(Number(F.target.value||0)||0))})]})]}),s.jsxs("div",{className:"amx-actions",style:{marginTop:10},children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>bi({kind:Ke,seed:wt}),disabled:!rn.length,children:"Apply layout"}),Ke==="force"?s.jsx("button",{type:"button",className:"amx-btn",onClick:ds,disabled:!rn.length,children:yt?"Pause simulation":"Play simulation"}):null,s.jsx("button",{type:"button",className:"amx-btn",onClick:el,disabled:!rn.length,children:"Save layout"}),Vn?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:ms,children:"Load saved"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Xl,children:"Clear saved"})]}):null]}),s.jsxs("div",{className:"amx-small",style:{marginTop:10,opacity:.9},children:["Drag nodes to adjust manually; use ",s.jsx("span",{className:"amx-mono",children:"Save layout"})," for a stable, replayable view.",Vn?s.jsxs("span",{children:[" ","(saved",hn?`: ${hn}`:"",")"]}):s.jsx("span",{children:" (no saved layout)"})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"path"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["path start",s.jsxs("select",{value:Qt,onChange:F=>ar(F.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),rn.map(F=>s.jsx("option",{value:F,children:(()=>{const ae=xi.get(F)||F;return ae===F?ae:`${ae} (${F})`})()},F))]})]}),s.jsxs("label",{children:["path end",s.jsxs("select",{value:_n,onChange:F=>Hn(F.target.value),children:[s.jsx("option",{value:"",children:"(none)"}),rn.map(F=>s.jsx("option",{value:F,children:(()=>{const ae=xi.get(F)||F;return ae===F?ae:`${ae} (${F})`})()},F))]})]})]}),Wn?s.jsx("div",{className:"amx-small",style:{marginTop:10},children:la.map((F,ae)=>{const we=xi.get(F.from)||F.from,ke=xi.get(F.to)||F.to,$e=F.dir==="reverse"?" ← ":" → ",We=F.predicate?` (${F.predicate})`:"";return s.jsxs("div",{children:[ae===0?s.jsx("span",{children:we}):null,$e,s.jsxs("span",{children:[ke,We]})]},`${F.edgeId}:${ae}`)})}):Qt&&_n?s.jsxs("div",{className:"amx-small",style:{marginTop:10,opacity:.9},children:["No path found in the current subgraph (",(Gn==null?void 0:Gn.assertions)??Ts," assertions · ",(Gn==null?void 0:Gn.nodes)??rt.nodes.length," nodes ·"," ",(Gn==null?void 0:Gn.edges)??rt.edges.length," edges). Start reaches ",(Gn==null?void 0:Gn.reachableFromStart)??0," nodes.",v?s.jsx("div",{style:{marginTop:10},children:s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void hs(),disabled:pe,children:pe?"Expanding…":"Expand neighborhood"})}):null]}):s.jsx("div",{className:"amx-small",style:{marginTop:10},children:"(no path)"})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"query"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["query_text (semantic)",s.jsx("input",{value:qe,onChange:F=>He(F.target.value),placeholder:"e.g. emotion chip"})]}),s.jsxs("label",{children:["subject (exact)",s.jsx("input",{value:it,onChange:F=>pt(F.target.value),placeholder:"e.g. ex:person-data"})]}),s.jsxs("label",{children:["predicate (exact)",s.jsx("input",{value:vt,onChange:F=>Rt(F.target.value),placeholder:"e.g. schema:about"})]}),s.jsxs("label",{children:["object (exact)",s.jsx("input",{value:lt,onChange:F=>Pt(F.target.value),placeholder:"e.g. ex:concept-emotion-chip"})]}),s.jsxs("label",{children:["min_score",s.jsx("input",{type:"number",step:"any",value:Vt,onChange:F=>ce(F.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["limit",s.jsx("input",{type:"number",min:"-1",step:"1",value:kt,onChange:F=>Lt(F.target.value),placeholder:"0/-1 = unlimited (if supported)"})]})]})]}),s.jsxs("details",{className:"amx-details",children:[s.jsx("summary",{children:"advanced"}),s.jsxs("div",{className:"amx-toolbar-grid",style:{marginTop:10},children:[s.jsxs("label",{children:["scope",s.jsxs("select",{value:Pn,onChange:F=>te(ty(F.target.value,Pn)),children:[s.jsx("option",{value:"run",children:"run"}),s.jsx("option",{value:"session",children:"session"}),s.jsx("option",{value:"global",children:"global"}),s.jsx("option",{value:"all",children:"all"})]})]}),s.jsxs("label",{children:["recall level",s.jsxs("select",{value:ge,onChange:F=>Te(F.target.value||"standard"),children:[s.jsx("option",{value:"urgent",children:"urgent"}),s.jsx("option",{value:"standard",children:"standard"}),s.jsx("option",{value:"deep",children:"deep"})]})]}),s.jsxs("label",{children:["max_input_tokens",s.jsx("input",{type:"number",min:"0",step:"1",value:Ve,onChange:F=>nn(F.target.value),placeholder:"(auto)"})]}),s.jsxs("label",{children:["model (budgeting)",s.jsx("input",{value:pn,onChange:F=>cn(F.target.value),placeholder:"qwen/qwen3-next-80b"})]})]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void Si(),disabled:!v||Z,children:Z?"Querying…":"Query store"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:vo,disabled:!q&&!ue&&!Z,children:"Reset to step output"}),q?s.jsxs("span",{className:"amx-small",children:["showing: ",Y||"live query"]}):s.jsx("span",{className:"amx-small",children:"showing: step output"}),ue?s.jsx("span",{className:"amx-small",style:{color:"var(--error, rgba(255, 80, 80, 0.95))"},children:ue}):null,E?s.jsx("span",{className:"amx-small",style:{color:"var(--error, rgba(255, 80, 80, 0.95))"},children:E}):null]})]})]})]})]}),s.jsxs("div",{className:"amx-right",children:[s.jsxs("div",{className:"amx-panel",children:[s.jsx("h3",{children:"Details"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Derived from `memory_kg_query` packetization (max_input_tokens); safe to inject into an LLM system prompt."}),(()=>{const F=EC(ra);return F?s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:F}):null})(),(()=>{const F=Yr;if(!F)return null;const ae=typeof F=="string"?F:Array.isArray(F)?F.map(we=>String(we)).join(" · "):JSON.stringify(F);return!ae||!ae.trim()?null:s.jsx("div",{className:"amx-small",style:{marginBottom:8,color:"var(--warning, rgba(255, 180, 90, 0.95))"},children:ae})})(),s.jsx("div",{className:"amx-small",style:{marginBottom:8,opacity:.9},children:(()=>{const F=(q==null?void 0:q.packets_version)??Nr,ae=(q==null?void 0:q.packed_count)??Gr,we=(q==null?void 0:q.dropped)??Gs,ke=(q==null?void 0:q.estimated_tokens)??$s,$e=[];return typeof F=="number"&&$e.push(`packets_v${F}`),typeof ae=="number"&&$e.push(`packed=${ae}`),typeof we=="number"&&$e.push(`dropped=${we}`),typeof ke=="number"&&$e.push(`est_tokens=${ke}`),$e.length?$e.join(" · "):"No packetization stats (set max_input_tokens > 0)."})()}),s.jsx("div",{className:"amx-active-memory",children:MC(an||"(empty)",R)}),(()=>{const F=q!=null&&q.packets&&Array.isArray(q.packets)?q.packets:Vr;return!Array.isArray(F)||F.length===0?null:s.jsxs("div",{style:{marginTop:10},children:[s.jsxs("button",{type:"button",className:"amx-btn",onClick:()=>Yt(ae=>!ae),children:[Js?"Hide":"Show"," packets (",F.length,")"]}),Js?s.jsx("div",{className:"amx-list",style:{marginTop:10},children:F.slice(0,120).map((ae,we)=>{const ke=ae&&typeof ae=="object"&&!Array.isArray(ae)?ae:null,$e=ke&&typeof ke.statement=="string"?ke.statement:typeof ae=="string"?ae:"",We=ke&&(typeof ke.retrieval_score=="number"||typeof ke.retrieval_score=="string")?ke.retrieval_score:null,dt=ke&&typeof ke.observed_at=="string"?ke.observed_at:null;return s.jsxs("div",{className:"amx-item",children:[s.jsx("div",{className:"amx-mono",children:$e||"(packet)"}),dt||We!==null?s.jsxs("div",{className:"amx-small",children:[dt?`[${dt}]`:null,dt&&We!==null?" ":null,We!==null?`score:${We}`:null]}):null]},we)})}):null]})})(),s.jsx("div",{style:{marginTop:14,marginBottom:12,borderTop:"1px solid var(--ui-border-1, rgba(255,255,255,0.08))"}}),s.jsx("div",{className:"amx-small",style:{marginBottom:8,fontWeight:700,opacity:.9},children:"Inspect"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Click a node or edge to inspect its assertions."}),In?s.jsxs("div",{className:"amx-item",style:{marginBottom:10,display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsx("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:xi.get(In)||In}),s.jsxs("div",{className:"amx-small",children:["kind=",_r.get(In)||"entity"," · id=",In]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void nr(In),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Er,children:"Focus"})]})]}):zr&&zr.source&&zr.target?s.jsxs("div",{className:"amx-item",style:{marginBottom:10,display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:[zr.source," —",String(zr.label||((xo=zr.data)==null?void 0:xo.predicateSummary)||"").trim()||"?","→ ",zr.target]}),s.jsxs("div",{className:"amx-small",children:["edge_id=",zr.id]})]}),s.jsxs("div",{className:"amx-actions",children:[s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>void nr(zr.id),children:"Copy id"}),s.jsx("button",{type:"button",className:"amx-btn",onClick:Er,children:"Fit"})]})]}):s.jsx("div",{className:"amx-small",style:{marginBottom:10,opacity:.9},children:"(no selection)"}),s.jsx("div",{className:"amx-list",children:Zs.slice(0,80).map((F,ae)=>{const we=String(F.subject||"").trim(),ke=String(F.predicate||"").trim(),$e=String(F.object||"").trim(),We=xi.get(we)||we,dt=xi.get($e)||$e,tt=_r.get(we)||"entity",ct=_r.get($e)||"entity",Ot=Nd(tt),Gt=Nd(ct),Kt=Cd(F.observed_at),Et=$C(F),en=F.provenance&&typeof F.provenance=="object"&&!Array.isArray(F.provenance)?F.provenance:null,En=en&&typeof en.span_id=="string"?en.span_id.trim():"",un=en&&typeof en.writer_run_id=="string"?en.writer_run_id.trim():"",Dr=typeof F.owner_id=="string"?F.owner_id.trim():"",Kn=un||Dr,ji=!!((C||b)&&En&&Kn),ki=!!(C&&un&&!En),wo=ji||ki;return s.jsxs("div",{className:"amx-item amx-triple-card",children:[s.jsxs("div",{className:"amx-triple-row",children:[s.jsx("button",{type:"button",className:"amx-term",style:{borderColor:Ot.stroke,background:Ot.bg},title:we,onClick:()=>{we&&(cs(""),ls(we))},children:We||we||"(subject)"}),s.jsx("span",{className:"amx-arrow",children:"—"}),s.jsx("span",{className:"amx-predicate",title:ke,children:zx(ke)||"(predicate)"}),s.jsx("span",{className:"amx-arrow",children:"→"}),s.jsx("button",{type:"button",className:"amx-term",style:{borderColor:Gt.stroke,background:Gt.bg},title:$e,onClick:()=>{$e&&(cs(""),ls($e))},children:dt||$e||"(object)"})]}),s.jsxs("div",{className:"amx-triple-meta",children:[Kt?s.jsxs("span",{className:"amx-small",title:String(F.observed_at||""),children:["[",Kt,"]"]}):null,Et?s.jsx("span",{className:"amx-small",children:Et}):null]}),En||un?s.jsxs("div",{className:"amx-triple-actions",children:[En?s.jsxs("span",{className:"amx-small",children:["span:",En]}):null,un?s.jsxs("span",{className:"amx-small",children:["run:",un]}):null,wo?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>{if(ji&&En&&Kn){tr({run_id:Kn,span_id:En,assertion:F});return}ki&&un&&tr({run_id:un,assertion:F})},children:"Open transcript"}):null]}):null]},ae)})})]}),s.jsxs("div",{className:"amx-panel",children:[s.jsx("h3",{children:"Transcript"}),s.jsx("div",{className:"amx-small",style:{marginBottom:8},children:"Pivot from a triple to its provenance transcript (span/note artifact, or run input fallback)."}),yo.length?s.jsxs("div",{style:{marginBottom:12},children:[s.jsx("div",{className:"amx-small",style:{marginBottom:6,opacity:.85},children:"spans"}),s.jsx("div",{className:"amx-list",style:{maxHeight:320},children:yo.slice(0,60).map(F=>s.jsxs("div",{className:"amx-item",style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:["span:",F.span_id]}),s.jsxs("div",{className:"amx-small",children:["run_id=",F.span_run_id," · assertions=",F.count,F.last_observed_at_fmt?` · last=[${F.last_observed_at_fmt}]`:""]})]}),b||C?s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>tr({run_id:F.span_run_id,span_id:F.span_id,assertion:F.assertion}),children:"Open transcript"}):null]},`${F.span_run_id}|${F.span_id}`))})]}):null,C&&wi.length?s.jsxs("div",{style:{marginBottom:12},children:[s.jsx("div",{className:"amx-small",style:{marginBottom:6,opacity:.85},children:"runs (fallback)"}),s.jsx("div",{className:"amx-list",style:{maxHeight:240},children:wi.slice(0,40).map(F=>s.jsxs("div",{className:"amx-item",style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"center"},children:[s.jsxs("div",{style:{minWidth:0},children:[s.jsxs("div",{className:"amx-mono",style:{fontSize:11,opacity:.95},children:["run:",F.run_id]}),s.jsxs("div",{className:"amx-small",children:["assertions=",F.count,F.last_observed_at_fmt?` · last=[${F.last_observed_at_fmt}]`:""]})]}),s.jsx("button",{type:"button",className:"amx-btn",onClick:()=>tr({run_id:F.run_id,assertion:F.assertion}),children:"Open transcript"})]},F.run_id))})]}):null,!yo.length&&!(C&&wi.length)?s.jsx("div",{className:"amx-small",children:"(no provenance)"}):null]})]})]})}function qa({open:e,title:t,children:n,actions:o,variant:a="default",onClose:c}){if(h.useEffect(()=>{if(!e)return;const u=m=>{m.key==="Escape"&&c()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,c]),!e)return null;const d=a==="fullscreen";return s.jsx("div",{className:`modal_backdrop${d?" fullscreen":""}`,onMouseDown:u=>{u.target===u.currentTarget&&c()},children:s.jsxs("div",{className:`modal_panel${d?" fullscreen":""}`,children:[s.jsxs("div",{className:"modal_header",children:[s.jsx("div",{className:"modal_title",children:t}),s.jsx("button",{className:"btn",onClick:c,children:"Close"})]}),s.jsx("div",{className:"modal_body",children:n}),o?s.jsx("div",{className:"modal_footer",children:o}):null]})})}function Zh(e,t="session"){const n=String(e||"").trim().toLowerCase();return n==="run"||n==="session"||n==="global"||n==="all"?n:t}function Ba(e){const t=typeof e=="string"?e.trim():"";if(!t)return null;const n=t.replace(/(\.\d{3})\d+/,"$1"),o=Date.parse(n);return Number.isFinite(o)?o:null}function Il(e){if(typeof e!="number"||!Number.isFinite(e))return"—";const t=new Date(e),n=t.getUTCFullYear(),o=String(t.getUTCMonth()+1).padStart(2,"0"),a=String(t.getUTCDate()).padStart(2,"0"),c=String(t.getUTCHours()).padStart(2,"0"),d=String(t.getUTCMinutes()).padStart(2,"0");return`${n}/${o}/${a} ${c}:${d}`}function RC(e){const t=String(e??"").trim();if(!t)return"";if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}$/.test(t))return t;const n=Ba(t);return n!==null?Il(n):t}function hp(e){const t=typeof e=="string"?e:String(e??"");return t?!t.includes("\\n")&&!t.includes("\\r")&&!t.includes("\\t")?t:t.replace(/\\r\\n/g,`
123
+ `).replace(/\\n/g,`
124
+ `).replace(/\\t/g," "):""}function Ix(e){return String(e??"").replace(/[*_`~]/g,"")}function am(e,t){const n=!!(t!=null&&t.strip_punct),o=hp(e);let a=Ix(o).replace(/\s+/g," ").trim().toLowerCase();return n&&(a=a.replace(/[^\p{L}\p{N}\s]+/gu,"").replace(/\s+/g," ").trim()),a}function lm(e,t){const n=String(t??"").trim();if(!n)return!1;const o=am(n,{strip_punct:!1});if(!o)return!1;if(am(String(e??""),{strip_punct:!1}).includes(o))return!0;const c=am(n,{strip_punct:!0});return c?am(String(e??""),{strip_punct:!0}).includes(c):!1}function ry(e){const t=hp(e).trim();if(!t)return[];const n=[],o=d=>{const u=String(d??"").replace(/\s+/g," ").trim();u&&(u.length<6||n.includes(u)||n.push(u))},a=t.search(/[`*_~]/);if(a>0){const d=t.slice(0,a);d.replace(/\s+/g," ").trim().length>=10&&o(d)}const c=[/`([^`]+)`/g,/\*\*([^*]+)\*\*/g,/__([^_]+)__/g,/\*([^*]+)\*/g,/_([^_]+)_/g];for(const d of c){let u;for(;(u=d.exec(t))!==null;){const m=String(u[1]??"").trim();m&&o(m)}}return o(Ix(t)),n}function PC(e){const t=String(e??"").replace(/\r\n/g,`
125
+ `).replace(/\r/g,`
126
+ `);if(!t)return null;const n=t.split(`
127
+ `);let o;const a=[],c=[];let d=null,u=[],m=!1;const y=()=>{if(!d)return;const x=u.join(`
128
+ `).trim();x&&c.push({role:d,lines:[x]}),d=null,u=[]};for(const x of n){const b=o?null:x.match(/^\s*created_at\s*=\s*(.+)\s*$/i);if(b&&b[1]){o=b[1].trim();continue}const C=x.match(/^\s*(USER|ASSISTANT|SYSTEM)\s*:\s*(.*)$/i);if(C){m=!0,y();const S=String(C[1]||"").trim().toLowerCase();d=S==="user"?"user":S==="assistant"?"assistant":"system";const L=String(C[2]??"");u=L?[L]:[];continue}d?u.push(x):a.push(x)}if(y(),!m||!c.length)return null;const g=a.join(`
129
+ `).trim(),v={messages:[]};o&&(v.created_at=o),g&&v.messages.push({role:"system",content:g});for(const x of c)v.messages.push({role:x.role,content:x.lines.join(`
130
+ `)});return v.messages.length?v:null}function sy(e,t){const n=String(e||""),o=String(t||"");return o>n?o:n}function iy(e){const t=String((e==null?void 0:e.subject)||"").trim(),n=String((e==null?void 0:e.predicate)||"").trim(),o=String((e==null?void 0:e.object)||"").trim(),a=String((e==null?void 0:e.observed_at)||"").trim(),c=String((e==null?void 0:e.scope)||"").trim(),d=String((e==null?void 0:e.owner_id)||"").trim();return`${t}|${n}|${o}|${a}|${c}|${d}`}function OC(e){const t=String((e==null?void 0:e.observed_at)||"").trim(),n=String((e==null?void 0:e.subject)||"").trim(),o=String((e==null?void 0:e.predicate)||"").trim(),a=String((e==null?void 0:e.object)||"").trim(),c=String((e==null?void 0:e.scope)||"").trim(),d=String((e==null?void 0:e.owner_id)||"").trim(),u=[];c&&u.push(`scope=${c}`),d&&u.push(`owner=${d}`);const m=u.length?` (${u.join(", ")})`:"";return`${t?`[${t}] `:""}${n} --${o}--> ${a}${m}`}function zC({gateway:e,selected_run_id:t,selected_session_id:n}){const[o,a]=h.useState(String(t||"").trim()),[c,d]=h.useState(String(n||"").trim()),[u,m]=h.useState("all"),y=u==="all",[g,v]=h.useState(!0),[x,b]=h.useState(750),[C,S]=h.useState(5e3),[L,M]=h.useState([]),[W,q]=h.useState(void 0),[z,Y]=h.useState(""),[Q,Z]=h.useState(!1),[ne,ue]=h.useState([]),[de,pe]=h.useState(!1),[D,E]=h.useState(!1),[j,R]=h.useState(""),[O,ee]=h.useState(""),[I,P]=h.useState(""),[G,$]=h.useState(""),[K,se]=h.useState("artifact"),[le,he]=h.useState(null),[be,je]=h.useState(""),[Ee,Fe]=h.useState(null),Ye=h.useRef(!1),Ke=h.useMemo(()=>{const te=Ee,ge=te!=null&&te.attributes&&typeof te.attributes=="object"&&!Array.isArray(te.attributes)?te.attributes:null;return(ge&&typeof ge.evidence_quote=="string"?String(ge.evidence_quote):"").trim()},[Ee]),Ct=h.useMemo(()=>{const te=le,ge=te&&typeof te=="object"&&!Array.isArray(te)?te:null,Te=ge&&typeof ge.note=="string"?String(ge.note):"";return hp(Te).trim()},[le]),wt=h.useMemo(()=>{const te=le&&typeof le=="object"&&!Array.isArray(le)?le:null,ge=te&&Array.isArray(te.messages)?te.messages:null;return Array.isArray(ge)?ge:null},[le]),at=h.useMemo(()=>{const te=Ct,ge=Ke;return!te||!ge?!1:lm(te,ge)},[Ke,Ct]),yt=h.useMemo(()=>{const te=wt,ge=Ke;if(!te||!ge)return[];const Te=[];for(let qe=0;qe<Math.min(te.length,500);qe++){const He=te[qe],it=(He==null?void 0:He.content)==null?"":String(He.content);lm(it,ge)&&Te.push(qe)}return Te},[Ke,wt]),nt=h.useMemo(()=>new Set(yt),[yt]),Ne=yt.length?yt[0]:null,Oe=h.useCallback(te=>{const ge=document.getElementById(`source_msg_${te}`);ge&&typeof ge.scrollIntoView=="function"&&ge.scrollIntoView({block:"center",behavior:"smooth"})},[]),st=h.useCallback(()=>{const te=document.getElementById("source_note_hit_0")||document.getElementById("source_note_msg_hit_0");te&&typeof te.scrollIntoView=="function"&&te.scrollIntoView({block:"center",behavior:"smooth"})},[]);h.useEffect(()=>{if(de&&!(D||j)&&!Ye.current){if(Ne!==null){Ye.current=!0,window.setTimeout(()=>Oe(Ne),0);return}if(at){Ye.current=!0,window.setTimeout(()=>st(),0);return}}},[Oe,st,j,Ne,D,at,de]);const ve=h.useRef(new Set),Ie=h.useRef(""),Ge=h.useRef(null),At=h.useRef(null);h.useEffect(()=>{a(String(t||"").trim())},[t]),h.useEffect(()=>{d(String(n||"").trim())},[n]);const Ft=h.useMemo(()=>{const te=String(o||"").trim(),ge=String(c||"").trim();return`mindmap:${u}:${te}:${ge}`},[o,c,u]),fn=h.useMemo(()=>{let te=null,ge=null;for(const Te of L){const qe=Ba(Te==null?void 0:Te.observed_at);qe!==null&&(te=te===null?qe:Math.min(te,qe),ge=ge===null?qe:Math.max(ge,qe))}return{min_ms:te,max_ms:ge}},[L]),Dt=1e3,Tt=h.useMemo(()=>{const te=fn.min_ms,ge=fn.max_ms;if(typeof te!="number"||typeof ge!="number"||!Number.isFinite(te)||!Number.isFinite(ge))return null;if(ge<=te)return{min_ms:te,max_ms:te,real_max_ms:ge};const Te=te+Math.ceil((ge-te)/Dt)*Dt;return{min_ms:te,max_ms:Te,real_max_ms:ge}},[fn.max_ms,fn.min_ms]),[mn,Vn]=h.useState(!0),[jt,hn]=h.useState(null);h.useEffect(()=>{mn&&Tt&&hn(Tt.max_ms)},[mn,Tt]);const Un=h.useMemo(()=>{const te=typeof jt=="number"?jt:null;return te===null?L:L.filter(ge=>{const Te=Ba(ge==null?void 0:ge.observed_at);return Te===null?!0:Te<=te})},[L,jt]),Nn=h.useCallback((te,ge)=>{const Te=Array.isArray(te)?te:[],qe=String(Ie.current||"").trim(),He=new Set,it=[];let pt="";for(const vt of Te){if(!vt||typeof vt!="object"||typeof vt.subject!="string"||typeof vt.predicate!="string"||typeof vt.object!="string")continue;const Rt=iy(vt);if(He.has(Rt))continue;He.add(Rt),it.push(vt);const lt=String(vt.observed_at||"").trim();lt&&(pt=sy(pt,lt))}M(it),q(ge==null?void 0:ge.warnings),ve.current=He,Ie.current=pt||qe},[]),yn=h.useCallback(async te=>{const ge=Zh(te.scope,"session"),Te=String(te.subject||"").trim(),qe=String(te.predicate||"").trim(),He=String(te.object||"").trim(),it=String(te.since||"").trim(),pt=String(te.until||"").trim(),vt=String(te.active_at||"").trim(),Rt=String(te.query_text||"").trim(),lt=typeof te.min_score=="number"&&Number.isFinite(te.min_score)?Number(te.min_score):void 0,Pt=te.order==="asc"?"asc":"desc",Vt=typeof te.limit=="number"&&Number.isFinite(te.limit)?Number(te.limit):0,ce=String(o||"").trim(),kt=String(c||"").trim(),Lt={scope:ge,all_owners:y,limit:Vt,order:Pt};Te&&(Lt.subject=Te),qe&&(Lt.predicate=qe),He&&(Lt.object=He),it&&(Lt.since=it),pt&&(Lt.until=pt),vt&&(Lt.active_at=vt),Rt&&(Lt.query_text=Rt),typeof lt=="number"&&(Lt.min_score=lt),y||(ge==="run"?ce&&(Lt.run_id=ce):ge==="session"?kt?Lt.session_id=kt:ce&&(Lt.run_id=ce):ge==="all"&&(ce?Lt.run_id=ce:kt&&(Lt.session_id=kt)));try{const Ve=await e.kg_query(Lt),nn=Array.isArray(Ve==null?void 0:Ve.items)?Ve.items:[],pn=Ve==null?void 0:Ve.warnings;return{ok:(Ve==null?void 0:Ve.ok)!==!1,count:Number((Ve==null?void 0:Ve.count)||nn.length),items:nn,warnings:pn,raw:Ve}}catch(Ve){const nn=Ve instanceof Error?Ve.message:String(Ve);if(nn.includes("Run '")&&nn.includes("not found")&&!kt&&(ge==="session"||ge==="all")&&ce){const cn=await e.kg_query({...Lt,run_id:void 0,session_id:ce}),gn=Array.isArray(cn==null?void 0:cn.items)?cn.items:[],er=cn==null?void 0:cn.warnings;return{ok:(cn==null?void 0:cn.ok)!==!1,count:Number((cn==null?void 0:cn.count)||gn.length),items:gn,warnings:er,raw:cn}}throw new Error(nn||"KG query failed")}},[y,e,o,c]),Cn=h.useCallback(async te=>{var qe;const ge=String(te.run_id||"").trim(),Te=String(te.span_id||"").trim();if(!(!ge||!Te)){pe(!0),E(!0),R(""),P(ge),$(Te),se("artifact"),ee(`source span:${Te}`),he(null),je(""),Fe(te.assertion&&typeof te.assertion=="object"?te.assertion:null),Ye.current=!1;try{const He=[ge],it=typeof((qe=te.assertion)==null?void 0:qe.owner_id)=="string"?String(te.assertion.owner_id).trim():"";it&&it!==ge&&He.push(it);let pt=null,vt=null;for(const Rt of He)try{vt=await(await e.download_run_artifact_content(Rt,Te)).text(),Rt!==ge&&P(Rt);break}catch(lt){pt=lt instanceof Error?lt.message:String(lt)}if(vt==null)throw new Error(pt||"Failed to load source span");je(vt);try{const Rt=JSON.parse(vt);he(Rt)}catch{he(null)}}catch(He){const it=He instanceof Error?He.message:String(He);R(it||"Failed to load source span")}finally{E(!1)}}},[e]),Qt=h.useCallback(async te=>{const ge=String(te.run_id||"").trim();if(!ge)return null;try{const Te=await e.list_run_artifacts(ge,{limit:200}),He=(Array.isArray(Te==null?void 0:Te.items)?Te.items:[]).map(lt=>{const Pt=typeof(lt==null?void 0:lt.artifact_id)=="string"?String(lt.artifact_id).trim():"",Vt=lt!=null&&lt.tags&&typeof lt.tags=="object"&&!Array.isArray(lt.tags)?lt.tags:null,ce=Vt&&typeof Vt.kind=="string"?String(Vt.kind).trim():"";return{artifact_id:Pt,kind:ce}}).filter(lt=>!!(lt.artifact_id&&(lt.kind==="conversation_span"||lt.kind==="memory_note")));if(!He.length)return null;if(He.length===1)return He[0].artifact_id;const it=te.assertion,pt=it!=null&&it.attributes&&typeof it.attributes=="object"&&!Array.isArray(it.attributes)?it.attributes:null,Rt=(pt&&typeof pt.evidence_quote=="string"?String(pt.evidence_quote):"").trim();if(!Rt)return null;for(const lt of He.slice(0,10))try{const Vt=await(await e.download_run_artifact_content(ge,lt.artifact_id)).text(),ce=JSON.parse(Vt);if(ce&&typeof ce=="object"){const kt=typeof ce.note=="string"?String(ce.note):"";if(kt&&kt.includes(Rt))return lt.artifact_id;const Lt=Array.isArray(ce.messages)?ce.messages:null;if(Lt){for(const Ve of Lt.slice(0,200))if(((Ve==null?void 0:Ve.content)==null?"":String(Ve.content)).includes(Rt))return lt.artifact_id}}}catch{}}catch{}return null},[e]),ar=h.useCallback(async te=>{const ge=String(te.run_id||"").trim();if(ge){pe(!0),E(!0),R(""),P(ge),$(""),se("run_input"),ee(`transcript run:${ge}`),he(null),je(""),Fe(te.assertion&&typeof te.assertion=="object"?te.assertion:null),Ye.current=!1;try{const Te=await Qt({run_id:ge,assertion:te.assertion});if(Te){await Cn({run_id:ge,span_id:Te,assertion:te.assertion});return}const qe=await e.get_run_input_data(ge),He=qe&&typeof qe=="object"&&!Array.isArray(qe)?qe.input_data:null,it={kind:"run_input_data",run_id:ge};if(qe&&typeof(qe==null?void 0:qe.workflow_id)=="string"&&(it.workflow_id=String(qe.workflow_id)),He&&typeof He=="object"&&!Array.isArray(He)){const pt=He.context,Rt=(pt&&typeof pt=="object"&&Array.isArray(pt.messages)?pt.messages:null)||(Array.isArray(He.messages)?He.messages:null);Array.isArray(Rt)&&(it.messages=Rt);const lt=["text","prompt","task","message"];for(const Pt of lt){const Vt=He[Pt];if(typeof Vt=="string"&&Vt.trim()){it.note=Vt.trim();break}}it.input_data=He}!it.messages&&!it.note&&(it.note=JSON.stringify(He??qe??{},null,2));try{const pt=await e.get_run(ge),vt=pt&&typeof(pt==null?void 0:pt.created_at)=="string"?String(pt.created_at):"";vt&&(it.created_at=vt)}catch{}he(it),je(JSON.stringify(qe,null,2))}catch(Te){const qe=Te instanceof Error?Te.message:String(Te);R(qe||"Failed to load run input transcript")}finally{E(!1)}}},[e,Cn,Qt]),_n=h.useCallback(async()=>{Y(""),Z(!0);try{const te=u==="all"?"all":u,ge=await yn({scope:te,limit:0,order:"desc"});Nn(ge.items||[],{warnings:ge.warnings}),Ge.current={scope:te}}catch(te){const ge=te instanceof Error?te.message:String(te);Y(ge||"Load failed")}finally{Z(!1)}},[yn,Nn,u]);h.useEffect(()=>{L.length||_n()},[]);const Hn=h.useCallback(async te=>{const ge=Zh(te.scope,"session");return At.current=te,await yn({scope:ge,subject:te.subject,predicate:te.predicate,object:te.object,query_text:te.query_text,min_score:te.min_score,since:te.since,until:te.until,active_at:te.active_at,limit:typeof te.limit=="number"?te.limit:0,order:"desc"})},[yn]),vn=h.useCallback((te,ge)=>{var Te;if((ge==null?void 0:ge.kind)==="live query"){const qe=At.current;qe&&(Ge.current={scope:Zh(qe.scope,"session"),subject:typeof qe.subject=="string"?qe.subject:void 0,predicate:typeof qe.predicate=="string"?qe.predicate:void 0,object:typeof qe.object=="string"?qe.object:void 0})}Nn(te,{warnings:(Te=ge==null?void 0:ge.result)==null?void 0:Te.warnings})},[Nn]),Pn=h.useCallback(async()=>{const te=Ge.current;if(!te)return;const ge=String(Ie.current||"").trim(),Te=await yn({scope:te.scope,subject:te.subject,predicate:te.predicate,object:te.object,since:ge||void 0,order:"asc",limit:0}),qe=Array.isArray(Te.items)?Te.items:[];if(!qe.length)return;const it=Date.now()+Math.max(250,Math.min(2e4,C)),pt=ve.current,vt=[],Rt=[];let lt=String(Ie.current||"").trim();for(const Pt of qe){if(!Pt||typeof Pt!="object"||typeof Pt.subject!="string"||typeof Pt.predicate!="string"||typeof Pt.object!="string")continue;const Vt=iy(Pt);if(pt.has(Vt))continue;pt.add(Vt),vt.push(Pt),Rt.push({id:Vt,assertion:Pt,expires_at_ms:it});const ce=String(Pt.observed_at||"").trim();ce&&(lt=sy(lt,ce))}vt.length&&(Ie.current=lt,M(Pt=>{const Vt=Pt.concat(vt);return Vt.sort((ce,kt)=>String((kt==null?void 0:kt.observed_at)||"").localeCompare(String((ce==null?void 0:ce.observed_at)||""))),Vt}),ue(Pt=>{const Vt=Pt.concat(Rt);return Vt.sort((ce,kt)=>kt.expires_at_ms-ce.expires_at_ms),Vt.slice(0,30)}))},[C,yn]);return h.useEffect(()=>{if(!g)return;let te=!1,ge=null;const Te=async()=>{if(!te){try{await Pn()}catch{}te||(ge=window.setTimeout(()=>void Te(),Math.max(250,Math.min(6e4,x))))}};return Te(),()=>{te=!0,ge!==null&&window.clearTimeout(ge)}},[g,x,Pn]),h.useEffect(()=>{if(!ne.length)return;const te=window.setInterval(()=>{const ge=Date.now();ue(Te=>Te.filter(qe=>qe.expires_at_ms>ge))},250);return()=>window.clearInterval(te)},[ne.length]),s.jsxs("div",{className:"mindmap_root",children:[s.jsxs("div",{className:"mindmap_bar",children:[s.jsx("button",{className:"btn",onClick:()=>void _n(),disabled:Q,children:Q?"Loading…":"Load snapshot"}),s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"source"}),s.jsxs("select",{value:u,onChange:te=>{const ge=String(te.target.value||"").trim();(ge==="all"||ge==="global"||ge==="session"||ge==="run")&&m(ge)},children:[s.jsx("option",{value:"all",children:"all memory"}),s.jsx("option",{value:"global",children:"global"}),s.jsx("option",{value:"session",children:"session"}),s.jsx("option",{value:"run",children:"run"})]})]}),s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"live"}),s.jsx("input",{type:"checkbox",checked:g,onChange:te=>v(!!te.target.checked)})]}),u==="session"?s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"session_id"}),s.jsx("input",{className:"mono",value:c,onChange:te=>d(String(te.target.value||"")),placeholder:"(required)"})]}):null,u==="run"?s.jsxs("label",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",children:"run_id"}),s.jsx("input",{className:"mono",value:o,onChange:te=>a(String(te.target.value||"")),placeholder:"(required)"})]}):null,s.jsxs("details",{className:"mindmap_details",children:[s.jsx("summary",{className:"mono muted",children:"advanced"}),s.jsx("div",{className:"mindmap_advanced",children:s.jsxs("div",{className:"field_inline",children:[s.jsx("span",{className:"mono muted",style:{width:84},children:"poll_ms"}),s.jsx("input",{type:"number",min:250,max:6e4,step:50,value:x,onChange:te=>b(Math.max(250,Number(te.target.value||0)||750))}),s.jsx("span",{className:"mono muted",children:"highlight_ms"}),s.jsx("input",{type:"number",min:250,max:2e4,step:250,value:C,onChange:te=>S(Math.max(250,Number(te.target.value||0)||5e3))})]})})]})]}),z?s.jsx("div",{className:"mindmap_error mono",children:z}):null,s.jsxs("div",{className:"mindmap_explorer",children:[s.jsx(LC,{title:"mindmap",resetKey:Ft,queryMode:"replace",items:Un,warnings:W,onQuery:Hn,onItemsReplace:vn,onOpenSpan:({run_id:te,span_id:ge,assertion:Te})=>{Cn({run_id:te,span_id:ge,assertion:Te})},onOpenTranscript:({run_id:te,span_id:ge,assertion:Te})=>{const qe=String(te||"").trim(),He=typeof ge=="string"?String(ge).trim():"";qe&&(He?Cn({run_id:qe,span_id:He,assertion:Te}):ar({run_id:qe,assertion:Te}))}},Ft),ne.length?s.jsxs("div",{className:"mindmap_recent mindmap_overlay mindmap_overlay_recent",children:[s.jsx("div",{className:"mindmap_recent_title mono muted",children:"new assertions"}),s.jsx("div",{className:"mindmap_recent_list",children:ne.slice().sort((te,ge)=>ge.expires_at_ms-te.expires_at_ms).slice(0,12).map(te=>s.jsx("div",{className:"mindmap_recent_item mono",children:OC(te.assertion)},te.id))})]}):null,Tt?s.jsx("div",{className:"mindmap_timeline mindmap_overlay mindmap_overlay_timeline",children:s.jsxs("div",{className:"mindmap_timeline_row",children:[s.jsx("div",{className:"mindmap_timeline_label mono muted",children:Il(Math.min(typeof jt=="number"?jt:Tt.max_ms,Tt.real_max_ms))}),s.jsx("input",{className:"mindmap_slider",type:"range",min:Tt.min_ms,max:Tt.max_ms,step:Dt,value:typeof jt=="number"?jt:Tt.max_ms,onChange:te=>{const ge=Number(te.target.value||0);hn(ge),Vn(ge>=Tt.max_ms)}}),s.jsxs("div",{className:"mindmap_timeline_counts mono muted",children:[Un.length.toLocaleString(),"/",L.length.toLocaleString()]})]})}):null]}),s.jsxs(qa,{open:de,title:O||"source",onClose:()=>{pe(!1)},children:[D?s.jsx("div",{className:"mono muted",children:"Loading…"}):null,j?s.jsx("div",{className:"mindmap_error mono",children:j}):null,!D&&!j?s.jsxs("div",{className:"source_span",children:[(()=>{const te=Ee;if(!te)return null;const ge=String(te.subject||"").trim(),Te=String(te.predicate||"").trim(),qe=String(te.object||"").trim(),He=Il(Ba(te.observed_at)),it=te.attributes&&typeof te.attributes=="object"&&!Array.isArray(te.attributes)?te.attributes:null,pt=it&&typeof it.evidence_quote=="string"?String(it.evidence_quote):"",vt=it&&typeof it.original_context=="string"?String(it.original_context):"";return s.jsxs("div",{className:"source_header",children:[s.jsxs("div",{className:"mono source_triple",title:`${ge} --${Te}--> ${qe}`,children:[ge," ",s.jsxs("span",{className:"muted",children:["—",Te,"→"]})," ",qe," ",He?s.jsxs("span",{className:"muted",children:["[",He,"]"]}):null]}),pt?s.jsxs("div",{className:"source_evidence",children:[s.jsx("div",{className:"mono muted",style:{fontSize:11,marginBottom:6},children:"evidence_quote"}),s.jsx("pre",{className:"mono source_evidence_quote",children:pt}),vt?s.jsxs("details",{className:"source_evidence_more",children:[s.jsx("summary",{className:"mono muted",children:"original_context"}),s.jsx("pre",{className:"mono source_evidence_quote",children:vt})]}):null]}):null]})})(),s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["run_id=",I," · ",K==="artifact"?`span_id=${G}`:"source=input_data"]}),s.jsxs("div",{className:"source_actions",children:[Ne!==null?s.jsx("button",{className:"btn",onClick:()=>Oe(Ne),children:"Jump to evidence"}):null,Ne===null&&at?s.jsx("button",{className:"btn",onClick:()=>st(),children:"Jump to evidence"}):null]}),(()=>{const te=le,ge=te&&typeof te=="object"&&!Array.isArray(te)?te:null,Te=wt,qe=Ct,He=ge&&typeof ge.created_at=="string"?String(ge.created_at):"",it=He?Ba(He):null,pt=it!==null?Il(it):He,vt=ge&&ge.span&&typeof ge.span=="object"&&!Array.isArray(ge.span)?ge.span:null,Rt=vt&&typeof vt.from_timestamp=="string"?String(vt.from_timestamp):"",lt=vt&&typeof vt.to_timestamp=="string"?String(vt.to_timestamp):"",Pt=Rt?Ba(Rt):null,Vt=lt?Ba(lt):null,ce=Pt!==null&&Vt!==null?`${Il(Pt)} → ${Il(Vt)}`:"";if(qe){const kt=PC(qe);if(kt){const Lt=Ke,Ve=Lt?kt.messages.findIndex(gn=>lm(gn.content,Lt)):-1,nn=Lt?ry(Lt):[],pn=kt.created_at||He,cn=pn?RC(pn):He?pt:"";return s.jsx("div",{className:"source_chat",children:kt.messages.map((gn,er)=>{const Vr=gn.role,Nr=!!(Lt&&lm(gn.content,Lt)),Gr=Vr==="user"?"USER":Vr==="assistant"?"ASSISTANT":"SYSTEM";return s.jsxs("div",{id:er===Ve?"source_note_msg_hit_0":void 0,className:`source_msg source_${Vr} ${Nr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",er+1," · ",Gr,Nr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null]}),cn?s.jsx("span",{title:pn||"",children:cn}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(gi,{text:gn.content,highlights:Nr&&nn.length?nn:void 0,highlightClassName:"source_note_hit",highlightId:er===Ve?"source_note_hit_0":void 0})})]},`note_msg:${er}`)})})}return s.jsxs("div",{className:"source_note",children:[He?s.jsx("div",{className:"mono muted",style:{marginBottom:10},children:s.jsxs("span",{title:He,children:["created_at=",pt]})}):null,s.jsx(gi,{text:qe,highlights:Ke?ry(Ke):void 0,highlightClassName:"source_note_hit",highlightId:"source_note_hit_0"})]})}if(Te){const kt=new Map;for(const Ve of Te){const nn=typeof(Ve==null?void 0:Ve.role)=="string"?String(Ve.role):"unknown";kt.set(nn,(kt.get(nn)||0)+1)}const Lt=Array.from(kt.entries()).sort((Ve,nn)=>nn[1]-Ve[1]||Ve[0].localeCompare(nn[0])).map(([Ve,nn])=>`${Ve}×${nn}`).join(" · ");return s.jsxs("div",{className:"source_chat",children:[He?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:[s.jsxs("span",{title:He,children:["created_at=",pt]})," · messages=",Te.length]}):null,ce?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["span=",ce]}):null,Lt?s.jsxs("div",{className:"mono muted",style:{marginBottom:10},children:["participants: ",Lt]}):null,Te.slice(0,200).map((Ve,nn)=>{var Gs,$s;const pn=typeof(Ve==null?void 0:Ve.role)=="string"?String(Ve.role):"unknown",cn=(Ve==null?void 0:Ve.content)==null?"":String(Ve.content),gn=typeof(Ve==null?void 0:Ve.timestamp)=="string"?String(Ve.timestamp):"",er=gn?Ba(gn):null,Vr=er!==null?Il(er):gn,Nr=typeof(Ve==null?void 0:Ve.message_id)=="string"?String(Ve.message_id):typeof((Gs=Ve==null?void 0:Ve.metadata)==null?void 0:Gs.message_id)=="string"?String(Ve.metadata.message_id):typeof(($s=Ve==null?void 0:Ve.metadata)==null?void 0:$s.id)=="string"?String(Ve.metadata.id):"",Gr=nt.has(nn);return s.jsxs("div",{id:`source_msg_${nn}`,className:`source_msg source_${pn} ${Gr?"source_match":""}`,children:[s.jsxs("div",{className:"source_msg_meta mono muted",children:[s.jsxs("span",{children:["#",nn+1," · ",pn,Gr?s.jsx("span",{className:"source_match_badge",children:"evidence"}):null,Nr?s.jsx("span",{className:"source_msg_id",children:Nr}):null]}),gn?s.jsx("span",{title:gn,children:Vr}):null]}),s.jsx("div",{className:"source_msg_body",children:s.jsx(gi,{text:cn})})]},nn)})]})}return s.jsx("pre",{className:"mono source_raw",style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:(typeof te=="string"?te:be)||"(empty)"})})()]}):null]})]})}const Qh=4;function IC(e){var c;const t=(c=e==null?void 0:e.discoveries)==null?void 0:c.dreams_signals_brief;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=typeof t.count=="number"&&Number.isInteger(t.count)&&t.count>0?t.count:0;if(!n)return null;const o=d=>Array.isArray(d)?d.filter(u=>typeof u=="string").map(u=>u.trim()).filter(Boolean):[],a=typeof t.dreams=="number"&&Number.isInteger(t.dreams)&&t.dreams>0?t.dreams:null;return{count:n,kinds:o(t.kinds),felt_tones:o(t.felt_tones),dreams:a}}function oy(e){if(!e||typeof e!="object")return null;const t=String(e.title||"").trim(),n=String(e.statement||"").trim();if(!t&&!n)return null;const o=typeof e.entry_id=="string"&&e.entry_id.trim()?e.entry_id.trim():null;return{record_id:String(e.record_id||"").trim(),title:t,statement:n,entry_id:o}}function DC(e){var u,m;const t=y=>{var v;const g=(v=e==null?void 0:e[y])==null?void 0:v.open;return Array.isArray(g)?g.map(oy).filter(x=>x!==null):[]},n=t("questions"),o=t("problems"),a=(u=e==null?void 0:e.lessons)==null?void 0:u.lessons,c=Array.isArray(a)?a.map(oy).filter(y=>y!==null):[],d=typeof((m=e==null?void 0:e.lessons)==null?void 0:m.total)=="number"?e.lessons.total:c.length;return{questions:n.slice(0,Qh),questions_total:n.length,problems:o.slice(0,Qh),problems_total:o.length,lessons:c.slice(0,Qh),lessons_total:d}}function e_(e){return e===null||!Number.isFinite(e)||e<0?"":e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)}k`:`${(e/1e6).toFixed(1)}M`}const ay={review:"Review",working:"Working",pending:"Pending",done:"Done"},FC={review:"nothing needs you",working:"idle",pending:"nothing scheduled",done:"no recent runs"},BC={pending:"scheduled or queued — will run without you",working:"running or parked listening — no action needed",review:"needs a human decision — act here",done:"terminal — read the outcome"};function UC(e){const t=String((e==null?void 0:e.status)||"").trim().toLowerCase();if(yi(t))return"done";const n=du(e);return n==="tool_approval"||n==="user_response"?"review":n==="scheduled"||t==="pending"||t==="queued"||t==="created"?"pending":"working"}function HC(e){const t=du(e);return t==="tool_approval"||t==="user_response"}function ly(e,t=Date.now()){const n=UC(e),o=e!=null&&e.waiting&&typeof e.waiting=="object"?e.waiting:null,a=uu(o),c=Sn((o==null?void 0:o.since)||(e==null?void 0:e.updated_at)||(e==null?void 0:e.created_at)||"");return{run_id:String((e==null?void 0:e.run_id)||""),column:n,workflow:String((e==null?void 0:e.workflow_id)||"").trim()||"(workflow?)",status:String((e==null?void 0:e.status)||"").trim().toLowerCase(),wait_kind:du(e),reason:av(e),tool_names:a.map(d=>String((d==null?void 0:d.name)||"tool")).filter(Boolean),wait_key:String((o==null?void 0:o.wait_key)||"").trim(),allow_free_text:(o==null?void 0:o.allow_free_text)!==!1,prompt:String((o==null?void 0:o.prompt)||"").trim(),since_ms:c,duration_ms:W_(e,t),tokens_total:typeof(e==null?void 0:e.tokens_total)=="number"?e.tokens_total:null,llm_calls:typeof(e==null?void 0:e.llm_calls)=="number"?e.llm_calls:null,tool_calls:typeof(e==null?void 0:e.tool_calls)=="number"?e.tool_calls:null,is_scheduled:!!(e!=null&&e.is_scheduled),schedule_interval:String((e==null?void 0:e.schedule_interval)||"").trim(),failed:String((e==null?void 0:e.status)||"").trim().toLowerCase()==="failed",error:String((e==null?void 0:e.error)||"").trim(),paused:!!(e!=null&&e.paused),is_subrun:!!String((e==null?void 0:e.parent_run_id)||"").trim()}}function WC(e,t,n=Date.now()){const o={pending:[],working:[],review:[],done:[]},a=t&&t.length?t:e,c=new Set;for(const d of a||[]){const u=String((d==null?void 0:d.run_id)||"").trim();!d||!u||c.has(u)||HC(d)&&(c.add(u),o.review.push(ly(d,n)))}for(const d of e||[]){const u=String((d==null?void 0:d.run_id)||"").trim();if(!d||!u||c.has(u))continue;const m=ly(d,n);o[m.column].push(m)}return o.review.sort((d,u)=>(d.since_ms??0)-(u.since_ms??0)),o.working.sort((d,u)=>(u.since_ms??0)-(d.since_ms??0)),o.pending.sort((d,u)=>(u.since_ms??0)-(d.since_ms??0)),o.done.sort((d,u)=>Number(u.failed)-Number(d.failed)||(u.since_ms??0)-(d.since_ms??0)),o}const F_={"12h":12*36e5,"24h":24*36e5,"48h":48*36e5,"72h":72*36e5,"7d":7*864e5,"14d":14*864e5,"1m":30*864e5,all:null},t_={"12h":"last 12h","24h":"last 24h","48h":"last 48h","72h":"last 72h","7d":"last 7 days","14d":"last 14 days","1m":"last month",all:"all loaded"},cy="48h";function qC(e,t,n=Date.now()){const o=F_[t]??null;if(o===null)return{visible:e,hidden_count:0};const a=n-o,c=[];let d=0;for(const u of e)u.since_ms===null||u.since_ms>=a?c.push(u):d+=1;return{visible:c,hidden_count:d}}function VC(e,t=Date.now()){const n=String(e||"").trim();if(!n)return null;const o=Date.parse(n);return Number.isFinite(o)?Math.max(0,t-o):null}const GC=6e4;function Ed(e,t=Date.now()){if(e===null||!Number.isFinite(e))return"";const n=Math.max(0,t-e);return n<6e4?`${Math.round(n/1e3)}s`:n<36e5?`${Math.round(n/6e4)}m`:n<864e5?`${(n/36e5).toFixed(1)}h`:`${(n/864e5).toFixed(1)}d`}function YC(e){return!Number.isFinite(e)||e<0?"":e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.floor(e/6e4)}m${Math.round(e%6e4/1e3)}s`:`${(e/36e5).toFixed(1)}h`}function KC(e){const t=String(e||"");return t.length>14?`${t.slice(0,6)}…${t.slice(-6)}`:t}function n_(e){const t=String(e||"").trim();return t.length>72?`${t.slice(0,70)}…`:t}function XC(e){const t=String(e||"");let n=t.includes(":")?t.slice(t.lastIndexOf(":")+1):t;if(t.includes(":")&&/^[0-9a-f]{6,}$/i.test(n.trim())){const o=t.slice(0,t.lastIndexOf(":"));/[a-z]/i.test(o)&&!/^[0-9a-f]+$/i.test(o.replace(/[@.\-_]/g,""))&&(n=o)}return n.length>34?`${n.slice(0,32)}…`:n}function gm(e){return e.toLowerCase().replace(/[_-]+/g," ")}function JC(e){var y,g;const t=e!=null&&e.spec&&typeof e.spec=="object"?e.spec:null,n=t!=null&&t.phases&&typeof t.phases=="object"&&!Array.isArray(t.phases)?t.phases:null;if(!n)return null;const o=Object.keys(n).filter(v=>v&&typeof v=="string");if(!o.length)return null;const a=[];for(const v of o){a.push({needle:gm(v),phase:v});const x=(y=n[v])==null?void 0:y.spoken_synonyms;if(Array.isArray(x))for(const b of x){const C=gm(String(b||"").trim());C&&a.push({needle:C,phase:v})}}const d=(typeof t.initial_phase=="string"&&o.includes(t.initial_phase)?t.initial_phase:null)??(o.includes("sleep")?"sleep":null);if(!d)return null;const u=[],m=(g=t==null?void 0:t.state_mode_axis)==null?void 0:g.words;if(m&&typeof m=="object"&&!Array.isArray(m))for(const[v,x]of Object.entries(m)){const b=String((x==null?void 0:x.phase)||"").trim(),C=gm(String(v||"").trim());C&&o.includes(b)&&u.push({needle:C,phase:b})}return{phases:o,synonyms:a,modes:u,initial:d,version:typeof t.version=="number"?t.version:null,sha256:String((e==null?void 0:e.sha256)||"").trim()}}const ZC=["asleep","sleep","dream"],QC=["rest"],eE=["awake","idle"];function tE(e,t){const n=String(e||"").trim().toLowerCase();if(!n)return"unknown";if(t){const o=gm(n),a=t.synonyms.filter(d=>o.includes(d.needle)).sort((d,u)=>u.needle.length-d.needle.length);if(a.length)return a[0].phase;const c=t.modes.filter(d=>o.includes(d.needle)).sort((d,u)=>u.needle.length-d.needle.length);return c.length?c[0].phase:n.includes("task")&&!n.includes("no_task")&&t.phases.includes("work")?"work":ZC.some(d=>n.includes(d))?t.initial:QC.some(d=>n.includes(d))&&t.phases.includes("personal")?"personal":eE.some(d=>n.includes(d))?t.initial:n.includes("stop")?"stopped":n.includes("pause")?"paused":n}return n.includes("visit")?"visit":n.includes("sleep")||n.includes("dream")?"sleep":n.includes("personal")||n.includes("own_time")||n.includes("own time")?"personal":n.includes("task")&&!n.includes("no_task")||n.includes("work")?"work":n.includes("awake")||n.includes("idle")?"sleep":n.includes("stop")?"stopped":n.includes("pause")?"paused":n.includes("rest")?"resting":n}const nE=new Set(["visit","work","personal","sleep","paused","resting","stopped","unknown"]),rE=new Set(["visit","work","personal","sleep","paused","resting","stopped","unknown"]);function sE(e){if(!e)return nE;const t=e.phases.filter(n=>rE.has(n));return new Set([...t,"paused","stopped","unknown"])}function iE(e){var Q,Z,ne,ue,de,pe;const t=Date.now(),n=h.useMemo(()=>WC(e.runs,e.all_runs,Date.now()),[e.runs,e.all_runs]),[o,a]=h.useState(""),[c,d]=h.useState(""),[u,m]=h.useState(!1),[y,g]=h.useState(()=>{try{const D=localStorage.getItem("abstractobserver_done_window_v1");return D&&D in F_?D:cy}catch{return cy}}),v=h.useMemo(()=>qC(n.done,y,t),[n.done,y]),x=Ed(e.runs_refreshed_at,t),b=n.review.length,C=v.visible.filter(D=>D.failed).length,[S,L]=h.useState(""),[M,W]=h.useState(null),q=D=>`${D.run_id}:${D.wait_key}:${D.since_ms??""}`;h.useEffect(()=>{o&&(n.review.some(D=>q(D)===o)||a(""))},[n,o]);async function z(D,E){a(q(D)),d("");try{await e.on_resume_wait(D.run_id,D.wait_key,E)}catch(j){d(`${D.run_id}: ${String((j==null?void 0:j.message)||j||"resume failed")}`),a("")}}function Y(D){const E=o===q(D),j=D.column==="review",R=j&&!D.wait_key;return s.jsxs("div",{className:`mc_card ${j?"mc_card_review":""} ${D.failed?"mc_card_failed":""}`,onClick:()=>e.on_open_run(D.run_id),role:"button",tabIndex:0,onKeyDown:O=>{O.key==="Enter"&&O.target===O.currentTarget&&e.on_open_run(D.run_id)},children:[s.jsxs("div",{className:"mc_card_head",children:[s.jsx("span",{className:"mc_card_title",title:D.workflow,children:XC(D.workflow)}),(()=>{const O=D.failed?"failed":wm({status:D.status,paused:D.paused});return s.jsx("span",{className:`mc_status ${Ka(O)}`,children:O==="unknown"?"?":O})})()]}),s.jsxs("div",{className:"mc_card_meta",children:[s.jsx("span",{className:"mono",title:D.run_id,children:KC(D.run_id)}),D.is_subrun?s.jsx("span",{title:"This wait lives in a child run of an agent workflow",children:"subrun"}):null,D.duration_ms>=0?s.jsx("span",{children:YC(D.duration_ms)}):null,D.tokens_total!==null?s.jsxs("span",{children:[D.tokens_total.toLocaleString()," tk"]}):null,D.tool_calls!==null&&D.tool_calls>0?s.jsxs("span",{children:[D.tool_calls," tools"]}):null]}),D.is_scheduled&&D.schedule_interval?s.jsxs("div",{className:"mc_card_line",children:["every ",D.schedule_interval]}):null,D.failed&&D.error?s.jsx("div",{className:"mc_card_error",title:D.error,children:D.error.length>120?`${D.error.slice(0,118)}…`:D.error}):null,j?s.jsxs("div",{className:"mc_card_review_body",onClick:O=>O.stopPropagation(),onKeyDown:O=>O.stopPropagation(),children:[s.jsx("div",{className:"mc_card_reason",children:D.reason||"Needs a decision"}),D.prompt?s.jsx("div",{className:"mc_card_prompt",title:D.prompt,children:D.prompt.length>240?`${D.prompt.slice(0,238)}…`:D.prompt}):null,D.tool_names.length?s.jsxs("div",{className:"mc_card_tools",title:"Tool calls awaiting your approval",children:[D.tool_names.slice(0,4).map((O,ee)=>s.jsx("span",{className:"mc_tool_chip mono",children:O},`${O}_${ee}`)),D.tool_names.length>4?s.jsxs("span",{className:"mc_tool_chip",children:["+",D.tool_names.length-4," more"]}):null]}):null,D.since_ms!==null?s.jsxs("div",{className:"mc_card_waiting",children:["waiting ",Ed(D.since_ms,t)]}):null,R?s.jsx("div",{className:"mc_card_line",title:"The wait has not registered a wait_key yet — open the run to inspect.",children:"wait key not published yet — open the run"}):null,R?s.jsx("div",{className:"mc_card_actions",children:s.jsx("button",{className:"btn",onClick:()=>e.on_open_run(D.run_id),children:"Open the run →"})}):D.wait_kind==="tool_approval"?s.jsxs("div",{className:"mc_card_actions",children:[s.jsx("button",{className:"btn success",disabled:E,onClick:()=>void z(D,{approved:!0}),children:E?"Resuming…":"Approve"}),s.jsx("button",{className:"btn danger",disabled:E,onClick:()=>void z(D,{approved:!1}),children:"Reject"})]}):s.jsx("div",{className:"mc_card_actions",children:s.jsx("button",{className:"btn primary",onClick:()=>e.on_open_run(D.run_id),children:"Review & answer →"})})]}):null]},D.run_id)}return s.jsxs("div",{className:"page page_scroll mc_page",children:[s.jsxs("div",{className:"mc_health",children:[s.jsx("span",{className:`mc_led ${e.gateway_connected?"ok":"bad"}`,title:e.gateway_connected?"Gateway connected":"Gateway unreachable"}),e.gateway_connected?null:s.jsx("span",{className:"mc_health_text",children:"gateway unreachable"}),e.runs_refreshed_at===null?s.jsx("span",{className:"mc_health_text muted mc_loading",children:"loading runs…"}):s.jsxs("div",{className:"mc_stats",children:[s.jsxs("div",{className:`mc_stat ${b?"is_hot":""}`,title:"runs blocked on a human decision (Review column)",children:[s.jsx("span",{className:"mc_stat_value",children:b}),s.jsx("span",{className:"mc_stat_label",children:"need you"})]}),s.jsxs("div",{className:`mc_stat ${C?"is_bad":""}`,title:"failed runs in the Done column",children:[s.jsx("span",{className:"mc_stat_value",children:C}),s.jsx("span",{className:"mc_stat_label",children:"failed"})]}),s.jsxs("div",{className:"mc_stat",title:"runs executing or parked listening",children:[s.jsx("span",{className:"mc_stat_value",children:n.working.length}),s.jsx("span",{className:"mc_stat_label",children:"working"})]})]}),s.jsx("span",{className:"mc_spacer"}),s.jsxs("div",{className:"mc_health_side",children:[x?s.jsxs("span",{className:"mc_health_text muted",title:"age of the last runs poll — the board is only as live as this",children:["data ",x," old"]}):null,s.jsx("button",{className:"btn",onClick:e.on_refresh,disabled:e.refreshing,children:e.refreshing?"Refreshing…":"Refresh"})]})]}),c?s.jsx("div",{className:"mc_error",children:c}):null,e.entities.length||e.entities_error?s.jsxs("div",{className:"mc_entities",children:[s.jsxs("div",{className:"mc_entities_head",children:[s.jsxs("span",{children:["Entities",e.entities_total>e.entities.length?` (${e.entities.length} of ${e.entities_total} — open the entity app for all)`:""]}),s.jsx("a",{className:"mc_entity_link",href:e.entity_app_href,target:"_blank",rel:"noreferrer",children:"open the entity app →"})]}),e.entities_error?s.jsx("div",{className:"muted",children:e.entities_error}):null,s.jsx("div",{className:"mc_entities_row",children:e.entities.map(D=>s.jsxs("div",{className:"mc_entity_cell",children:[s.jsxs("a",{className:"mc_entity",href:`${e.entity_app_href}${e.entity_app_href.includes("?")?"&":"?"}entity=${encodeURIComponent(D.name)}&live=1`,target:"_blank",rel:"noreferrer",title:[D.error,D.age_days!==null?`${D.age_days.toFixed(0)} days old`:"",D.last_moment].filter(Boolean).join(" — ")||D.name,children:[s.jsx("span",{className:"mc_entity_name",children:D.name}),(()=>{var P;const E=String(D.live_phase||D.state||"").trim(),j=tE(E,e.phase_graph),R=sE(e.phase_graph).has(j)?j:"other",O=((P=e.phase_graph)==null?void 0:P.initial)??"sleep",ee=/awake|idle/i.test(E)&&j===O,I=E&&E.toLowerCase()!==j?` — wire word: ${E}${ee?" (settling)":""}`:"";return s.jsx("span",{className:`mc_entity_phase mc_phase_${R}`,title:(D.live_phase?"phase (cognition wire)":"phase from card state — cognition wire unavailable")+I,children:j})})(),D.last_moment?s.jsx("span",{className:"mc_entity_moment",title:D.last_moment,children:D.last_moment.replace(/_/g," ")}):null,(()=>{if(D.working===!0)return s.jsx("span",{className:"mc_entity_live",title:"busy now (loop mid-day or live visit — store-read, never fabricated)",children:"● busy"});const E=VC(D.last_moment_at,t);return D.working===!1?s.jsxs("span",{className:"mc_entity_live muted",title:"idle (cognition wire)",children:["idle",E!==null?` · ${Ed(t-E,t)} ago`:""]}):E===null?null:E<=GC?s.jsx("span",{className:"mc_entity_live",title:`last moment ${Ed(t-E,t)} ago`,children:"● active"}):s.jsxs("span",{className:"mc_entity_live muted",title:"time since the last recorded moment",children:[Ed(t-E,t)," ago"]})})(),D.tokens_total!==null?s.jsxs("span",{className:"muted mc_entity_spend",title:`lifetime billed tokens (home run ledger)${D.live_visit_tokens!==null?`; open visit: ${e_(D.live_visit_tokens)} tk`:""}${D.spend_warning?`; ${D.spend_warning}`:""}`,children:[e_(D.tokens_total)," tk",D.live_visit_tokens!==null?` (+${e_(D.live_visit_tokens)})`:"",D.spend_warning?"*":""]}):null]}),D.open_questions_total||D.open_problems_total||D.lessons_total||D.dreams_brief?s.jsx("button",{type:"button",className:"mc_entity_hints_btn","aria-expanded":S===D.name,title:"open questions / problems + distilled lessons + night signals from the entity card — click to expand",onClick:()=>L(S===D.name?"":D.name),children:[D.open_questions_total?`${D.open_questions_total} question${D.open_questions_total>1?"s":""}`:"",D.open_problems_total?`${D.open_problems_total} problem${D.open_problems_total>1?"s":""}`:"",D.lessons_total?`${D.lessons_total} lesson${D.lessons_total>1?"s":""}`:"",D.dreams_brief?`night: ${D.dreams_brief.count} signal${D.dreams_brief.count>1?"s":""}`:""].filter(Boolean).join(" · ")}):null]},D.name))}),(()=>{if(!S)return null;const D=e.entities.find(R=>R.name===S);if(!D||!D.open_questions.length&&!D.open_problems.length&&!D.lessons.length&&!D.dreams_brief)return null;const E=e.on_read_diary?async R=>{const O=await e.on_read_diary(D.name,R);W({entity:D.name,entry:(O==null?void 0:O.entry)??O,seq:typeof(O==null?void 0:O.read_recorded_at_seq)=="number"?O.read_recorded_at_seq:null})}:void 0,j=D.open_questions_total-D.open_questions.length+(D.open_problems_total-D.open_problems.length)+(D.lessons_total-D.lessons.length);return s.jsxs("div",{className:"mc_entity_hints_panel",children:[D.open_questions.map((R,O)=>s.jsx(Ch,{kind:"question",label:R.title||n_(R.statement),entryId:R.entry_id,onOpen:E,title:R.statement||R.title},`q_${R.record_id||O}`)),D.open_problems.map((R,O)=>s.jsx(Ch,{kind:"problem",label:R.title||n_(R.statement),entryId:R.entry_id,onOpen:E,title:R.statement||R.title},`p_${R.record_id||O}`)),D.lessons.map((R,O)=>s.jsx(Ch,{kind:"lesson",label:R.title||n_(R.statement),entryId:R.entry_id,onOpen:E,title:R.statement||R.title},`l_${R.record_id||O}`)),D.dreams_brief?s.jsxs("span",{className:"mc_entity_dreams muted",title:"night signals carried by STANDING dreams (the sleep pass's maintenance stream; count = signals, not dreams); felt tones color the content, they never rank it — the entity app renders the full stream",children:["night signals: ",D.dreams_brief.count,D.dreams_brief.dreams?` across ${D.dreams_brief.dreams} dream${D.dreams_brief.dreams>1?"s":""}`:"",D.dreams_brief.kinds.length?` — ${D.dreams_brief.kinds.slice(0,6).join(", ")}${D.dreams_brief.kinds.length>6?` +${D.dreams_brief.kinds.length-6} more`:""}`:"",D.dreams_brief.felt_tones.length?` · felt: ${D.dreams_brief.felt_tones.slice(0,6).join(", ")}`:""]}):null,j>0?s.jsxs("span",{className:"muted mc_entity_hints_more",children:["+",j," more — open the entity app"]}):null]})})()]}):null,M?s.jsx(qa,{open:!0,title:`${M.entity} — diary entry`,onClose:()=>W(null),children:s.jsxs("div",{className:"mc_diary_entry",children:[s.jsx("div",{className:"mc_diary_meta muted",children:[(Q=M.entry)!=null&&Q.kind?`kind: ${M.entry.kind}`:"",(Z=M.entry)!=null&&Z.visibility?`visibility: ${M.entry.visibility}`:"",(ne=M.entry)!=null&&ne.written_at?`written: ${M.entry.written_at}`:"",(ue=M.entry)!=null&&ue.entry_id?`id: ${M.entry.entry_id}`:""].filter(Boolean).join(" · ")}),s.jsxs("div",{className:"mc_diary_recorded muted",children:["this read was recorded in ",M.entity,"’s stream",M.seq!==null?` (seq ${M.seq})`:""]}),(de=M.entry)!=null&&de.gist?s.jsx("div",{className:"mc_diary_gist",children:String(M.entry.gist)}):null,s.jsx("pre",{className:"mc_diary_text",children:String(((pe=M.entry)==null?void 0:pe.text)||"(entry carries no text)")})]})}):null,s.jsx("div",{className:"mc_board",children:Object.keys(ay).map(D=>{const E=D==="done"?v.visible:n[D],j=D==="done"&&!u?E.slice(0,8):E;return s.jsxs("div",{className:`mc_column mc_column_${D}`,children:[s.jsxs("div",{className:"mc_column_head",children:[s.jsx("span",{className:"mc_column_title",children:ay[D]}),D==="done"?s.jsx("select",{className:"mc_window_select",value:y,title:"Show terminal runs from this time window",onClick:R=>R.stopPropagation(),onChange:R=>{const O=R.target.value;g(O),m(!1);try{localStorage.setItem("abstractobserver_done_window_v1",O)}catch{}},children:Object.keys(F_).map(R=>s.jsx("option",{value:R,children:t_[R]},R))}):null,s.jsx("span",{className:"mc_column_count",title:D==="done"&&v.hidden_count?`${v.hidden_count} older run(s) outside this window`:void 0,children:E.length})]}),s.jsx("div",{className:"mc_column_hint muted",children:BC[D]}),s.jsxs("div",{className:"mc_column_cards",children:[j.map(R=>Y(R)),E.length?null:s.jsx("div",{className:"mc_empty muted",children:e.runs_refreshed_at===null?"loading…":D==="done"&&v.hidden_count?`none in the ${t_[y]} — ${v.hidden_count} older`:FC[D]}),D==="done"&&E.length>8&&!u?s.jsxs("button",{className:"btn mc_more",onClick:()=>m(!0),children:["show all ",E.length]}):null,D==="done"&&v.hidden_count&&E.length?s.jsxs("div",{className:"mc_window_note muted",title:"Widen the window above to see older terminal runs",children:["+",v.hidden_count," older outside ",t_[y]]}):null]})]},D)})})]})}function uy(e){const t=Array.from(new Set(e.map(n=>String(n||"").trim()).filter(Boolean)));return t.sort((n,o)=>n.localeCompare(o)),t}function r_(e){const t=e.disabled===!0,n=h.useMemo(()=>uy(e.options||[]),[e.options]),o=h.useMemo(()=>uy(e.value||[]),[e.value]),[a,c]=h.useState(!1),[d,u]=h.useState(""),m=h.useMemo(()=>{const v=d.trim().toLowerCase();return v?n.filter(x=>x.toLowerCase().includes(v)):n},[n,d]),y=h.useMemo(()=>new Set(o),[o]),g=typeof e.max_list_height_px=="number"?e.max_list_height_px:220;return s.jsxs("div",{className:"multi_select",children:[s.jsxs("div",{className:"multi_select_row",children:[s.jsxs("button",{className:"btn",type:"button",onClick:()=>c(v=>!v),disabled:t||!n.length,"aria-expanded":a,children:[a?"Hide":"Select"," • ",o.length>0?`${o.length} of ${n.length}`:e.placeholder||"(none)"]}),s.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange(n.slice()),disabled:t||!n.length||o.length===n.length,title:"Select all",children:"All"}),s.jsx("button",{className:"btn",type:"button",onClick:()=>e.onChange([]),disabled:t||o.length===0,title:"Clear selection",children:"Clear"})]}),o.length>0?s.jsx("div",{className:"multi_select_chips",children:o.map(v=>s.jsxs("span",{className:"multi_select_chip",title:v,onClick:()=>{if(t)return;const x=new Set(y);x.delete(v),e.onChange(Array.from(x.values()))},children:[v,t?null:s.jsx("span",{className:"multi_select_chip_x",children:"×"})]},v))}):null,a?s.jsxs("div",{className:"multi_select_panel",children:[s.jsx("input",{className:"mono",value:d,onChange:v=>u(String(v.target.value||"")),placeholder:"filter…",disabled:t}),s.jsxs("div",{className:"multi_select_list",style:{maxHeight:`${g}px`},children:[m.map(v=>{const x=y.has(v);return s.jsxs("label",{className:`multi_select_item mono ${x?"checked":""}`,children:[s.jsx("input",{type:"checkbox",checked:x,disabled:t,onChange:b=>{const C=new Set(y);b.target.checked?C.add(v):C.delete(v),e.onChange(Array.from(C.values()))}}),s.jsx("span",{children:v})]},v)}),m.length?null:s.jsx("div",{className:"mono muted",children:"(no matches)"})]})]}):null]})}function oE(){var t;if(typeof window>"u")return!1;const e=navigator;return!!((t=e==null?void 0:e.mediaDevices)!=null&&t.getUserMedia)&&typeof window.MediaRecorder=="function"}function aE(){if(typeof window>"u")return!1;const e=window;return!!(e!=null&&e.AudioContext||e!=null&&e.webkitAudioContext)}function lE(){const e=window.MediaRecorder,t=o=>{var a;try{return!!((a=e==null?void 0:e.isTypeSupported)!=null&&a.call(e,o))}catch{return!1}},n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const o of n)if(t(o))return o;return""}async function cE(e,t){var a;const n=t.slice(0),o=(a=e.decodeAudioData)==null?void 0:a.bind(e);if(typeof o!="function")throw new Error("decodeAudioData not available");try{const c=o(n);if(c&&typeof c.then=="function")return await c}catch{}return await new Promise((c,d)=>{try{o(n,c,d)}catch(u){d(u)}})}function uE(e){const t=R=>{var O;return(O=e.on_error)==null?void 0:O.call(e,R)},n=h.useMemo(()=>aE(),[]),o=h.useMemo(()=>oE(),[]),[a,c]=h.useState({key:"",status:"idle"}),d=h.useRef(""),u=h.useRef(""),m=h.useRef(null),y=h.useRef(null),g=h.useRef(null),v=h.useRef(null),x=h.useRef(0),b=h.useRef(0),C=()=>{try{const R=globalThis,O=(R==null?void 0:R.AudioContext)||(R==null?void 0:R.webkitAudioContext);if(!O)return null;if(!m.current){const P=new O,G=P.createGain();G.gain.value=1,G.connect(P.destination),m.current=P,y.current=G}const ee=m.current,I=y.current;if(!ee||!I)return null;try{ee.state==="suspended"&&ee.resume()}catch{}return{ctx:ee,gain:I}}catch{return null}},S=()=>{const R=g.current;if(g.current=null,!!R){try{R.onended=null}catch{}try{R.stop()}catch{}try{R.disconnect()}catch{}}},L=()=>{S(),u.current="",d.current="",v.current=null,x.current=0,b.current=0,c({key:"",status:"idle"})};h.useEffect(()=>()=>{var R,O;L();try{(R=y.current)==null||R.disconnect()}catch{}try{(O=m.current)==null||O.close()}catch{}m.current=null,y.current=null,v.current=null},[]);const M=async(R,O,ee)=>{const I=C();if(!I)throw new Error("TTS playback is not supported in this browser");const{ctx:P,gain:G}=I;try{P.state==="suspended"&&await P.resume()}catch{}S();const $=P.createBufferSource();$.buffer=O,$.connect(G);const K=Number.isFinite(Number(O.duration))?Number(O.duration):0,se=Math.max(0,Math.min(Number(ee||0),K>0?Math.max(0,K-.01):0));b.current=P.currentTime-se,x.current=se,g.current=$,d.current=R,$.onended=()=>{g.current===$&&(g.current=null,x.current=0,b.current=0,d.current="",c({key:"",status:"idle"}))},$.start(0,se),c({key:R,status:"playing"})},W=async(R,O)=>{const ee=String(R||"").trim(),I=String(O||"").trim();if(!ee||!I)return;const P=e.gateway,G=String(e.run_id||"").trim();if(!P){t==null||t("Connect to the gateway first.");return}if(!G){t==null||t("Voice store not available (missing run_id).");return}const $=C();if(!$){t==null||t("TTS playback is not supported in this browser.");return}const K=a.key===ee;if(K&&a.status==="playing"){const se=Math.max(0,$.ctx.currentTime-Number(b.current||0));x.current=se,S(),c({key:ee,status:"paused"});return}if(K&&a.status==="paused"){const se=v.current;if(se){t==null||t("");try{await M(ee,se,x.current)}catch(le){t==null||t(String((le==null?void 0:le.message)||le||"TTS play failed")),c({key:"",status:"idle"})}return}}if(!(K&&a.status==="loading")){S(),v.current=null,x.current=0,b.current=0,d.current=ee,u.current=ee,c({key:ee,status:"loading"}),t==null||t("");try{const se=await P.voice_tts(G,{text:I,request_id:ss()}),le=se==null?void 0:se.audio_artifact,he=le&&typeof le=="object"&&!Array.isArray(le)?String(le.$artifact||"").trim():"";if(!he)throw new Error("TTS failed: missing audio artifact");const je=await(await P.download_run_artifact_content(G,he)).arrayBuffer();if(u.current!==ee)return;const Ee=await cE($.ctx,je);if(u.current!==ee)return;v.current=Ee,x.current=0,await M(ee,Ee,0)}catch(se){u.current===ee&&(u.current="",d.current="",c({key:"",status:"idle"})),t==null||t(String((se==null?void 0:se.message)||se||"TTS failed"))}}},[q,z]=h.useState(!1),[Y,Q]=h.useState(!1),Z=h.useRef(null),ne=h.useRef(null),ue=h.useRef([]),de=h.useRef("");function pe(){var R,O;try{(O=(R=Z.current)==null?void 0:R.getTracks)==null||O.call(R).forEach(ee=>{try{ee.stop()}catch{}})}catch{}Z.current=null}h.useEffect(()=>()=>{var R,O;try{(O=(R=ne.current)==null?void 0:R.stop)==null||O.call(R)}catch{}ne.current=null,pe()},[]);async function D(R,O){var G;if(t==null||t(""),!R||!R.size||Y)return;const ee=e.gateway,I=String(e.session_id||"").trim(),P=String(e.run_id||"").trim();if(!ee){t==null||t("Connect to the gateway first.");return}if(!I){t==null||t("Voice input unavailable (missing session_id).");return}if(!P){t==null||t("Voice input unavailable (missing run_id).");return}Q(!0);try{const $=String(O||R.type||"").toLowerCase(),K=$.includes("mp4")?"m4a":$.includes("ogg")?"ogg":$.includes("wav")?"wav":"webm",se=new File([R],`recording.${K}`,{type:$||"audio/webm"}),le=await ee.attachments_upload(I,se,{filename:se.name,content_type:se.type}),he=await ee.audio_transcribe(P,{audio_artifact:le,request_id:ss()}),be=String((he==null?void 0:he.text)||"").trim();be&&((G=e.on_transcript)==null||G.call(e,be))}catch($){t==null||t(String(($==null?void 0:$.message)||$||"Transcription failed"))}finally{Q(!1)}}async function E(){if(t==null||t(""),!o){t==null||t("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(!Y&&!(q||ne.current)){ue.current=[];try{const R=await navigator.mediaDevices.getUserMedia({audio:!0});Z.current=R;const O=lE();de.current=O;const ee=O?new MediaRecorder(R,{mimeType:O}):new MediaRecorder(R);ne.current=ee,ee.ondataavailable=I=>{try{I!=null&&I.data&&ue.current.push(I.data)}catch{}},ee.onerror=()=>{t==null||t("Recording failed.")},ee.onstop=()=>{z(!1),pe(),ne.current=null;try{const I=new Blob(ue.current,{type:de.current||""});D(I,de.current)}catch(I){t==null||t(String((I==null?void 0:I.message)||I||"Failed to build recording"))}},ee.start(),z(!0)}catch(R){pe(),ne.current=null,z(!1);const O=String((R==null?void 0:R.message)||R||"Failed to access microphone");t==null||t(O.toLowerCase().includes("permission")?`Microphone permission denied: ${O}`:O)}}}function j(){const R=ne.current;if(!(!q||!R)){ne.current=null,z(!1);try{R.stop()}catch(O){t==null||t(String((O==null?void 0:O.message)||O||"Failed to stop recording"))}}}return h.useEffect(()=>{if(!q)return;const R=()=>j();return window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R),()=>{window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R)}},[q]),{tts_supported:n,tts_playback:a,toggle_tts:W,stop_tts:L,voice_ptt_supported:o,voice_ptt_recording:q,voice_ptt_busy:Y,start_voice_ptt_recording:E,stop_voice_ptt_recording:j}}const cm=500,Rm="http://127.0.0.1:8080";function s_(e){const t=String(e||"").trim(),n=t.indexOf(":");return n<=0||n>=t.length-1?null:{bundle_id:t.slice(0,n),flow_id:t.slice(n+1)}}function $d(e){const t=String(e||"").trim();return t.startsWith("abstractcode.")?`abstract.${t.slice(13)}`:t}function i_(e){const t=e&&typeof e=="object"?e:{},n=typeof(t==null?void 0:t.count)=="number"&&Number.isFinite(t.count)?Number(t.count):null,o=typeof(t==null?void 0:t.node_id)=="string"&&t.node_id.trim()?` before ${t.node_id.trim()}`:"";return`${n===null?"steering":`${n} steer message${n===1?"":"s"}`} folded into the run${o} — the loop sees it at this boundary`}function o_(e){const t=String(e||"").trim();return t.startsWith("abstract.")||t.startsWith("abstractcode.")}function dE(e){const t=String(e||"").trim();if(t.startsWith("evt:")){const n=t.split(":",4);if(n.length===4&&n[3])return String(n[3]).trim()}return t}function fE(e){if(!e||typeof e!="object")return[];const t=Array.isArray(e.nodes)?e.nodes:[];if(!t.length)return[];let n=null;for(const u of t){if(!u||typeof u!="object")continue;const m=u.data&&typeof u.data=="object"?u.data:{};if(String(m.nodeType||u.type||"").trim()==="on_flow_start"){n=u;break}}if(!n)return[];const o=n.data&&typeof n.data=="object"?n.data:{},a=Array.isArray(o.outputs)?o.outputs:[],c=o.pinDefaults&&typeof o.pinDefaults=="object"?o.pinDefaults:{},d=[];for(const u of a){if(!u||typeof u!="object")continue;const m=String(u.id||"").trim();if(!m)continue;const y=String(u.type||"").trim();if(y==="execution"||m==="exec-out"||m==="exec")continue;const g=String(u.label||m).trim()||m,v={id:m,label:g,type:y||"unknown"};c&&Object.prototype.hasOwnProperty.call(c,m)&&(v.default=c[m]),d.push(v)}return d}function a_(e,t){const n=String((e==null?void 0:e.message)||e||"Discovery failed");if(/\b401\b/.test(n)){const o=String(t.gateway_user||"").trim();return o?`Gateway authentication failed for user '${o}'. Sign in again through the connection dialog. (${n})`:`Gateway authentication failed. Sign in through the connection dialog (or check the dev bearer token under Settings → Advanced). (${n})`}return n}const mE=/^[a-zA-Z0-9_-]+$/;function dy(e){return mE.test(String(e||"").trim())}async function hE(e){const t=String(e||""),n=new TextEncoder().encode(t),o=globalThis.crypto;if(!o||!o.subtle||typeof o.subtle.digest!="function")throw new Error("crypto.subtle.digest not available");const a=await o.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join("")}async function fy(e){const t=String(e||"").trim();if(!t)throw new Error("session_id is required");if(dy(t)){const o=`session_memory_${t}`;if(dy(o))return o}return`session_memory_sha_${(await hE(t)).slice(0,32)}`}const my=new Set(["abstract.status","abstract.summary","abstract.chat"]);function _E(e){if(!e)return!1;if(e.kind==="error")return!0;if(e.kind==="info")return!1;const t=String(e.emit_name||"").trim();if((e.kind==="event"||e.kind==="message")&&t)return!my.has(t);const n=String(e.effect_type||"").trim();if(n){if(n==="tool_calls"||n==="llm_call"||n==="ask_user"||n==="answer_user"||n==="memory_compact"||n==="start_subworkflow")return!0;if(n==="emit_event")return!(t&&my.has(t))}if(String(e.status||"").trim()==="waiting"){const c=Vi(e.data),d=String((c==null?void 0:c.reason)||"").trim();return!!(d==="user"||d==="event"||uu(c).length)}return!!Yd(e.data)}function pE(){try{const e=localStorage.getItem("abstractobserver_settings");if(!e)throw new Error("missing");const t=JSON.parse(e);return{gateway_url:String((t==null?void 0:t.gateway_url)||Rm),auth_token:"",gateway_user:String((t==null?void 0:t.gateway_user)||""),gateway_auth_mode:(t==null?void 0:t.gateway_auth_mode)==="direct"?"direct":"session",worker_url:String((t==null?void 0:t.worker_url)||""),worker_token:String((t==null?void 0:t.worker_token)||""),theme:String((t==null?void 0:t.theme)||"dark"),font_scale:String((t==null?void 0:t.font_scale)||(t==null?void 0:t.fontScale)||"md").trim()||"md",header_density:String((t==null?void 0:t.header_density)||(t==null?void 0:t.headerDensity)||"standard").trim()||"standard",auto_connect_gateway:(t==null?void 0:t.auto_connect_gateway)!==!1,maintenance_ai_provider:String((t==null?void 0:t.maintenance_ai_provider)||""),assistant_skill_names:Array.isArray(t==null?void 0:t.assistant_skill_names)?t.assistant_skill_names.map(n=>String(n||"").trim()).filter(Boolean):[],maintenance_ai_model:String((t==null?void 0:t.maintenance_ai_model)||"")}}catch{return{gateway_url:Rm,auth_token:"",gateway_user:"",gateway_auth_mode:"session",worker_url:"",worker_token:"",theme:"dark",font_scale:"md",header_density:"standard",auto_connect_gateway:!0,maintenance_ai_provider:"",assistant_skill_names:[],maintenance_ai_model:""}}}function gE(e){localStorage.setItem("abstractobserver_settings",JSON.stringify({...e,auth_token:""}))}function yE(e){if(!e||typeof e!="object"||Array.isArray(e))return[];const t=[],n=(a,c)=>{const d=String(c??"").trim();d&&(t.some(u=>u.label===a&&u.value===d)||t.push({label:a,value:d}))},o=String(e.display??"").trim().replace(/^\[/,"").replace(/\]$/,"");return n("time",o||e.local_datetime),n("tz",e.timezone),n("country",e.country),n("user",e.user),t}function hy(e){const t=yE(e.metadata);return t.length?s.jsx("div",{className:"runtime_metadata_chips","aria-label":"Runtime metadata",children:t.map(n=>s.jsxs("span",{className:"chip mono muted",children:[n.label,": ",n.value]},`${n.label}:${n.value}`))}):null}function _y(e){const t=String(e||"").trim();return t?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t):!1}function vE(){try{const t=String(window.location.hash||"").replace(/^#/,"").split("/").filter(Boolean),n=t.length?String(t[t.length-1]||"").trim():"";if(_y(n))return n;const a=String(window.location.pathname||"").split("/").filter(Boolean),c=a.length?String(a[a.length-1]||"").trim():"";if(_y(c))return c}catch{}return""}function xE(){try{const e="abstractobserver_session_id_v1",t=window.sessionStorage.getItem(e);if(t&&t.trim())return t.trim();const n=globalThis.crypto,a=`obs_${n&&typeof n.randomUUID=="function"?n.randomUUID():`${Math.random().toString(16).slice(2)}_${Date.now().toString(16)}`}`;return window.sessionStorage.setItem(e,a),a}catch{return""}}function wE(){var Yo,mi,Al,Fc,Wi,Tl,qi,Ll,Oa,Bc,Rl,Pl,br;const[e,t]=h.useState("board"),[n,o]=h.useState(()=>pE()),a=typeof window<"u"&&((Yo=window.__ABSTRACT_UI_CONFIG__)==null?void 0:Yo.monitor_gpu)===!0,c=typeof window<"u"&&(((mi=window.__ABSTRACT_UI_CONFIG__)==null?void 0:mi.entity_app_url)||"").trim().replace(/\/+$/,"")||"http://127.0.0.1:3007",d=h.useRef(null),[u,m]=h.useState(""),[y,g]=h.useState(""),[v,x]=h.useState(()=>vE()),[b,C]=h.useState(""),[S,L]=h.useState(""),[M,W]=h.useState("{}"),[q]=h.useState(()=>xE()),[z,Y]=h.useState(null),[Q,Z]=h.useState(!1),[ne,ue]=h.useState(""),[de,pe]=h.useState(!1),[D,E]=h.useState(""),[j,R]=h.useState(!1),O=f0({appName:"AbstractObserver",variant:"dismissable",defaultGatewayUrl:typeof window<"u"&&((Al=window.__ABSTRACT_UI_CONFIG__)==null?void 0:Al.gateway_url)||Rm,onStatusChange:_=>yr(_)}),[ee,I]=h.useState(null),[P,G]=h.useState(null),[$,K]=h.useState(!1),[se,le]=h.useState(null),[he,be]=h.useState([]),[je,Ee]=w0("abstractobserver",{legacyKey:"abstractobserver_settings"}),[Fe,Ye]=h.useState(!1),[Ke,Ct]=h.useState(!1),[wt,at]=h.useState([]),[yt,nt]=h.useState([]),[Ne,Oe]=h.useState([]),[st,ve]=h.useState(!1),[Ie,Ge]=h.useState(null),[At,Ft]=h.useState([]),[fn,Dt]=h.useState(0),[Tt,mn]=h.useState(""),Vn=h.useRef(!1),jt=h.useRef(0),hn=h.useRef(0),[Un,Nn]=h.useState(!1),[yn,Cn]=h.useState([]),[Qt,ar]=h.useState([]),[_n,Hn]=h.useState({}),[vn,Pn]=h.useState(!1),[te,ge]=h.useState(!1),[Te,qe]=h.useState(!1),[He,it]=h.useState([]),[pt,vt]=h.useState([]),Rt=h.useRef(0),lt=h.useRef(null);lt.current||(lt.current=new rg(_=>window.setTimeout(_,40),_=>it(k=>k.concat(_))));const Pt=h.useRef(null);Pt.current||(Pt.current=new rg(_=>window.setTimeout(_,40),_=>vt(k=>k.concat(_))));const Vt=h.useRef({scanned:0,found:null}),[ce,kt]=h.useState(null),[Lt,Ve]=h.useState(""),[nn,pn]=h.useState(""),[cn,gn]=h.useState(!1),[er,Vr]=h.useState(!1),Nr=h.useRef(null),[Gr,Gs]=h.useState({}),[$s,vi]=h.useState({}),[Ys,Or]=h.useState("now"),[an,ra]=h.useState(""),[Yr,Ms]=h.useState("once"),[As,Ks]=h.useState(1),[rt,rn]=h.useState("days"),[Cr,xi]=h.useState(2),[_r,sa]=h.useState(""),[Ja,Za]=h.useState("23:59"),[Wn,as]=h.useState(!0),[Gn,Xs]=h.useState(!1),[ia,In]=h.useState(""),[ls,Yn]=h.useState(!0),[cs,Fn]=h.useState(""),[us,Js]=h.useState(!1),[Yt,go]=h.useState(!1),[oa,aa]=h.useState(6),[zr,Qa]=h.useState("standard"),[Zs,yo]=h.useState(""),[wi,tr]=h.useState(""),[nr,Er]=h.useState(!1),[bi,ds]=h.useState(!1),[Ir,fs]=h.useState("pause"),[el,ms]=h.useState(""),[Xl,Qs]=h.useState(""),[Zi,la]=h.useState(""),Si=h.useRef(null),hs=h.useRef(null),[vo,ei]=h.useState(!1),pr=h.useRef(null),[fu,Ts]=h.useState(""),[xo,F]=h.useState(""),[ae,we]=h.useState(""),[ke,$e]=h.useState(""),[We,dt]=h.useState(""),[tt,ct]=h.useState(!1),[Ot,Gt]=h.useState("idle"),[Kt,Et]=h.useState([]),en=h.useRef(null),[En,un]=h.useState(!1),[Dr,Kn]=h.useState(""),[ji,ki]=h.useState(""),[wo,bo]=h.useState(""),[mu,So]=h.useState([]),[tl,Jl]=h.useState(!1),[Zd,Zl]=h.useState(""),[hu,nl]=h.useState(""),[Ql,ec]=h.useState(!1),[Qd,jo]=h.useState(""),tc=h.useMemo(()=>{if(!Kt.length)return"";try{return JSON.stringify(Kt.map(_=>({role:_.role,content:_.content,ts:_.ts})))}catch{return"1"}},[Kt]),_u=h.useMemo(()=>Kt.length?wo?tc!==wo:!0:!1,[tc,Kt.length,wo]),pu=h.useMemo(()=>mu.map(_=>{const k=String(_.title||"").trim()||`Chat ${String(_.thread_id||"").slice(0,8)}`,N=String(_.created_at||"").trim(),T=N?N.replace("T"," ").slice(0,19):"",B=String(_.run_id||"").trim()?String(_.run_id).slice(0,8):"",H=[k,T&&`(${T})`,B&&`run ${B}`].filter(Boolean).join(" • ");return{value:String(_.thread_id||""),label:H}}),[mu]);h.useEffect(()=>{a&&sb()},[a]),h.useEffect(()=>{if(!a)return;const _=d.current;_&&(_.token=n.gateway_auth_mode==="direct"&&n.auth_token||"")},[a,n.auth_token,n.gateway_auth_mode]);const[gu,nc]=h.useState([]),[Vm,yu]=h.useState({}),[Gm,ef]=h.useState({}),[vu,Ht]=h.useState(""),[xu,wu]=h.useState(""),[Ls,Ym]=h.useState("all"),[rl,tf]=h.useState("status"),[rr,Rs]=h.useState("overview"),[ca,ua]=h.useState(!0),[sl,bu]=h.useState("steps"),[Km,Su]=h.useState(""),[rc,ko]=h.useState(""),[da,sc]=h.useState([]),[il,nf]=h.useState(!1),[rf,fa]=h.useState(""),[ic,oc]=h.useState(""),[sf,ac]=h.useState([]),[Xm,of]=h.useState(!1),[Jm,ju]=h.useState(""),[Zm,Kr]=h.useState(!1),[ol,af]=h.useState(""),[lf,No]=h.useState(""),[ku,ma]=h.useState(""),[Qm,lc]=h.useState(!1),[Ps,Co]=h.useState(""),[ti,Eo]=h.useState(null),[al,ha]=h.useState({}),[$o,Mo]=h.useState(!1),[Nu,Qi]=h.useState(""),[ll,cf]=h.useState(!1),[Cu,uf]=h.useState(!1),[df,cl]=h.useState(()=>Date.now()),[gr,eo]=h.useState(""),[Eu,cc]=h.useState({}),[eh,Ao]=h.useState({}),ul=h.useRef([]),Xr=h.useRef(null),Ni=h.useRef(""),dn=h.useRef({}),Ci=h.useRef({}),_a=h.useRef({}),Ei=h.useRef(new Set),[ni,pa]=h.useState([]),$i=h.useRef(""),Mi=h.useRef({}),Jr=h.useRef(null),$r=h.useRef(null),To=h.useRef(0),ga=h.useRef({}),dl=h.useRef(!1),ri=h.useRef(new Set),[ya,va]=h.useState(""),[_s,si]=h.useState(""),ps=h.useRef(""),[ff,uc]=h.useState(!1),[th,dc]=h.useState(""),fc=()=>({artifact_id:"",kind:"binary",render_kind:"",text:"",url:"",loading:!1,error:""}),[gs,$u]=h.useState("activity"),[to,Os]=h.useState([]),[xa,ii]=h.useState(0),[Mu,mf]=h.useState(0),[nh,no]=h.useState({}),[fl,Lo]=h.useState({}),[mc,hc]=h.useState(!1),[wa,Ai]=h.useState(""),[ln,xn]=h.useState(""),[ys,sr]=h.useState("all"),[lr,ro]=h.useState(""),[zs,Fr]=h.useState([]),[Ro,hf]=h.useState("all"),[Po,_c]=h.useState("type"),[ml,Ti]=h.useState("newest"),[Is,pc]=h.useState(""),[ba,hl]=h.useState(""),[Li,so]=h.useState(""),[oi,Sa]=h.useState(0),[Ri,Br]=h.useState(()=>fc()),[vs,ai]=h.useState(!1),[li,Pi]=h.useState(""),[Oo,io]=h.useState(""),[cr,ja]=h.useState(""),[Mr,Zr]=h.useState("text"),[$n,Ur]=h.useState(null),[_f,ka]=h.useState(!1),[gc,zo]=h.useState(""),[Au,_l]=h.useState(""),[pf,Io]=h.useState(""),[yc,gf]=h.useState(!1),[pl,gl]=h.useState(""),[yl,yf]=h.useState("run_ledger"),[Na,vf]=h.useState(""),[vc,Ca]=h.useState([]),[Ea,vl]=h.useState(""),[Tu,xc]=h.useState(!1),[Lu,oo]=h.useState(""),Pe=h.useMemo(()=>new Rh({base_url:n.gateway_auth_mode==="session"?"":n.gateway_url,auth_token:n.gateway_auth_mode==="session"?"":n.auth_token}),[n.gateway_auth_mode,n.gateway_url,n.auth_token]),ci=h.useMemo(()=>n.worker_url.trim()?new sS({url:n.worker_url.trim(),auth_token:n.worker_token}):null,[n.worker_url,n.worker_token]),ur=He.length?He[He.length-1].record:null,Xt=h.useMemo(()=>Vi(ur),[ur]),Mn=h.useMemo(()=>{const _=S.trim();if(!z||!_||String(z.bundle_id||"").trim()&&String(z.bundle_id||"").trim()!==_)return null;const k=Array.isArray(z.entrypoints)?z.entrypoints:[];if(!k.length)return null;const N=b.trim();if(N)return k.find(B=>String(B.flow_id||"").trim()===N)||null;if(k.length===1)return k[0];const T=String(z.default_entrypoint||"").trim();return T&&k.find(B=>String(B.flow_id||"").trim()===T)||null},[z,S,b]),ui=h.useMemo(()=>{const _=Mn==null?void 0:Mn.inputs;return Array.isArray(_)?_:[]},[Mn]),wc=h.useMemo(()=>fE(ti),[ti]),Do=h.useMemo(()=>ui.length?ui:wc,[ui,wc]),di=h.useMemo(()=>{const _=typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):"",k=s_(_);if(k&&z&&String(z.bundle_id||"").trim()===k.bundle_id){const B=(Array.isArray(z.entrypoints)?z.entrypoints:[]).find(H=>String((H==null?void 0:H.flow_id)||"").trim()===k.flow_id);if(B&&B.node_index&&typeof B.node_index=="object")return B.node_index}const N=Mn==null?void 0:Mn.node_index;return N&&typeof N=="object"?N:{}},[ce,z,Mn]);h.useEffect(()=>{gE(n)},[n]),h.useEffect(()=>()=>{Jr.current&&Jr.current.abort(),$r.current&&$r.current.abort(),Si.current&&window.clearTimeout(Si.current),hs.current&&window.clearTimeout(hs.current),Xr.current&&window.clearTimeout(Xr.current),pr.current&&window.clearTimeout(pr.current)},[]);const ft=h.useMemo(()=>{const _=M.trim();if(!_)return{};try{const k=JSON.parse(_);return typeof k!="object"||k===null||Array.isArray(k)?null:k}catch{return null}},[M]),bc=typeof(ft==null?void 0:ft.prompt)=="string"?String(ft.prompt):"",Sc=typeof(ft==null?void 0:ft.provider)=="string"?String(ft.provider):"",jc=typeof(ft==null?void 0:ft.model)=="string"?String(ft.model):"",xf=typeof(ft==null?void 0:ft.workspace_root)=="string"?String(ft.workspace_root):"",$a=typeof(ft==null?void 0:ft.workspace_access_mode)=="string"?String(ft.workspace_access_mode):"",fi=h.useMemo(()=>{const _=ft==null?void 0:ft.workspace_allowed_paths;return Array.isArray(_)?_.map(k=>String(k||"").trim()).filter(Boolean).join(`
131
+ `):typeof _=="string"?String(_):""},[ft]),xl=h.useMemo(()=>{const _=ft==null?void 0:ft.workspace_ignored_paths;return Array.isArray(_)?_.map(k=>String(k||"").trim()).filter(Boolean).join(`
132
+ `):typeof _=="string"?String(_):""},[ft]),wl=Do.length>0&&!!S.trim(),Oi=_=>{const k=String(_||"").trim().toLowerCase();return k==="object"||k==="memory"||k==="assertion"||k==="assertions"||k==="any"};h.useEffect(()=>{vi({})},[S,b]),h.useEffect(()=>{ft!==null&&Gs(_=>{const k={};for(const N of Do){if(!N||typeof N!="object")continue;const T=String(N.id||"").trim();if(!T)continue;const B=String(N.type||"").trim();if(!Oi(B))continue;if(String($s[T]||"").trim()){k[T]=typeof _[T]=="string"?_[T]:"";continue}const V=ft==null?void 0:ft[T];V===void 0?k[T]="":k[T]=ib(V)}return k})},[Do,ft,$s]);const Ru=S.trim()&&b.trim()?`${S.trim()}:${b.trim()}`:"",dr=h.useMemo(()=>{const _={};for(const k of wt){const N=String(k.workflow_id||"").trim(),T=String(k.label||"").trim();N&&T&&(_[N]=T)}return _},[wt]),kc=h.useMemo(()=>wt.filter(_=>_.has_interface),[wt]),Pu=h.useMemo(()=>{const _=new Set;for(const k of Array.isArray(Qt)?Qt:[]){const N=String((k==null?void 0:k.name)||"").trim();N&&_.add(N)}return Array.from(_).sort()},[Qt]),On=h.useMemo(()=>{const _=[];for(const k of Array.isArray(Qt)?Qt:[]){const N=String((k==null?void 0:k.name)||"").trim();if(!N)continue;const T=String((k==null?void 0:k.display_name)||"").trim();_.push({name:N,display_name:T||void 0})}return _},[Qt]),Nc=h.useMemo(()=>{const _=new Set;for(const k of yn||[]){if(!k||typeof k!="object")continue;const N=String(k.name||"").trim();N&&_.add(N)}return Array.from(_).sort()},[yn]),Cc=h.useMemo(()=>{const _=n.maintenance_ai_provider.trim();if(!_)return{models:[],error:""};const k=_n[_];return k?{models:(Array.isArray(k.models)?k.models:[]).map(T=>String(T||"").trim()).filter(Boolean),error:String(k.error||"")}:{models:[],error:""}},[_n,n.maintenance_ai_provider]),bl=n.maintenance_ai_provider.trim(),Ec=!!(bl&&j&&!Object.prototype.hasOwnProperty.call(_n,bl));h.useEffect(()=>{const _=Sc.trim();if(!_||_n[_]||Mi.current[_])return;Mi.current[_]=!0;let k=!1;return(async()=>{try{const T=await Pe.discovery_provider_models(_);if(k)return;const B=Array.isArray(T==null?void 0:T.models)?T.models:[],H=typeof(T==null?void 0:T.error)=="string"?String(T.error):"";Hn(V=>({...V,[_]:{models:B,error:H||void 0}}))}catch(T){if(k)return;Hn(B=>({...B,[_]:{models:[],error:String((T==null?void 0:T.message)||T||"Failed to load models")}}))}finally{delete Mi.current[_]}})(),()=>{k=!0}},[Sc,_n,Pe]),h.useEffect(()=>{const _=n.maintenance_ai_provider.trim();if(!_||!j||_n[_]||Mi.current[_])return;Mi.current[_]=!0;let k=!1;return(async()=>{try{const T=await Pe.discovery_provider_models(_);if(k)return;const B=Array.isArray(T==null?void 0:T.models)?T.models:[],H=typeof(T==null?void 0:T.error)=="string"?String(T.error):"";Hn(V=>({...V,[_]:{models:B,error:H||void 0}}))}catch(T){if(k)return;Hn(B=>({...B,[_]:{models:[],error:String((T==null?void 0:T.message)||T||"Failed to load models")}}))}finally{delete Mi.current[_]}})(),()=>{k=!0}},[n.maintenance_ai_provider,_n,Pe,j]);function jn(_,k){const N=String(_||"").trim();if(!N)return;let T={};try{const B=JSON.parse(M||"{}");typeof B=="object"&&B!==null&&!Array.isArray(B)&&(T=B)}catch{T={}}if(k==null){delete T[N],W(JSON.stringify(T,null,2));return}if(typeof k=="string")k?T[N]=k:delete T[N];else if(Array.isArray(k)){const B=k.map(H=>H).filter(H=>H!=null);B.length?T[N]=B:delete T[N]}else T[N]=k;W(JSON.stringify(T,null,2))}async function ao(_){const k=String(_||"").trim();if(!k)return ue("Missing bundle_id"),null;ue(""),Z(!0);try{const N=await Pe.get_bundle(k);return Y(N),Wt({ts:Nt(),kind:"info",title:`Loaded bundle ${k}`}),N}catch(N){return Y(null),ue(String((N==null?void 0:N.message)||N||"Failed to load bundle")),null}finally{Z(!1)}}function kn(_){const k=[],N=Array.isArray(_==null?void 0:_.items)?_.items:[];for(const T of N){const B=String((T==null?void 0:T.bundle_id)||"").trim();if(!B)continue;const H=Array.isArray(T==null?void 0:T.entrypoints)?T.entrypoints:[];if(H.length)for(const V of H){const X=String((V==null?void 0:V.flow_id)||"").trim();if(!X||(V==null?void 0:V.deprecated)===!0)continue;const Se=`${B}:${X}`,ie=String((V==null?void 0:V.name)||"").trim(),U=ie?`${B} · ${ie}`:`${B} · ${X}`,xe=String((V==null?void 0:V.description)||"").trim(),Re=(Array.isArray(V==null?void 0:V.interfaces)?V.interfaces:[]).some(ze=>String(ze||"").trim().length>0);k.push({workflow_id:Se,bundle_id:B,flow_id:X,label:U,description:xe||void 0,has_interface:Re})}}return k.sort((T,B)=>T.label.localeCompare(B.label)),k}async function Jt(_=Pe,k){if(Vn.current&&!(k!=null&&k.force))return;Vn.current=!0;const N=zi.current;ve(!0);try{const T=ie=>ie.map(U=>{var xe,Ce,Re,ze,Ue,$t;return{run_id:String((U==null?void 0:U.run_id)||"").trim(),workflow_id:typeof(U==null?void 0:U.workflow_id)=="string"?String(U.workflow_id):(U==null?void 0:U.workflow_id)??null,status:typeof(U==null?void 0:U.status)=="string"?String(U.status):"",created_at:typeof(U==null?void 0:U.created_at)=="string"?String(U.created_at):(U==null?void 0:U.created_at)??null,updated_at:typeof(U==null?void 0:U.updated_at)=="string"?String(U.updated_at):(U==null?void 0:U.updated_at)??null,ledger_len:typeof(U==null?void 0:U.ledger_len)=="number"?Number(U.ledger_len):(U==null?void 0:U.ledger_len)??null,parent_run_id:typeof(U==null?void 0:U.parent_run_id)=="string"?String(U.parent_run_id):(U==null?void 0:U.parent_run_id)??null,session_id:typeof(U==null?void 0:U.session_id)=="string"?String(U.session_id):(U==null?void 0:U.session_id)??null,is_scheduled:typeof(U==null?void 0:U.is_scheduled)=="boolean"?!!U.is_scheduled:(U==null?void 0:U.is_scheduled)??null,paused:typeof(U==null?void 0:U.paused)=="boolean"?!!U.paused:(U==null?void 0:U.paused)??null,waiting_reason:typeof((xe=U==null?void 0:U.waiting)==null?void 0:xe.reason)=="string"?String(U.waiting.reason):((Ce=U==null?void 0:U.waiting)==null?void 0:Ce.reason)??null,schedule_interval:typeof((Re=U==null?void 0:U.schedule)==null?void 0:Re.interval)=="string"?String(U.schedule.interval).trim():((ze=U==null?void 0:U.schedule)==null?void 0:ze.interval)??null,schedule_target_workflow_id:typeof((Ue=U==null?void 0:U.schedule)==null?void 0:Ue.target_workflow_id)=="string"?String(U.schedule.target_workflow_id).trim():(($t=U==null?void 0:U.schedule)==null?void 0:$t.target_workflow_id)??null,current_node:typeof(U==null?void 0:U.current_node)=="string"?String(U.current_node).trim():(U==null?void 0:U.current_node)??null,llm_calls:typeof(U==null?void 0:U.llm_calls)=="number"?Number(U.llm_calls):(U==null?void 0:U.llm_calls)??null,tool_calls:typeof(U==null?void 0:U.tool_calls)=="number"?Number(U.tool_calls):(U==null?void 0:U.tool_calls)??null,tokens_total:typeof(U==null?void 0:U.tokens_total)=="number"?Number(U.tokens_total):(U==null?void 0:U.tokens_total)??null,error:(U==null?void 0:U.error)??null,waiting:(U==null?void 0:U.waiting)??null}}).filter(U=>!!U.run_id),[B,H]=await Promise.all([_.list_runs({limit:200,root_only:!0,include_metrics:!0}),_.list_runs({limit:500,root_only:!1,include_metrics:!0})]);if(N!==zi.current)return;const V=Array.isArray(B==null?void 0:B.items)?B.items:[],X=Array.isArray(H==null?void 0:H.items)?H.items:[],Se=T(V).filter(ie=>!String(ie.parent_run_id||"").trim());nt(Se),Oe(T(X).filter(ie=>!!ie.run_id)),Ge(Date.now()),hn.current=0,jt.current=0}catch(T){const B=String((T==null?void 0:T.message)||T||"");if(Wt({ts:Nt(),kind:"error",title:"Refresh runs failed",preview:_t(B)}),(/\b40[13]\b/.test(B)||/unauthorized|forbidden/i.test(B))&&O.refresh().catch(()=>{}),/\b429\b/.test(B)||/too many requests/i.test(B)){const H=Math.min(12e4,Math.max(15e3,hn.current*2||15e3));hn.current=H,jt.current=Date.now()+H,Wt({ts:Nt(),kind:"info",title:`Gateway rate-limited — pausing polls ${Math.round(H/1e3)}s`})}}finally{Vn.current=!1,ve(!1)}}async function Xn(_){var V,X;const k=zi.current;R(!0),Hn({});const[N,,T,B]=await Promise.allSettled([_.list_bundles(),Jt(_),_.discovery_tools(),_.discovery_providers({include_models:!1})]);if(k!==zi.current)return;if(N.status==="rejected"&&T.status==="rejected"&&B.status==="rejected"){R(!1),E(a_(N.reason,n)),Wt({ts:Nt(),kind:"error",title:"Discovery failed",preview:_t(String(N.reason||""))});return}let H=0;if(N.status==="fulfilled"){const Se=kn(N.value);H=Se.length,at(Se)}else at([]),Wt({ts:Nt(),kind:"error",title:"Discovery bundles failed",preview:_t(String(N.reason||""))});if(T.status==="fulfilled"){const Se=Array.isArray((V=T.value)==null?void 0:V.items)?T.value.items:[];Cn(Se)}else Cn([]),Wt({ts:Nt(),kind:"error",title:"Discovery tools failed",preview:_t(String(T.reason||""))});if(B.status==="fulfilled"){const Se=Array.isArray((X=B.value)==null?void 0:X.items)?B.value.items:[];ar(Se)}else ar([]),Wt({ts:Nt(),kind:"error",title:"Discovery providers failed",preview:_t(String(B.reason||""))});Wt({ts:Nt(),kind:"info",title:"Gateway discovery loaded",preview:_t(`workflows: ${H}`)})}async function lo(_){var k,N;E(""),R(!1),pe(!0);try{if(!(_!=null&&_.prefer_direct)&&(await O.refresh(),Fo.current))return;const T=String(n.auth_token||"").trim();if(!T){_!=null&&_.open_modal_if_needed&&O.openModal();return}const B=String(n.gateway_url||"").trim();if(B){const V=B.toLowerCase();if(!V.startsWith("http://")&&!V.startsWith("https://"))throw new Error("Gateway URL must start with http:// or https:// (or leave it blank to use same origin / dev proxy).");try{if(String(((k=window==null?void 0:window.location)==null?void 0:k.protocol)||"")==="https:"&&V.startsWith("http://"))throw new Error("Gateway URL is http:// but this page is https:// (mixed content is blocked). Use https:// or leave Gateway URL blank to use same origin /api proxy.");const Se=new URL(B),ie=String(((N=window==null?void 0:window.location)==null?void 0:N.hostname)||"").trim().toLowerCase(),U=String(Se.hostname||"").trim().toLowerCase(),xe=Ce=>Ce==="localhost"||Ce==="127.0.0.1"||Ce==="::1";if(xe(U)&&ie&&!xe(ie))throw new Error("Gateway URL points to localhost, which from this device is not your machine. Use the gateway's public URL (e.g. an ngrok https URL) or leave Gateway URL blank to use same origin /api proxy.")}catch(X){throw new Error(String((X==null?void 0:X.message)||X||"Invalid Gateway URL"))}}const H=new Rh({base_url:B,auth_token:T});await H.list_bundles(),o(V=>({...V,gateway_auth_mode:"direct"})),await Xn(H)}catch(T){E(a_(T,n))}finally{pe(!1)}}const Fo=h.useRef(!1),zi=h.useRef(0),Ou=h.useRef(!1);function yr(_){var N,T,B;I(_);const k=!!(_&&_.has_session&&((N=_.gateway)!=null&&N.ok));if(Fo.current=k,k){if(Ou.current=!1,j&&n.gateway_auth_mode==="direct")return;const H=String(((B=(T=_==null?void 0:_.gateway)==null?void 0:T.principal)==null?void 0:B.user_id)||"").trim();if(o(V=>({...V,gateway_auth_mode:"session",auth_token:"",gateway_user:H||V.gateway_user})),j&&n.gateway_auth_mode==="session")return;E(""),pe(!0),Xn(new Rh({base_url:"",auth_token:""})).catch(V=>E(a_(V,n))).finally(()=>pe(!1));return}_&&!_.has_session&&(n.gateway_auth_mode==="session"&&Sl({keep_session:!0}),String(n.auth_token||"").trim()&&!j&&!Ou.current&&(Ou.current=!0,lo({prefer_direct:!0})))}async function zu(){if(!(Un||de)){Nn(!0);try{await Pe.reload_bundles();const _=await Pe.list_bundles(),k=kn(_);at(k),Wt({ts:Nt(),kind:"info",title:"Bundles reloaded",preview:_t(`workflows: ${k.length}`)})}catch(_){const k=String((_==null?void 0:_.message)||_||"Bundle reload failed");Wt({ts:Nt(),kind:"error",title:"Bundle reload failed",preview:_t(k),data:{error:k}})}finally{Nn(!1)}}}async function Iu(_){if(er||de||!j)return;const k=_;if(k){Vr(!0),Ht("");try{const N=await Pe.upload_bundle(k,{overwrite:!1,reload:!0});Wt({ts:Nt(),kind:"info",title:"Bundle uploaded",preview:_t(String((N==null?void 0:N.bundle_ref)||""))});const T=await Pe.list_bundles(),B=kn(T);at(B)}catch(N){const T=String((N==null?void 0:N.message)||N||"Upload failed");Ht(T),Wt({ts:Nt(),kind:"error",title:"Upload .flow failed",preview:_t(T),data:{error:T}})}finally{Vr(!1);try{Nr.current&&(Nr.current.value="")}catch{}}}}function Sl(_){zi.current+=1,_!=null&&_.keep_session||(O.signOut().catch(()=>{}),Fo.current=!1),Ef(),L(""),C(""),Co(""),Y(null),ue(""),Z(!1),at([]),nt([]),Oe([]),Ge(null),Ft([]),Cn([]),ar([]),Hn({}),E(""),R(!1),I(null),o(k=>({...k,auth_token:""})),Wt({ts:Nt(),kind:"info",title:"Gateway disconnected"})}async function xs(_){const k=String(_??"");if(k){try{await navigator.clipboard.writeText(k),An("Copied to clipboard",2);return}catch{}try{const N=document.createElement("textarea");N.value=k,N.style.position="fixed",N.style.left="-9999px",N.style.top="0",N.style.opacity="0",document.body.appendChild(N),N.focus(),N.select(),document.execCommand("copy"),document.body.removeChild(N),An("Copied to clipboard",2)}catch{An("Copy failed",2)}}}h.useEffect(()=>{const _=u.trim();if(!vn||!_)return;let k=!1;const N=async()=>{if(!(jt.current>Date.now()))try{const B=await Pe.get_run(_);k||kt(B)}catch{}};N();const T=window.setInterval(N,2e3);return()=>{k=!0,window.clearInterval(T)}},[vn,u,Pe]),h.useEffect(()=>{if(!j)return;let _=null,k=!1,N=!1;const T=V=>{k||(_!==null&&window.clearTimeout(_),_=window.setTimeout(()=>void B(),V))},B=async()=>{if(N)return;const V=jt.current-Date.now();if(V>0){T(V+500);return}N=!0;const X=Date.now();try{await Jt(Pe)}finally{N=!1;const Se=Date.now()-X,ie=document.visibilityState==="hidden"?3e4:5e3;T(Math.max(ie,Se*3))}},H=()=>{document.visibilityState==="visible"&&B()};return B(),document.addEventListener("visibilitychange",H),()=>{k=!0,_!==null&&window.clearTimeout(_),document.removeEventListener("visibilitychange",H)}},[j,Pe]);const[ws,Bo]=h.useState(null);h.useEffect(()=>{if(!j){Bo(null);return}let _=!1;return(async()=>{try{const k=await Pe.get_entity_phases_spec();if(_)return;const N=JC(k);if(Bo(N),N)try{const T=localStorage.getItem("abstractobserver_phase_graph_id_v1"),B=T?JSON.parse(T):null;B&&B.sha256&&N.sha256&&B.sha256!==N.sha256&&B.version===N.version&&Wt({ts:Nt(),kind:"error",title:"Phase-graph drift: served bytes changed without a version bump",preview:_t(`v${N.version}: ${String(B.sha256).slice(0,12)}… -> ${String(N.sha256).slice(0,12)}…`),data:{prev:B,now:{sha256:N.sha256,version:N.version}}}),localStorage.setItem("abstractobserver_phase_graph_id_v1",JSON.stringify({sha256:N.sha256,version:N.version}))}catch{}}catch(k){if(!_){Bo(null);const N=String((k==null?void 0:k.message)||k||"");/404|not found/i.test(N)||Wt({ts:Nt(),kind:"info",title:"Phase-graph fetch failed — pre-wire fallback vocabulary in use (#FALLBACK)",preview:_t(N),data:{error:N}})}}})(),()=>{_=!0}},[j]),h.useEffect(()=>{if(!j){Ft([]),mn("");return}let _=!1,k=null;const N=async()=>{if(!(jt.current>Date.now())){try{const T=await Pe.list_entities(),B=T.entities.map(V=>String((V==null?void 0:V.name)||(V==null?void 0:V.slug)||"").trim()).filter(Boolean).slice(0,12),H=await Promise.all(B.map(async V=>{var X,Se;try{const[ie,U]=await Promise.all([Pe.get_entity_card(V),Pe.get_entity_cognition(V).catch(()=>null)]),xe=ie!=null&&ie.state&&typeof ie.state=="object"?ie.state:null,Ce=Array.isArray(ie==null?void 0:ie.moments)?ie.moments:[],Re=Ce.length?Ce[Ce.length-1]:null,ze=(X=U==null?void 0:U.spend)==null?void 0:X.lifetime,Ue=(Se=U==null?void 0:U.spend)==null?void 0:Se.live_visit,$t=Array.isArray(U==null?void 0:U.warnings)?U.warnings.map(Be=>String(Be||"")).filter(Boolean):[],bt=DC(ie);return{name:V,state:String((xe==null?void 0:xe.state)??(typeof(ie==null?void 0:ie.state)=="string"?ie.state:"")).trim(),age_days:typeof(ie==null?void 0:ie.age_days)=="number"?ie.age_days:null,last_moment:String((Re==null?void 0:Re.kind)||"").trim(),last_moment_at:String((Re==null?void 0:Re.at)||"").trim(),working:typeof(U==null?void 0:U.working)=="boolean"?U.working:null,tokens_total:typeof(ze==null?void 0:ze.tokens_total)=="number"?ze.tokens_total:null,live_visit_tokens:typeof(Ue==null?void 0:Ue.tokens_total)=="number"?Ue.tokens_total:null,spend_warning:$t.join(" | "),live_phase:typeof(U==null?void 0:U.phase)=="string"?U.phase:"",open_questions:bt.questions,open_questions_total:bt.questions_total,open_problems:bt.problems,open_problems_total:bt.problems_total,lessons:bt.lessons,lessons_total:bt.lessons_total,dreams_brief:IC(ie),error:""}}catch(ie){return{name:V,state:"",age_days:null,last_moment:"",last_moment_at:"",working:null,tokens_total:null,live_visit_tokens:null,spend_warning:"",live_phase:"",open_questions:[],open_questions_total:0,open_problems:[],open_problems_total:0,lessons:[],lessons_total:0,dreams_brief:null,error:String((ie==null?void 0:ie.message)||ie||"card failed")}}}));_||(Ft(H),Dt(T.entities.length),mn(""))}catch(T){if(!_){Ft([]);const B=String((T==null?void 0:T.message)||T||"");mn(/404|not found/i.test(B)?"":B)}}_||(k=window.setTimeout(()=>void N(),3e4))}};return N(),()=>{_=!0,k!==null&&window.clearTimeout(k)}},[j,Pe]);async function Du(_,k,N){const T=String(k||"").trim();if(!_||!T)throw new Error("This wait has no wait_key yet — open the run to inspect.");await Pe.submit_command({command_id:ss(),run_id:_,type:"resume",payload:{wait_key:T,payload:N||{}},client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:"Board resume submitted",preview:_t(`run ${_} · wait ${T}`),data:{run_id:_,wait_key:T}}),Jt(Pe,{force:!0}),window.setTimeout(()=>void Jt(Pe,{force:!0}),1200)}const Qr=h.useMemo(()=>{const _=ce==null?void 0:ce.session_id;return typeof _=="string"?_.trim():_==null?"":String(_||"").trim()},[ce]),Uo=h.useMemo(()=>{const _=String(Qr||"").trim();return _||String(q||"").trim()},[Qr,q]);h.useEffect(()=>{if(!j||!Uo){dt(""),$e("");return}(async()=>{try{const _=await fy(Uo);dt(_)}catch{dt("")}})()},[j,Uo]);const Bn=uE({gateway:j?Pe:null,session_id:Uo,run_id:We,on_error:$e,on_transcript:_=>{const k=String(_||"").trim();k&&(F(N=>{const T=String(N||"");return T.trim()?`${T.trimEnd()}
133
+ ${k}`:k}),window.setTimeout(()=>{var N;return(N=en.current)==null?void 0:N.focus()},0))}});function Fu(_,k){try{const N=URL.createObjectURL(_),T=document.createElement("a");T.href=N,T.download=k||"download",T.rel="noreferrer",document.body.appendChild(T),T.click(),document.body.removeChild(T),window.setTimeout(()=>URL.revokeObjectURL(N),5e3)}catch{}}async function Bu(){if(!il){if(!j||!Qr){ko(""),sc([]),fa("");return}nf(!0),fa("");try{const _=await fy(Qr);ko(_);const k=await Pe.list_run_artifacts(_,{limit:800}),T=(Array.isArray(k==null?void 0:k.items)?k.items:[]).filter(B=>{const H=B==null?void 0:B.tags;return H&&typeof H=="object"&&String(H.kind||"").trim()==="attachment"});sc(T)}catch(_){const k=String((_==null?void 0:_.message)||_||"Failed to load session attachments"),N=k.toLowerCase();k.includes("404")||N.includes("session_memory_")&&N.includes("not found")||N.includes('"detail"')&&N.includes("not found")&&N.includes("session_memory_")?(sc([]),fa("")):(sc([]),fa(k)),ko("")}finally{nf(!1)}}}async function wf(){const _=ic.trim();if(!_){An("This run recorded no workspace folder",2);return}try{const k=await fetch("/api/local/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:_})}),N=await k.json().catch(()=>({}));k.ok&&(N!=null&&N.ok)?An(`Opened ${String(N.path||_)}`,2):An(String((N==null?void 0:N.error)||`Folder reveal failed (${k.status})`),3)}catch(k){An(String((k==null?void 0:k.message)||k||"Folder reveal failed"),3)}}async function bf(_){const k=String(rc||"").trim();if(!k){An("No session attachment store yet",2);return}const N=String((_==null?void 0:_.artifact_id)||"").trim();if(!N)return;const T=_!=null&&_.tags&&typeof _.tags=="object"?_.tags:{},B=String(T.filename||"").trim(),H=String(T.path||"").trim(),V=B||(H?H.split("/").pop():"")||N,X=Ah(V);try{const Se=await Pe.download_run_artifact_content(k,N,{access:"download"});Fu(Se,X),An("Downloaded attachment",2)}catch(Se){An(String((Se==null?void 0:Se.message)||Se||"Download failed"),3)}}async function Sf(_){const k=String(rc||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N)return;const T=_!=null&&_.tags&&typeof _.tags=="object"?_.tags:{},B=String(T.filename||"").trim(),H=String(T.path||"").trim(),V=H?`@${H}`:B||N,X=typeof(_==null?void 0:_.size_bytes)=="number"?Number(_.size_bytes):null,Se=String((_==null?void 0:_.content_type)||T.content_type||"").trim().toLowerCase();if(af(V),No(""),ma(""),Kr(!0),typeof X=="number"&&X>1e6){No(`(Attachment is ${X.toLocaleString()} bytes; download to view.)`);return}if(!(!Se||Se.startsWith("text/")||Se.includes("json")||Se.includes("yaml")||Se.includes("toml")||Se.includes("xml"))){No(`(Binary attachment: ${Se||"unknown"}; download to view.)`);return}lc(!0);try{const xe=await(await Pe.download_run_artifact_content(k,N,{access:"download"})).text(),Ce=14e3,Re=xe.length>Ce?`${xe.slice(0,Math.max(0,Ce-1))}…`:xe;No(Re)}catch(U){ma(String((U==null?void 0:U.message)||U||"Preview failed"))}finally{lc(!1)}}async function Uu(_){const k=String((_==null?void 0:_.run_id)||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N){An("Artifact download needs a run id",3);return}const T=p_(_)||N;try{const B=await Pe.download_run_artifact_content(k,N,{access:"preview"});Fu(B,Ah(T)),An("Downloaded artifact",2)}catch(B){An(String((B==null?void 0:B.message)||B||"Download failed"),3)}}async function Ma(_){const k=String((_==null?void 0:_.run_id)||"").trim(),N=String((_==null?void 0:_.artifact_id)||"").trim();if(!k||!N){An("Artifact preview needs a run id",3);return}const T=p_(_),B=String((_==null?void 0:_.content_type)||"").trim().toLowerCase(),H=Ld(_),X=H==="text"&&Rd(_,"")==="html"?window.open("about:blank","_blank"):null;if(X&&(X.document.write('<!doctype html><title>Loading artifact preview...</title><body style="font:14px system-ui;padding:24px">Loading artifact preview...</body>'),X.document.close()),Pi(T||N),io(""),zo(""),Zr(H),Ur(_),ai(!0),cr&&(URL.revokeObjectURL(cr),ja("")),H==="binary"){io(`(Binary artifact: ${B||"unknown"}; download to view.)`);return}if(H==="text"&&typeof _.size_bytes=="number"&&_.size_bytes>15e5){io(`(Text artifact is ${_.size_bytes.toLocaleString()} bytes; download to view.)`);return}ka(!0);try{const Se=await Pe.download_run_artifact_content(k,N,{access:"preview"});if(H==="text"){const ie=await Se.text(),U=Rd(_,ie);if(U==="html"){const Ce=new Blob([ie],{type:B.includes("html")?String(_.content_type||"text/html"):"text/html;charset=utf-8"}),Re=URL.createObjectURL(Ce),ze=X||window.open("about:blank","_blank");if(ze){ze.location.href=Re,ai(!1),Ur(null),io(""),ka(!1),setTimeout(()=>URL.revokeObjectURL(Re),300*1e3),An("Opened HTML preview",2);return}URL.revokeObjectURL(Re),zo("Browser blocked opening the HTML page. Showing highlighted source instead.")}else X&&X.close();const xe=U==="json"?15e5:U==="markdown"?25e4:U==="html"?3e5:22e3;io(ie.length>xe&&U!=="text"?`${Fl(_.size_bytes??ie.length)} ${U.toUpperCase()} artifact. Download to inspect it.`:ie.length>xe?`${ie.slice(0,Math.max(0,xe-1))}…`:ie)}else X&&X.close(),ja(URL.createObjectURL(Se))}catch(Se){X&&X.close(),zo(String((Se==null?void 0:Se.message)||Se||"Preview failed"))}finally{ka(!1)}}h.useEffect(()=>()=>{cr&&URL.revokeObjectURL(cr)},[cr]);async function jf(_){const k=String(_.artifact_id||"").trim(),N=String(_.run_id||"").trim(),T=Ld(_);if(!N||!k)return{artifact_id:k,kind:T,render_kind:"",text:"Preview needs artifact run metadata.",url:"",loading:!1,error:""};if(T==="binary")return{artifact_id:k,kind:T,render_kind:"",text:`Preview unavailable for ${_.content_type||_.modality||"this artifact"}. Download to inspect it.`,url:"",loading:!1,error:""};if(T==="text"&&typeof _.size_bytes=="number"&&_.size_bytes>5e5)return{artifact_id:k,kind:T,render_kind:"",text:`${Fl(_.size_bytes)} text artifact. Use Preview for a larger view or Download to inspect locally.`,url:"",loading:!1,error:""};try{const B=await Pe.download_run_artifact_content(N,k,{access:"preview"});if(T==="text"){const H=await B.text(),V=Rd(_,H),X=V==="json"?5e5:V==="markdown"?12e4:V==="html"?3e5:8e3;return{artifact_id:k,kind:T,render_kind:V,text:H.length>X&&V!=="text"?`${Fl(_.size_bytes??H.length)} ${V.toUpperCase()} artifact. Use Larger preview or Download to inspect it.`:H.length>X?`${H.slice(0,Math.max(0,X-1))}…`:H,url:"",loading:!1,error:""}}return{artifact_id:k,kind:T,render_kind:"",text:"",url:URL.createObjectURL(B),loading:!1,error:""}}catch(B){return{artifact_id:k,kind:T,render_kind:"",text:"",url:"",loading:!1,error:String((B==null?void 0:B.message)||B||"Preview failed")}}}async function $c(_){if(Ri.url&&URL.revokeObjectURL(Ri.url),!_){Br(fc());return}const k=String(_.artifact_id||"").trim(),N=Ld(_);Br({artifact_id:k,kind:N,render_kind:"",text:"",url:"",loading:!0,error:""}),Br(await jf(_))}h.useEffect(()=>{Bu()},[Pe,j,Qr]);function Wt(_){const k=String(_.id||"").trim()||ss();nc(N=>[{..._,id:k},...N].slice(0,800))}function An(_,k){la(_),hs.current&&window.clearTimeout(hs.current),ei(!1),window.requestAnimationFrame(()=>ei(!0)),hs.current=window.setTimeout(()=>{ei(!1),hs.current=null},1500),Si.current&&(window.clearTimeout(Si.current),Si.current=null),k>0&&(Si.current=window.setTimeout(()=>{la(""),Si.current=null},Math.max(1,k)*1e3))}function Ar(_,k){const N=String(_||"").trim(),T=String(k||"").trim();if(!T)return"";const B=N?String(dn.current[N]||"").trim():"";return B?`${B}::${T}`:T}function Mc(_,k,N){const T=String(_||"").trim(),B=String(k||"").trim(),H=String(N||"").trim();if(!T||!B||!H)return;const V=Ar(T,B);V&&(dn.current[H]=V,Ci.current[H]=T,_a.current[H]={parent_run_id:T,parent_node_id:B},Ei.current.has(H)||(Ei.current.add(H),pa(X=>X.includes(H)?X:[...X,H])))}function jl(_){const k=String(_||"").trim();if(!k)return;const N=Date.now(),T=Ni.current;Ni.current=k,cl(N),cc(B=>{const H={};for(const[ie,U]of Object.entries(B))typeof U=="number"&&U>N&&(H[ie]=U);H[k]=Math.max(H[k]||0,N+2e3),T&&T!==k&&(H[T]=Math.max(H[T]||0,N+2e3));const V=Object.keys(H);if(V.length<=200)return H;const X=V.sort((ie,U)=>(H[U]||0)-(H[ie]||0)).slice(0,200),Se={};for(const ie of X)Se[ie]=H[ie]||0;return Se}),Ao(B=>{if(typeof B[k]=="number")return B;const H={...B,[k]:N};if(ul.current.push(k),ul.current.length>8e3){const V=ul.current.splice(0,1500);for(const X of V)delete H[X]}return H}),Xr.current&&window.clearTimeout(Xr.current),Xr.current=window.setTimeout(()=>{const B=Date.now();cc(H=>{const V={};for(const[X,Se]of Object.entries(H))typeof Se=="number"&&Se>B&&(V[X]=Se);return V}),cl(B),Xr.current=null},2200)}function Hu(_,k){var Ue,$t,bt;const N=String(k||"").trim()||u.trim();Rt.current=_.cursor,(Ue=lt.current)==null||Ue.push({cursor:_.cursor,record:_.record}),N&&ri.current.add(`${N}:${_.cursor}`);const T=Kf(_.record),B=T&&T.name?$d(T.name):"",H=_.record,V=typeof(H==null?void 0:H.node_id)=="string"?H.node_id:"",X=typeof(H==null?void 0:H.status)=="string"?H.status:"",Se=typeof(($t=H==null?void 0:H.effect)==null?void 0:$t.type)=="string"?H.effect.type:"",ie=typeof(H==null?void 0:H.run_id)=="string"?H.run_id:"",U=ie||N;if(B==="abstract.status"&&U===N){const{text:Be,duration:ot}=Hc(T==null?void 0:T.payload);An(Be,ot)}const xe=V?Ar(U,V):"";if(X==="waiting"){const Be=Vi(H);if(String((Be==null?void 0:Be.reason)||"").trim()==="subworkflow"){const gt=typeof((bt=Be==null?void 0:Be.details)==null?void 0:bt.sub_run_id)=="string"?String(Be.details.sub_run_id):"";gt&&V&&Mc(U,V,gt)}}if(V&&(jl(Ar(U,V)),X==="waiting"||X==="running")){const Be=Ar(U,V);Be&&(Ni.current=Be,eo(Be))}let Ce="step",Re=xe||V||"(node?)",ze="";if(T&&T.name&&o_(T.name))Ce=B==="abstract.message"?"message":"event",Re=B||T.name,ze=_t(B==="abstract.steer_seen"?i_(T==null?void 0:T.payload):Hc(T==null?void 0:T.payload).text);else if(H!=null&&H.error)Ce="error",Re="error",ze=_t(jr(H.error,360));else if(X==="waiting"){const Be=Vi(H),ot=String((Be==null?void 0:Be.reason)||"").trim();ze=_t(ot?`waiting • ${ot}`:"waiting")}else H!=null&&H.result?ze=_t(jr(H.result,360)):Se?ze=_t(Se):ze=_t(fm(H));Wt({id:`step:${ie||N||"?"}:${_.cursor}`,ts:String((H==null?void 0:H.ended_at)||(H==null?void 0:H.started_at)||Nt()),kind:Ce,title:Re,preview:ze,data:H,cursor:_.cursor,run_id:ie||N||void 0,node_id:xe||V,status:X,effect_type:Se,emit_name:B||(T==null?void 0:T.name)||void 0})}function kf(_,k){var ze,Ue,$t;To.current=Math.max(To.current,k.cursor);const N=`${_}:${k.cursor}`;if(!!ri.current.has(N))return;ri.current.add(N),(ze=Pt.current)==null||ze.push({run_id:_,cursor:k.cursor,record:k.record});const B=Kf(k.record),H=B&&B.name?$d(B.name):"",V=k.record,X=typeof(V==null?void 0:V.node_id)=="string"?V.node_id:"",Se=X?Ar(_,X):"",ie=typeof(V==null?void 0:V.status)=="string"?V.status:"",U=typeof((Ue=V==null?void 0:V.effect)==null?void 0:Ue.type)=="string"?V.effect.type:"";if(ie==="waiting"){const bt=Vi(V);if(String((bt==null?void 0:bt.reason)||"").trim()==="subworkflow"){const ot=typeof(($t=bt==null?void 0:bt.details)==null?void 0:$t.sub_run_id)=="string"?String(bt.details.sub_run_id):"";ot&&X&&Mc(_,X,ot),ot&&ps.current.trim()===String(_||"").trim()&&(ps.current=ot,si(ot))}}if(X&&(jl(Ar(_,X)),ie==="waiting"||ie==="running")){const bt=Ar(_,X);bt&&(Ni.current=bt,eo(bt))}if((ie==="completed"||ie==="failed")&&ps.current.trim()===String(_||"").trim()){const bt=String(Ci.current[String(_||"").trim()]||"").trim();bt&&bt!==u.trim()?(ps.current=bt,si(bt)):(ps.current="",si(""))}if(H==="abstract.status"&&_===u.trim()){const{text:bt,duration:Be}=Hc(B==null?void 0:B.payload);An(bt,Be)}let xe="step",Ce=Se||X||"(node?)",Re="";if(B&&B.name&&o_(B.name))xe=H==="abstract.message"?"message":"event",Ce=`subrun • ${H||B.name}`,Re=_t(H==="abstract.steer_seen"?i_(B==null?void 0:B.payload):Hc(B==null?void 0:B.payload).text);else if(V!=null&&V.error)xe="error",Ce="error",Re=_t(jr(V.error,360));else if(ie==="waiting"){const bt=Vi(V),Be=String((bt==null?void 0:bt.reason)||"").trim();Re=_t(Be?`waiting • ${Be}`:"waiting")}else V!=null&&V.result?Re=_t(jr(V.result,360)):U?Re=_t(U):Re=_t(fm(V));Wt({id:`step:${_}:${k.cursor}`,ts:String((V==null?void 0:V.ended_at)||(V==null?void 0:V.started_at)||Nt()),kind:xe,title:Ce,preview:Re,data:V,cursor:k.cursor,run_id:_,node_id:Se||X,status:ie,effect_type:U,emit_name:H||(B==null?void 0:B.name)||""})}function Wu(_,k){var Ue,$t,bt;const N=String(_||"").trim();if(!N)return;const T=`${N}:${k.cursor}`;if(!!ri.current.has(T))return;ri.current.add(T),(Ue=Pt.current)==null||Ue.push({run_id:N,cursor:k.cursor,record:k.record});const H=Kf(k.record),V=H&&H.name?$d(H.name):"",X=k.record,Se=typeof(X==null?void 0:X.node_id)=="string"?X.node_id:"",ie=Se?Ar(N,Se):"",U=typeof(X==null?void 0:X.status)=="string"?X.status:"",xe=typeof(($t=X==null?void 0:X.effect)==null?void 0:$t.type)=="string"?X.effect.type:"";if(U==="waiting"){const Be=Vi(X);if(String((Be==null?void 0:Be.reason)||"").trim()==="subworkflow"){const gt=typeof((bt=Be==null?void 0:Be.details)==null?void 0:bt.sub_run_id)=="string"?String(Be.details.sub_run_id):"";gt&&Se&&Mc(N,Se,gt)}}if(Se&&(jl(Ar(N,Se)),U==="waiting"||U==="running")){const Be=Ar(N,Se);Be&&(Ni.current=Be,eo(Be))}if(V==="abstract.status"&&N===u.trim()){const{text:Be,duration:ot}=Hc(H==null?void 0:H.payload);An(Be,ot)}let Ce="step",Re=ie||Se||"(node?)",ze="";if(H&&H.name&&o_(H.name))Ce=V==="abstract.message"?"message":"event",Re=`subrun • ${V||H.name}`,ze=_t(V==="abstract.steer_seen"?i_(H==null?void 0:H.payload):Hc(H==null?void 0:H.payload).text);else if(X!=null&&X.error)Ce="error",Re="error",ze=_t(jr(X.error,360));else if(U==="waiting"){const Be=Vi(X),ot=String((Be==null?void 0:Be.reason)||"").trim();ze=_t(ot?`waiting • ${ot}`:"waiting")}else X!=null&&X.result?ze=_t(jr(X.result,360)):xe?ze=_t(xe):ze=_t(fm(X));Wt({id:`step:${N}:${k.cursor}`,ts:String((X==null?void 0:X.ended_at)||(X==null?void 0:X.started_at)||Nt()),kind:Ce,title:Re,preview:ze,data:X,cursor:k.cursor,run_id:N,node_id:ie||Se,status:U,effect_type:xe,emit_name:V||(H==null?void 0:H.name)||""})}async function qu(_,k){var T,B;let N=k.after;for(;;){if((T=k.signal)!=null&&T.aborted)return N;const H=await Pe.get_ledger(_,{after:N,limit:200,signal:k.signal});if((B=k.signal)!=null&&B.aborted)return N;const V=Array.isArray(H.items)?H.items:[];if(!V.length)return Rt.current=N,N;const X=N;for(let Se=0;Se<V.length;Se++){const ie=V[Se];Hu({cursor:X+Se+1,record:ie},_)}N=typeof H.next_after=="number"?H.next_after:N}}async function Ho(_){var H,V,X,Se;const k=String(_||"").trim();Ht(""),ge(!0),Pn(!1),(H=lt.current)==null||H.reset(),(V=Pt.current)==null||V.reset(),Vt.current={scanned:0,found:null},it([]),Rt.current=0,vt([]),ri.current=new Set,nc([]),yu({}),ef({}),bu("steps"),Su(""),la(""),kt(null),Ts(""),oc(""),ac([]),ju(""),eo(""),Ni.current="",cc({}),Ao({}),ul.current=[],cl(Date.now()),dn.current=k?{[k]:""}:{},Ci.current={},_a.current={},Ei.current=new Set,pa([]),$i.current="",ps.current="",si(""),ga.current={},Xr.current&&window.clearTimeout(Xr.current),Xr.current=null,pr.current&&window.clearTimeout(pr.current),pr.current=null,Jr.current&&Jr.current.abort(),$r.current&&$r.current.abort(),$r.current=null,To.current=0,va("");const N=new AbortController;Jr.current=N;let T=!1;try{let ie="",U="";try{const xe=await Pe.get_run(k);kt(xe);const Ce=typeof(xe==null?void 0:xe.workflow_id)=="string"?String(xe.workflow_id):"",Re=s_(Ce);Re&&(ie=Re.bundle_id,U=Re.flow_id)}catch{}try{const xe=await Pe.get_run_input_data(k);typeof(xe==null?void 0:xe.bundle_id)=="string"&&(ie=String(xe.bundle_id||"").trim()||ie),typeof(xe==null?void 0:xe.flow_id)=="string"&&(U=String(xe.flow_id||"").trim()||U);const Ce=xe&&typeof xe.input_data=="object"&&xe.input_data&&!Array.isArray(xe.input_data)?xe.input_data:null;Ce&&W(JSON.stringify(Ce,null,2));const Re=xe==null?void 0:xe.workspace,ze=typeof(Re==null?void 0:Re.workspace_root)=="string"?String(Re.workspace_root).trim():"";oc(ze)}catch{oc("")}(async()=>{of(!0),ju("");try{const xe=await Pe.list_run_artifacts(k,{limit:200}),Ce=Array.isArray(xe==null?void 0:xe.items)?xe.items:[];N.signal.aborted||ac(Ce)}catch(xe){N.signal.aborted||(ac([]),ju(String((xe==null?void 0:xe.message)||xe||"artifact listing failed")))}finally{N.signal.aborted||of(!1)}})(),ie&&U&&(L(ie),C(U),Co(U),await ao(ie)),await qu(k,{after:0,signal:N.signal});try{const xe=await Pe.get_run_history_bundle(k,{include_subruns:!0,include_session:!1,ledger_mode:"tail",ledger_max_items:1}),Ce=xe&&typeof xe=="object"?xe.ledgers:null,ze=(Ce&&typeof Ce=="object"?Object.keys(Ce):[]).map(Ue=>String(Ue||"").trim()).filter(Boolean).filter(Ue=>Ue!==k);if(ze.length){for(const Ue of ze)Ei.current.add(Ue);pa(Ue=>Array.from(new Set([...Ue,...ze])));try{const Ue=typeof((X=Ce==null?void 0:Ce[k])==null?void 0:X.total)=="number"?Number(Ce[k].total):0;let $t="",bt=-1;for(const Be of ze){const ot=typeof((Se=Ce==null?void 0:Ce[Be])==null?void 0:Se.total)=="number"?Number(Ce[Be].total):0;ot>bt&&($t=Be,bt=ot)}$t&&bt>Math.max(Ue*3,Ue+20)&&(ps.current=$t,si($t))}catch{}}}catch{}Pn(!0),Wt({ts:Nt(),kind:"info",title:`Attached to run ${k}`,data:{run_id:k}}),T=!0}catch(ie){const U=String((ie==null?void 0:ie.message)||ie||"unknown error");Ht(U),Wt({ts:Nt(),kind:"error",title:"Connection error",preview:_t(U),data:{error:U}}),Pn(!1)}finally{ge(!1)}if(!T||N.signal.aborted)return;(async()=>{let ie=250;for(;!N.signal.aborted;){try{const U=await qu(k,{after:Rt.current,signal:N.signal});await Pe.stream_ledger(k,{after:U,on_step:xe=>Hu(xe,k),signal:N.signal})}catch(U){if(N.signal.aborted)break;const xe=String((U==null?void 0:U.message)||U||"stream error");Wt({ts:Nt(),kind:"error",title:"Ledger stream error (will retry)",preview:_t(xe),data:{error:xe}})}if(N.signal.aborted)break;await new Promise(U=>setTimeout(U,ie)),ie=Math.min(5e3,Math.floor(ie*1.6))}})()}async function Nf(){const _=b.trim(),k=S.trim();if(!_||!k){const N="Select a workflow first (Launch → pick a workflow).";return Ht(N),N}Ht(""),ge(!0);try{let N={};const T=M.trim();if(T)try{if(N=JSON.parse(T),typeof N!="object"||N===null||Array.isArray(N))throw new Error("input_data must be a JSON object")}catch(ie){const U=`Invalid input_data JSON: ${String((ie==null?void 0:ie.message)||ie)}`;return Ht(U),U}for(const[ie,U]of Object.entries(N)){if(typeof U!="string")continue;const xe=U.trim();xe?N[ie]=xe:delete N[ie]}const B=(Do||[]).find(ie=>ie&&typeof ie=="object"&&ie.id==="prompt"),H=B&&typeof B=="object"&&Object.prototype.hasOwnProperty.call(B,"default"),V=N==null?void 0:N.prompt,X=typeof V=="string"?V.trim():"";if(B&&!H&&!X){const ie="Missing required input_data.prompt";return Ht(ie),ie}const Se=await Pe.start_run(_,N,{bundle_id:k,session_id:String(q||"").trim()||null});return g(Se),m(Se),Ve(""),await Ho(Se),Jt(),null}catch(N){const T=String((N==null?void 0:N.message)||N||"start failed");return Ht(T),T}finally{ge(!1)}}async function rh(_){const k=b.trim(),N=S.trim();if(!k||!N){const T="Select a workflow first (Launch → pick a workflow).";return Ht(T),T}if(cn)return"Schedule already in progress";pn(""),Ht(""),gn(!0),ge(!0);try{let T={};const B=M.trim();if(B)try{if(T=JSON.parse(B),typeof T!="object"||T===null||Array.isArray(T))throw new Error("input_data must be a JSON object")}catch(gt){const xt=`Invalid input_data JSON: ${String((gt==null?void 0:gt.message)||gt)}`;return pn(xt),xt}const H=(Do||[]).find(gt=>gt&&typeof gt=="object"&&gt.id==="prompt"),V=H&&typeof H=="object"&&Object.prototype.hasOwnProperty.call(H,"default"),X=T==null?void 0:T.prompt,Se=typeof X=="string"?X.trim():"";if(H&&!V&&!Se){const gt="Missing required input_data.prompt";return pn(gt),gt}let ie=null,U=null;if(_.start_mode==="now")ie="now",U=new Date;else{const gt=String(_.start_at_local||"").trim();if(!gt){const Ln="Pick a start date/time (or choose 'now').";return pn(Ln),Ln}const xt=new Date(gt);if(!Number.isFinite(xt.getTime())){const Ln="Invalid start date/time";return pn(Ln),Ln}ie=xt.toISOString(),U=new Date(ie)}const xe=Number.isFinite(_.every_n)?_.every_n:1,Ce=Math.max(1,Math.min(1e4,Math.floor(xe))),Re=String(_.every_unit||"").trim();let ze="1d";Re==="minutes"?ze=`${Ce}m`:Re==="hours"?ze=`${Ce}h`:Re==="days"?ze=`${Ce}d`:Re==="weeks"?ze=`${Ce*7}d`:Re==="months"&&(ze=`${Ce*30}d`);const Ue=_.repeat_mode,$t=Ue==="once"?null:ze,bt=Ue==="count"?Math.max(1,Math.floor(Number.isFinite(_.repeat_count)?_.repeat_count:1)):null;let Be=null;if(Ue==="until"){const gt=String(_.repeat_until_date_local||"").trim(),xt=String(_.repeat_until_time_local||"").trim()||"23:59";if(!gt){const wn="Pick an end date (Until).";return pn(wn),wn}const Ln=new Date(`${gt}T${xt}`);if(!Number.isFinite(Ln.getTime())){const wn="Invalid end date/time";return pn(wn),wn}if(Be=Ln.toISOString(),U&&Number.isFinite(U.getTime())&&Ln.getTime()<U.getTime()){const wn="End date must be after the start date.";return pn(wn),wn}}const ot=await Pe.schedule_run({bundle_id:N,flow_id:k,input_data:T,start_at:ie,interval:$t,repeat_count:bt,repeat_until:Be,share_context:!!_.share_context,session_id:String(q||"").trim()||null});return g(ot),m(ot),pn(""),await Ho(ot),Jt(),null}catch(T){const B=String((T==null?void 0:T.message)||T||"schedule failed");return pn(B),Ht(B),B}finally{ge(!1),gn(!1)}}async function Cf(){Ve(""),pn("");const k=Ys!=="now"||Yr!=="once"?await rh({start_mode:Ys,start_at_local:an,repeat_mode:Yr,every_n:As,every_unit:rt,repeat_count:Cr,repeat_until_date_local:_r,repeat_until_time_local:Ja,share_context:Wn}):await Nf();if(k){Ve(k);return}Rs("overview"),t("observe")}async function Aa(_,k){const N=String(_||"").trim();if(!N)return;if(te){An(`Still attaching — retry in a moment (${Mt(N,14)})`,2500);return}Ht("");const T=String((k==null?void 0:k.root_run_id)||N).trim()||N;g(T),m(N),await Ho(N)}h.useEffect(()=>{const _=String(v||"").trim();if(!_)return;let k=!1;return(async()=>{try{if(j||await lo({open_modal_if_needed:!0}),k)return;Rs("overview"),t("observe"),await Aa(_)}catch(N){k||Ht(String((N==null?void 0:N.message)||N||"Failed to attach run from URL"))}finally{k||x("")}})(),()=>{k=!0}},[v]);function Ef(){var _,k;Jr.current&&Jr.current.abort(),Jr.current=null,$r.current&&$r.current.abort(),$r.current=null,To.current=0,va(""),m(""),g(""),dn.current={},Ci.current={},_a.current={},Ei.current=new Set,pa([]),$i.current="",ps.current="",si(""),ga.current={},Ts(""),Xr.current&&window.clearTimeout(Xr.current),Xr.current=null,pr.current&&window.clearTimeout(pr.current),pr.current=null,Pn(!1),ge(!1),qe(!1),Rt.current=0,(_=lt.current)==null||_.reset(),(k=Pt.current)==null||k.reset(),Vt.current={scanned:0,found:null},it([]),vt([]),ri.current=new Set,kt(null),nc([]),yu({}),eo(""),Ni.current="",cc({}),Ao({}),ul.current=[],cl(Date.now()),An("",-1),Ht(""),uc(!1),dc(""),Et([]),F(""),we(""),ct(!1),un(!1),Kn(""),ki(""),bo(""),So([]),Jl(!1),Zl(""),nl(""),ec(!1),jo("")}h.useEffect(()=>{Et([]),F(""),we(""),ct(!1),un(!1),Kn(""),ki(""),bo(""),So([]),Jl(!1),Zl(""),nl(""),ec(!1),jo("")},[u]),h.useEffect(()=>{rr==="chat"&&u.trim()&&j&&Lc()},[rr,u,j,ce==null?void 0:ce.workflow_id]);async function Vu(_,k,N){const T=String(_||"").trim();if(!T)return Ht("Missing run_id"),"Missing run_id";Ht("");try{const B={},H=String((N==null?void 0:N.reason)||"").trim();H&&(B.reason=H),await Pe.submit_command({command_id:ss(),run_id:T,type:k,payload:B,client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:`${k} submitted`,preview:H?`reason: ${H}`:"",data:{run_id:T,type:k,reason:H}});try{if(T===u.trim()){const V=await Pe.get_run(T);kt(V)}}catch{}return Jt(Pe,{force:!0}),window.setTimeout(()=>void Jt(Pe,{force:!0}),900),window.setTimeout(()=>void Jt(Pe,{force:!0}),2400),null}catch(B){const H=String((B==null?void 0:B.message)||B||`${k} failed`);return Ht(H),H}}async function Gu(_,k){return Vu(u.trim(),_,k)}async function Yu(_,k="Stopped from AbstractObserver"){const N=String(_||"").trim();if(!N||!window.confirm(`Cancel run ${Mt(N,24)}?`))return;await Vu(N,"cancel",{reason:k})||An("Cancel submitted",2)}async function Ac(){var N;const _=u.trim();if(!_){Ht("Select a run first.");return}if(!j){Ht("Connect to the gateway first.");return}if(Te)return;const k=String(((N=ce==null?void 0:ce.waiting)==null?void 0:N.reason)||"").trim().toLowerCase()||String(ir||"").trim().toLowerCase();if(!es||Bs||Bi||Fi.toLowerCase()!=="waiting"||k!=="until"){Ht("This run is not a scheduled wait that can be triggered now.");return}Ht(""),qe(!0);try{const T={payload:{mode:"run_now",requested_at:Nt()}},B=String(Tr||"").trim();B&&(T.wait_key=B),await Pe.submit_command({command_id:ss(),run_id:_,type:"resume",payload:T,client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:"Scheduled run triggered",preview:_t(`run ${_}`),data:{run_id:_,until:Fs||null}});try{const H=await Pe.get_run(_);kt(H)}catch{}}catch(T){Ht(String((T==null?void 0:T.message)||T||"Failed to trigger scheduled run"))}finally{qe(!1)}}async function sh(_){const k=u.trim();if(!k)return Ht("Missing run_id"),"Missing run_id";if(us)return"Schedule update already in progress";const N=String(_.interval||"").trim();if(!/^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)\s*$/i.test(N)){const B="Invalid interval (expected like '20m', '1h', '0.5s', '250ms')";return Fn(B),B}Fn(""),Ht(""),Js(!0),ge(!0);try{await Pe.submit_command({command_id:ss(),run_id:k,type:"update_schedule",payload:{interval:N,apply_immediately:_.apply_immediately!==!1},client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:"Schedule updated",preview:_t(`interval: ${N}`),data:{interval:N},run_id:k});try{const B=await Pe.get_run(k);kt(B)}catch{}return null}catch(B){const H=String((B==null?void 0:B.message)||B||"update_schedule failed");return Fn(H),Ht(H),H}finally{ge(!1),Js(!1)}}async function ih(_){const k=u.trim();if(!k)return Ht("Missing run_id"),"Missing run_id";if(nr)return"Compaction already in progress";const N=typeof(_==null?void 0:_.preserve_recent)=="number"?_.preserve_recent:oa,T=Math.max(0,Math.min(500,Math.floor(Number.isFinite(N)?N:6))),B=(_==null?void 0:_.compression_mode)||zr,H=String((_==null?void 0:_.focus)??Zs??"").trim();tr(""),Ht(""),Er(!0),ge(!0);try{const V={preserve_recent:T,compression_mode:B};return H&&(V.focus=H),await Pe.submit_command({command_id:ss(),run_id:k,type:"compact_memory",payload:V,client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:"Compaction requested",preview:_t(`mode: ${B} • preserve_recent: ${T}`),data:V,run_id:k}),null}catch(V){const X=String((V==null?void 0:V.message)||V||"compact_memory failed");return tr(X),Ht(X),X}finally{ge(!1),Er(!1)}}async function oh(){const _=u.trim();if(!_){dc("Missing run_id");return}if(!ff){dc(""),uc(!0);try{const k=n.maintenance_ai_provider.trim(),N=n.maintenance_ai_model.trim();await Pe.generate_run_summary(_,{provider:k||void 0,model:N||void 0,include_subruns:!0}),Wt({ts:Nt(),kind:"info",title:"Summary generation requested",preview:_t(`run ${_}`)})}catch(k){dc(String((k==null?void 0:k.message)||k||"Failed to generate summary"))}finally{uc(!1)}}}async function Ds(){const _=u.trim();if(!_){we("Select a run first.");return}if(!j){we("Connect to the gateway first.");return}const k=xo.trim();if(!k||tt)return;if(Bn.voice_ptt_busy){$e("Wait for transcription to finish.");return}we(""),$e(""),ct(!0);const T={id:`local:${ss()}`,role:"user",content:k,ts:Nt()};Et(B=>[...B,T]),F("");try{const B=[...Kt,T].slice(-20).map(U=>({role:U.role,content:U.content})),H=n.maintenance_ai_provider.trim(),V=n.maintenance_ai_model.trim(),X=await Pe.run_chat(_,{provider:H||void 0,model:V||void 0,include_subruns:!0,messages:B}),Se=String((X==null?void 0:X.answer)||"").trim()||"(empty response)",ie=String((X==null?void 0:X.generated_at)||"").trim()||Nt();Et(U=>[...U,{id:`local:${ss()}`,role:"assistant",content:Se,ts:ie}])}catch(B){we(String((B==null?void 0:B.message)||B||"Chat failed")),Et(H=>[...H,{id:`local:${ss()}`,role:"assistant",content:"(error: failed to generate answer)",ts:Nt()}])}finally{ct(!1)}}function Ku(_){const k=String(_.id||_.ts||"").trim(),N=String(_.content||"").trim();!k||!N||($e(""),Bn.toggle_tts(k,N))}function Tc(_){const k=String(_.id||_.ts||"").trim(),N=Bn.tts_playback;return!k||!N.key||N.key!==k?"idle":N.status}function Xu(_){if(!Kt.length)return;const k=u.trim(),N=k?`Run ${k}`:"Chat",T=zw(Kt.map(B=>({role:B.role,content:B.content,ts:B.ts})),{heading:N});if(_==="download"){const B=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),H=`abstractobserver-chat-${Ah(k||"run")}-${B}.md`;Iw({filename:H,text:T,mime:"text/markdown;charset=utf-8"});return}(async()=>{const B=await Vl(T);Gt(B?"copied":"failed"),window.setTimeout(()=>Gt("idle"),900)})()}async function Lc(){const _=typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id).trim():"";if(!_){So([]);return}if(j&&!tl){Zl(""),Jl(!0);try{const k=await Pe.list_runs({limit:200,workflow_id:_,root_only:!0}),N=Array.isArray(k==null?void 0:k.items)?k.items:[],T=[];for(const ie of N){const U=typeof(ie==null?void 0:ie.run_id)=="string"?String(ie.run_id).trim():"";if(!U)continue;const xe=typeof(ie==null?void 0:ie.ledger_len)=="number"?Number(ie.ledger_len):0;T.push({run_id:U,ledger_len:Number.isFinite(xe)?xe:0})}if(!T.length){So([]);return}const B=400,H=T.map(ie=>({run_id:ie.run_id,after:Math.max(0,(ie.ledger_len||0)-B)})),V=await Pe.get_ledger_batch({runs:H,limit:B}),X=[],Se=new Set;for(const ie of T){const U=V!=null&&V.runs&&typeof V.runs=="object"?V.runs[ie.run_id]:null,xe=Array.isArray(U==null?void 0:U.items)?U.items:[];for(const Ce of xe){const Re=Ce==null?void 0:Ce.effect;if(!Re||typeof Re!="object"||String(Re.type||"")!=="emit_event")continue;const ze=Re.payload;if(!ze||typeof ze!="object"||String(ze.name||"")!=="abstract.chat.thread")continue;const Ue=ze.payload;if(!Ue||typeof Ue!="object")continue;const $t=typeof Ue.thread_id=="string"?String(Ue.thread_id).trim():"";if(!$t||Se.has($t))continue;Se.add($t);const bt=typeof Ue.created_at=="string"?String(Ue.created_at):"",Be=typeof Ue.title=="string"?String(Ue.title):"",ot=typeof Ue.workflow_id=="string"?String(Ue.workflow_id):_,gt=typeof Ue.run_id=="string"?String(Ue.run_id):ie.run_id,xt=typeof Ue.provider=="string"?String(Ue.provider):"",Ln=typeof Ue.model=="string"?String(Ue.model):"",wn=typeof Ue.message_count=="number"?Number(Ue.message_count):null,ks=Ue.chat_artifact,bn=ks&&typeof ks=="object"&&typeof ks.$artifact=="string"?String(ks.$artifact):"";bn&&X.push({thread_id:$t,created_at:bt,title:Be||`Chat ${$t.slice(0,8)}`,run_id:gt,workflow_id:ot,message_count:wn,provider:xt,model:Ln,artifact_id:bn})}}X.sort((ie,U)=>String(U.created_at||"").localeCompare(String(ie.created_at||""))),So(X)}catch(k){Zl(String((k==null?void 0:k.message)||k||"Failed to load saved discussions"))}finally{Jl(!1)}}}async function $f(){const _=u.trim();if(!_){Kn("Select a run first.");return}if(!j){Kn("Connect to the gateway first.");return}if(Kt.length&&!En){Kn(""),un(!0);try{const k=n.maintenance_ai_provider.trim(),N=n.maintenance_ai_model.trim(),T=await Pe.save_chat_thread(_,{provider:k||void 0,model:N||void 0,include_subruns:!0,messages:Kt.map(V=>({role:V.role,content:V.content,ts:V.ts}))}),B=typeof(T==null?void 0:T.created_at)=="string"?String(T.created_at):Nt();ki(B);try{const V=JSON.stringify(Kt.map(X=>({role:X.role,content:X.content,ts:X.ts})));bo(V)}catch{bo("1")}typeof(T==null?void 0:T.thread_id)=="string"&&String(T.thread_id).trim()&&nl(String(T.thread_id).trim());const H=!!(T!=null&&T.duplicate);An(H?"Already saved":"Saved discussion",2),await Lc()}catch(k){Kn(String((k==null?void 0:k.message)||k||"Failed to save discussion"))}finally{un(!1)}}}async function Ju(){const _=String(hu||"").trim();if(!_)return;const k=mu.find(B=>String(B.thread_id||"").trim()===_)||null;if(!k){jo("Saved discussion not found (refresh list).");return}if(!j){jo("Connect to the gateway first.");return}if(Ql)return;const N=Kt.length>0,T=(()=>{if(!N)return!1;if(!wo)return!0;try{return JSON.stringify(Kt.map(H=>({role:H.role,content:H.content,ts:H.ts})))!==wo}catch{return!0}})();if(!(N&&T&&!window.confirm("Replace the current chat with the selected saved discussion? Unsaved changes will be lost."))){jo(""),ec(!0);try{const H=await(await Pe.download_run_artifact_content(k.run_id,k.artifact_id)).text(),V=JSON.parse(H),X=Array.isArray(V==null?void 0:V.messages)?V.messages:[],Se=typeof(V==null?void 0:V.created_at)=="string"?String(V.created_at):String(k.created_at||""),ie=[];for(let U=0;U<X.length;U++){const xe=X[U];if(!xe||typeof xe!="object")continue;const Ce=String(xe.role||"").trim()==="assistant"?"assistant":"user",Re=typeof xe.content=="string"?String(xe.content):"";if(!Re.trim())continue;const ze=typeof xe.ts=="string"?String(xe.ts):Se||Nt();ie.push({id:`thread:${_}:${U}`,role:Ce,content:Re.trim(),ts:ze})}Et(ie),F(""),we(""),Kn(""),ki(Se||"");try{const U=JSON.stringify(ie.map(xe=>({role:xe.role,content:xe.content,ts:xe.ts})));bo(U)}catch{bo("1")}An("Loaded discussion",2)}catch(B){jo(String((B==null?void 0:B.message)||B||"Failed to load saved discussion"))}finally{ec(!1)}}}async function Ii(_){const k=u.trim(),N=String((Xt==null?void 0:Xt.wait_key)||"").trim();if(!k||!N){Ht("No active wait to resume");return}if(String((Xt==null?void 0:Xt.reason)||"").trim()==="subworkflow"){Ht("This run is waiting on a subworkflow; attach to the child run instead of resuming manually.");return}Ht(""),qe(!0);try{await Pe.submit_command({command_id:ss(),run_id:k,type:"resume",payload:{wait_key:N,payload:_||{}},client_id:"web_pwa"}),Wt({ts:Nt(),kind:"info",title:"Resume submitted",preview:_t(`wait_key: ${N}`),data:{wait_key:N,payload:_||{}}}),Ts(N);try{const T=await Pe.get_run(k);kt(T)}catch{}Jt(Pe,{force:!0}),window.setTimeout(()=>void Jt(Pe,{force:!0}),900),window.setTimeout(()=>void Jt(Pe,{force:!0}),2400),pr.current&&window.clearTimeout(pr.current),pr.current=window.setTimeout(()=>{Ts(T=>T===N?"":T)},2e3)}catch(T){Ht(String((T==null?void 0:T.message)||T||"resume failed"))}finally{qe(!1)}}async function Zu(_){if(!ci){Ht("No worker configured");return}if(!Te){Ht(""),qe(!0);try{const k=[];for(const N of _){const T=await ci.call_tool(N);k.push(T)}await Ii({mode:"executed",results:k})}finally{qe(!1)}}}const Di=h.useMemo(()=>uu(Xt),[Xt]),Tr=String((Xt==null?void 0:Xt.wait_key)||"").trim(),ir=String((Xt==null?void 0:Xt.reason)||"").trim(),Fs=typeof(Xt==null?void 0:Xt.until)=="string"?String(Xt.until):"",Fi=typeof(ce==null?void 0:ce.status)=="string"?String(ce.status):"",Bi=!!(ce!=null&&ce.paused),Bs=Fi==="completed"||Fi==="failed"||Fi==="cancelled",ah=ir==="until"&&!!Fs,fr=!Bs&&Rb(ur)&&(!!Tr||ah),Lr=ir==="user",Rc=ir==="event"?$d(dE(Tr)):"",Mf=ir==="event"&&Rc==="abstract.ask",Af=Di.length>0,Qu=fr&&Tr&&(Lr||Mf||Af)&&fu!==Tr&&e!=="board",co=typeof((Fc=Xt==null?void 0:Xt.details)==null?void 0:Fc.sub_run_id)=="string"?String(Xt.details.sub_run_id):"",Wo={run_id:u.trim(),workflow_id:typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):null,status:Fi,created_at:typeof(ce==null?void 0:ce.created_at)=="string"?String(ce.created_at):null,updated_at:typeof(ce==null?void 0:ce.updated_at)=="string"?String(ce.updated_at):null,session_id:typeof(ce==null?void 0:ce.session_id)=="string"?String(ce.session_id):null,current_node:typeof(ce==null?void 0:ce.current_node)=="string"?String(ce.current_node):null},ed=He.slice(-10).map(_=>{var k,N,T,B,H,V;return{cursor:_.cursor,node_id:String(((k=_.record)==null?void 0:k.node_id)||"").trim(),status:String(((N=_.record)==null?void 0:N.status)||"").trim(),effect_type:String(((B=(T=_.record)==null?void 0:T.effect)==null?void 0:B.type)||"").trim(),ts:String(((H=_.record)==null?void 0:H.ended_at)||((V=_.record)==null?void 0:V.started_at)||"").trim(),summary:nv(_.record)}}),Pc=G_(Xt,Di),Tf=Zy(Xt,Di),td=Qy(Xt,ft),uo=td.text,nd=td.runtime_metadata,kl=String((Xt==null?void 0:Xt.prompt)||"").trim(),Oc=vb(ft,6),zc=!!(kl&&Ky(kl)),rd=!!(kl&&!zc),Lf=rd?"Question from workflow":uo&&uo!==kl?"Closest prior user request":"Request context",sd=bb(ft,M),Rf=!!M.trim(),vr=ce!=null&&ce.schedule&&typeof ce.schedule=="object"?ce.schedule:null,Hr=typeof(vr==null?void 0:vr.interval)=="string"?String(vr.interval).trim():"",lh=typeof(vr==null?void 0:vr.share_context)=="boolean"?!!vr.share_context:null,id=typeof(vr==null?void 0:vr.repeat_count)=="number"?Number(vr.repeat_count):null,es=!!(ce!=null&&ce.is_scheduled)||!!vr||typeof(ce==null?void 0:ce.workflow_id)=="string"&&String(ce.workflow_id).startsWith("scheduled:"),Ic=es&&!!Hr,od=es?Bi?"Resume schedule":"Suspend schedule":Fi==="running"&&!Bi?"Pause":"Resume",Ta=es?Bi?"resume":"pause":od==="Pause"?"pause":"resume",xr=es?!u.trim()||te||Te||Bs:!u.trim()||te||Te||Bs||Ta==="resume"&&!Bi,ch=es&&!Bi&&!Bs&&!te&&!Te&&Fi.toLowerCase()==="waiting"&&(String(((Wi=ce==null?void 0:ce.waiting)==null?void 0:Wi.reason)||"").trim().toLowerCase()==="until"||ir==="until")&&!!String(Fs||"").trim(),ts=(Tl=ce==null?void 0:ce.limits)==null?void 0:Tl.tokens,fo=typeof(ts==null?void 0:ts.pct)=="number"?Number(ts.pct):null,mr=ts==null?void 0:ts.estimated_used,Pf=(ts==null?void 0:ts.max_input_tokens)??(ts==null?void 0:ts.max_tokens),Je=h.useMemo(()=>{const _=Vt.current;He.length<_.scanned&&(_.scanned=0,_.found=null);for(let k=_.scanned;k<He.length;k++){const N=He[k],T=N==null?void 0:N.record;if(!T)continue;const B=Kf(T);if((B&&B.name?$d(B.name):"")!=="abstract.summary")continue;const V=B!=null&&B.payload&&typeof B.payload=="object"?B.payload:{},X=typeof(V==null?void 0:V.text)=="string"?String(V.text):"";X.trim()&&(_.found={cursor:N.cursor,ts:String((T==null?void 0:T.ended_at)||(T==null?void 0:T.started_at)||""),text:X,provider:typeof(V==null?void 0:V.provider)=="string"?String(V.provider):void 0,model:typeof(V==null?void 0:V.model)=="string"?String(V.model):void 0,generated_at:typeof(V==null?void 0:V.generated_at)=="string"?String(V.generated_at):void 0,source:V==null?void 0:V.source})}return _.scanned=He.length,_.found},[He]);h.useEffect(()=>{ps.current=_s.trim()},[_s]),h.useEffect(()=>{const _=u.trim(),k=co.trim();if(!(vn&&ir==="subworkflow"&&!!k&&k!==_)){$i.current="",_s.trim()&&si("");return}$i.current!==k&&($i.current=k,ps.current=k,si(k))},[vn,u,ir,co,_s]),h.useEffect(()=>{ha({})},[S]);const qo=h.useMemo(()=>((Array.isArray(z==null?void 0:z.entrypoints)?z==null?void 0:z.entrypoints:[])||[]).map(k=>String((k==null?void 0:k.flow_id)||"").trim()).filter(Boolean),[z]),Us=h.useMemo(()=>{const _=String((ce==null?void 0:ce.workflow_id)||"").trim();return vn&&_.startsWith("scheduled:")?_:""},[vn,ce==null?void 0:ce.workflow_id]),Of=h.useMemo(()=>{var V;if(!vn||!u.trim()||!Us.trim())return gr;const _=String((ce==null?void 0:ce.status)||"").trim().toLowerCase(),k=String((ce==null?void 0:ce.current_node)||"").trim();if(_!=="waiting"&&_!=="running"||!k)return gr;const N=Ar(u.trim(),k);if(!N)return gr;const T=String(ir||((V=ce==null?void 0:ce.waiting)==null?void 0:V.reason)||"").trim().toLowerCase(),B=typeof(ur==null?void 0:ur.node_id)=="string"?String(ur.node_id).trim():"",H=typeof(ur==null?void 0:ur.status)=="string"?String(ur.status).trim().toLowerCase():"";return _==="waiting"&&T==="until"||!gr.trim()||(H==="waiting"||H==="running")&&!B?N:gr},[vn,u,Us,ce==null?void 0:ce.status,ce==null?void 0:ce.current_node,(qi=ce==null?void 0:ce.waiting)==null?void 0:qi.reason,ir,gr,ur]),uh=h.useMemo(()=>{const _={},k=u.trim(),N=(T,B)=>{if(!B)return;const H=typeof(B==null?void 0:B.node_id)=="string"?String(B.node_id).trim():"";if(!H)return;const V=Ar(T,H);if(!V)return;const X=String((B==null?void 0:B.ended_at)||(B==null?void 0:B.started_at)||"").trim(),Se=Sn(X);Se!==null&&(_[V]=Math.max(_[V]||0,Se))};for(const T of He)T&&T.record&&N(k,T.record);for(const T of pt)T&&T.record&&N(String(T.run_id||"").trim(),T.record);return _},[He,pt,u,ni]);h.useEffect(()=>{var N;if(!vn||!u.trim()||!Us.trim())return;const _=String((ce==null?void 0:ce.current_node)||"").trim();!_||String(((N=ce==null?void 0:ce.waiting)==null?void 0:N.reason)||"").trim()==="subworkflow"||jl(Ar(u.trim(),_))},[vn,u,Us,ce==null?void 0:ce.current_node,(Ll=ce==null?void 0:ce.waiting)==null?void 0:Ll.reason]),h.useEffect(()=>{const _=String((Mn==null?void 0:Mn.flow_id)||"").trim();_&&(Ps.trim()||Co(_))},[Mn,Ps]),h.useEffect(()=>{const _=Us.trim(),k=S.trim(),N=Ps.trim();if(_){let B=!1;return Mo(!0),Qi(""),Pe.get_workflow_flow(_).then(H=>{if(B)return;const V=H==null?void 0:H.flow;Eo(V&&typeof V=="object"?V:null)}).catch(H=>{B||(Eo(null),Qi(String((H==null?void 0:H.message)||H||"Failed to load workflow flow")))}).finally(()=>{B||Mo(!1)}),()=>{B=!0}}if(!k||!N){Eo(null),Qi(""),Mo(!1);return}let T=!1;return Mo(!0),Qi(""),Pe.get_bundle_flow(k,N).then(B=>{if(T)return;const H=B==null?void 0:B.flow,V=H&&typeof H=="object"?H:null;Eo(V),V&&ha(X=>({...X,[N]:V}))}).catch(B=>{T||(Eo(null),Qi(String((B==null?void 0:B.message)||B||"Failed to load flow")))}).finally(()=>{T||Mo(!1)}),()=>{T=!0}},[Us,S,Ps,Pe]),h.useEffect(()=>{const _=S.trim();if(!ll||!_||!ti)return;let k=!1;const N=3,T=ie=>{const U=Array.isArray(ie==null?void 0:ie.nodes)?ie.nodes:[],xe=[];for(const Ce of U){const Re=Ce!=null&&Ce.data&&typeof Ce.data=="object"?Ce.data:{};if(String((Re==null?void 0:Re.nodeType)||(Ce==null?void 0:Ce.type)||"").trim()!=="subflow")continue;const Ue=(Re==null?void 0:Re.subflowId)||(Re==null?void 0:Re.flowId),$t=typeof Ue=="string"?Ue.trim():"";$t&&xe.push($t.includes(":")?$t.split(":",2)[1]:$t)}return xe},B=new Set,H=new Set,V=(ie,U)=>{if(!(!ie||U>=N))for(const xe of T(ie)){const Ce=String(xe||"").trim();if(!Ce||B.has(Ce))continue;B.add(Ce),H.add(Ce);const Re=al[Ce];Re&&V(Re,U+1)}};V(ti,0);const X=Array.from(H).filter(ie=>!al[ie]).slice(0,20);return X.length?((async()=>{for(const ie of X){if(k)return;try{const U=await Pe.get_bundle_flow(_,ie),xe=U==null?void 0:U.flow,Ce=xe&&typeof xe=="object"?xe:null;if(!Ce)continue;ha(Re=>Re[ie]?Re:{...Re,[ie]:Ce})}catch{}}})(),()=>{k=!0}):void 0},[ll,S,ti,al,Pe]);const La=h.useMemo(()=>{const k=(Array.isArray(z==null?void 0:z.flows)?z==null?void 0:z.flows:[]).map(N=>String(N||"").trim()).filter(Boolean);return k.length?Array.from(new Set(k)).sort():Array.from(new Set(qo)).sort()},[z,qo]);h.useEffect(()=>{Bs&&gr.trim()&&(eo(""),Ni.current="")},[Bs,u,gr]),h.useEffect(()=>{const _=_s.trim(),k=u.trim();if(!(vn&&!!_&&_!==k)){$r.current&&$r.current.abort(),$r.current=null,To.current=0,ya&&va("");return}if(ya===_)return;$r.current&&$r.current.abort();const T=new AbortController;$r.current=T,To.current=0,va(_),Wt({ts:Nt(),kind:"info",title:`Following run ${_} (status/events)`});let B=250;return(async()=>{for(;!T.signal.aborted;){try{await Pe.stream_ledger(_,{after:To.current,on_step:V=>kf(_,V),signal:T.signal});return}catch(V){if(T.signal.aborted)break;const X=String((V==null?void 0:V.message)||V||"stream error");Wt({ts:Nt(),kind:"error",title:"Child ledger stream error (will retry)",preview:_t(X),data:{child_run_id:_,error:X}})}if(T.signal.aborted)break;await new Promise(V=>setTimeout(V,B)),B=Math.min(5e3,Math.floor(B*1.6))}})(),()=>{T.abort()}},[vn,_s,u,Pe,ya]),h.useEffect(()=>{if(!vn||!u.trim())return;let _=!1;const k=async()=>{if(!_&&!dl.current&&ni.length&&!(jt.current>Date.now())){dl.current=!0;try{const T=ni.map(X=>String(X||"").trim()).filter(Boolean);if(!T.length)return;const B=T.map(X=>({run_id:X,after:Number(ga.current[X]||0)})),H=await Pe.get_ledger_batch({runs:B,limit:200}),V=H&&typeof H=="object"?H.runs:{};for(const X of T){if(_)return;const Se=V&&typeof V=="object"?V[X]:null,ie=Array.isArray(Se==null?void 0:Se.items)?Se.items:[],U=typeof(Se==null?void 0:Se.next_after)=="number"?Se.next_after:Number(ga.current[X]||0),xe=Number(ga.current[X]||0);for(let Ce=0;Ce<ie.length;Ce++){const Re=ie[Ce];Wu(X,{cursor:xe+Ce+1,record:Re})}ga.current[X]=U}}catch(T){if(_)return;Wt({ts:Nt(),kind:"error",title:"Subrun digest poll failed",preview:_t(String((T==null?void 0:T.message)||T||""))})}finally{dl.current=!1}}};k();const N=window.setInterval(()=>void k(),2e3);return()=>{_=!0,window.clearInterval(N),dl.current=!1}},[vn,u,ni,Pe]);const Ra=h.useMemo(()=>ca?gu.filter(_E):gu,[ca,gu]),bs=h.useMemo(()=>{const _=u.trim(),k=[];for(const N of He)!N||!N.record||k.push({run_id:_,cursor:N.cursor,record:N.record});for(const N of pt)!N||!N.record||k.push({run_id:String(N.run_id||"").trim(),cursor:N.cursor,record:N.record});return k},[He,pt,u]),Nl=h.useMemo(()=>{var k,N,T;const _={};for(const B of bs){const H=String(B.run_id||((k=B.record)==null?void 0:k.run_id)||"").trim();!H||String(((T=(N=B.record)==null?void 0:N.effect)==null?void 0:T.type)||"").trim()!=="llm_call"||(_[H]=(_[H]||0)+1)}return _},[bs]),zf=h.useMemo(()=>{const _=_s.trim();if(_)return _;let k="",N=-1;for(const[T,B]of Object.entries(Nl))B>N&&(k=T,N=B);return k||u.trim()},[Nl,_s,u]),Ui=(Km.trim()||zf).trim(),Cl=h.useMemo(()=>{var B;const _=new Set,k=u.trim(),N=_s.trim();k&&_.add(k),N&&_.add(N);for(const H of ni){const V=String(H||"").trim();V&&_.add(V)}for(const H of bs){const V=String(H.run_id||((B=H.record)==null?void 0:B.run_id)||"").trim();V&&_.add(V)}const T=Array.from(_);return T.sort((H,V)=>k&&H===k&&V!==k?-1:k&&V===k&&H!==k?1:N&&H===N&&V!==N?-1:N&&V===N&&H!==N?1:H<V?-1:H>V?1:0),T},[u,_s,ni,bs]),El=h.useMemo(()=>Tw(bs,{run_id:Ui}),[bs,Ui]),qt=h.useMemo(()=>{const _=u.trim();return _&&(Ne.find(k=>String(k.run_id||"").trim()===_)||yt.find(k=>String(k.run_id||"").trim()===_))||null},[Ne,yt,u]),wr=String((ce==null?void 0:ce.status)||(qt==null?void 0:qt.status)||"").trim(),mo=String(ir||((Oa=ce==null?void 0:ce.waiting)==null?void 0:Oa.reason)||(qt==null?void 0:qt.waiting_reason)||"").trim().toLowerCase(),ad=!!(ce!=null&&ce.is_scheduled||qt!=null&&qt.is_scheduled),ld=!!(ce!=null&&ce.paused||qt!=null&&qt.paused),Ss=ad&&wr.toLowerCase()==="waiting",cd=Ss&&mo==="until",Hs=Sn(Fs),ud=cd&&Hs!==null?qp(Hs-Date.now()):"",Pa=pb(ce),$l=ad&&ld?"Suspended":Ss?"Scheduled":wm({status:wr,paused:ld,stop_reason:Pa});async function dd(){if(j){hc(!0),Ai("");try{const _=ys,k=_==="session"?String(lr||Qr||q||"").trim():"",N=_==="run"?String(Is||u||"").trim():"",T=$b(Ro),B=zs.length?zs.join(","):"",H=Mb(ml),V=Math.max(0,oi)*cm,X=await Pe.search_artifacts({scope:_,session_id:k||void 0,run_id:N||void 0,query:ln||void 0,artifact_kind:B||void 0,created_after:T||void 0,include_stats:!0,limit:cm,offset:V,order_by:H.order_by,order:H.order}),Se=[],ie=new Set;for(const ze of Array.isArray(X==null?void 0:X.items)?X.items:[]){const Ue=Nb(ze,"search");!Ue||ie.has(Ue.artifact_id)||(ie.add(Ue.artifact_id),Se.push(Ue))}const U=X!=null&&X.stats&&typeof X.stats=="object"?X.stats:{},xe=Number((U==null?void 0:U.total)??(X==null?void 0:X.total)??Se.length),Ce=Yp(X);let Re=Ce;if(zs.length)try{const ze=await Pe.search_artifacts({scope:_,session_id:k||void 0,run_id:N||void 0,query:ln||void 0,created_after:T||void 0,include_stats:!0,limit:1,offset:0,order_by:H.order_by,order:H.order});Re=Yp(ze)}catch{Re=Ce}ii(Number.isFinite(xe)?Math.max(0,xe):Se.length),mf(Number((U==null?void 0:U.total_bytes)??(U==null?void 0:U.byte_total)??0)||0),no(Ce),Lo(Re),Os(Se),so(ze=>{var Ue;return ze&&Se.some($t=>$t.artifact_id===ze)?ze:((Ue=Se[0])==null?void 0:Ue.artifact_id)||""})}catch(_){Ai(String((_==null?void 0:_.message)||_||"Failed to load artifacts")),Os([]),ii(0),mf(0),no({}),Lo({}),so("")}finally{hc(!1)}}}async function fd(){if(j){gf(!0),gl("");try{const _=await Pe.audit_log_tail({max_bytes:16e4}),k=typeof(_==null?void 0:_.bytes)=="number"?Number(_.bytes):0,N=!!(_!=null&&_.truncated);_l(String((_==null?void 0:_.content)||"")),Io(`${k.toLocaleString()} bytes${N?" (tail)":""}`)}catch(_){gl(String((_==null?void 0:_.message)||_||"Failed to load audit log")),_l(""),Io("")}finally{gf(!1)}}}async function If(_){if(!j)return;const k=String(_||ba||Is||u||"").trim();if(!k){Ca([]),vl(""),oo("Select a run in Activity or Artifacts to load its runtime ledger.");return}xc(!0),oo("");try{const N=await Pe.get_ledger(k,{after:0,limit:2e3}),T=Array.isArray(N.items)?N.items:[];Ca(T.map((H,V)=>({cursor:V+1,record:H})));const B=typeof N.next_after=="number"?Number(N.next_after):T.length;vl(`${T.length.toLocaleString()} record${T.length===1?"":"s"}${B>=2e3?" (first 2,000)":""}`)}catch(N){oo(String((N==null?void 0:N.message)||N||"Failed to load run ledger")),Ca([]),vl("")}finally{xc(!1)}}h.useEffect(()=>{j&&e==="runtime"&&dd()},[j,e,ys,lr,Is,ln,zs,Ro,ml,oi]),h.useEffect(()=>{j&&(yc||Au||e==="runtime"&&fd())},[j,e,rr]),h.useEffect(()=>{if(!j||e!=="runtime"||gs!=="logs"||yl!=="run_ledger"&&yl!=="provider_calls")return;const _=String(ba||Is||u||"").trim();_&&If(_)},[j,e,gs,yl,ba,Is,u]);const Ws=h.useMemo(()=>{const _=new Map;for(const k of[...yt,...Ne]){const N=String(k.run_id||"").trim();N&&_.set(N,k)}for(const k of ni){const N=String(k||"").trim();!N||_.has(N)||_.set(N,{run_id:N,workflow_id:null,status:"",created_at:null,updated_at:null,ledger_len:null,parent_run_id:Ci.current[N]||null,session_id:Qr||null})}return u.trim()&&!_.has(u.trim())&&_.set(u.trim(),{run_id:u.trim(),workflow_id:typeof(ce==null?void 0:ce.workflow_id)=="string"?String(ce.workflow_id):null,status:typeof(ce==null?void 0:ce.status)=="string"?String(ce.status):"",created_at:typeof(ce==null?void 0:ce.created_at)=="string"?String(ce.created_at):null,updated_at:typeof(ce==null?void 0:ce.updated_at)=="string"?String(ce.updated_at):null,ledger_len:He.length||null,parent_run_id:typeof(ce==null?void 0:ce.parent_run_id)=="string"?String(ce.parent_run_id):null,session_id:typeof(ce==null?void 0:ce.session_id)=="string"?String(ce.session_id):Qr||null}),Array.from(_.values()).sort((k,N)=>{const T=Sn(k.updated_at||k.created_at)??0;return(Sn(N.updated_at||N.created_at)??0)-T})},[Ne,yt,u,ce,He.length,ni,Qr]),md=h.useMemo(()=>{const _=xu.trim().toLowerCase(),k=Ws,N={},T={};for(const ie of k){const U=String(ie.run_id||"").trim();if(!U)continue;T[U]=ie;const xe=String(ie.parent_run_id||Ci.current[U]||"").trim();xe&&(N[xe]||(N[xe]=[]),N[xe].push(ie))}const B=ie=>{const U=String(ie.status||"").trim().toLowerCase();return Ls==="all"?!0:Ls==="active"?Qc(U):Ls==="waiting"?U==="waiting":Ls==="terminal"?yi(U):Ls==="failed"?U==="failed":!0},H=ie=>{if(!_)return!0;const U=String(ie.workflow_id||ie.schedule_target_workflow_id||"").trim(),xe=U?dr[U]||U:"";return[ie.run_id,U,xe,ie.session_id,ie.status].join(" ").toLowerCase().includes(_)},V=new Set;for(const ie of k){const U=String(ie.run_id||"").trim();if(!U)continue;const xe=String(ie.parent_run_id||Ci.current[U]||"").trim();(!xe||!T[xe])&&V.add(U)}const X={},Se=ie=>{if(rl==="workflow"){const xe=String(ie.schedule_target_workflow_id||ie.workflow_id||"").trim()||"(unknown workflow)";return{key:xe,label:dr[xe]||xe}}if(rl==="session"){const xe=String(ie.session_id||"").trim()||"(no session)";return{key:xe,label:xe}}const U=String(ie.status||"").trim().toLowerCase()||"unknown";return Qc(U)?{key:"active",label:"Active"}:U==="failed"?{key:"failed",label:"Failed"}:yi(U)?{key:"finished",label:"Finished"}:{key:U,label:U}};for(const ie of V){const U=T[ie];if(!U)continue;const xe=[...N[ie]||[]].sort((ze,Ue)=>{const $t=Sn(ze.updated_at||ze.created_at)??0;return(Sn(Ue.updated_at||Ue.created_at)??0)-$t}),Ce=xe.some(ze=>B(ze)&&H(ze));if(!(B(U)&&H(U))&&!Ce)continue;const Re=Se(U);X[Re.key]||(X[Re.key]={key:Re.key,label:Re.label,rows:[]}),X[Re.key].rows.push({run:U,children:xe})}return Object.values(X).sort((ie,U)=>{const xe={active:0,waiting:1,failed:2,finished:3},Ce=xe[ie.key]??10,Re=xe[U.key]??10;return Ce!==Re?Ce-Re:ie.label.localeCompare(U.label)})},[Ws,xu,Ls,rl,dr]),js=h.useMemo(()=>rv(bs),[bs]),Zt=h.useMemo(()=>{const _=[...bs];return _.sort((k,N)=>{var H,V,X,Se;const T=Sn(((H=k.record)==null?void 0:H.ended_at)||((V=k.record)==null?void 0:V.started_at))??0,B=Sn(((X=N.record)==null?void 0:X.ended_at)||((Se=N.record)==null?void 0:Se.started_at))??0;return T-B}),_.slice(-240)},[bs]),Tn=h.useMemo(()=>{const _={};for(const k of Ws){const N=String(k.run_id||"").trim();N&&(_[N]=k)}return _},[Ws]),Dn=String(ba||Is||u||"").trim(),Jn=Dn&&Tn[Dn]||null,Wr=String(lr||(Jn==null?void 0:Jn.session_id)||Qr||q||"").trim(),Vo=h.useMemo(()=>to.map(_=>Sm(_,Tn,dr)),[to,Tn,dr]);h.useEffect(()=>{Sa(0)},[ln,zs,Ro,Is,ml,Po,ys,lr]);const Zn=Math.max(1,Math.ceil(xa/cm)),Hi=Math.min(Math.max(0,oi),Zn-1);h.useEffect(()=>{oi!==Hi&&Sa(Hi)},[oi,Hi]);const ns=h.useMemo(()=>Vo,[Vo,Hi]),Dc=h.useMemo(()=>{const _={};for(const k of ns){const N=Po==="type"?y_(k,Tn,dr):Cb(k,Po);_[N]||(_[N]=[]),_[N].push(k)}return Object.entries(_).map(([k,N])=>({key:k,items:N})).sort((k,N)=>{var T,B;if(Po==="time"){const H=Sn((T=k.items[0])==null?void 0:T.created_at)??0,V=Sn((B=N.items[0])==null?void 0:B.created_at)??0;if(H!==V)return V-H}return k.key.localeCompare(N.key)})},[ns,Po,Tn,dr]),Go=h.useMemo(()=>{const _=Li.trim();return _?ns.find(k=>k.artifact_id===_)||ns[0]||null:ns[0]||null},[ns,Li]);h.useEffect(()=>{e!=="runtime"||gs!=="artifacts"||$c(Go)},[e,gs,Go==null?void 0:Go.artifact_id]),h.useEffect(()=>()=>{Ri.url&&URL.revokeObjectURL(Ri.url)},[Ri.url]);const Ml=h.useMemo(()=>Ws.filter(_=>Qc(_.status)),[Ws]);h.useEffect(()=>{if(e!=="settings"&&e!=="launch"||!j||$)return;let _=!1;return(async()=>{const[k,N]=await Promise.all([Pe.list_skills(),Pe.list_mcp_servers()]);_||(G(k),le(N),K(!0))})(),()=>{_=!0}},[e,j,$]);const qr=[{id:"board",label:"Board",icon:s.jsx(zn,{name:"board",size:16})},{id:"observe",label:"Observe",icon:s.jsx(zn,{name:"history",size:16})},{id:"runtime",label:"System",icon:s.jsx(zn,{name:"server",size:16})},{id:"launch",label:"Launch",icon:s.jsx(zn,{name:"send",size:16})}],hd={board:"Board",observe:"Observe",runtime:"System",launch:"Launch",settings:"Settings"};return s.jsxs("div",{className:"app-shell shell",children:[s.jsxs("aside",{className:"shell_sidebar",children:[s.jsxs("div",{className:"shell_brand",title:"AbstractObserver (Web/PWA)",children:[s.jsx("span",{className:"logo-icon shell_brand_mark","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"4.2",transform:"rotate(-18 12 12)",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",opacity:"0.75"}),s.jsx("circle",{cx:"12",cy:"12",r:"4.7",fill:"currentColor",opacity:"0.95"}),s.jsx("circle",{cx:"10.3",cy:"10.7",r:"1.6",fill:"#ffffff",opacity:"0.18"}),s.jsx("circle",{cx:"19",cy:"13.6",r:"1.2",fill:"currentColor"})]})}),s.jsx("span",{className:"shell_brand_name",children:"Observer"})]}),s.jsxs("nav",{className:"shell_nav",children:[qr.map(_=>s.jsxs("button",{className:`shell_nav_item ${e===_.id?"active":""}`,onClick:()=>t(_.id),type:"button",children:[s.jsx("span",{className:"shell_nav_icon",children:_.icon}),s.jsx("span",{className:"shell_nav_label",children:_.label})]},_.id)),s.jsxs("a",{className:"shell_nav_item",href:c,target:"_blank",rel:"noreferrer",title:"Open the entity app (memory graph + visits)",children:[s.jsx("span",{className:"shell_nav_icon",children:s.jsx(zn,{name:"bot",size:16})}),s.jsx("span",{className:"shell_nav_label",children:"Entities ↗"})]}),s.jsxs("button",{className:`shell_nav_item ${e==="settings"?"active":""}`,onClick:()=>t("settings"),type:"button",children:[s.jsx("span",{className:"shell_nav_icon",children:s.jsx(zn,{name:"settings",size:16})}),s.jsx("span",{className:"shell_nav_label",children:"Settings"})]})]}),s.jsx("div",{className:"shell_sidebar_footer",children:s.jsxs("div",{className:"shell_connection shell_connection_passive",title:j?"Gateway connected":de?"Gateway: connecting…":"Gateway: signed out",children:[s.jsx("span",{className:`gateway_led ${j?"ok":de?"warn":"err"}`,"aria-hidden":"true"}),s.jsx("span",{className:`shell_connection_label ${j&&((Rl=(Bc=ee==null?void 0:ee.gateway)==null?void 0:Bc.principal)!=null&&Rl.user_id)?"mono":""}`,children:j?((br=(Pl=ee==null?void 0:ee.gateway)==null?void 0:Pl.principal)==null?void 0:br.user_id)||(n.gateway_auth_mode==="direct"?"direct dev":"connected"):de?"connecting…":"signed out"})]})})]}),s.jsxs("div",{className:"shell_main",children:[s.jsxs("header",{className:"shell_header",children:[s.jsx("div",{className:"shell_header_title",children:hd[e]||"Observer"}),s.jsxs("div",{className:"shell_header_actions",children:[a?s.jsx("monitor-gpu",{ref:d,mode:"icon","history-size":"5","tick-ms":"1500","base-url":n.gateway_auth_mode==="session"?"":n.gateway_url,title:"GPU usage (host)",style:{"--monitor-gpu-width":"34px","--monitor-gpu-bars-height":"22px","--monitor-gpu-padding":"2px 4px","--monitor-gpu-radius":"999px","--monitor-gpu-bg":"rgba(0,0,0,0.22)","--monitor-gpu-border":"rgba(255,255,255,0.16)",flexShrink:0}}):null,s.jsx(y0,{assistant:{open:Ke,onToggle:()=>Ct(_=>!_),label:"Observer assistant (docs-grounded)"},appearance:{onOpen:()=>Ye(!0)},connection:{phase:O.phase,signingOut:O.signingOut,onConnect:()=>O.openModal(),onDisconnect:()=>Sl()}})]})]}),s.jsx(u0,{...O.modalProps}),s.jsx(b0,{open:Fe,onClose:()=>Ye(!1),value:je,onChange:Ee}),s.jsx(Y0,{open:Ke,onClose:()=>Ct(!1),connected:j,topOffset:44,gateway:Pe}),s.jsxs("div",{className:"app-body shell_content",children:[e==="board"?j?s.jsx(iE,{gateway_connected:j,runs:yt,all_runs:Ne,runs_refreshed_at:Ie,entities:At,entities_total:fn,entities_error:Tt,refreshing:st,on_refresh:()=>void Jt(Pe,{force:!0}),on_open_run:_=>{t("observe"),Rs("overview"),Aa(_)},on_resume_wait:Du,entity_app_href:c,on_read_diary:(_,k)=>Pe.read_entity_diary_entry(_,k),phase_graph:ws}):s.jsx("div",{className:"page page_scroll",children:s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card mc_hero",children:[s.jsx("div",{className:"title",children:s.jsx("h1",{children:"Connect to your gateway"})}),s.jsxs("p",{className:"muted",children:["Mission Control shows every run and entity on one board — but nothing is connected yet.",D?` Last attempt: ${D}`:""]}),s.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center"},children:[s.jsx("button",{className:"btn primary",onClick:()=>O.openModal(),disabled:de,children:de?"Connecting…":"Sign in"}),s.jsx("button",{className:"btn",onClick:()=>void lo({open_modal_if_needed:!0}),disabled:de,title:"Retry with an existing browser session or a direct dev token",children:"Retry connection"})]})]})})}):null,e==="settings"?s.jsx("div",{className:"page page_scroll",children:s.jsxs("div",{className:"page_inner settings_col",children:[s.jsxs("section",{className:"pane",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Gateway"}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:`chip ${j?"ok":"warn"}`,children:zy(ee).label})]}),s.jsxs("div",{className:"pane_body settings_body",children:[s.jsxs("div",{className:"settings_row",children:[s.jsxs("div",{className:"settings_row_main",children:[s.jsx("div",{className:"settings_row_title",children:"Connection"}),s.jsx("div",{className:"settings_row_help",children:"The shared AbstractFramework sign-in: a gateway user token exchanges for an HTTP-only browser session. Raw tokens are never stored."})]}),s.jsxs("div",{className:"settings_row_actions",children:[s.jsx("button",{className:"btn",onClick:()=>O.openModal(),children:"Manage connection…"}),j?s.jsx("button",{className:"btn",onClick:()=>Sl(),title:"Sign this browser out of the gateway (this app's session only)",children:"Sign out"}):null]})]}),D?s.jsx("div",{className:"warn_callout",children:D}):null,s.jsxs("div",{className:"settings_row",children:[s.jsxs("div",{className:"settings_row_main",children:[s.jsx("div",{className:"settings_row_title",children:"Auto-connect on load"}),s.jsx("div",{className:"settings_row_help",children:"Reuse the browser session automatically when the app opens."})]}),s.jsx("div",{className:"settings_row_actions",children:s.jsxs("select",{value:n.auto_connect_gateway?"on":"off",onChange:_=>o(k=>({...k,auto_connect_gateway:_.target.value==="on"})),children:[s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})})]}),s.jsxs("details",{className:"settings_advanced",children:[s.jsx("summary",{children:"Advanced: direct dev connection (bearer token, cross-origin)"}),s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{children:"Gateway URL"}),s.jsx("input",{value:n.gateway_url,onChange:_=>o(k=>({...k,gateway_url:_.target.value})),placeholder:Rm})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Dev bearer token"}),s.jsx("input",{type:"password",value:n.auth_token,onChange:_=>o(k=>({...k,auth_token:_.target.value,gateway_auth_mode:"direct"})),placeholder:"development only — prefer the sign-in dialog"})]}),s.jsx("button",{className:"btn",onClick:()=>void lo({prefer_direct:!0}),disabled:de,children:de?"Connecting…":"Connect directly"})]})]})]}),s.jsxs("section",{className:"pane",children:[s.jsxs("div",{className:"pane_header",children:[s.jsx("span",{className:"pane_title",children:"Assistant"}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:"chip muted",children:"docs Q&A + run Ask"})]}),s.jsxs("div",{className:"pane_body settings_body",children:[s.jsx("div",{className:"settings_row_help",style:{marginTop:0},children:"The model answering the header assistant and the run page's Ask tab. Blank fields follow the gateway defaults."}),s.jsx(t0,{className:"field",providerLabel:"Provider",modelLabel:"Model",providerPlaceholder:"(gateway default)",modelPlaceholder:"(gateway default)",provider:n.maintenance_ai_provider,model:n.maintenance_ai_model,providers:On,models:Cc.models,loadingProviders:de,loadingModels:Ec,modelError:bl?Cc.error:"",allowCustomProvider:!0,allowCustomModel:!0,allowGatewayDefault:!0,gatewayDefaultLabel:"(gateway default)",onChange:_=>o(k=>({...k,maintenance_ai_provider:_.provider,maintenance_ai_model:_.model}))}),s.jsx("div",{className:"settings_subhead",children:"Skills"}),P===null?s.jsx("div",{className:"settings_row_help",children:j?$?"The gateway does not serve a skills inventory yet — the abstractskill shelf list lights up here the day it ships.":"Probing the gateway for the skills inventory…":"Connect to the gateway to list installable skills (abstractskill shelf)."}):P.length?s.jsx("div",{className:"settings_choice_list",children:P.map(_=>{const k=n.assistant_skill_names.includes(_.name);return s.jsxs("label",{className:`settings_choice ${k?"on":""}`,title:_.description||_.name,children:[s.jsx("input",{type:"checkbox",checked:k,onChange:N=>o(T=>({...T,assistant_skill_names:N.target.checked?Array.from(new Set([...T.assistant_skill_names,_.name])):T.assistant_skill_names.filter(B=>B!==_.name)}))}),s.jsxs("span",{className:"settings_choice_name",children:[_.name,_.version?s.jsxs("em",{children:[" v",_.version]}):null]}),_.description?s.jsx("span",{className:"settings_choice_desc",children:_.description}):null]},_.name)})}):s.jsx("div",{className:"settings_row_help",children:"The gateway serves an empty skills inventory."}),s.jsx("div",{className:"settings_row_help",children:"Selected skills ride the assistant's runs once the gateway's skills-attachment lane serves them; the selection persists here meanwhile."}),s.jsx("div",{className:"settings_subhead",children:"MCP servers"}),s.jsx("div",{className:"settings_row_help",style:{marginTop:0},children:"Remote tool endpoints the assistant may call. The gateway does not serve an MCP inventory yet — one manual endpoint is supported (advanced / potentially dangerous: it executes tool waits from this browser)."}),s.jsxs("div",{className:"settings_mcp_row",children:[s.jsx("input",{className:"mono",value:n.worker_url,onChange:_=>o(k=>({...k,worker_url:_.target.value})),placeholder:"https://your-mcp-worker-endpoint"}),s.jsx("input",{className:"mono",type:"password",value:n.worker_token,onChange:_=>o(k=>({...k,worker_token:_.target.value})),placeholder:"Bearer token (optional)"}),s.jsx("span",{className:`chip ${n.worker_url.trim()?"ok":"muted"}`,children:n.worker_url.trim()?"configured":"none"})]})]})]})]})}):null,e==="launch"?s.jsx("div",{className:"page page_scroll",children:s.jsx("div",{className:"page_inner constrained",children:s.jsxs("div",{className:"card",children:[s.jsx("div",{className:"help_text muted",children:"Pick a workflow, fill its inputs, and start a run on the connected gateway."}),j?null:s.jsxs("div",{className:"warn_callout",children:["Not connected."," ",s.jsx("button",{className:"btn primary",onClick:()=>O.openModal(),children:"Sign in"})," ","to launch workflows on this gateway."]}),s.jsxs("div",{className:"launch_workflow_bar",children:[s.jsxs("select",{className:"launch_workflow_select",value:Ru,onChange:async _=>{const k=String(_.target.value||"").trim();if(!k)return;const N=s_(k);N&&(L(N.bundle_id),C(N.flow_id),Co(N.flow_id),be([]),await ao(N.bundle_id))},disabled:de||!kc.length,children:[s.jsx("option",{value:"",children:kc.length?"(select workflow)":vn?de?"(loading workflows…)":"(no executable workflows published on this gateway)":"(sign in to load workflows)"}),kc.map(_=>s.jsx("option",{value:_.workflow_id,children:_.label},_.workflow_id))]}),s.jsx("input",{ref:Nr,type:"file",accept:".flow",style:{display:"none"},onChange:_=>{const k=_.target.files&&_.target.files.length?_.target.files[0]:null;k&&Iu(k)}}),s.jsx("button",{type:"button",className:"btn launch_btn_upload",onClick:()=>{var _;return(_=Nr.current)==null?void 0:_.click()},disabled:!j||de||er||te||Te,title:"Upload a .flow bundle",children:er?"…":"Upload"}),s.jsxs("button",{type:"button",className:"btn launch_btn_reload",onClick:()=>void zu(),disabled:!j||de||Un||te||Te,title:"Reload picks up server-side edits",children:[s.jsx(zn,{name:"refresh",size:14}),Un?"…":"Reload"]})]}),s.jsxs("div",{className:"field",children:[Mn!=null&&Mn.description?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:String(Mn.description)}):null,Q?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading workflow…"}):null,ne?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ne}):null]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Inputs"}),!S.trim()||!b.trim()?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Select a workflow above to configure inputs."}):ft===null?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginTop:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"input error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:"Invalid input JSON — reselect the workflow to reset its inputs."})]}):wl?s.jsx("div",{className:"launch_inputs",children:(()=>{const _=te||Te,k=[],N=[];for(const H of Do){if(!H||typeof H!="object")continue;const V=String(H.id||"").trim();if(!V)continue;const X=String(H.type||"").trim().toLowerCase();X==="tools"||X==="skills"||X==="mcp"||X==="mcp_servers"||V==="skills"||V==="mcp"||V==="mcp_servers"||X==="array"||Oi(X)||V==="prompt"||V==="system"?k.push(H):N.push(H)}const T=H=>String(H||"").trim().replace(/_/g," ").replace(/\b\w/g,V=>V.toUpperCase()),B=(H,V)=>{const X=String(H.id||"").trim();if(!X)return null;const Se=String(H.label||X).trim()||X,ie=Se===X?T(X):Se,U=String(H.type||"").trim().toLowerCase(),xe=Object.prototype.hasOwnProperty.call(H,"default"),Ce=xe?H.default:void 0,Re=xe?typeof Ce=="string"?Ce:jr(Ce,80):"",ze=ft==null?void 0:ft[X],Ue=xe?`${Re}`:"";if(U==="tools"){const Be=Array.isArray(ze)?ze.map(xt=>String(xt||"").trim()).filter(Boolean):[],ot=Array.isArray(Ce)?Ce.map(xt=>String(xt||"").trim()).filter(Boolean):[],gt=Array.from(new Set([...Nc,...Be,...ot])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(r_,{options:gt,value:Be,disabled:_,placeholder:"(no tools selected)",onChange:xt=>jn(X,xt)})]},X)}if(U==="skills"||X==="skills"){const Be=Array.isArray(ze)?ze.map(xt=>String(xt||"").trim()).filter(Boolean):[];if(P===null&&!Be.length)return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("div",{className:"help_text muted",children:"This gateway does not serve a skills inventory yet — skill selection lights up here when it ships (abstractskill shelf via abstractgateway)."})]},X);const ot=(P||[]).filter(xt=>xt.blocked!==!0).map(xt=>xt.name),gt=Array.from(new Set([...ot,...Be])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(r_,{options:gt,value:Be,disabled:_,placeholder:"(no skills selected)",onChange:xt=>jn(X,xt)})]},X)}if(U==="mcp"||U==="mcp_servers"||X==="mcp"||X==="mcp_servers"){const Be=Array.isArray(ze)?ze.map(xt=>String(xt||"").trim()).filter(Boolean):[];if(se===null&&!Be.length)return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("div",{className:"help_text muted",children:"This gateway does not serve an MCP server inventory yet — MCP selection lights up here when it ships."})]},X);const ot=(se||[]).map(xt=>xt.name),gt=Array.from(new Set([...ot,...Be])).sort();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx(r_,{options:gt,value:Be,disabled:_,placeholder:"(no MCP servers selected)",onChange:xt=>jn(X,xt)})]},X)}if(U==="provider"||U==="provider_text"){const Be=typeof ze=="string"?String(ze):"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsxs("select",{value:Be,onChange:ot=>jn(X,ot.target.value),disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(select)"}),Pu.map(ot=>s.jsx("option",{value:ot,children:ot},ot))]})]},X)}if(U==="model"||U==="model_text"){const Be=typeof ze=="string"?String(ze):"",ot=String((ft==null?void 0:ft.provider)||"").trim(),gt=ot?_n[ot]:void 0,xt=gt&&Array.isArray(gt.models)?gt.models.map(Ln=>String(Ln||"").trim()).filter(Boolean):[];return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),xt.length?s.jsxs("select",{value:Be,onChange:Ln=>jn(X,Ln.target.value),disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(select)"}),xt.map(Ln=>s.jsx("option",{value:Ln,children:Ln},Ln))]}):s.jsx("input",{value:Be,onChange:Ln=>jn(X,Ln.target.value),placeholder:Ue||"model id",disabled:_})]},X)}if(U==="boolean"){const Be=typeof ze=="boolean"?ze?"true":"false":"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsxs("select",{value:Be,onChange:ot=>{const gt=String(ot.target.value||"").trim();gt?jn(X,gt==="true"):jn(X,void 0)},disabled:_,children:[s.jsx("option",{value:"",children:Ue||"(default)"}),s.jsx("option",{value:"true",children:"Yes"}),s.jsx("option",{value:"false",children:"No"})]})]},X)}if(U==="number"){const Be=typeof ze=="number"&&Number.isFinite(ze)?String(ze):"";return s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("input",{type:"number",value:Be,onChange:ot=>{const gt=String(ot.target.value||"").trim();if(!gt){jn(X,void 0);return}const xt=Number(gt);Number.isFinite(xt)&&jn(X,xt)},placeholder:Ue,disabled:_})]},X)}if(U==="array"){const Be=Array.isArray(ze)?ze.map(ot=>String(ot||"").trim()).filter(Boolean).join(`
134
+ `):"";return s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("textarea",{className:"mono",value:Be,onChange:ot=>{const gt=String(ot.target.value||"").split(/\r?\n/g).map(xt=>String(xt||"").trim()).filter(Boolean);jn(X,gt.length?gt:void 0)},placeholder:Ue||"(one item per line)",rows:2,disabled:_})]},X)}if(Oi(U)){const Be=typeof Gr[X]=="string"?Gr[X]:"",ot=String($s[X]||"").trim();return s.jsxs("div",{className:"launch_field_wide",children:[s.jsxs("label",{className:"launch_label",children:[ie," ",s.jsx("span",{className:"launch_label_type",children:U})]}),s.jsx("textarea",{className:"mono",value:Be,onChange:gt=>{const xt=String(gt.target.value??"");Gs(wn=>({...wn,[X]:xt}));const Ln=xt.trim();if(!Ln){vi(wn=>{const ks={...wn};return delete ks[X],ks}),jn(X,void 0);return}try{const wn=JSON.parse(Ln);vi(ks=>{const bn={...ks};return delete bn[X],bn}),jn(X,wn)}catch(wn){vi(ks=>({...ks,[X]:String((wn==null?void 0:wn.message)||wn||"Invalid JSON")}))}},placeholder:Ue||"{...}",rows:3,disabled:_}),ot?s.jsx("div",{className:"launch_field_error",children:ot}):null]},X)}const $t=typeof ze=="string"?String(ze):"";return X==="prompt"||X==="system"?s.jsxs("div",{className:"launch_field_wide",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("textarea",{value:$t,onChange:Be=>jn(X,Be.target.value),placeholder:Ue||(X==="prompt"?"What should the agent do?":"System instructions (optional)"),rows:3,disabled:_})]},X):s.jsxs("div",{className:V||"launch_field",children:[s.jsx("label",{className:"launch_label",children:ie}),s.jsx("input",{value:$t,onChange:Be=>jn(X,Be.target.value),placeholder:Ue,disabled:_})]},X)};return k.sort((H,V)=>{const X={system:0,prompt:1,tools:2};return(X[String(H.id||"")]??10)-(X[String(V.id||"")]??10)}),s.jsxs(s.Fragment,{children:[k.map(H=>B(H)),N.length>0?s.jsx("div",{className:"launch_grid",children:N.map(H=>B(H,"launch_grid_cell"))}):null]})})()}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsx("label",{children:"Prompt (common)"}),s.jsx("textarea",{value:bc,onChange:_=>jn("prompt",_.target.value),placeholder:"What do you want the workflow/agent to do?",rows:3,disabled:te||Te})]}),s.jsxs("div",{className:"row",children:[s.jsx("div",{className:"col",children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Provider (common)"}),s.jsx("input",{value:Sc,onChange:_=>jn("provider",_.target.value),placeholder:"lmstudio / ollama / openai / ...",disabled:te||Te})]})}),s.jsx("div",{className:"col",children:s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Model (common)"}),s.jsx("input",{value:jc,onChange:_=>jn("model",_.target.value),placeholder:"qwen/qwen3-next-80b / gpt-4.1 / ...",disabled:te||Te})]})})]})]}),S.trim()&&b.trim()?s.jsxs("details",{className:"launch_capabilities",style:{marginTop:"10px"},children:[s.jsxs("summary",{className:"help_text muted",style:{cursor:"pointer"},children:["Capabilities",he.length?` · ${he.length} skill${he.length===1?"":"s"}`:""]}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Skills attach knowledge procedures to this run. The gateway resolves selections through the trust gate at start: validated skills activate, unverified ones are held for review, blocked ones never ride."}),P===null?s.jsx("div",{className:"help_text muted",style:{marginTop:"8px"},children:"This gateway does not serve a skills inventory yet — the shelf lights up here when it ships."}):P.length?s.jsx("div",{className:"launch_skill_list",children:P.map(_=>{var B;const k=he.includes(_.name),N=_.blocked===!0,T=_.requires_review===!0&&!N;return s.jsxs("label",{className:`launch_skill_row ${N?"is_blocked":""} ${k?"is_on":""}`,title:[_.description||"",_.tree_hash?`tree ${_.tree_hash.slice(0,16)}…`:"",N&&((B=_.reasons)!=null&&B.length)?`blocked: ${_.reasons.join("; ")}`:""].filter(Boolean).join(`
135
+ `),children:[s.jsx("input",{type:"checkbox",checked:k,disabled:N||te||Te,onChange:H=>{const V=H.target.checked?Array.from(new Set([...he,_.name])):he.filter(X=>X!==_.name);be(V),jn("skills",V.length?V:void 0)}}),s.jsx("span",{className:"launch_skill_name",children:_.name}),_.trust_level?s.jsx("span",{className:`chip ${N?"danger":T?"warn":"muted"}`,children:N?"blocked":T?"review":_.trust_level}):null,_.description?s.jsx("span",{className:"launch_skill_desc",children:_.description}):null]},_.name)})}):s.jsx("div",{className:"help_text muted",style:{marginTop:"8px"},children:"The gateway's skills shelf is empty."}),he.length?s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)",marginTop:"6px"},children:"Selected skills ride the run as input_data.skills; the resolved verdicts land in the run's record."}):null]}):null,s.jsxs("details",{style:{marginTop:"10px"},children:[s.jsx("summary",{className:"help_text muted",style:{cursor:"pointer"},children:"Workspace"}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Controls what the agent can access via filesystem tools."}),s.jsxs("div",{className:"launch_grid",style:{marginTop:"8px"},children:[s.jsxs("div",{className:"launch_grid_cell",style:{gridColumn:"1 / -1"},children:[s.jsx("label",{className:"launch_label",children:"Workspace Root"}),s.jsx("input",{className:"mono",value:xf,onChange:_=>jn("workspace_root",_.target.value),placeholder:"/path/to/workspace",disabled:te||Te}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)"},children:"Empty = gateway default (isolated per-run workspace)"})]}),s.jsxs("div",{className:"launch_grid_cell",children:[s.jsx("label",{className:"launch_label",children:"Access Mode"}),s.jsxs("select",{className:"mono",value:($a||"workspace_only").trim()||"workspace_only",onChange:_=>jn("workspace_access_mode",_.target.value),disabled:te||Te,children:[s.jsx("option",{value:"workspace_only",children:"workspace_only"}),s.jsx("option",{value:"workspace_or_allowed",children:"workspace_or_allowed"}),s.jsx("option",{value:"all_except_ignored",children:"all_except_ignored"})]}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)"},children:"workspace_only: absolute paths must stay under root. workspace_or_allowed: allow additional roots."})]})]}),($a||"").trim()==="workspace_or_allowed"?s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{className:"launch_label",children:"Allowed Paths"}),s.jsx("textarea",{className:"mono",rows:3,value:fi,onChange:_=>jn("workspace_allowed_paths",_.target.value),placeholder:`/path/to/project
136
+ /path/to/workspace`,disabled:te||Te,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)"},children:"Newline-separated directories (absolute or relative to workspace_root)"})]}):null,s.jsxs("div",{className:"field",style:{marginTop:"8px"},children:[s.jsx("label",{className:"launch_label",children:"Ignored Paths"}),s.jsx("textarea",{className:"mono",rows:3,value:xl,onChange:_=>jn("workspace_ignored_paths",_.target.value),placeholder:`node_modules
137
+ runtime
138
+ secret`,disabled:te||Te,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off"}),s.jsx("div",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)"},children:"Newline-separated paths to block (absolute or relative to workspace_root)"})]})]}),s.jsx("div",{className:"section_divider"}),s.jsx("div",{className:"section_title",children:"Schedule"}),nn?s.jsxs("div",{className:"observe_context_card error",style:{marginTop:"6px"},children:[s.jsx("span",{className:"chip mono danger",children:"error"}),s.jsx("span",{className:"mono",children:nn})]}):null,s.jsxs("div",{className:"sched_grid",children:[s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Start"}),s.jsxs("div",{className:"sched_radio_row",children:[s.jsxs("label",{className:"sched_radio",children:[s.jsx("input",{type:"radio",name:"schedule_start",checked:Ys==="now",onChange:()=>Or("now")}),s.jsx("span",{children:"Now"})]}),s.jsxs("label",{className:"sched_radio",children:[s.jsx("input",{type:"radio",name:"schedule_start",checked:Ys==="at",onChange:()=>Or("at")}),s.jsx("span",{children:"Scheduled"})]})]}),Ys==="at"?s.jsx("input",{type:"datetime-local",value:an,onChange:_=>ra(_.target.value),style:{marginTop:"6px"}}):null]}),s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Cadence"}),s.jsxs("select",{value:Yr,onChange:_=>Ms(_.target.value),children:[s.jsx("option",{value:"once",children:"Run once"}),s.jsx("option",{value:"forever",children:"Repeat forever"}),s.jsx("option",{value:"count",children:"Repeat N times"}),s.jsx("option",{value:"until",children:"Repeat until date"})]})]}),Yr!=="once"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Every"}),s.jsxs("div",{className:"sched_inline",children:[s.jsx("input",{type:"number",min:1,value:String(As),onChange:_=>Ks(Math.max(1,parseInt(_.target.value||"1",10)||1)),style:{width:"70px"}}),s.jsxs("select",{value:rt,onChange:_=>rn(_.target.value),children:[s.jsx("option",{value:"minutes",children:"min"}),s.jsx("option",{value:"hours",children:"hours"}),s.jsx("option",{value:"days",children:"days"}),s.jsx("option",{value:"weeks",children:"weeks"}),s.jsx("option",{value:"months",children:"months"})]})]})]}):null,Yr==="count"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"Total runs"}),s.jsx("input",{type:"number",min:1,value:String(Cr),onChange:_=>xi(Math.max(1,parseInt(_.target.value||"1",10)||1)),style:{width:"100px"}})]}):null,Yr==="until"?s.jsxs("div",{className:"sched_cell",children:[s.jsx("label",{className:"launch_label",children:"End date"}),s.jsxs("div",{className:"sched_inline",children:[s.jsx("input",{type:"date",value:_r,onChange:_=>sa(_.target.value)}),s.jsx("input",{type:"time",value:Ja,onChange:_=>Za(_.target.value)})]})]}):null]}),s.jsxs("label",{className:"launch_checkbox",style:{marginTop:"8px"},children:[s.jsx("input",{type:"checkbox",checked:Wn,onChange:_=>as(!!_.target.checked)}),s.jsxs("span",{children:["Share context across executions ",s.jsx("span",{className:"help_text muted",style:{fontSize:"var(--font-size-xxs)",fontWeight:400},children:"(when disabled, each run gets its own isolated session)"})]})]}),s.jsx("div",{className:"section_divider"}),Lt?s.jsxs("div",{className:"observe_context_card error",style:{marginBottom:"10px"},children:[s.jsx("span",{className:"chip mono danger",children:"error"}),s.jsx("span",{className:"mono",children:Lt})]}):null,s.jsx("div",{className:"launch_actions_bar launch_actions_stack",children:(()=>{const _=j?!S.trim()||!b.trim()?"Select a workflow":ft===null?"Inputs contain invalid JSON":te||Te?"Attaching to a run…":de||Q?"Loading…":cn?"Submitting…":"":"Sign in first";return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"launch_submit_btn",onClick:()=>void Cf(),disabled:!!_,title:_,children:cn||te?"Launching…":Ys!=="now"||Yr!=="once"?"Launch (scheduled)":"Launch now"}),_&&!cn&&!te?s.jsx("span",{className:"mono muted launch_disabled_reason",children:_}):null]})})()})]})})}):null,e==="runtime"?s.jsx(Xb,{gateway_connected:j,tab:gs,runs:Ws,active_runs:Ml,all_artifacts:to,artifacts:ns,artifact_total_count:xa,artifact_total_bytes:Mu,artifact_facets:nh,artifact_type_facets:fl,artifact_page:Hi,artifact_page_size:cm,artifact_groups:Dc,selected_artifact:Go,embedded_preview:Ri,loading:mc,error:wa,query:ln,scope:ys,type_filters:zs,date_filter:Ro,group_by:Po,sort_by:ml,artifact_run_filter:Is,audit_log_text:Au,audit_log_meta:pf,audit_log_loading:yc,audit_log_error:pl,workflow_label_by_id:dr,run_by_id:Tn,selected_run_id:Dn,session_id:Wr,runtime_log_source:yl,runtime_log_query:Na,runtime_ledger_log_items:vc,runtime_ledger_log_meta:Ea,runtime_ledger_log_loading:Tu,runtime_ledger_log_error:Lu,on_tab_change:$u,on_query_change:xn,on_scope_change:sr,on_session_filter_change:ro,on_type_filters_change:Fr,on_date_filter_change:hf,on_group_by_change:_c,on_sort_by_change:Ti,on_artifact_page_change:Sa,on_artifact_run_filter_change:_=>{const k=String(_||"").trim();pc(k),k&&hl(k),k&&ys!=="run"&&sr("run")},on_refresh_artifacts:()=>void dd(),on_refresh_audit:()=>void fd(),on_refresh_runtime_ledger:_=>void If(_),on_runtime_log_source_change:yf,on_runtime_log_query_change:vf,on_select_run:_=>{const k=String(_||"").trim();hl(k);const N=k&&Tn[k]||null,T=String((N==null?void 0:N.session_id)||"").trim();T&&ro(T)},on_select_artifact:so,on_preview_artifact:_=>void Ma(_),on_download_artifact:_=>void Uu(_),on_open_run:_=>{hl(String(_||"").trim()),t("observe"),Rs("overview"),Aa(_)},on_open_ledger:_=>{hl(String(_||"").trim()),t("observe"),Rs("ledger"),Aa(_)},on_refresh_runs:()=>void Jt(Pe,{force:!0}),on_reconnect:()=>void lo({open_modal_if_needed:!0}),on_open_settings:()=>t("settings"),memory_panel:j?s.jsx(zC,{gateway:Pe,selected_run_id:ba,selected_session_id:Wr}):null}):null,e==="observe"?s.jsx("div",{className:"page observe_page",children:s.jsxs("div",{className:"observatory_layout",children:[s.jsx(Zb,{sections:md,selected_run_id:u,root_run_id:y,search:xu,filter:Ls,group_by:rl,loading:st,connected:j,on_sign_in:()=>O.openModal(),total_runs:Ws.length,workflow_label_by_id:dr,on_search:wu,on_filter:Ym,on_group_by:tf,on_refresh:()=>void Jt(),on_select:(_,k)=>void Aa(_,{root_run_id:k||_})}),s.jsxs("div",{className:"observatory_main",children:[s.jsxs("div",{className:"observe_toolbar",children:[s.jsxs("div",{className:"observe_toolbar_row",children:[u.trim()?s.jsxs("div",{className:"observe_run_identity",title:u.trim(),children:[s.jsx("span",{className:"observe_run_name",children:dr[String((qt==null?void 0:qt.workflow_id)||"")]||String((qt==null?void 0:qt.workflow_id)||"").trim()||Mt(u.trim(),22)}),s.jsx("span",{className:"chip mono muted",children:Mt(u.trim(),14)}),s.jsx("span",{className:`chip ${Ka($l||wr,Pa)}`,title:String((Pa==null?void 0:Pa.headline)||""),children:$l||wr||"unknown"})]}):s.jsx("span",{className:"observe_run_identity_empty",children:"No run selected"}),s.jsx("span",{className:"observe_toolbar_spacer"}),u.trim()?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{if(Ta==="pause"){fs("pause"),ms(""),Qs(""),ds(!0);return}Gu("resume")},disabled:xr,children:od}),ch?s.jsx("button",{className:"btn primary",onClick:()=>void Ac(),disabled:te||Te||Bs||Bi,children:"Run now"}):null,s.jsx("button",{className:"btn danger",onClick:()=>{fs("cancel"),ms(""),Qs(""),ds(!0)},disabled:te||Te||Bs,children:"Cancel"}),s.jsx("button",{className:"btn btn_icon",onClick:Ef,title:"Clear the run view",children:s.jsx(zn,{name:"x",size:14})})]}):null]}),u.trim()&&!Bs?s.jsx("div",{className:"observe_steer_row",children:s.jsx(p0,{runId:u.trim(),parked:fr,submit:(_,k)=>Pe.submit_command({command_id:`steer-${ss()}`,run_id:_,type:"inject_guidance",payload:{guidance:k},client_id:"web_pwa"}).then(N=>({accepted:!!(N!=null&&N.accepted),duplicate:!!(N!=null&&N.duplicate),seq:Number((N==null?void 0:N.seq)??0)})),onSent:()=>Wt({ts:Nt(),kind:"info",title:"Steer queued",preview:"inject_guidance submitted — delivery shows as abstract.steer_seen in the ledger"})})}):null,fr||es||vu?s.jsxs("div",{className:"observe_toolbar_context",children:[fr?s.jsxs("div",{className:"observe_context_card info",children:[s.jsxs("div",{className:"observe_context_label",children:[(()=>{const _=es?Bi?"suspended":"scheduled":"waiting";return s.jsx("span",{className:`chip ${Ka(_)}`,children:_})})(),s.jsx("span",{className:"muted",children:ir||"unknown"})]}),s.jsxs("div",{className:"observe_context_body",children:[Tr?s.jsxs("span",{className:"mono",title:Tr,children:[s.jsx("span",{className:"muted",children:"wait_key"}),": ",Mt(Tr,46)]}):null,ir==="event"&&Rc?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"event"}),": ",Rc]}):null,ir==="subworkflow"&&co?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"child"}),": ",Mt(co,18)]}):null,ir==="until"&&Fs?s.jsxs("span",{className:"mono",title:Fs,children:[s.jsx("span",{className:"muted",children:"until"}),": ",Mt(Fs,46)]}):null,ir==="until"&&Fs?s.jsx("span",{className:"mono muted",children:(()=>{const _=Sn(Fs),k=_!==null?new Date(_).toLocaleString():Fs,N=_!==null?qp(_-Date.now()):"";return`Next at ${k}${N?` (in ${N})`:""}`})()}):null]}),ir==="subworkflow"&&co?s.jsxs("div",{className:"observe_context_actions",children:[s.jsx("button",{className:"btn primary",onClick:async()=>{m(co),await Ho(co)},disabled:te,children:"Attach to child"}),y.trim()&&y.trim()!==u.trim()?s.jsx("button",{className:"btn",onClick:async()=>{m(y.trim()),await Ho(y.trim())},disabled:te,children:"Back to root"}):null]}):null]}):null,es?s.jsxs("div",{className:"observe_context_card muted",children:[s.jsxs("div",{className:"observe_context_label",children:[s.jsx("span",{className:"chip muted",children:"schedule"}),s.jsx("span",{className:"muted",children:Ic?`every ${Hr}`:"once"})]}),s.jsxs("div",{className:"observe_context_body",children:[Hr?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"interval"}),": ",Hr]}):null,s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"share ctx"}),": ",lh?"yes":"no"]}),typeof id=="number"?s.jsxs("span",{className:"mono",children:[s.jsx("span",{className:"muted",children:"repeats"}),": ",id]}):null]}),fo!==null?s.jsxs("div",{className:"observe_context_budget",children:[s.jsxs("span",{className:"mono muted",children:[typeof mr=="number"&&typeof Pf=="number"?`${mr.toLocaleString()} / ${Pf.toLocaleString()}`:"",` • ${Math.round(Math.max(0,Math.min(1,fo))*100)}%`]}),s.jsx("div",{className:"observe_budget_bar",children:s.jsx("div",{className:`observe_budget_fill ${fo>=.9?"danger":fo>=.75?"warn":"ok"}`,style:{width:`${Math.round(Math.max(0,Math.min(1,fo))*100)}%`}})})]}):null,s.jsxs("div",{className:"observe_context_actions",children:[Ic?s.jsx("button",{className:"btn",onClick:()=>{In(Hr||""),Yn(!0),Fn(""),Xs(!0)},disabled:te||us,children:"Edit schedule"}):null,Ic?s.jsx("button",{className:"btn",onClick:()=>{tr(""),go(!0)},disabled:te||nr,children:"Compact context"}):null]})]}):null,vu?s.jsxs("div",{className:"observe_context_card error",children:[s.jsx("span",{className:"chip danger",children:"error"}),s.jsx("span",{className:"mono",children:vu})]}):null]}):null]}),s.jsxs("div",{className:"card panel_card card_scroll observe_viewer observe_viewer_full",children:[s.jsxs("div",{className:"tab_bar",children:[s.jsxs("div",{role:"tablist","aria-label":"Run views",className:"observe_tablist",children:[s.jsx("button",{role:"tab","aria-selected":rr==="overview",className:`tab ${rr==="overview"?"active":""}`,onClick:()=>Rs("overview"),children:"Story"}),s.jsx("button",{role:"tab","aria-selected":rr==="ledger",className:`tab ${rr==="ledger"?"active":""}`,onClick:()=>Rs("ledger"),children:"Ledger"}),s.jsx("button",{role:"tab","aria-selected":rr==="graph",className:`tab ${rr==="graph"?"active":""}`,onClick:()=>Rs("graph"),children:"Flow"}),s.jsx("button",{role:"tab","aria-selected":rr==="chat",className:`tab ${rr==="chat"?"active":""}`,onClick:()=>Rs("chat"),children:"Ask"})]}),rr==="ledger"&&(Ra.length>0||sl==="cycles")?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsxs("div",{className:"seg_toggle",children:[s.jsx("button",{className:`seg_btn ${sl==="steps"?"active":""}`,onClick:()=>bu("steps"),children:"Steps"}),s.jsx("button",{className:`seg_btn ${sl==="cycles"?"active":""}`,onClick:()=>bu("cycles"),children:"Cycles"})]}),sl==="steps"?s.jsx("button",{className:`seg_action ${ca?"active":""}`,onClick:()=>ua(_=>!_),title:ca?"Showing condensed view":"Showing all steps",children:ca?"Condensed":"All"}):s.jsxs("select",{className:"mono seg_select",value:Ui,onChange:_=>Su(String(_.target.value||"")),disabled:!Cl.length,title:"Select run for cycles view",children:[Cl.length?null:s.jsx("option",{value:"",children:"(no runs)"}),Cl.map(_=>{const k=typeof Nl[_]=="number"?Number(Nl[_]):0,N=`${Mt(_,18)}${k?` • ${k} llm`:""}`;return s.jsx("option",{value:_,children:N},_)})]}),s.jsx("button",{className:"seg_action",disabled:!He.length&&!pt.length,title:"Copy full ledger as JSONL",onClick:()=>{const N=[...He.map(H=>({run_id:u.trim()||H.record.run_id||"",cursor:H.cursor,record:H.record})),...pt.map(H=>({run_id:H.run_id,cursor:H.cursor,record:H.record}))].map(H=>{var Se,ie;const V=String(((Se=H.record)==null?void 0:Se.ended_at)||((ie=H.record)==null?void 0:ie.started_at)||"").trim(),X=Sn(V);return{...H,_ms:X??0}});N.sort((H,V)=>(H._ms||0)-(V._ms||0));const B=(N.length>5e3?N.slice(N.length-5e3):N).map(({_ms:H,...V})=>JSON.stringify(V)).join(`
139
+ `);xs(B)},children:"Copy JSONL"})]}):null,rr==="graph"?s.jsxs("div",{className:"tab_bar_controls",children:[s.jsx("button",{className:`seg_action ${ll?"active":""}`,onClick:()=>cf(_=>!_),children:"Subflows"}),s.jsx("button",{className:`seg_action ${Cu?"active":""}`,onClick:()=>uf(_=>!_),children:"Path"}),La.length?s.jsx("select",{className:"mono seg_select",value:Ps,onChange:_=>Co(String(_.target.value||"")),disabled:!!Us.trim()||!S.trim()||$o,children:La.map(_=>s.jsx("option",{value:_,children:_},_))}):null]}):null]}),rr==="overview"?s.jsx(Qb,{run_id:u,run:qt,run_state:ce,status_label:$l||wr||"unknown",workflow_label_by_id:dr,root_run_id:y,subrun_ids:ni,session_id:Qr,records_count:He.length,records:He,child_records_count:pt.length,provider_activities:js,attachments_count:da.length,latest_summary:Je,wait_state:Xt,summary_generating:ff,summary_error:th,on_generate_summary:()=>void oh(),on_open_runtime:()=>{const _=String(u||"").trim();_&&(hl(_),pc(_),sr("run")),$u("artifacts"),t("runtime")},on_open_subrun:_=>void Aa(_,{root_run_id:y||u||_}),on_answer_wait:()=>Ts(""),workspace_root:ic,on_reveal_workspace:()=>void wf(),run_artifacts:sf,run_artifacts_loading:Xm,run_artifacts_error:Jm,on_preview_run_artifact:_=>void Ma(_),on_download_run_artifact:_=>void Uu(_),timeline_items:Zt,node_index:di,attachments:da,attachments_loading:il,attachments_error:rf,attachments_ready:!!rc.trim(),on_refresh_attachments:()=>void Bu(),on_preview_attachment:_=>void Sf(_),on_download_attachment:_=>void bf(_),on_copy:_=>void xs(_)}):null,rr==="ledger"?s.jsx(s.Fragment,{children:sl==="steps"?s.jsxs("div",{className:"log log_scroll",children:[Ra.map(_=>s.jsx(tS,{item:_,open:Vm[_.id]===!0,on_toggle:()=>yu(k=>({...k,[_.id]:!k[_.id]})),response_open:Gm[_.id]===!0,on_toggle_response:()=>ef(k=>({...k,[_.id]:!k[_.id]})),node_index:di,on_copy:k=>void xs(k)},_.id)),Ra.length?null:s.jsx("div",{className:"empty_state_inline",children:"(no ledger items)"})]}):s.jsx("div",{className:"log log_scroll",children:s.jsx(Nw,{items:El.items,title:"Agent",subtitle:El.node_id?`node_id: ${El.node_id}`:"Live per-effect trace (LLM/tool calls).",subRunId:Ui,onOpenSubRun:Ui&&Ui!==u.trim()?()=>{m(Ui),Ho(Ui)}:void 0})})}):null,rr==="graph"?s.jsxs(s.Fragment,{children:[Nu?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"graph error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:Nu})]}):null,$o?s.jsxs("div",{className:"log_item log_item_info",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"loading"}),s.jsx("span",{className:"mono",children:Us.trim()?Us.trim():Ps})]}),s.jsx("div",{className:"body mono",children:"Loading graph…"})]}):null,s.jsx("div",{className:"graph_panel",children:s.jsx(fS,{flow:ti,flow_by_id:al,expand_subflows:ll,simplify:!0,prefer_vertical:!0,vertical_compact:.78,schedule_next_in:ud,schedule_interval:Hr,node_last_ms:uh,active_node_id:Of,recent_nodes:Eu,visited_nodes:eh,highlight_path:Cu,now_ms:df})})]}):null,s.jsxs(qa,{open:Zm,title:ol||"Attachment",onClose:()=>{Kr(!1),No(""),ma(""),lc(!1)},actions:s.jsx(s.Fragment,{children:s.jsx("button",{className:"btn",onClick:()=>{Kr(!1),No(""),ma(""),lc(!1)},children:"Close"})}),children:[Qm?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"Loading…"}):null,ku?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:ku}):null,s.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",maxHeight:"62vh",overflow:"auto",margin:0},children:lf||"(empty)"})]}),rr==="chat"?s.jsxs("div",{className:"ask_tab log_scroll",style:{marginTop:"6px"},children:[s.jsxs("div",{className:"ask_header",children:[s.jsx("span",{className:"ask_title",children:"Ask about this run"}),s.jsx("span",{className:"chip muted",title:"Model comes from Settings → Assistant (blank = gateway default)",children:(n.maintenance_ai_provider.trim()||"gateway")+" / "+(n.maintenance_ai_model.trim()||"default")}),s.jsx("span",{className:"pane_spacer"}),s.jsx("span",{className:"ask_hint",children:"Read-only · grounded in this run + subflows"})]}),s.jsxs("details",{className:"ask_manage",children:[s.jsx("summary",{children:"History & export"}),s.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[s.jsxs("div",{className:"actions",style:{justifyContent:"space-between",alignItems:"center",gap:"10px",flexWrap:"wrap",marginTop:0},children:[s.jsx("div",{style:{flex:1,minWidth:260},children:s.jsx(iu,{value:hu,options:pu,placeholder:tl?"Loading…":pu.length?"Select a saved discussion…":"(none saved)",disabled:!u.trim()||!j||!pu.length,loading:tl,searchable:!0,clearable:!0,onChange:_=>{nl(_),jo("")}})}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:0},children:[s.jsx("button",{className:"btn",type:"button",disabled:!hu.trim()||!j||Ql,onClick:()=>void Ju(),children:Ql?"Loading…":"Load"}),s.jsx("button",{className:"btn",type:"button",disabled:!Kt.length||tt||En||Ql,onClick:()=>{Et([]),F(""),we(""),Kn(""),ki(""),bo("")},children:"Clear"}),s.jsx("button",{className:"btn",type:"button",onClick:()=>void Lc(),disabled:!u.trim()||!j||tl,children:tl?"Refreshing…":"Refresh"})]})]}),s.jsxs("div",{className:"actions",style:{justifyContent:"flex-end",marginTop:"8px",flexWrap:"wrap"},children:[s.jsx("button",{className:"btn",type:"button",disabled:!Kt.length||!u.trim()||!j||En||!_u,onClick:()=>void $f(),title:_u?"":"No changes since last save",children:En?"Saving…":!_u&&ji?"Saved":"Save discussion"}),s.jsx("button",{className:"btn",type:"button",disabled:!Kt.length,onClick:()=>Xu("download"),children:"Export Markdown"}),s.jsx("button",{className:"btn",type:"button",disabled:!Kt.length,onClick:()=>Xu("copy"),children:Ot==="copied"?"Copied":Ot==="failed"?"Copy failed":"Copy Markdown"})]}),ji?s.jsxs("div",{className:"chat_hint",children:["Last saved: ",Zo(ji)]}):null,Dr?s.jsx("div",{className:"chat_hint chat_hint_danger",children:Dr}):null,Qd?s.jsx("div",{className:"chat_hint chat_hint_danger",children:Qd}):null,Zd?s.jsx("div",{className:"chat_hint chat_hint_danger",children:Zd}):null]})]}),ae?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:ae})]}):null,ke?s.jsxs("div",{className:"log_item log_item_danger",children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{children:"voice"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:ke})]}):null,s.jsx("div",{className:"chat_messages",style:{marginTop:"10px"},children:s.jsx(Uy,{messages:Kt,className:"log_scroll",messageProps:Bn.tts_supported&&j&&We.trim()?{onSpeakToggle:Ku,getSpeakState:Tc,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:s.jsx("div",{className:"chat_empty_hint",children:"Ask about this run (why failed, which tools, what happened in subflows)."})})}),s.jsx("div",{className:"chat_composer",style:{marginTop:"10px"},children:s.jsx(Hy,{ref:en,value:xo,onChange:F,onSubmit:()=>void Ds(),placeholder:"Ask about this run…",disabled:!u.trim()||!j||tt,busy:tt||Bn.voice_ptt_busy,busyLabel:Bn.voice_ptt_busy?"Transcribing…":"Thinking…",rows:3,sendButtonClassName:"btn primary",actions:s.jsxs("button",{className:`btn btn_icon voice_btn${Bn.voice_ptt_recording?" danger":""}`,type:"button",disabled:!j||!Uo.trim()||!We.trim()||tt||Bn.voice_ptt_busy||!Bn.voice_ptt_supported,title:Bn.voice_ptt_supported?Bn.voice_ptt_busy?"Transcribing…":Bn.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":"Voice recording is not supported in this browser","aria-label":"Voice input",onPointerDown:_=>{var k,N;if(!(!j||!Uo.trim()||!We.trim()||tt||Bn.voice_ptt_busy||!Bn.voice_ptt_supported)){_.preventDefault();try{(N=(k=_.currentTarget)==null?void 0:k.setPointerCapture)==null||N.call(k,_.pointerId)}catch{}Bn.start_voice_ptt_recording()}},onPointerUp:_=>{_.preventDefault(),Bn.stop_voice_ptt_recording()},onPointerCancel:_=>{_.preventDefault(),Bn.stop_voice_ptt_recording()},children:[s.jsx(zn,{name:Bn.voice_ptt_recording?"x":"mic",size:16}),Bn.voice_ptt_busy?"Transcribing…":Bn.voice_ptt_recording?"Recording…":"Voice"]})})})]}):null,u.trim()?s.jsxs("div",{className:`status_bar ${vo?"pulse":""}`,children:[s.jsx("strong",{children:"Run"}),":"," ",s.jsx("span",{className:"mono",children:$l||wr||"unknown"}),cd&&ud?s.jsxs("span",{className:"mono muted",children:[" • next in ",ud]}):null,Zi?s.jsxs("span",{className:"mono muted",children:[" • ",Zi]}):null]}):null]})]})]})}):null,s.jsxs(qa,{open:vs,title:li||"Artifact",onClose:()=>{ai(!1),io(""),zo(""),ka(!1),Ur(null),cr&&(URL.revokeObjectURL(cr),ja(""))},actions:s.jsx("button",{className:"btn",onClick:()=>{ai(!1),io(""),zo(""),ka(!1),Ur(null),cr&&(URL.revokeObjectURL(cr),ja(""))},children:"Close"}),children:[_f?s.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"Loading…"}):null,gc?s.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:gc}):null,Mr==="image"&&cr?s.jsx("img",{className:"runtime_preview_media",src:cr,alt:li||"Artifact preview"}):Mr==="audio"&&cr?s.jsx("audio",{className:"runtime_preview_media",controls:!0,src:cr}):Mr==="video"&&cr?s.jsx("video",{className:"runtime_preview_media",controls:!0,src:cr}):s.jsx(iv,{artifact:$n,text:Oo||"(empty)",className:"runtime_preview_text"})]}),Gn?s.jsxs(qa,{open:Gn,title:"Edit schedule",onClose:()=>{Xs(!1),In(""),Yn(!0),Fn(""),Js(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Xs(!1),In(""),Yn(!0),Fn(""),Js(!1)},disabled:te||us,children:"Back"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await sh({interval:ia,apply_immediately:ls})||(Xs(!1),Fn(""),Js(!1))},disabled:te||us||!ia.trim(),children:"Save"})]}),children:[cs?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:cs})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Interval"}),s.jsx("input",{className:"mono",value:ia,onChange:_=>In(String(_.target.value||"")),placeholder:"20m / 1h / 0.5s / 250ms",disabled:te||us}),s.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:["Accepted units: ",s.jsx("span",{className:"mono",children:"ms"}),", ",s.jsx("span",{className:"mono",children:"s"}),", ",s.jsx("span",{className:"mono",children:"m"}),","," ",s.jsx("span",{className:"mono",children:"h"}),", ",s.jsx("span",{className:"mono",children:"d"}),". This updates the existing scheduled run in place (no context loss)."]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Quick picks"}),s.jsx("div",{className:"actions",style:{gap:"8px",flexWrap:"wrap"},children:["15m","30m","1h","2h","6h","1d"].map(_=>s.jsx("button",{className:"btn",onClick:()=>In(_),disabled:te||us,children:_},_))})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Apply"}),s.jsxs("label",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[s.jsx("input",{type:"checkbox",checked:ls,onChange:_=>Yn(!!_.target.checked),disabled:te||us}),"Apply immediately (recompute next run from now if waiting)"]})]})]}):null,Yt?s.jsxs(qa,{open:Yt,title:"Compact scheduled context",onClose:()=>{go(!1),tr(""),Er(!1)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{go(!1),tr(""),Er(!1)},disabled:te||nr,children:"Cancel"}),s.jsx("button",{className:"btn primary",onClick:async()=>{await ih({preserve_recent:oa,compression_mode:zr,focus:Zs})||(go(!1),tr(""),Er(!1))},disabled:te||nr,children:nr?"Compacting…":"Compact"})]}),children:[wi?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:wi})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Preserve recent turns"}),s.jsx("input",{type:"number",min:1,value:String(oa),onChange:_=>aa(Math.max(1,parseInt(_.target.value||"6",10)||6)),disabled:te||nr})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Mode"}),s.jsxs("select",{value:zr,onChange:_=>Qa(_.target.value),disabled:te||nr,children:[s.jsx("option",{value:"light",children:"light"}),s.jsx("option",{value:"standard",children:"standard"}),s.jsx("option",{value:"heavy",children:"heavy"})]})]}),s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Focus (optional)"}),s.jsx("input",{className:"mono",value:Zs,onChange:_=>yo(String(_.target.value||"")),placeholder:"e.g. important decisions, next steps…",disabled:te||nr})]})]}):null,bi?s.jsxs(qa,{open:bi,title:Ir==="cancel"?"Cancel run":es?"Suspend schedule":"Pause run",onClose:()=>{ds(!1),ms(""),Qs("")},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{ds(!1),ms(""),Qs("")},disabled:te||Te,children:"Back"}),s.jsx("button",{className:`btn ${Ir==="cancel"?"danger":"primary"}`,onClick:async()=>{Qs("");const _=await Gu(Ir,{reason:el});if(_){Qs(_);return}ds(!1),ms(""),Qs("")},disabled:te||Te,children:Ir==="pause"?es?"Suspend":"Pause":"Cancel"})]}),children:[Xl?s.jsxs("div",{className:"log_item",style:{borderColor:"rgba(239, 68, 68, 0.35)",marginBottom:"10px"},children:[s.jsxs("div",{className:"meta",children:[s.jsx("span",{className:"mono",children:"error"}),s.jsx("span",{className:"mono",children:Nt()})]}),s.jsx("div",{className:"body mono",children:Xl})]}):null,s.jsxs("div",{className:"field",children:[s.jsx("label",{children:"Reason (optional)"}),s.jsx("input",{className:"mono",value:el,onChange:_=>ms(_.target.value),placeholder:"reason…"})]})]}):null,Qu?s.jsxs(qa,{open:Qu,title:Pc,onClose:()=>{Tr&&Ts(Tr)},actions:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn",onClick:()=>{Rs("ledger"),t("observe"),Tr&&Ts(Tr)},disabled:!u.trim(),children:"Open ledger"}),s.jsx("button",{className:"btn",onClick:()=>Tr&&Ts(Tr),disabled:Te,children:"Dismiss"}),Di.length?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn danger",disabled:Te,onClick:()=>Ii({approved:!1}),children:"Reject"}),s.jsx("button",{className:"btn",disabled:Te,onClick:()=>Ii({approved:!0}),children:"Approve only"}),s.jsx("button",{className:"btn primary",disabled:!ci||Te,onClick:()=>Zu(Di),children:"Approve and execute"})]}):null]}),children:[s.jsxs("div",{className:"wait_context_panel",children:[s.jsxs("div",{className:"wait_context_header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"run_hero_eyebrow",children:"What you need to do"}),s.jsx("strong",{children:Pc}),s.jsx("p",{children:Tf})]}),s.jsx(Xa,{status:Fi||"waiting"})]}),uo?s.jsxs("div",{className:`wait_request_card ${rd?"":"inferred"}`,children:[s.jsx("span",{children:Lf}),s.jsx(hy,{metadata:nd}),s.jsx(gi,{text:uo}),rd?null:s.jsx("p",{className:"wait_context_note",children:"The runtime did not attach a specific question to this wait. This is inferred from the run input; verify the session turns and workflow steps before answering."})]}):s.jsx("div",{className:"warn_callout",children:"This wait did not provide a clear prompt or recoverable prior user request. Review the full run input and recent workflow steps before submitting a response."}),Oc.length?s.jsxs("section",{className:"wait_context_block wait_conversation_context",children:[s.jsx("span",{children:"Recent session turns"}),s.jsx("div",{className:"wait_turn_list",children:Oc.map((_,k)=>s.jsxs("div",{className:`wait_turn_row role_${_.role.replace(/[^a-z0-9_-]+/g,"_")}`,children:[s.jsxs("div",{className:"wait_turn_meta",children:[s.jsx("strong",{children:_.role==="assistant"?"Assistant":_.role==="user"||_.role==="human"?"User":_.role}),_.ts?s.jsx("span",{className:"mono muted",children:Zo(_.ts)}):null]}),s.jsx(hy,{metadata:_.runtime_metadata}),s.jsx(gi,{text:_t(_.text,{max_chars:1200,max_lines:10})})]},`${_.role}:${k}`))})]}):null,s.jsxs("div",{className:"artifact_detail_grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Workflow"}),s.jsx("strong",{children:qs(Wo,dr)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Run"}),s.jsx("strong",{className:"mono",children:Mt(u.trim(),24)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Node"}),s.jsx("strong",{className:"mono",children:Wo.current_node||String((ur==null?void 0:ur.node_id)||"—")})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Elapsed"}),s.jsx("strong",{children:Gl(Wo)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Session"}),s.jsx("strong",{className:"mono",children:Wo.session_id?Mt(String(Wo.session_id),18):"—"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Wait key"}),s.jsx("strong",{className:"mono",children:Mt(Tr,28)})]})]}),Rf?s.jsxs("details",{className:"runtime_raw_details wait_full_input_details",open:!uo,children:[s.jsx("summary",{className:"mono muted",children:"Full run input JSON"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:sd,collapseAfterDepth:4,showCopy:!0})})]}):null,s.jsxs("section",{className:"wait_context_block",children:[s.jsx("span",{children:"Recent workflow steps leading to this wait"}),s.jsxs("div",{className:"wait_event_list",children:[ed.map(_=>s.jsxs("div",{className:"wait_event_row",children:[s.jsxs("span",{className:"mono",children:["#",_.cursor]}),s.jsx("strong",{children:_.summary||_.effect_type||_.status||"event"}),s.jsx("span",{className:"mono muted",children:[_.node_id,_.status,Zo(_.ts)].filter(Boolean).join(" · ")})]},`${_.cursor}:${_.node_id}:${_.status}`)),ed.length?null:s.jsx("div",{className:"empty_state_inline",children:"No ledger context is loaded. Open the ledger before deciding."})]})]})]}),Di.length?s.jsxs("div",{className:"wait_action_panel",children:[s.jsx("div",{className:"wait_action_intro",children:"Approve and execute runs the listed tool request through your configured worker. Approve only sends approval without local execution. Reject returns a denial. Cancel run stops the whole workflow run."}),s.jsx("div",{className:"wait_tool_list",children:Di.map((_,k)=>s.jsxs("div",{className:"wait_tool_card",children:[s.jsxs("div",{className:"wait_tool_header",children:[s.jsx("strong",{children:String((_==null?void 0:_.name)||"tool")}),s.jsxs("div",{className:"wait_tool_badges",children:[s.jsx("span",{className:"chip mono warn",children:"approval"}),Jy(_).map(N=>s.jsxs("span",{className:"chip mono muted",title:Xy,children:[N,"~"]},N))]})]}),s.jsx("div",{className:"wait_tool_args",children:s.jsx(os,{value:(_==null?void 0:_.arguments)||{},collapseAfterDepth:3,showCopy:!0})})]},`${String((_==null?void 0:_.name)||"tool")}:${k}`))}),ci?null:s.jsx("div",{className:"warn_callout",children:"No tool worker is configured, so Observer cannot execute these calls directly."}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn danger",onClick:()=>void Yu(u.trim(),"Cancelled from wait prompt"),disabled:!u.trim()||Te,children:"Cancel whole run"})}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Diagnostics"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:Xt||{},collapseAfterDepth:3,showCopy:!0})})]})]}):s.jsxs("div",{className:"wait_action_panel",children:[s.jsx("div",{className:"wait_action_intro",children:"Submit only when the request above is clear. The response resumes this wait only; Cancel run attempts to stop the whole workflow and prevent further work."}),s.jsx("div",{className:"wait_prompt_text",children:uo||"No explicit prompt was provided. Open the ledger for context before responding."}),s.jsx(Jb,{wait:Xt,disabled:Te,on_submit:_=>Ii({response:_})}),s.jsx("div",{className:"actions",children:s.jsx("button",{className:"btn danger",onClick:()=>void Yu(u.trim(),"Cancelled from wait prompt"),disabled:!u.trim()||Te,children:"Cancel whole run"})}),s.jsxs("details",{className:"runtime_raw_details",children:[s.jsx("summary",{className:"mono muted",children:"Diagnostics"}),s.jsx("div",{className:"wait_shared_json",children:s.jsx(os,{value:Xt||{},collapseAfterDepth:3,showCopy:!0})})]})]})]}):null]})]})]})}if("serviceWorker"in navigator){window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").then(t=>t.update()).catch(()=>{})});let e=!1;navigator.serviceWorker.addEventListener("controllerchange",()=>{e||(e=!0,window.location.reload())})}aw.createRoot(document.getElementById("root")).render(s.jsx(ye.StrictMode,{children:s.jsx(wE,{})}));
140
+ //# sourceMappingURL=index-DdaTQ1ps.js.map