@abstractframework/code 0.4.0 → 0.4.2

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,56 @@
1
+ var Ah=Object.defineProperty;var Mh=(n,r,i)=>r in n?Ah(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i;var xr=(n,r,i)=>Mh(n,typeof r!="symbol"?r+"":r,i);(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))a(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const f of d.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&a(f)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function a(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();function kf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fl={exports:{}},ji={},Dl={exports:{}},ze={};/**
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 Pd;function Ih(){if(Pd)return ze;Pd=1;var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),f=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),_=Symbol.iterator;function w(E){return E===null||typeof E!="object"?null:(E=_&&E[_]||E["@@iterator"],typeof E=="function"?E:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,N={};function A(E,D,z){this.props=E,this.context=D,this.refs=N,this.updater=z||k}A.prototype.isReactComponent={},A.prototype.setState=function(E,D){if(typeof E!="object"&&typeof E!="function"&&E!=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,E,D,"setState")},A.prototype.forceUpdate=function(E){this.updater.enqueueForceUpdate(this,E,"forceUpdate")};function S(){}S.prototype=A.prototype;function P(E,D,z){this.props=E,this.context=D,this.refs=N,this.updater=z||k}var C=P.prototype=new S;C.constructor=P,T(C,A.prototype),C.isPureReactComponent=!0;var j=Array.isArray,L=Object.prototype.hasOwnProperty,W={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function Q(E,D,z){var re,ce={},ve=null,_e=null;if(D!=null)for(re in D.ref!==void 0&&(_e=D.ref),D.key!==void 0&&(ve=""+D.key),D)L.call(D,re)&&!V.hasOwnProperty(re)&&(ce[re]=D[re]);var ie=arguments.length-2;if(ie===1)ce.children=z;else if(1<ie){for(var $e=Array(ie),Ue=0;Ue<ie;Ue++)$e[Ue]=arguments[Ue+2];ce.children=$e}if(E&&E.defaultProps)for(re in ie=E.defaultProps,ie)ce[re]===void 0&&(ce[re]=ie[re]);return{$$typeof:n,type:E,key:ve,ref:_e,props:ce,_owner:W.current}}function me(E,D){return{$$typeof:n,type:E.type,key:D,ref:E.ref,props:E.props,_owner:E._owner}}function oe(E){return typeof E=="object"&&E!==null&&E.$$typeof===n}function X(E){var D={"=":"=0",":":"=2"};return"$"+E.replace(/[=:]/g,function(z){return D[z]})}var le=/\/+/g;function H(E,D){return typeof E=="object"&&E!==null&&E.key!=null?X(""+E.key):D.toString(36)}function ae(E,D,z,re,ce){var ve=typeof E;(ve==="undefined"||ve==="boolean")&&(E=null);var _e=!1;if(E===null)_e=!0;else switch(ve){case"string":case"number":_e=!0;break;case"object":switch(E.$$typeof){case n:case r:_e=!0}}if(_e)return _e=E,ce=ce(_e),E=re===""?"."+H(_e,0):re,j(ce)?(z="",E!=null&&(z=E.replace(le,"$&/")+"/"),ae(ce,D,z,"",function(Ue){return Ue})):ce!=null&&(oe(ce)&&(ce=me(ce,z+(!ce.key||_e&&_e.key===ce.key?"":(""+ce.key).replace(le,"$&/")+"/")+E)),D.push(ce)),1;if(_e=0,re=re===""?".":re+":",j(E))for(var ie=0;ie<E.length;ie++){ve=E[ie];var $e=re+H(ve,ie);_e+=ae(ve,D,z,$e,ce)}else if($e=w(E),typeof $e=="function")for(E=$e.call(E),ie=0;!(ve=E.next()).done;)ve=ve.value,$e=re+H(ve,ie++),_e+=ae(ve,D,z,$e,ce);else if(ve==="object")throw D=String(E),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(E).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return _e}function se(E,D,z){if(E==null)return E;var re=[],ce=0;return ae(E,re,"","",function(ve){return D.call(z,ve,ce++)}),re}function ye(E){if(E._status===-1){var D=E._result;D=D(),D.then(function(z){(E._status===0||E._status===-1)&&(E._status=1,E._result=z)},function(z){(E._status===0||E._status===-1)&&(E._status=2,E._result=z)}),E._status===-1&&(E._status=0,E._result=D)}if(E._status===1)return E._result.default;throw E._result}var we={current:null},J={transition:null},ne={ReactCurrentDispatcher:we,ReactCurrentBatchConfig:J,ReactCurrentOwner:W};function U(){throw Error("act(...) is not supported in production builds of React.")}return ze.Children={map:se,forEach:function(E,D,z){se(E,function(){D.apply(this,arguments)},z)},count:function(E){var D=0;return se(E,function(){D++}),D},toArray:function(E){return se(E,function(D){return D})||[]},only:function(E){if(!oe(E))throw Error("React.Children.only expected to receive a single React element child.");return E}},ze.Component=A,ze.Fragment=i,ze.Profiler=c,ze.PureComponent=P,ze.StrictMode=a,ze.Suspense=p,ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ne,ze.act=U,ze.cloneElement=function(E,D,z){if(E==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+E+".");var re=T({},E.props),ce=E.key,ve=E.ref,_e=E._owner;if(D!=null){if(D.ref!==void 0&&(ve=D.ref,_e=W.current),D.key!==void 0&&(ce=""+D.key),E.type&&E.type.defaultProps)var ie=E.type.defaultProps;for($e in D)L.call(D,$e)&&!V.hasOwnProperty($e)&&(re[$e]=D[$e]===void 0&&ie!==void 0?ie[$e]:D[$e])}var $e=arguments.length-2;if($e===1)re.children=z;else if(1<$e){ie=Array($e);for(var Ue=0;Ue<$e;Ue++)ie[Ue]=arguments[Ue+2];re.children=ie}return{$$typeof:n,type:E.type,key:ce,ref:ve,props:re,_owner:_e}},ze.createContext=function(E){return E={$$typeof:f,_currentValue:E,_currentValue2:E,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},E.Provider={$$typeof:d,_context:E},E.Consumer=E},ze.createElement=Q,ze.createFactory=function(E){var D=Q.bind(null,E);return D.type=E,D},ze.createRef=function(){return{current:null}},ze.forwardRef=function(E){return{$$typeof:m,render:E}},ze.isValidElement=oe,ze.lazy=function(E){return{$$typeof:y,_payload:{_status:-1,_result:E},_init:ye}},ze.memo=function(E,D){return{$$typeof:g,type:E,compare:D===void 0?null:D}},ze.startTransition=function(E){var D=J.transition;J.transition={};try{E()}finally{J.transition=D}},ze.unstable_act=U,ze.useCallback=function(E,D){return we.current.useCallback(E,D)},ze.useContext=function(E){return we.current.useContext(E)},ze.useDebugValue=function(){},ze.useDeferredValue=function(E){return we.current.useDeferredValue(E)},ze.useEffect=function(E,D){return we.current.useEffect(E,D)},ze.useId=function(){return we.current.useId()},ze.useImperativeHandle=function(E,D,z){return we.current.useImperativeHandle(E,D,z)},ze.useInsertionEffect=function(E,D){return we.current.useInsertionEffect(E,D)},ze.useLayoutEffect=function(E,D){return we.current.useLayoutEffect(E,D)},ze.useMemo=function(E,D){return we.current.useMemo(E,D)},ze.useReducer=function(E,D,z){return we.current.useReducer(E,D,z)},ze.useRef=function(E){return we.current.useRef(E)},ze.useState=function(E){return we.current.useState(E)},ze.useSyncExternalStore=function(E,D,z){return we.current.useSyncExternalStore(E,D,z)},ze.useTransition=function(){return we.current.useTransition()},ze.version="18.3.1",ze}var Ld;function uc(){return Ld||(Ld=1,Dl.exports=Ih()),Dl.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 Od;function Ph(){if(Od)return ji;Od=1;var n=uc(),r=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function f(m,p,g){var y,_={},w=null,k=null;g!==void 0&&(w=""+g),p.key!==void 0&&(w=""+p.key),p.ref!==void 0&&(k=p.ref);for(y in p)a.call(p,y)&&!d.hasOwnProperty(y)&&(_[y]=p[y]);if(m&&m.defaultProps)for(y in p=m.defaultProps,p)_[y]===void 0&&(_[y]=p[y]);return{$$typeof:r,type:m,key:w,ref:k,props:_,_owner:c.current}}return ji.Fragment=i,ji.jsx=f,ji.jsxs=f,ji}var zd;function Lh(){return zd||(zd=1,Fl.exports=Ph()),Fl.exports}var o=Lh(),x=uc();const _t=kf(x);var Ho={},Bl={exports:{}},Xt={},Ul={exports:{}},Wl={};/**
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 Fd;function Oh(){return Fd||(Fd=1,(function(n){function r(J,ne){var U=J.length;J.push(ne);e:for(;0<U;){var E=U-1>>>1,D=J[E];if(0<c(D,ne))J[E]=ne,J[U]=D,U=E;else break e}}function i(J){return J.length===0?null:J[0]}function a(J){if(J.length===0)return null;var ne=J[0],U=J.pop();if(U!==ne){J[0]=U;e:for(var E=0,D=J.length,z=D>>>1;E<z;){var re=2*(E+1)-1,ce=J[re],ve=re+1,_e=J[ve];if(0>c(ce,U))ve<D&&0>c(_e,ce)?(J[E]=_e,J[ve]=U,E=ve):(J[E]=ce,J[re]=U,E=re);else if(ve<D&&0>c(_e,U))J[E]=_e,J[ve]=U,E=ve;else break e}}return ne}function c(J,ne){var U=J.sortIndex-ne.sortIndex;return U!==0?U:J.id-ne.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var f=Date,m=f.now();n.unstable_now=function(){return f.now()-m}}var p=[],g=[],y=1,_=null,w=3,k=!1,T=!1,N=!1,A=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(J){for(var ne=i(g);ne!==null;){if(ne.callback===null)a(g);else if(ne.startTime<=J)a(g),ne.sortIndex=ne.expirationTime,r(p,ne);else break;ne=i(g)}}function j(J){if(N=!1,C(J),!T)if(i(p)!==null)T=!0,ye(L);else{var ne=i(g);ne!==null&&we(j,ne.startTime-J)}}function L(J,ne){T=!1,N&&(N=!1,S(Q),Q=-1),k=!0;var U=w;try{for(C(ne),_=i(p);_!==null&&(!(_.expirationTime>ne)||J&&!X());){var E=_.callback;if(typeof E=="function"){_.callback=null,w=_.priorityLevel;var D=E(_.expirationTime<=ne);ne=n.unstable_now(),typeof D=="function"?_.callback=D:_===i(p)&&a(p),C(ne)}else a(p);_=i(p)}if(_!==null)var z=!0;else{var re=i(g);re!==null&&we(j,re.startTime-ne),z=!1}return z}finally{_=null,w=U,k=!1}}var W=!1,V=null,Q=-1,me=5,oe=-1;function X(){return!(n.unstable_now()-oe<me)}function le(){if(V!==null){var J=n.unstable_now();oe=J;var ne=!0;try{ne=V(!0,J)}finally{ne?H():(W=!1,V=null)}}else W=!1}var H;if(typeof P=="function")H=function(){P(le)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,se=ae.port2;ae.port1.onmessage=le,H=function(){se.postMessage(null)}}else H=function(){A(le,0)};function ye(J){V=J,W||(W=!0,H())}function we(J,ne){Q=A(function(){J(n.unstable_now())},ne)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(J){J.callback=null},n.unstable_continueExecution=function(){T||k||(T=!0,ye(L))},n.unstable_forceFrameRate=function(J){0>J||125<J?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<J?Math.floor(1e3/J):5},n.unstable_getCurrentPriorityLevel=function(){return w},n.unstable_getFirstCallbackNode=function(){return i(p)},n.unstable_next=function(J){switch(w){case 1:case 2:case 3:var ne=3;break;default:ne=w}var U=w;w=ne;try{return J()}finally{w=U}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(J,ne){switch(J){case 1:case 2:case 3:case 4:case 5:break;default:J=3}var U=w;w=J;try{return ne()}finally{w=U}},n.unstable_scheduleCallback=function(J,ne,U){var E=n.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?E+U:E):U=E,J){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=U+D,J={id:y++,callback:ne,priorityLevel:J,startTime:U,expirationTime:D,sortIndex:-1},U>E?(J.sortIndex=U,r(g,J),i(p)===null&&J===i(g)&&(N?(S(Q),Q=-1):N=!0,we(j,U-E))):(J.sortIndex=D,r(p,J),T||k||(T=!0,ye(L))),J},n.unstable_shouldYield=X,n.unstable_wrapCallback=function(J){var ne=w;return function(){var U=w;w=ne;try{return J.apply(this,arguments)}finally{w=U}}}})(Wl)),Wl}var Dd;function zh(){return Dd||(Dd=1,Ul.exports=Oh()),Ul.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 Bd;function Fh(){if(Bd)return Xt;Bd=1;var n=uc(),r=zh();function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var a=new Set,c={};function d(e,t){f(e,t),f(e+"Capture",t)}function f(e,t){for(c[e]=t,e=0;e<t.length;e++)a.add(t[e])}var m=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,g=/^[: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]*$/,y={},_={};function w(e){return p.call(_,e)?!0:p.call(y,e)?!1:g.test(e)?_[e]=!0:(y[e]=!0,!1)}function k(e,t,s,l){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return l?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function T(e,t,s,l){if(t===null||typeof t>"u"||k(e,t,s,l))return!0;if(l)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function N(e,t,s,l,u,h,v){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=l,this.attributeNamespace=u,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=h,this.removeEmptyString=v}var A={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){A[e]=new N(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];A[t]=new N(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){A[e]=new N(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){A[e]=new N(e,2,!1,e,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(e){A[e]=new N(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){A[e]=new N(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){A[e]=new N(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){A[e]=new N(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){A[e]=new N(e,5,!1,e.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function P(e){return e[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(e){var t=e.replace(S,P);A[t]=new N(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(S,P);A[t]=new N(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(S,P);A[t]=new N(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){A[e]=new N(e,1,!1,e.toLowerCase(),null,!1,!1)}),A.xlinkHref=new N("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){A[e]=new N(e,1,!1,e.toLowerCase(),null,!0,!0)});function C(e,t,s,l){var u=A.hasOwnProperty(t)?A[t]:null;(u!==null?u.type!==0:l||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(T(t,s,u,l)&&(s=null),l||u===null?w(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):u.mustUseProperty?e[u.propertyName]=s===null?u.type===3?!1:"":s:(t=u.attributeName,l=u.attributeNamespace,s===null?e.removeAttribute(t):(u=u.type,s=u===3||u===4&&s===!0?"":""+s,l?e.setAttributeNS(l,t,s):e.setAttribute(t,s))))}var j=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,L=Symbol.for("react.element"),W=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),oe=Symbol.for("react.provider"),X=Symbol.for("react.context"),le=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),ye=Symbol.for("react.lazy"),we=Symbol.for("react.offscreen"),J=Symbol.iterator;function ne(e){return e===null||typeof e!="object"?null:(e=J&&e[J]||e["@@iterator"],typeof e=="function"?e:null)}var U=Object.assign,E;function D(e){if(E===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);E=t&&t[1]||""}return`
34
+ `+E+e}var z=!1;function re(e,t){if(!e||z)return"";z=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(F){var l=F}Reflect.construct(e,[],t)}else{try{t.call()}catch(F){l=F}e.call(t.prototype)}else{try{throw Error()}catch(F){l=F}e()}}catch(F){if(F&&l&&typeof F.stack=="string"){for(var u=F.stack.split(`
35
+ `),h=l.stack.split(`
36
+ `),v=u.length-1,b=h.length-1;1<=v&&0<=b&&u[v]!==h[b];)b--;for(;1<=v&&0<=b;v--,b--)if(u[v]!==h[b]){if(v!==1||b!==1)do if(v--,b--,0>b||u[v]!==h[b]){var $=`
37
+ `+u[v].replace(" at new "," at ");return e.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",e.displayName)),$}while(1<=v&&0<=b);break}}}finally{z=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?D(e):""}function ce(e){switch(e.tag){case 5:return D(e.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(e.type,!0),e;default:return""}}function ve(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case W:return"Portal";case me:return"Profiler";case Q:return"StrictMode";case H:return"Suspense";case ae:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case X:return(e.displayName||"Context")+".Consumer";case oe:return(e._context.displayName||"Context")+".Provider";case le:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return t=e.displayName||null,t!==null?t:ve(e.type)||"Memo";case ye:t=e._payload,e=e._init;try{return ve(e(t))}catch{}}return null}function _e(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(t);case 8:return t===Q?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ie(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function $e(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ue(e){var t=$e(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),l=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var u=s.get,h=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(v){l=""+v,h.call(this,v)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return l},setValue:function(v){l=""+v},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function We(e){e._valueTracker||(e._valueTracker=Ue(e))}function ee(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),l="";return e&&(l=$e(e)?e.checked?"true":"false":e.value),e=l,e!==s?(t.setValue(e),!0):!1}function Z(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function de(e,t){var s=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function je(e,t){var s=t.defaultValue==null?"":t.defaultValue,l=t.checked!=null?t.checked:t.defaultChecked;s=ie(t.value!=null?t.value:s),e._wrapperState={initialChecked:l,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ke(e,t){t=t.checked,t!=null&&C(e,"checked",t,!1)}function Ee(e,t){ke(e,t);var s=ie(t.value),l=t.type;if(s!=null)l==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qe(e,t.type,s):t.hasOwnProperty("defaultValue")&&qe(e,t.type,ie(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Oe(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var l=t.type;if(!(l!=="submit"&&l!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function qe(e,t,s){(t!=="number"||Z(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var B=Array.isArray;function pe(e,t,s,l){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&l&&(e[s].defaultSelected=!0)}else{for(s=""+ie(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,l&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function Le(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(i(91));return U({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ge(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(i(92));if(B(s)){if(1<s.length)throw Error(i(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:ie(s)}}function zt(e,t){var s=ie(t.value),l=ie(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),l!=null&&(e.defaultValue=""+l)}function vn(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function wn(e){switch(e){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 $n(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?wn(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Tn,Nr=(function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,l,u){MSApp.execUnsafeLocalFunction(function(){return e(t,s,l,u)})}:e})(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Tn=Tn||document.createElement("div"),Tn.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Tn.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ut(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Dn={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},oa=["Webkit","ms","Moz","O"];Object.keys(Dn).forEach(function(e){oa.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Dn[t]=Dn[e]})});function Vs(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Dn.hasOwnProperty(e)&&Dn[e]?(""+t).trim():t+"px"}function qn(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var l=s.indexOf("--")===0,u=Vs(s,t[s],l);s==="float"&&(s="cssFloat"),l?e.setProperty(s,u):e[s]=u}}var aa=U({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 _n(e,t){if(t){if(aa[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(i(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(i(61))}if(t.style!=null&&typeof t.style!="object")throw Error(i(62))}}function cn(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Er=null;function tn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zr=null,Rn=null,xn=null;function qr(e){if(e=ci(e)){if(typeof Zr!="function")throw Error(i(280));var t=e.stateNode;t&&(t=io(t),Zr(e.stateNode,e.type,t))}}function Pi(e){Rn?xn?xn.push(e):xn=[e]:Rn=e}function An(){if(Rn){var e=Rn,t=xn;if(xn=Rn=null,qr(e),t)for(e=0;e<t.length;e++)qr(t[e])}}function Fe(e,t){return e(t)}function Wt(){}var $r=!1;function Bn(e,t,s){if($r)return e(t,s);$r=!0;try{return Fe(e,t,s)}finally{$r=!1,(Rn!==null||xn!==null)&&(Wt(),An())}}function nn(e,t){var s=e.stateNode;if(s===null)return null;var l=io(s);if(l===null)return null;s=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(i(231,t,typeof s));return s}var es=!1;if(m)try{var un={};Object.defineProperty(un,"passive",{get:function(){es=!0}}),window.addEventListener("test",un,un),window.removeEventListener("test",un,un)}catch{es=!1}function Li(e,t,s,l,u,h,v,b,$){var F=Array.prototype.slice.call(arguments,3);try{t.apply(s,F)}catch(Y){this.onError(Y)}}var $t=!1,Tr=null,Vt=!1,ts=null,er={onError:function(e){$t=!0,Tr=e}};function tr(e,t,s,l,u,h,v,b,$){$t=!1,Tr=null,Li.apply(er,arguments)}function ns(e,t,s,l,u,h,v,b,$){if(tr.apply(this,arguments),$t){if($t){var F=Tr;$t=!1,Tr=null}else throw Error(i(198));Vt||(Vt=!0,ts=F)}}function ft(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function Hs(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function rs(e){if(ft(e)!==e)throw Error(i(188))}function Rr(e){var t=e.alternate;if(!t){if(t=ft(e),t===null)throw Error(i(188));return t!==e?null:e}for(var s=e,l=t;;){var u=s.return;if(u===null)break;var h=u.alternate;if(h===null){if(l=u.return,l!==null){s=l;continue}break}if(u.child===h.child){for(h=u.child;h;){if(h===s)return rs(u),e;if(h===l)return rs(u),t;h=h.sibling}throw Error(i(188))}if(s.return!==l.return)s=u,l=h;else{for(var v=!1,b=u.child;b;){if(b===s){v=!0,s=u,l=h;break}if(b===l){v=!0,l=u,s=h;break}b=b.sibling}if(!v){for(b=h.child;b;){if(b===s){v=!0,s=h,l=u;break}if(b===l){v=!0,l=h,s=u;break}b=b.sibling}if(!v)throw Error(i(189))}}if(s.alternate!==l)throw Error(i(190))}if(s.tag!==3)throw Error(i(188));return s.stateNode.current===s?e:t}function ut(e){return e=Rr(e),e!==null?ss(e):null}function ss(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ss(e);if(t!==null)return t;e=e.sibling}return null}var gt=r.unstable_scheduleCallback,Ar=r.unstable_cancelCallback,is=r.unstable_shouldYield,la=r.unstable_requestPaint,nt=r.unstable_now,Oi=r.unstable_getCurrentPriorityLevel,os=r.unstable_ImmediatePriority,zi=r.unstable_UserBlockingPriority,as=r.unstable_NormalPriority,ca=r.unstable_LowPriority,nr=r.unstable_IdlePriority,Mn=null,rn=null;function ua(e){if(rn&&typeof rn.onCommitFiberRoot=="function")try{rn.onCommitFiberRoot(Mn,e,void 0,(e.current.flags&128)===128)}catch{}}var Ht=Math.clz32?Math.clz32:Bi,Fi=Math.log,Di=Math.LN2;function Bi(e){return e>>>=0,e===0?32:31-(Fi(e)/Di|0)|0}var Mr=64,Ir=4194304;function rr(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Pr(e,t){var s=e.pendingLanes;if(s===0)return 0;var l=0,u=e.suspendedLanes,h=e.pingedLanes,v=s&268435455;if(v!==0){var b=v&~u;b!==0?l=rr(b):(h&=v,h!==0&&(l=rr(h)))}else v=s&~u,v!==0?l=rr(v):h!==0&&(l=rr(h));if(l===0)return 0;if(t!==0&&t!==l&&(t&u)===0&&(u=l&-l,h=t&-t,u>=h||u===16&&(h&4194240)!==0))return t;if((l&4)!==0&&(l|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=l;0<t;)s=31-Ht(t),u=1<<s,l|=e[s],t&=~u;return l}function Ui(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 Wi(e,t){for(var s=e.suspendedLanes,l=e.pingedLanes,u=e.expirationTimes,h=e.pendingLanes;0<h;){var v=31-Ht(h),b=1<<v,$=u[v];$===-1?((b&s)===0||(b&l)!==0)&&(u[v]=Ui(b,t)):$<=t&&(e.expiredLanes|=b),h&=~b}}function ls(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Gs(){var e=Mr;return Mr<<=1,(Mr&4194240)===0&&(Mr=64),e}function cs(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function sr(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ht(t),e[t]=s}function Vi(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0<s;){var u=31-Ht(s),h=1<<u;t[u]=0,l[u]=-1,e[u]=-1,s&=~h}}function M(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var l=31-Ht(s),u=1<<l;u&t|e[l]&t&&(e[l]|=t),s&=~u}}var G=0;function Ie(e){return e&=-e,1<e?4<e?(e&268435455)!==0?16:536870912:4:1}var De,Pe,xt,Un,Wn,pt=!1,kt=[],lt=null,Tt=null,Rt=null,Ks=new Map,Qs=new Map,ir=[],ep="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 vc(e,t){switch(e){case"focusin":case"focusout":lt=null;break;case"dragenter":case"dragleave":Tt=null;break;case"mouseover":case"mouseout":Rt=null;break;case"pointerover":case"pointerout":Ks.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Qs.delete(t.pointerId)}}function Js(e,t,s,l,u,h){return e===null||e.nativeEvent!==h?(e={blockedOn:t,domEventName:s,eventSystemFlags:l,nativeEvent:h,targetContainers:[u]},t!==null&&(t=ci(t),t!==null&&Pe(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function tp(e,t,s,l,u){switch(t){case"focusin":return lt=Js(lt,e,t,s,l,u),!0;case"dragenter":return Tt=Js(Tt,e,t,s,l,u),!0;case"mouseover":return Rt=Js(Rt,e,t,s,l,u),!0;case"pointerover":var h=u.pointerId;return Ks.set(h,Js(Ks.get(h)||null,e,t,s,l,u)),!0;case"gotpointercapture":return h=u.pointerId,Qs.set(h,Js(Qs.get(h)||null,e,t,s,l,u)),!0}return!1}function wc(e){var t=Lr(e.target);if(t!==null){var s=ft(t);if(s!==null){if(t=s.tag,t===13){if(t=Hs(s),t!==null){e.blockedOn=t,Wn(e.priority,function(){xt(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Hi(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=fa(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var l=new s.constructor(s.type,s);Er=l,s.target.dispatchEvent(l),Er=null}else return t=ci(s),t!==null&&Pe(t),e.blockedOn=s,!1;t.shift()}return!0}function _c(e,t,s){Hi(e)&&s.delete(t)}function np(){pt=!1,lt!==null&&Hi(lt)&&(lt=null),Tt!==null&&Hi(Tt)&&(Tt=null),Rt!==null&&Hi(Rt)&&(Rt=null),Ks.forEach(_c),Qs.forEach(_c)}function Ys(e,t){e.blockedOn===t&&(e.blockedOn=null,pt||(pt=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,np)))}function Xs(e){function t(u){return Ys(u,e)}if(0<kt.length){Ys(kt[0],e);for(var s=1;s<kt.length;s++){var l=kt[s];l.blockedOn===e&&(l.blockedOn=null)}}for(lt!==null&&Ys(lt,e),Tt!==null&&Ys(Tt,e),Rt!==null&&Ys(Rt,e),Ks.forEach(t),Qs.forEach(t),s=0;s<ir.length;s++)l=ir[s],l.blockedOn===e&&(l.blockedOn=null);for(;0<ir.length&&(s=ir[0],s.blockedOn===null);)wc(s),s.blockedOn===null&&ir.shift()}var us=j.ReactCurrentBatchConfig,Gi=!0;function rp(e,t,s,l){var u=G,h=us.transition;us.transition=null;try{G=1,da(e,t,s,l)}finally{G=u,us.transition=h}}function sp(e,t,s,l){var u=G,h=us.transition;us.transition=null;try{G=4,da(e,t,s,l)}finally{G=u,us.transition=h}}function da(e,t,s,l){if(Gi){var u=fa(e,t,s,l);if(u===null)$a(e,t,l,Ki,s),vc(e,l);else if(tp(u,e,t,s,l))l.stopPropagation();else if(vc(e,l),t&4&&-1<ep.indexOf(e)){for(;u!==null;){var h=ci(u);if(h!==null&&De(h),h=fa(e,t,s,l),h===null&&$a(e,t,l,Ki,s),h===u)break;u=h}u!==null&&l.stopPropagation()}else $a(e,t,l,null,s)}}var Ki=null;function fa(e,t,s,l){if(Ki=null,e=tn(l),e=Lr(e),e!==null)if(t=ft(e),t===null)e=null;else if(s=t.tag,s===13){if(e=Hs(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Ki=e,null}function xc(e){switch(e){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(Oi()){case os:return 1;case zi:return 4;case as:case ca:return 16;case nr:return 536870912;default:return 16}default:return 16}}var or=null,pa=null,Qi=null;function kc(){if(Qi)return Qi;var e,t=pa,s=t.length,l,u="value"in or?or.value:or.textContent,h=u.length;for(e=0;e<s&&t[e]===u[e];e++);var v=s-e;for(l=1;l<=v&&t[s-l]===u[h-l];l++);return Qi=u.slice(e,1<l?1-l:void 0)}function Ji(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Yi(){return!0}function Sc(){return!1}function sn(e){function t(s,l,u,h,v){this._reactName=s,this._targetInst=u,this.type=l,this.nativeEvent=h,this.target=v,this.currentTarget=null;for(var b in e)e.hasOwnProperty(b)&&(s=e[b],this[b]=s?s(h):h[b]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Yi:Sc,this.isPropagationStopped=Sc,this}return U(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Yi)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Yi)},persist:function(){},isPersistent:Yi}),t}var ds={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ha=sn(ds),Zs=U({},ds,{view:0,detail:0}),ip=sn(Zs),ma,ga,qs,Xi=U({},Zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:va,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==qs&&(qs&&e.type==="mousemove"?(ma=e.screenX-qs.screenX,ga=e.screenY-qs.screenY):ga=ma=0,qs=e),ma)},movementY:function(e){return"movementY"in e?e.movementY:ga}}),jc=sn(Xi),op=U({},Xi,{dataTransfer:0}),ap=sn(op),lp=U({},Zs,{relatedTarget:0}),ya=sn(lp),cp=U({},ds,{animationName:0,elapsedTime:0,pseudoElement:0}),up=sn(cp),dp=U({},ds,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),fp=sn(dp),pp=U({},ds,{data:0}),bc=sn(pp),hp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mp={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"},gp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yp(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=gp[e])?!!t[e]:!1}function va(){return yp}var vp=U({},Zs,{key:function(e){if(e.key){var t=hp[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ji(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?mp[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:va,charCode:function(e){return e.type==="keypress"?Ji(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ji(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),wp=sn(vp),_p=U({},Xi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cc=sn(_p),xp=U({},Zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:va}),kp=sn(xp),Sp=U({},ds,{propertyName:0,elapsedTime:0,pseudoElement:0}),jp=sn(Sp),bp=U({},Xi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Cp=sn(bp),Np=[9,13,27,32],wa=m&&"CompositionEvent"in window,ei=null;m&&"documentMode"in document&&(ei=document.documentMode);var Ep=m&&"TextEvent"in window&&!ei,Nc=m&&(!wa||ei&&8<ei&&11>=ei),Ec=" ",$c=!1;function Tc(e,t){switch(e){case"keyup":return Np.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Rc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fs=!1;function $p(e,t){switch(e){case"compositionend":return Rc(t);case"keypress":return t.which!==32?null:($c=!0,Ec);case"textInput":return e=t.data,e===Ec&&$c?null:e;default:return null}}function Tp(e,t){if(fs)return e==="compositionend"||!wa&&Tc(e,t)?(e=kc(),Qi=pa=or=null,fs=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Nc&&t.locale!=="ko"?null:t.data;default:return null}}var Rp={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 Ac(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Rp[e.type]:t==="textarea"}function Mc(e,t,s,l){Pi(l),t=no(t,"onChange"),0<t.length&&(s=new ha("onChange","change",null,s,l),e.push({event:s,listeners:t}))}var ti=null,ni=null;function Ap(e){Xc(e,0)}function Zi(e){var t=ys(e);if(ee(t))return e}function Mp(e,t){if(e==="change")return t}var Ic=!1;if(m){var _a;if(m){var xa="oninput"in document;if(!xa){var Pc=document.createElement("div");Pc.setAttribute("oninput","return;"),xa=typeof Pc.oninput=="function"}_a=xa}else _a=!1;Ic=_a&&(!document.documentMode||9<document.documentMode)}function Lc(){ti&&(ti.detachEvent("onpropertychange",Oc),ni=ti=null)}function Oc(e){if(e.propertyName==="value"&&Zi(ni)){var t=[];Mc(t,ni,e,tn(e)),Bn(Ap,t)}}function Ip(e,t,s){e==="focusin"?(Lc(),ti=t,ni=s,ti.attachEvent("onpropertychange",Oc)):e==="focusout"&&Lc()}function Pp(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Zi(ni)}function Lp(e,t){if(e==="click")return Zi(t)}function Op(e,t){if(e==="input"||e==="change")return Zi(t)}function zp(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kn=typeof Object.is=="function"?Object.is:zp;function ri(e,t){if(kn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),l=Object.keys(t);if(s.length!==l.length)return!1;for(l=0;l<s.length;l++){var u=s[l];if(!p.call(t,u)||!kn(e[u],t[u]))return!1}return!0}function zc(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Fc(e,t){var s=zc(e);e=0;for(var l;s;){if(s.nodeType===3){if(l=e+s.textContent.length,e<=t&&l>=t)return{node:s,offset:t-e};e=l}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=zc(s)}}function Dc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Dc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Bc(){for(var e=window,t=Z();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Z(e.document)}return t}function ka(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Fp(e){var t=Bc(),s=e.focusedElem,l=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Dc(s.ownerDocument.documentElement,s)){if(l!==null&&ka(s)){if(t=l.start,e=l.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var u=s.textContent.length,h=Math.min(l.start,u);l=l.end===void 0?h:Math.min(l.end,u),!e.extend&&h>l&&(u=l,l=h,h=u),u=Fc(s,h);var v=Fc(s,l);u&&v&&(e.rangeCount!==1||e.anchorNode!==u.node||e.anchorOffset!==u.offset||e.focusNode!==v.node||e.focusOffset!==v.offset)&&(t=t.createRange(),t.setStart(u.node,u.offset),e.removeAllRanges(),h>l?(e.addRange(t),e.extend(v.node,v.offset)):(t.setEnd(v.node,v.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Dp=m&&"documentMode"in document&&11>=document.documentMode,ps=null,Sa=null,si=null,ja=!1;function Uc(e,t,s){var l=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;ja||ps==null||ps!==Z(l)||(l=ps,"selectionStart"in l&&ka(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),si&&ri(si,l)||(si=l,l=no(Sa,"onSelect"),0<l.length&&(t=new ha("onSelect","select",null,t,s),e.push({event:t,listeners:l}),t.target=ps)))}function qi(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var hs={animationend:qi("Animation","AnimationEnd"),animationiteration:qi("Animation","AnimationIteration"),animationstart:qi("Animation","AnimationStart"),transitionend:qi("Transition","TransitionEnd")},ba={},Wc={};m&&(Wc=document.createElement("div").style,"AnimationEvent"in window||(delete hs.animationend.animation,delete hs.animationiteration.animation,delete hs.animationstart.animation),"TransitionEvent"in window||delete hs.transitionend.transition);function eo(e){if(ba[e])return ba[e];if(!hs[e])return e;var t=hs[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in Wc)return ba[e]=t[s];return e}var Vc=eo("animationend"),Hc=eo("animationiteration"),Gc=eo("animationstart"),Kc=eo("transitionend"),Qc=new Map,Jc="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 ar(e,t){Qc.set(e,t),d(t,[e])}for(var Ca=0;Ca<Jc.length;Ca++){var Na=Jc[Ca],Bp=Na.toLowerCase(),Up=Na[0].toUpperCase()+Na.slice(1);ar(Bp,"on"+Up)}ar(Vc,"onAnimationEnd"),ar(Hc,"onAnimationIteration"),ar(Gc,"onAnimationStart"),ar("dblclick","onDoubleClick"),ar("focusin","onFocus"),ar("focusout","onBlur"),ar(Kc,"onTransitionEnd"),f("onMouseEnter",["mouseout","mouseover"]),f("onMouseLeave",["mouseout","mouseover"]),f("onPointerEnter",["pointerout","pointerover"]),f("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ii="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(" "),Wp=new Set("cancel close invalid load scroll toggle".split(" ").concat(ii));function Yc(e,t,s){var l=e.type||"unknown-event";e.currentTarget=s,ns(l,t,void 0,e),e.currentTarget=null}function Xc(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var l=e[s],u=l.event;l=l.listeners;e:{var h=void 0;if(t)for(var v=l.length-1;0<=v;v--){var b=l[v],$=b.instance,F=b.currentTarget;if(b=b.listener,$!==h&&u.isPropagationStopped())break e;Yc(u,b,F),h=$}else for(v=0;v<l.length;v++){if(b=l[v],$=b.instance,F=b.currentTarget,b=b.listener,$!==h&&u.isPropagationStopped())break e;Yc(u,b,F),h=$}}}if(Vt)throw e=ts,Vt=!1,ts=null,e}function et(e,t){var s=t[Pa];s===void 0&&(s=t[Pa]=new Set);var l=e+"__bubble";s.has(l)||(Zc(t,e,2,!1),s.add(l))}function Ea(e,t,s){var l=0;t&&(l|=4),Zc(s,e,l,t)}var to="_reactListening"+Math.random().toString(36).slice(2);function oi(e){if(!e[to]){e[to]=!0,a.forEach(function(s){s!=="selectionchange"&&(Wp.has(s)||Ea(s,!1,e),Ea(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[to]||(t[to]=!0,Ea("selectionchange",!1,t))}}function Zc(e,t,s,l){switch(xc(t)){case 1:var u=rp;break;case 4:u=sp;break;default:u=da}s=u.bind(null,t,s,e),u=void 0,!es||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),l?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function $a(e,t,s,l,u){var h=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var v=l.tag;if(v===3||v===4){var b=l.stateNode.containerInfo;if(b===u||b.nodeType===8&&b.parentNode===u)break;if(v===4)for(v=l.return;v!==null;){var $=v.tag;if(($===3||$===4)&&($=v.stateNode.containerInfo,$===u||$.nodeType===8&&$.parentNode===u))return;v=v.return}for(;b!==null;){if(v=Lr(b),v===null)return;if($=v.tag,$===5||$===6){l=h=v;continue e}b=b.parentNode}}l=l.return}Bn(function(){var F=h,Y=tn(s),q=[];e:{var K=Qc.get(e);if(K!==void 0){var ue=ha,ge=e;switch(e){case"keypress":if(Ji(s)===0)break e;case"keydown":case"keyup":ue=wp;break;case"focusin":ge="focus",ue=ya;break;case"focusout":ge="blur",ue=ya;break;case"beforeblur":case"afterblur":ue=ya;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ue=jc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ue=ap;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ue=kp;break;case Vc:case Hc:case Gc:ue=up;break;case Kc:ue=jp;break;case"scroll":ue=ip;break;case"wheel":ue=Cp;break;case"copy":case"cut":case"paste":ue=fp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ue=Cc}var xe=(t&4)!==0,ct=!xe&&e==="scroll",I=xe?K!==null?K+"Capture":null:K;xe=[];for(var R=F,O;R!==null;){O=R;var te=O.stateNode;if(O.tag===5&&te!==null&&(O=te,I!==null&&(te=nn(R,I),te!=null&&xe.push(ai(R,te,O)))),ct)break;R=R.return}0<xe.length&&(K=new ue(K,ge,null,s,Y),q.push({event:K,listeners:xe}))}}if((t&7)===0){e:{if(K=e==="mouseover"||e==="pointerover",ue=e==="mouseout"||e==="pointerout",K&&s!==Er&&(ge=s.relatedTarget||s.fromElement)&&(Lr(ge)||ge[Vn]))break e;if((ue||K)&&(K=Y.window===Y?Y:(K=Y.ownerDocument)?K.defaultView||K.parentWindow:window,ue?(ge=s.relatedTarget||s.toElement,ue=F,ge=ge?Lr(ge):null,ge!==null&&(ct=ft(ge),ge!==ct||ge.tag!==5&&ge.tag!==6)&&(ge=null)):(ue=null,ge=F),ue!==ge)){if(xe=jc,te="onMouseLeave",I="onMouseEnter",R="mouse",(e==="pointerout"||e==="pointerover")&&(xe=Cc,te="onPointerLeave",I="onPointerEnter",R="pointer"),ct=ue==null?K:ys(ue),O=ge==null?K:ys(ge),K=new xe(te,R+"leave",ue,s,Y),K.target=ct,K.relatedTarget=O,te=null,Lr(Y)===F&&(xe=new xe(I,R+"enter",ge,s,Y),xe.target=O,xe.relatedTarget=ct,te=xe),ct=te,ue&&ge)t:{for(xe=ue,I=ge,R=0,O=xe;O;O=ms(O))R++;for(O=0,te=I;te;te=ms(te))O++;for(;0<R-O;)xe=ms(xe),R--;for(;0<O-R;)I=ms(I),O--;for(;R--;){if(xe===I||I!==null&&xe===I.alternate)break t;xe=ms(xe),I=ms(I)}xe=null}else xe=null;ue!==null&&qc(q,K,ue,xe,!1),ge!==null&&ct!==null&&qc(q,ct,ge,xe,!0)}}e:{if(K=F?ys(F):window,ue=K.nodeName&&K.nodeName.toLowerCase(),ue==="select"||ue==="input"&&K.type==="file")var Se=Mp;else if(Ac(K))if(Ic)Se=Op;else{Se=Pp;var Ce=Ip}else(ue=K.nodeName)&&ue.toLowerCase()==="input"&&(K.type==="checkbox"||K.type==="radio")&&(Se=Lp);if(Se&&(Se=Se(e,F))){Mc(q,Se,s,Y);break e}Ce&&Ce(e,K,F),e==="focusout"&&(Ce=K._wrapperState)&&Ce.controlled&&K.type==="number"&&qe(K,"number",K.value)}switch(Ce=F?ys(F):window,e){case"focusin":(Ac(Ce)||Ce.contentEditable==="true")&&(ps=Ce,Sa=F,si=null);break;case"focusout":si=Sa=ps=null;break;case"mousedown":ja=!0;break;case"contextmenu":case"mouseup":case"dragend":ja=!1,Uc(q,s,Y);break;case"selectionchange":if(Dp)break;case"keydown":case"keyup":Uc(q,s,Y)}var Ne;if(wa)e:{switch(e){case"compositionstart":var Te="onCompositionStart";break e;case"compositionend":Te="onCompositionEnd";break e;case"compositionupdate":Te="onCompositionUpdate";break e}Te=void 0}else fs?Tc(e,s)&&(Te="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(Te="onCompositionStart");Te&&(Nc&&s.locale!=="ko"&&(fs||Te!=="onCompositionStart"?Te==="onCompositionEnd"&&fs&&(Ne=kc()):(or=Y,pa="value"in or?or.value:or.textContent,fs=!0)),Ce=no(F,Te),0<Ce.length&&(Te=new bc(Te,e,null,s,Y),q.push({event:Te,listeners:Ce}),Ne?Te.data=Ne:(Ne=Rc(s),Ne!==null&&(Te.data=Ne)))),(Ne=Ep?$p(e,s):Tp(e,s))&&(F=no(F,"onBeforeInput"),0<F.length&&(Y=new bc("onBeforeInput","beforeinput",null,s,Y),q.push({event:Y,listeners:F}),Y.data=Ne))}Xc(q,t)})}function ai(e,t,s){return{instance:e,listener:t,currentTarget:s}}function no(e,t){for(var s=t+"Capture",l=[];e!==null;){var u=e,h=u.stateNode;u.tag===5&&h!==null&&(u=h,h=nn(e,s),h!=null&&l.unshift(ai(e,h,u)),h=nn(e,t),h!=null&&l.push(ai(e,h,u))),e=e.return}return l}function ms(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qc(e,t,s,l,u){for(var h=t._reactName,v=[];s!==null&&s!==l;){var b=s,$=b.alternate,F=b.stateNode;if($!==null&&$===l)break;b.tag===5&&F!==null&&(b=F,u?($=nn(s,h),$!=null&&v.unshift(ai(s,$,b))):u||($=nn(s,h),$!=null&&v.push(ai(s,$,b)))),s=s.return}v.length!==0&&e.push({event:t,listeners:v})}var Vp=/\r\n?/g,Hp=/\u0000|\uFFFD/g;function eu(e){return(typeof e=="string"?e:""+e).replace(Vp,`
38
+ `).replace(Hp,"")}function ro(e,t,s){if(t=eu(t),eu(e)!==t&&s)throw Error(i(425))}function so(){}var Ta=null,Ra=null;function Aa(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ma=typeof setTimeout=="function"?setTimeout:void 0,Gp=typeof clearTimeout=="function"?clearTimeout:void 0,tu=typeof Promise=="function"?Promise:void 0,Kp=typeof queueMicrotask=="function"?queueMicrotask:typeof tu<"u"?function(e){return tu.resolve(null).then(e).catch(Qp)}:Ma;function Qp(e){setTimeout(function(){throw e})}function Ia(e,t){var s=t,l=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"){if(l===0){e.removeChild(u),Xs(t);return}l--}else s!=="$"&&s!=="$?"&&s!=="$!"||l++;s=u}while(s);Xs(t)}function lr(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function nu(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var gs=Math.random().toString(36).slice(2),In="__reactFiber$"+gs,li="__reactProps$"+gs,Vn="__reactContainer$"+gs,Pa="__reactEvents$"+gs,Jp="__reactListeners$"+gs,Yp="__reactHandles$"+gs;function Lr(e){var t=e[In];if(t)return t;for(var s=e.parentNode;s;){if(t=s[Vn]||s[In]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=nu(e);e!==null;){if(s=e[In])return s;e=nu(e)}return t}e=s,s=e.parentNode}return null}function ci(e){return e=e[In]||e[Vn],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ys(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(i(33))}function io(e){return e[li]||null}var La=[],vs=-1;function cr(e){return{current:e}}function tt(e){0>vs||(e.current=La[vs],La[vs]=null,vs--)}function Ze(e,t){vs++,La[vs]=e.current,e.current=t}var ur={},At=cr(ur),Gt=cr(!1),Or=ur;function ws(e,t){var s=e.type.contextTypes;if(!s)return ur;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===t)return l.__reactInternalMemoizedMaskedChildContext;var u={},h;for(h in s)u[h]=t[h];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=u),u}function Kt(e){return e=e.childContextTypes,e!=null}function oo(){tt(Gt),tt(At)}function ru(e,t,s){if(At.current!==ur)throw Error(i(168));Ze(At,t),Ze(Gt,s)}function su(e,t,s){var l=e.stateNode;if(t=t.childContextTypes,typeof l.getChildContext!="function")return s;l=l.getChildContext();for(var u in l)if(!(u in t))throw Error(i(108,_e(e)||"Unknown",u));return U({},s,l)}function ao(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ur,Or=At.current,Ze(At,e),Ze(Gt,Gt.current),!0}function iu(e,t,s){var l=e.stateNode;if(!l)throw Error(i(169));s?(e=su(e,t,Or),l.__reactInternalMemoizedMergedChildContext=e,tt(Gt),tt(At),Ze(At,e)):tt(Gt),Ze(Gt,s)}var Hn=null,lo=!1,Oa=!1;function ou(e){Hn===null?Hn=[e]:Hn.push(e)}function Xp(e){lo=!0,ou(e)}function dr(){if(!Oa&&Hn!==null){Oa=!0;var e=0,t=G;try{var s=Hn;for(G=1;e<s.length;e++){var l=s[e];do l=l(!0);while(l!==null)}Hn=null,lo=!1}catch(u){throw Hn!==null&&(Hn=Hn.slice(e+1)),gt(os,dr),u}finally{G=t,Oa=!1}}return null}var _s=[],xs=0,co=null,uo=0,dn=[],fn=0,zr=null,Gn=1,Kn="";function Fr(e,t){_s[xs++]=uo,_s[xs++]=co,co=e,uo=t}function au(e,t,s){dn[fn++]=Gn,dn[fn++]=Kn,dn[fn++]=zr,zr=e;var l=Gn;e=Kn;var u=32-Ht(l)-1;l&=~(1<<u),s+=1;var h=32-Ht(t)+u;if(30<h){var v=u-u%5;h=(l&(1<<v)-1).toString(32),l>>=v,u-=v,Gn=1<<32-Ht(t)+u|s<<u|l,Kn=h+e}else Gn=1<<h|s<<u|l,Kn=e}function za(e){e.return!==null&&(Fr(e,1),au(e,1,0))}function Fa(e){for(;e===co;)co=_s[--xs],_s[xs]=null,uo=_s[--xs],_s[xs]=null;for(;e===zr;)zr=dn[--fn],dn[fn]=null,Kn=dn[--fn],dn[fn]=null,Gn=dn[--fn],dn[fn]=null}var on=null,an=null,rt=!1,Sn=null;function lu(e,t){var s=gn(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function cu(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,on=e,an=lr(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,on=e,an=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=zr!==null?{id:Gn,overflow:Kn}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=gn(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,on=e,an=null,!0):!1;default:return!1}}function Da(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Ba(e){if(rt){var t=an;if(t){var s=t;if(!cu(e,t)){if(Da(e))throw Error(i(418));t=lr(s.nextSibling);var l=on;t&&cu(e,t)?lu(l,s):(e.flags=e.flags&-4097|2,rt=!1,on=e)}}else{if(Da(e))throw Error(i(418));e.flags=e.flags&-4097|2,rt=!1,on=e}}}function uu(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;on=e}function fo(e){if(e!==on)return!1;if(!rt)return uu(e),rt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Aa(e.type,e.memoizedProps)),t&&(t=an)){if(Da(e))throw du(),Error(i(418));for(;t;)lu(e,t),t=lr(t.nextSibling)}if(uu(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){an=lr(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}an=null}}else an=on?lr(e.stateNode.nextSibling):null;return!0}function du(){for(var e=an;e;)e=lr(e.nextSibling)}function ks(){an=on=null,rt=!1}function Ua(e){Sn===null?Sn=[e]:Sn.push(e)}var Zp=j.ReactCurrentBatchConfig;function ui(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(i(309));var l=s.stateNode}if(!l)throw Error(i(147,e));var u=l,h=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===h?t.ref:(t=function(v){var b=u.refs;v===null?delete b[h]:b[h]=v},t._stringRef=h,t)}if(typeof e!="string")throw Error(i(284));if(!s._owner)throw Error(i(290,e))}return e}function po(e,t){throw e=Object.prototype.toString.call(t),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fu(e){var t=e._init;return t(e._payload)}function pu(e){function t(I,R){if(e){var O=I.deletions;O===null?(I.deletions=[R],I.flags|=16):O.push(R)}}function s(I,R){if(!e)return null;for(;R!==null;)t(I,R),R=R.sibling;return null}function l(I,R){for(I=new Map;R!==null;)R.key!==null?I.set(R.key,R):I.set(R.index,R),R=R.sibling;return I}function u(I,R){return I=wr(I,R),I.index=0,I.sibling=null,I}function h(I,R,O){return I.index=O,e?(O=I.alternate,O!==null?(O=O.index,O<R?(I.flags|=2,R):O):(I.flags|=2,R)):(I.flags|=1048576,R)}function v(I){return e&&I.alternate===null&&(I.flags|=2),I}function b(I,R,O,te){return R===null||R.tag!==6?(R=Ml(O,I.mode,te),R.return=I,R):(R=u(R,O),R.return=I,R)}function $(I,R,O,te){var Se=O.type;return Se===V?Y(I,R,O.props.children,te,O.key):R!==null&&(R.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===ye&&fu(Se)===R.type)?(te=u(R,O.props),te.ref=ui(I,R,O),te.return=I,te):(te=Oo(O.type,O.key,O.props,null,I.mode,te),te.ref=ui(I,R,O),te.return=I,te)}function F(I,R,O,te){return R===null||R.tag!==4||R.stateNode.containerInfo!==O.containerInfo||R.stateNode.implementation!==O.implementation?(R=Il(O,I.mode,te),R.return=I,R):(R=u(R,O.children||[]),R.return=I,R)}function Y(I,R,O,te,Se){return R===null||R.tag!==7?(R=Kr(O,I.mode,te,Se),R.return=I,R):(R=u(R,O),R.return=I,R)}function q(I,R,O){if(typeof R=="string"&&R!==""||typeof R=="number")return R=Ml(""+R,I.mode,O),R.return=I,R;if(typeof R=="object"&&R!==null){switch(R.$$typeof){case L:return O=Oo(R.type,R.key,R.props,null,I.mode,O),O.ref=ui(I,null,R),O.return=I,O;case W:return R=Il(R,I.mode,O),R.return=I,R;case ye:var te=R._init;return q(I,te(R._payload),O)}if(B(R)||ne(R))return R=Kr(R,I.mode,O,null),R.return=I,R;po(I,R)}return null}function K(I,R,O,te){var Se=R!==null?R.key:null;if(typeof O=="string"&&O!==""||typeof O=="number")return Se!==null?null:b(I,R,""+O,te);if(typeof O=="object"&&O!==null){switch(O.$$typeof){case L:return O.key===Se?$(I,R,O,te):null;case W:return O.key===Se?F(I,R,O,te):null;case ye:return Se=O._init,K(I,R,Se(O._payload),te)}if(B(O)||ne(O))return Se!==null?null:Y(I,R,O,te,null);po(I,O)}return null}function ue(I,R,O,te,Se){if(typeof te=="string"&&te!==""||typeof te=="number")return I=I.get(O)||null,b(R,I,""+te,Se);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case L:return I=I.get(te.key===null?O:te.key)||null,$(R,I,te,Se);case W:return I=I.get(te.key===null?O:te.key)||null,F(R,I,te,Se);case ye:var Ce=te._init;return ue(I,R,O,Ce(te._payload),Se)}if(B(te)||ne(te))return I=I.get(O)||null,Y(R,I,te,Se,null);po(R,te)}return null}function ge(I,R,O,te){for(var Se=null,Ce=null,Ne=R,Te=R=0,wt=null;Ne!==null&&Te<O.length;Te++){Ne.index>Te?(wt=Ne,Ne=null):wt=Ne.sibling;var He=K(I,Ne,O[Te],te);if(He===null){Ne===null&&(Ne=wt);break}e&&Ne&&He.alternate===null&&t(I,Ne),R=h(He,R,Te),Ce===null?Se=He:Ce.sibling=He,Ce=He,Ne=wt}if(Te===O.length)return s(I,Ne),rt&&Fr(I,Te),Se;if(Ne===null){for(;Te<O.length;Te++)Ne=q(I,O[Te],te),Ne!==null&&(R=h(Ne,R,Te),Ce===null?Se=Ne:Ce.sibling=Ne,Ce=Ne);return rt&&Fr(I,Te),Se}for(Ne=l(I,Ne);Te<O.length;Te++)wt=ue(Ne,I,Te,O[Te],te),wt!==null&&(e&&wt.alternate!==null&&Ne.delete(wt.key===null?Te:wt.key),R=h(wt,R,Te),Ce===null?Se=wt:Ce.sibling=wt,Ce=wt);return e&&Ne.forEach(function(_r){return t(I,_r)}),rt&&Fr(I,Te),Se}function xe(I,R,O,te){var Se=ne(O);if(typeof Se!="function")throw Error(i(150));if(O=Se.call(O),O==null)throw Error(i(151));for(var Ce=Se=null,Ne=R,Te=R=0,wt=null,He=O.next();Ne!==null&&!He.done;Te++,He=O.next()){Ne.index>Te?(wt=Ne,Ne=null):wt=Ne.sibling;var _r=K(I,Ne,He.value,te);if(_r===null){Ne===null&&(Ne=wt);break}e&&Ne&&_r.alternate===null&&t(I,Ne),R=h(_r,R,Te),Ce===null?Se=_r:Ce.sibling=_r,Ce=_r,Ne=wt}if(He.done)return s(I,Ne),rt&&Fr(I,Te),Se;if(Ne===null){for(;!He.done;Te++,He=O.next())He=q(I,He.value,te),He!==null&&(R=h(He,R,Te),Ce===null?Se=He:Ce.sibling=He,Ce=He);return rt&&Fr(I,Te),Se}for(Ne=l(I,Ne);!He.done;Te++,He=O.next())He=ue(Ne,I,Te,He.value,te),He!==null&&(e&&He.alternate!==null&&Ne.delete(He.key===null?Te:He.key),R=h(He,R,Te),Ce===null?Se=He:Ce.sibling=He,Ce=He);return e&&Ne.forEach(function(Rh){return t(I,Rh)}),rt&&Fr(I,Te),Se}function ct(I,R,O,te){if(typeof O=="object"&&O!==null&&O.type===V&&O.key===null&&(O=O.props.children),typeof O=="object"&&O!==null){switch(O.$$typeof){case L:e:{for(var Se=O.key,Ce=R;Ce!==null;){if(Ce.key===Se){if(Se=O.type,Se===V){if(Ce.tag===7){s(I,Ce.sibling),R=u(Ce,O.props.children),R.return=I,I=R;break e}}else if(Ce.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===ye&&fu(Se)===Ce.type){s(I,Ce.sibling),R=u(Ce,O.props),R.ref=ui(I,Ce,O),R.return=I,I=R;break e}s(I,Ce);break}else t(I,Ce);Ce=Ce.sibling}O.type===V?(R=Kr(O.props.children,I.mode,te,O.key),R.return=I,I=R):(te=Oo(O.type,O.key,O.props,null,I.mode,te),te.ref=ui(I,R,O),te.return=I,I=te)}return v(I);case W:e:{for(Ce=O.key;R!==null;){if(R.key===Ce)if(R.tag===4&&R.stateNode.containerInfo===O.containerInfo&&R.stateNode.implementation===O.implementation){s(I,R.sibling),R=u(R,O.children||[]),R.return=I,I=R;break e}else{s(I,R);break}else t(I,R);R=R.sibling}R=Il(O,I.mode,te),R.return=I,I=R}return v(I);case ye:return Ce=O._init,ct(I,R,Ce(O._payload),te)}if(B(O))return ge(I,R,O,te);if(ne(O))return xe(I,R,O,te);po(I,O)}return typeof O=="string"&&O!==""||typeof O=="number"?(O=""+O,R!==null&&R.tag===6?(s(I,R.sibling),R=u(R,O),R.return=I,I=R):(s(I,R),R=Ml(O,I.mode,te),R.return=I,I=R),v(I)):s(I,R)}return ct}var Ss=pu(!0),hu=pu(!1),ho=cr(null),mo=null,js=null,Wa=null;function Va(){Wa=js=mo=null}function Ha(e){var t=ho.current;tt(ho),e._currentValue=t}function Ga(e,t,s){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===s)break;e=e.return}}function bs(e,t){mo=e,Wa=js=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Qt=!0),e.firstContext=null)}function pn(e){var t=e._currentValue;if(Wa!==e)if(e={context:e,memoizedValue:t,next:null},js===null){if(mo===null)throw Error(i(308));js=e,mo.dependencies={lanes:0,firstContext:e}}else js=js.next=e;return t}var Dr=null;function Ka(e){Dr===null?Dr=[e]:Dr.push(e)}function mu(e,t,s,l){var u=t.interleaved;return u===null?(s.next=s,Ka(t)):(s.next=u.next,u.next=s),t.interleaved=s,Qn(e,l)}function Qn(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var fr=!1;function Qa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function gu(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function pr(e,t,s){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ve&2)!==0){var u=l.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),l.pending=t,Qn(e,s)}return u=l.interleaved,u===null?(t.next=t,Ka(l)):(t.next=u.next,u.next=t),l.interleaved=t,Qn(e,s)}function go(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var l=t.lanes;l&=e.pendingLanes,s|=l,t.lanes=s,M(e,s)}}function yu(e,t){var s=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,s===l)){var u=null,h=null;if(s=s.firstBaseUpdate,s!==null){do{var v={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};h===null?u=h=v:h=h.next=v,s=s.next}while(s!==null);h===null?u=h=t:h=h.next=t}else u=h=t;s={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:h,shared:l.shared,effects:l.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function yo(e,t,s,l){var u=e.updateQueue;fr=!1;var h=u.firstBaseUpdate,v=u.lastBaseUpdate,b=u.shared.pending;if(b!==null){u.shared.pending=null;var $=b,F=$.next;$.next=null,v===null?h=F:v.next=F,v=$;var Y=e.alternate;Y!==null&&(Y=Y.updateQueue,b=Y.lastBaseUpdate,b!==v&&(b===null?Y.firstBaseUpdate=F:b.next=F,Y.lastBaseUpdate=$))}if(h!==null){var q=u.baseState;v=0,Y=F=$=null,b=h;do{var K=b.lane,ue=b.eventTime;if((l&K)===K){Y!==null&&(Y=Y.next={eventTime:ue,lane:0,tag:b.tag,payload:b.payload,callback:b.callback,next:null});e:{var ge=e,xe=b;switch(K=t,ue=s,xe.tag){case 1:if(ge=xe.payload,typeof ge=="function"){q=ge.call(ue,q,K);break e}q=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=xe.payload,K=typeof ge=="function"?ge.call(ue,q,K):ge,K==null)break e;q=U({},q,K);break e;case 2:fr=!0}}b.callback!==null&&b.lane!==0&&(e.flags|=64,K=u.effects,K===null?u.effects=[b]:K.push(b))}else ue={eventTime:ue,lane:K,tag:b.tag,payload:b.payload,callback:b.callback,next:null},Y===null?(F=Y=ue,$=q):Y=Y.next=ue,v|=K;if(b=b.next,b===null){if(b=u.shared.pending,b===null)break;K=b,b=K.next,K.next=null,u.lastBaseUpdate=K,u.shared.pending=null}}while(!0);if(Y===null&&($=q),u.baseState=$,u.firstBaseUpdate=F,u.lastBaseUpdate=Y,t=u.shared.interleaved,t!==null){u=t;do v|=u.lane,u=u.next;while(u!==t)}else h===null&&(u.shared.lanes=0);Wr|=v,e.lanes=v,e.memoizedState=q}}function vu(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var l=e[t],u=l.callback;if(u!==null){if(l.callback=null,l=s,typeof u!="function")throw Error(i(191,u));u.call(l)}}}var di={},Pn=cr(di),fi=cr(di),pi=cr(di);function Br(e){if(e===di)throw Error(i(174));return e}function Ja(e,t){switch(Ze(pi,t),Ze(fi,e),Ze(Pn,di),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:$n(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=$n(t,e)}tt(Pn),Ze(Pn,t)}function Cs(){tt(Pn),tt(fi),tt(pi)}function wu(e){Br(pi.current);var t=Br(Pn.current),s=$n(t,e.type);t!==s&&(Ze(fi,e),Ze(Pn,s))}function Ya(e){fi.current===e&&(tt(Pn),tt(fi))}var st=cr(0);function vo(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Xa=[];function Za(){for(var e=0;e<Xa.length;e++)Xa[e]._workInProgressVersionPrimary=null;Xa.length=0}var wo=j.ReactCurrentDispatcher,qa=j.ReactCurrentBatchConfig,Ur=0,it=null,ht=null,yt=null,_o=!1,hi=!1,mi=0,qp=0;function Mt(){throw Error(i(321))}function el(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!kn(e[s],t[s]))return!1;return!0}function tl(e,t,s,l,u,h){if(Ur=h,it=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,wo.current=e===null||e.memoizedState===null?rh:sh,e=s(l,u),hi){h=0;do{if(hi=!1,mi=0,25<=h)throw Error(i(301));h+=1,yt=ht=null,t.updateQueue=null,wo.current=ih,e=s(l,u)}while(hi)}if(wo.current=So,t=ht!==null&&ht.next!==null,Ur=0,yt=ht=it=null,_o=!1,t)throw Error(i(300));return e}function nl(){var e=mi!==0;return mi=0,e}function Ln(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yt===null?it.memoizedState=yt=e:yt=yt.next=e,yt}function hn(){if(ht===null){var e=it.alternate;e=e!==null?e.memoizedState:null}else e=ht.next;var t=yt===null?it.memoizedState:yt.next;if(t!==null)yt=t,ht=e;else{if(e===null)throw Error(i(310));ht=e,e={memoizedState:ht.memoizedState,baseState:ht.baseState,baseQueue:ht.baseQueue,queue:ht.queue,next:null},yt===null?it.memoizedState=yt=e:yt=yt.next=e}return yt}function gi(e,t){return typeof t=="function"?t(e):t}function rl(e){var t=hn(),s=t.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=e;var l=ht,u=l.baseQueue,h=s.pending;if(h!==null){if(u!==null){var v=u.next;u.next=h.next,h.next=v}l.baseQueue=u=h,s.pending=null}if(u!==null){h=u.next,l=l.baseState;var b=v=null,$=null,F=h;do{var Y=F.lane;if((Ur&Y)===Y)$!==null&&($=$.next={lane:0,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null}),l=F.hasEagerState?F.eagerState:e(l,F.action);else{var q={lane:Y,action:F.action,hasEagerState:F.hasEagerState,eagerState:F.eagerState,next:null};$===null?(b=$=q,v=l):$=$.next=q,it.lanes|=Y,Wr|=Y}F=F.next}while(F!==null&&F!==h);$===null?v=l:$.next=b,kn(l,t.memoizedState)||(Qt=!0),t.memoizedState=l,t.baseState=v,t.baseQueue=$,s.lastRenderedState=l}if(e=s.interleaved,e!==null){u=e;do h=u.lane,it.lanes|=h,Wr|=h,u=u.next;while(u!==e)}else u===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function sl(e){var t=hn(),s=t.queue;if(s===null)throw Error(i(311));s.lastRenderedReducer=e;var l=s.dispatch,u=s.pending,h=t.memoizedState;if(u!==null){s.pending=null;var v=u=u.next;do h=e(h,v.action),v=v.next;while(v!==u);kn(h,t.memoizedState)||(Qt=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),s.lastRenderedState=h}return[h,l]}function _u(){}function xu(e,t){var s=it,l=hn(),u=t(),h=!kn(l.memoizedState,u);if(h&&(l.memoizedState=u,Qt=!0),l=l.queue,il(ju.bind(null,s,l,e),[e]),l.getSnapshot!==t||h||yt!==null&&yt.memoizedState.tag&1){if(s.flags|=2048,yi(9,Su.bind(null,s,l,u,t),void 0,null),vt===null)throw Error(i(349));(Ur&30)!==0||ku(s,t,u)}return u}function ku(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Su(e,t,s,l){t.value=s,t.getSnapshot=l,bu(t)&&Cu(e)}function ju(e,t,s){return s(function(){bu(t)&&Cu(e)})}function bu(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!kn(e,s)}catch{return!0}}function Cu(e){var t=Qn(e,1);t!==null&&Nn(t,e,1,-1)}function Nu(e){var t=Ln();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gi,lastRenderedState:e},t.queue=e,e=e.dispatch=nh.bind(null,it,e),[t.memoizedState,e]}function yi(e,t,s,l){return e={tag:e,create:t,destroy:s,deps:l,next:null},t=it.updateQueue,t===null?(t={lastEffect:null,stores:null},it.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(l=s.next,s.next=e,e.next=l,t.lastEffect=e)),e}function Eu(){return hn().memoizedState}function xo(e,t,s,l){var u=Ln();it.flags|=e,u.memoizedState=yi(1|t,s,void 0,l===void 0?null:l)}function ko(e,t,s,l){var u=hn();l=l===void 0?null:l;var h=void 0;if(ht!==null){var v=ht.memoizedState;if(h=v.destroy,l!==null&&el(l,v.deps)){u.memoizedState=yi(t,s,h,l);return}}it.flags|=e,u.memoizedState=yi(1|t,s,h,l)}function $u(e,t){return xo(8390656,8,e,t)}function il(e,t){return ko(2048,8,e,t)}function Tu(e,t){return ko(4,2,e,t)}function Ru(e,t){return ko(4,4,e,t)}function Au(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Mu(e,t,s){return s=s!=null?s.concat([e]):null,ko(4,4,Au.bind(null,t,e),s)}function ol(){}function Iu(e,t){var s=hn();t=t===void 0?null:t;var l=s.memoizedState;return l!==null&&t!==null&&el(t,l[1])?l[0]:(s.memoizedState=[e,t],e)}function Pu(e,t){var s=hn();t=t===void 0?null:t;var l=s.memoizedState;return l!==null&&t!==null&&el(t,l[1])?l[0]:(e=e(),s.memoizedState=[e,t],e)}function Lu(e,t,s){return(Ur&21)===0?(e.baseState&&(e.baseState=!1,Qt=!0),e.memoizedState=s):(kn(s,t)||(s=Gs(),it.lanes|=s,Wr|=s,e.baseState=!0),t)}function eh(e,t){var s=G;G=s!==0&&4>s?s:4,e(!0);var l=qa.transition;qa.transition={};try{e(!1),t()}finally{G=s,qa.transition=l}}function Ou(){return hn().memoizedState}function th(e,t,s){var l=yr(e);if(s={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null},zu(e))Fu(t,s);else if(s=mu(e,t,s,l),s!==null){var u=Dt();Nn(s,e,l,u),Du(s,t,l)}}function nh(e,t,s){var l=yr(e),u={lane:l,action:s,hasEagerState:!1,eagerState:null,next:null};if(zu(e))Fu(t,u);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=t.lastRenderedReducer,h!==null))try{var v=t.lastRenderedState,b=h(v,s);if(u.hasEagerState=!0,u.eagerState=b,kn(b,v)){var $=t.interleaved;$===null?(u.next=u,Ka(t)):(u.next=$.next,$.next=u),t.interleaved=u;return}}catch{}finally{}s=mu(e,t,u,l),s!==null&&(u=Dt(),Nn(s,e,l,u),Du(s,t,l))}}function zu(e){var t=e.alternate;return e===it||t!==null&&t===it}function Fu(e,t){hi=_o=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Du(e,t,s){if((s&4194240)!==0){var l=t.lanes;l&=e.pendingLanes,s|=l,t.lanes=s,M(e,s)}}var So={readContext:pn,useCallback:Mt,useContext:Mt,useEffect:Mt,useImperativeHandle:Mt,useInsertionEffect:Mt,useLayoutEffect:Mt,useMemo:Mt,useReducer:Mt,useRef:Mt,useState:Mt,useDebugValue:Mt,useDeferredValue:Mt,useTransition:Mt,useMutableSource:Mt,useSyncExternalStore:Mt,useId:Mt,unstable_isNewReconciler:!1},rh={readContext:pn,useCallback:function(e,t){return Ln().memoizedState=[e,t===void 0?null:t],e},useContext:pn,useEffect:$u,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,xo(4194308,4,Au.bind(null,t,e),s)},useLayoutEffect:function(e,t){return xo(4194308,4,e,t)},useInsertionEffect:function(e,t){return xo(4,2,e,t)},useMemo:function(e,t){var s=Ln();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var l=Ln();return t=s!==void 0?s(t):t,l.memoizedState=l.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},l.queue=e,e=e.dispatch=th.bind(null,it,e),[l.memoizedState,e]},useRef:function(e){var t=Ln();return e={current:e},t.memoizedState=e},useState:Nu,useDebugValue:ol,useDeferredValue:function(e){return Ln().memoizedState=e},useTransition:function(){var e=Nu(!1),t=e[0];return e=eh.bind(null,e[1]),Ln().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var l=it,u=Ln();if(rt){if(s===void 0)throw Error(i(407));s=s()}else{if(s=t(),vt===null)throw Error(i(349));(Ur&30)!==0||ku(l,t,s)}u.memoizedState=s;var h={value:s,getSnapshot:t};return u.queue=h,$u(ju.bind(null,l,h,e),[e]),l.flags|=2048,yi(9,Su.bind(null,l,h,s,t),void 0,null),s},useId:function(){var e=Ln(),t=vt.identifierPrefix;if(rt){var s=Kn,l=Gn;s=(l&~(1<<32-Ht(l)-1)).toString(32)+s,t=":"+t+"R"+s,s=mi++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=qp++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},sh={readContext:pn,useCallback:Iu,useContext:pn,useEffect:il,useImperativeHandle:Mu,useInsertionEffect:Tu,useLayoutEffect:Ru,useMemo:Pu,useReducer:rl,useRef:Eu,useState:function(){return rl(gi)},useDebugValue:ol,useDeferredValue:function(e){var t=hn();return Lu(t,ht.memoizedState,e)},useTransition:function(){var e=rl(gi)[0],t=hn().memoizedState;return[e,t]},useMutableSource:_u,useSyncExternalStore:xu,useId:Ou,unstable_isNewReconciler:!1},ih={readContext:pn,useCallback:Iu,useContext:pn,useEffect:il,useImperativeHandle:Mu,useInsertionEffect:Tu,useLayoutEffect:Ru,useMemo:Pu,useReducer:sl,useRef:Eu,useState:function(){return sl(gi)},useDebugValue:ol,useDeferredValue:function(e){var t=hn();return ht===null?t.memoizedState=e:Lu(t,ht.memoizedState,e)},useTransition:function(){var e=sl(gi)[0],t=hn().memoizedState;return[e,t]},useMutableSource:_u,useSyncExternalStore:xu,useId:Ou,unstable_isNewReconciler:!1};function jn(e,t){if(e&&e.defaultProps){t=U({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function al(e,t,s,l){t=e.memoizedState,s=s(l,t),s=s==null?t:U({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var jo={isMounted:function(e){return(e=e._reactInternals)?ft(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var l=Dt(),u=yr(e),h=Jn(l,u);h.payload=t,s!=null&&(h.callback=s),t=pr(e,h,u),t!==null&&(Nn(t,e,u,l),go(t,e,u))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var l=Dt(),u=yr(e),h=Jn(l,u);h.tag=1,h.payload=t,s!=null&&(h.callback=s),t=pr(e,h,u),t!==null&&(Nn(t,e,u,l),go(t,e,u))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Dt(),l=yr(e),u=Jn(s,l);u.tag=2,t!=null&&(u.callback=t),t=pr(e,u,l),t!==null&&(Nn(t,e,l,s),go(t,e,l))}};function Bu(e,t,s,l,u,h,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,h,v):t.prototype&&t.prototype.isPureReactComponent?!ri(s,l)||!ri(u,h):!0}function Uu(e,t,s){var l=!1,u=ur,h=t.contextType;return typeof h=="object"&&h!==null?h=pn(h):(u=Kt(t)?Or:At.current,l=t.contextTypes,h=(l=l!=null)?ws(e,u):ur),t=new t(s,h),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=jo,e.stateNode=t,t._reactInternals=e,l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=u,e.__reactInternalMemoizedMaskedChildContext=h),t}function Wu(e,t,s,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,l),t.state!==e&&jo.enqueueReplaceState(t,t.state,null)}function ll(e,t,s,l){var u=e.stateNode;u.props=s,u.state=e.memoizedState,u.refs={},Qa(e);var h=t.contextType;typeof h=="object"&&h!==null?u.context=pn(h):(h=Kt(t)?Or:At.current,u.context=ws(e,h)),u.state=e.memoizedState,h=t.getDerivedStateFromProps,typeof h=="function"&&(al(e,t,h,s),u.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof u.getSnapshotBeforeUpdate=="function"||typeof u.UNSAFE_componentWillMount!="function"&&typeof u.componentWillMount!="function"||(t=u.state,typeof u.componentWillMount=="function"&&u.componentWillMount(),typeof u.UNSAFE_componentWillMount=="function"&&u.UNSAFE_componentWillMount(),t!==u.state&&jo.enqueueReplaceState(u,u.state,null),yo(e,s,u,l),u.state=e.memoizedState),typeof u.componentDidMount=="function"&&(e.flags|=4194308)}function Ns(e,t){try{var s="",l=t;do s+=ce(l),l=l.return;while(l);var u=s}catch(h){u=`
39
+ Error generating stack: `+h.message+`
40
+ `+h.stack}return{value:e,source:t,stack:u,digest:null}}function cl(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function ul(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var oh=typeof WeakMap=="function"?WeakMap:Map;function Vu(e,t,s){s=Jn(-1,s),s.tag=3,s.payload={element:null};var l=t.value;return s.callback=function(){Ro||(Ro=!0,bl=l),ul(e,t)},s}function Hu(e,t,s){s=Jn(-1,s),s.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var u=t.value;s.payload=function(){return l(u)},s.callback=function(){ul(e,t)}}var h=e.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(s.callback=function(){ul(e,t),typeof l!="function"&&(mr===null?mr=new Set([this]):mr.add(this));var v=t.stack;this.componentDidCatch(t.value,{componentStack:v!==null?v:""})}),s}function Gu(e,t,s){var l=e.pingCache;if(l===null){l=e.pingCache=new oh;var u=new Set;l.set(t,u)}else u=l.get(t),u===void 0&&(u=new Set,l.set(t,u));u.has(s)||(u.add(s),e=_h.bind(null,e,t,s),t.then(e,e))}function Ku(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Qu(e,t,s,l,u){return(e.mode&1)===0?(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=Jn(-1,1),t.tag=2,pr(s,t,1))),s.lanes|=1),e):(e.flags|=65536,e.lanes=u,e)}var ah=j.ReactCurrentOwner,Qt=!1;function Ft(e,t,s,l){t.child=e===null?hu(t,null,s,l):Ss(t,e.child,s,l)}function Ju(e,t,s,l,u){s=s.render;var h=t.ref;return bs(t,u),l=tl(e,t,s,l,h,u),s=nl(),e!==null&&!Qt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,Yn(e,t,u)):(rt&&s&&za(t),t.flags|=1,Ft(e,t,l,u),t.child)}function Yu(e,t,s,l,u){if(e===null){var h=s.type;return typeof h=="function"&&!Al(h)&&h.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=h,Xu(e,t,h,l,u)):(e=Oo(s.type,null,l,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,(e.lanes&u)===0){var v=h.memoizedProps;if(s=s.compare,s=s!==null?s:ri,s(v,l)&&e.ref===t.ref)return Yn(e,t,u)}return t.flags|=1,e=wr(h,l),e.ref=t.ref,e.return=t,t.child=e}function Xu(e,t,s,l,u){if(e!==null){var h=e.memoizedProps;if(ri(h,l)&&e.ref===t.ref)if(Qt=!1,t.pendingProps=l=h,(e.lanes&u)!==0)(e.flags&131072)!==0&&(Qt=!0);else return t.lanes=e.lanes,Yn(e,t,u)}return dl(e,t,s,l,u)}function Zu(e,t,s){var l=t.pendingProps,u=l.children,h=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((t.mode&1)===0)t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ze($s,ln),ln|=s;else{if((s&1073741824)===0)return e=h!==null?h.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ze($s,ln),ln|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=h!==null?h.baseLanes:s,Ze($s,ln),ln|=l}else h!==null?(l=h.baseLanes|s,t.memoizedState=null):l=s,Ze($s,ln),ln|=l;return Ft(e,t,u,s),t.child}function qu(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function dl(e,t,s,l,u){var h=Kt(s)?Or:At.current;return h=ws(t,h),bs(t,u),s=tl(e,t,s,l,h,u),l=nl(),e!==null&&!Qt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~u,Yn(e,t,u)):(rt&&l&&za(t),t.flags|=1,Ft(e,t,s,u),t.child)}function ed(e,t,s,l,u){if(Kt(s)){var h=!0;ao(t)}else h=!1;if(bs(t,u),t.stateNode===null)Co(e,t),Uu(t,s,l),ll(t,s,l,u),l=!0;else if(e===null){var v=t.stateNode,b=t.memoizedProps;v.props=b;var $=v.context,F=s.contextType;typeof F=="object"&&F!==null?F=pn(F):(F=Kt(s)?Or:At.current,F=ws(t,F));var Y=s.getDerivedStateFromProps,q=typeof Y=="function"||typeof v.getSnapshotBeforeUpdate=="function";q||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(b!==l||$!==F)&&Wu(t,v,l,F),fr=!1;var K=t.memoizedState;v.state=K,yo(t,l,v,u),$=t.memoizedState,b!==l||K!==$||Gt.current||fr?(typeof Y=="function"&&(al(t,s,Y,l),$=t.memoizedState),(b=fr||Bu(t,s,b,l,K,$,F))?(q||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount()),typeof v.componentDidMount=="function"&&(t.flags|=4194308)):(typeof v.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=$),v.props=l,v.state=$,v.context=F,l=b):(typeof v.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{v=t.stateNode,gu(e,t),b=t.memoizedProps,F=t.type===t.elementType?b:jn(t.type,b),v.props=F,q=t.pendingProps,K=v.context,$=s.contextType,typeof $=="object"&&$!==null?$=pn($):($=Kt(s)?Or:At.current,$=ws(t,$));var ue=s.getDerivedStateFromProps;(Y=typeof ue=="function"||typeof v.getSnapshotBeforeUpdate=="function")||typeof v.UNSAFE_componentWillReceiveProps!="function"&&typeof v.componentWillReceiveProps!="function"||(b!==q||K!==$)&&Wu(t,v,l,$),fr=!1,K=t.memoizedState,v.state=K,yo(t,l,v,u);var ge=t.memoizedState;b!==q||K!==ge||Gt.current||fr?(typeof ue=="function"&&(al(t,s,ue,l),ge=t.memoizedState),(F=fr||Bu(t,s,F,l,K,ge,$)||!1)?(Y||typeof v.UNSAFE_componentWillUpdate!="function"&&typeof v.componentWillUpdate!="function"||(typeof v.componentWillUpdate=="function"&&v.componentWillUpdate(l,ge,$),typeof v.UNSAFE_componentWillUpdate=="function"&&v.UNSAFE_componentWillUpdate(l,ge,$)),typeof v.componentDidUpdate=="function"&&(t.flags|=4),typeof v.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof v.componentDidUpdate!="function"||b===e.memoizedProps&&K===e.memoizedState||(t.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&K===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=ge),v.props=l,v.state=ge,v.context=$,l=F):(typeof v.componentDidUpdate!="function"||b===e.memoizedProps&&K===e.memoizedState||(t.flags|=4),typeof v.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&K===e.memoizedState||(t.flags|=1024),l=!1)}return fl(e,t,s,l,h,u)}function fl(e,t,s,l,u,h){qu(e,t);var v=(t.flags&128)!==0;if(!l&&!v)return u&&iu(t,s,!1),Yn(e,t,h);l=t.stateNode,ah.current=t;var b=v&&typeof s.getDerivedStateFromError!="function"?null:l.render();return t.flags|=1,e!==null&&v?(t.child=Ss(t,e.child,null,h),t.child=Ss(t,null,b,h)):Ft(e,t,b,h),t.memoizedState=l.state,u&&iu(t,s,!0),t.child}function td(e){var t=e.stateNode;t.pendingContext?ru(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ru(e,t.context,!1),Ja(e,t.containerInfo)}function nd(e,t,s,l,u){return ks(),Ua(u),t.flags|=256,Ft(e,t,s,l),t.child}var pl={dehydrated:null,treeContext:null,retryLane:0};function hl(e){return{baseLanes:e,cachePool:null,transitions:null}}function rd(e,t,s){var l=t.pendingProps,u=st.current,h=!1,v=(t.flags&128)!==0,b;if((b=v)||(b=e!==null&&e.memoizedState===null?!1:(u&2)!==0),b?(h=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(u|=1),Ze(st,u&1),e===null)return Ba(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((t.mode&1)===0?t.lanes=1:e.data==="$!"?t.lanes=8:t.lanes=1073741824,null):(v=l.children,e=l.fallback,h?(l=t.mode,h=t.child,v={mode:"hidden",children:v},(l&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=v):h=zo(v,l,0,null),e=Kr(e,l,s,null),h.return=t,e.return=t,h.sibling=e,t.child=h,t.child.memoizedState=hl(s),t.memoizedState=pl,e):ml(t,v));if(u=e.memoizedState,u!==null&&(b=u.dehydrated,b!==null))return lh(e,t,v,l,b,u,s);if(h){h=l.fallback,v=t.mode,u=e.child,b=u.sibling;var $={mode:"hidden",children:l.children};return(v&1)===0&&t.child!==u?(l=t.child,l.childLanes=0,l.pendingProps=$,t.deletions=null):(l=wr(u,$),l.subtreeFlags=u.subtreeFlags&14680064),b!==null?h=wr(b,h):(h=Kr(h,v,s,null),h.flags|=2),h.return=t,l.return=t,l.sibling=h,t.child=l,l=h,h=t.child,v=e.child.memoizedState,v=v===null?hl(s):{baseLanes:v.baseLanes|s,cachePool:null,transitions:v.transitions},h.memoizedState=v,h.childLanes=e.childLanes&~s,t.memoizedState=pl,l}return h=e.child,e=h.sibling,l=wr(h,{mode:"visible",children:l.children}),(t.mode&1)===0&&(l.lanes=s),l.return=t,l.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=l,t.memoizedState=null,l}function ml(e,t){return t=zo({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function bo(e,t,s,l){return l!==null&&Ua(l),Ss(t,e.child,null,s),e=ml(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function lh(e,t,s,l,u,h,v){if(s)return t.flags&256?(t.flags&=-257,l=cl(Error(i(422))),bo(e,t,v,l)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(h=l.fallback,u=t.mode,l=zo({mode:"visible",children:l.children},u,0,null),h=Kr(h,u,v,null),h.flags|=2,l.return=t,h.return=t,l.sibling=h,t.child=l,(t.mode&1)!==0&&Ss(t,e.child,null,v),t.child.memoizedState=hl(v),t.memoizedState=pl,h);if((t.mode&1)===0)return bo(e,t,v,null);if(u.data==="$!"){if(l=u.nextSibling&&u.nextSibling.dataset,l)var b=l.dgst;return l=b,h=Error(i(419)),l=cl(h,l,void 0),bo(e,t,v,l)}if(b=(v&e.childLanes)!==0,Qt||b){if(l=vt,l!==null){switch(v&-v){case 4:u=2;break;case 16:u=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:u=32;break;case 536870912:u=268435456;break;default:u=0}u=(u&(l.suspendedLanes|v))!==0?0:u,u!==0&&u!==h.retryLane&&(h.retryLane=u,Qn(e,u),Nn(l,e,u,-1))}return Rl(),l=cl(Error(i(421))),bo(e,t,v,l)}return u.data==="$?"?(t.flags|=128,t.child=e.child,t=xh.bind(null,e),u._reactRetry=t,null):(e=h.treeContext,an=lr(u.nextSibling),on=t,rt=!0,Sn=null,e!==null&&(dn[fn++]=Gn,dn[fn++]=Kn,dn[fn++]=zr,Gn=e.id,Kn=e.overflow,zr=t),t=ml(t,l.children),t.flags|=4096,t)}function sd(e,t,s){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),Ga(e.return,t,s)}function gl(e,t,s,l,u){var h=e.memoizedState;h===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:s,tailMode:u}:(h.isBackwards=t,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=s,h.tailMode=u)}function id(e,t,s){var l=t.pendingProps,u=l.revealOrder,h=l.tail;if(Ft(e,t,l.children,s),l=st.current,(l&2)!==0)l=l&1|2,t.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&sd(e,s,t);else if(e.tag===19)sd(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Ze(st,l),(t.mode&1)===0)t.memoizedState=null;else switch(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&vo(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),gl(t,!1,u,s,h);break;case"backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&vo(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}gl(t,!0,s,null,h);break;case"together":gl(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Co(e,t){(t.mode&1)===0&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Yn(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),Wr|=t.lanes,(s&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,s=wr(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=wr(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function ch(e,t,s){switch(t.tag){case 3:td(t),ks();break;case 5:wu(t);break;case 1:Kt(t.type)&&ao(t);break;case 4:Ja(t,t.stateNode.containerInfo);break;case 10:var l=t.type._context,u=t.memoizedProps.value;Ze(ho,l._currentValue),l._currentValue=u;break;case 13:if(l=t.memoizedState,l!==null)return l.dehydrated!==null?(Ze(st,st.current&1),t.flags|=128,null):(s&t.child.childLanes)!==0?rd(e,t,s):(Ze(st,st.current&1),e=Yn(e,t,s),e!==null?e.sibling:null);Ze(st,st.current&1);break;case 19:if(l=(s&t.childLanes)!==0,(e.flags&128)!==0){if(l)return id(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),Ze(st,st.current),l)break;return null;case 22:case 23:return t.lanes=0,Zu(e,t,s)}return Yn(e,t,s)}var od,yl,ad,ld;od=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}},yl=function(){},ad=function(e,t,s,l){var u=e.memoizedProps;if(u!==l){e=t.stateNode,Br(Pn.current);var h=null;switch(s){case"input":u=de(e,u),l=de(e,l),h=[];break;case"select":u=U({},u,{value:void 0}),l=U({},l,{value:void 0}),h=[];break;case"textarea":u=Le(e,u),l=Le(e,l),h=[];break;default:typeof u.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=so)}_n(s,l);var v;s=null;for(F in u)if(!l.hasOwnProperty(F)&&u.hasOwnProperty(F)&&u[F]!=null)if(F==="style"){var b=u[F];for(v in b)b.hasOwnProperty(v)&&(s||(s={}),s[v]="")}else F!=="dangerouslySetInnerHTML"&&F!=="children"&&F!=="suppressContentEditableWarning"&&F!=="suppressHydrationWarning"&&F!=="autoFocus"&&(c.hasOwnProperty(F)?h||(h=[]):(h=h||[]).push(F,null));for(F in l){var $=l[F];if(b=u!=null?u[F]:void 0,l.hasOwnProperty(F)&&$!==b&&($!=null||b!=null))if(F==="style")if(b){for(v in b)!b.hasOwnProperty(v)||$&&$.hasOwnProperty(v)||(s||(s={}),s[v]="");for(v in $)$.hasOwnProperty(v)&&b[v]!==$[v]&&(s||(s={}),s[v]=$[v])}else s||(h||(h=[]),h.push(F,s)),s=$;else F==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,b=b?b.__html:void 0,$!=null&&b!==$&&(h=h||[]).push(F,$)):F==="children"?typeof $!="string"&&typeof $!="number"||(h=h||[]).push(F,""+$):F!=="suppressContentEditableWarning"&&F!=="suppressHydrationWarning"&&(c.hasOwnProperty(F)?($!=null&&F==="onScroll"&&et("scroll",e),h||b===$||(h=[])):(h=h||[]).push(F,$))}s&&(h=h||[]).push("style",s);var F=h;(t.updateQueue=F)&&(t.flags|=4)}},ld=function(e,t,s,l){s!==l&&(t.flags|=4)};function vi(e,t){if(!rt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var l=null;s!==null;)s.alternate!==null&&(l=s),s=s.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function It(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,l=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,l|=u.subtreeFlags&14680064,l|=u.flags&14680064,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=l,e.childLanes=s,t}function uh(e,t,s){var l=t.pendingProps;switch(Fa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(t),null;case 1:return Kt(t.type)&&oo(),It(t),null;case 3:return l=t.stateNode,Cs(),tt(Gt),tt(At),Za(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(fo(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Sn!==null&&(El(Sn),Sn=null))),yl(e,t),It(t),null;case 5:Ya(t);var u=Br(pi.current);if(s=t.type,e!==null&&t.stateNode!=null)ad(e,t,s,l,u),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!l){if(t.stateNode===null)throw Error(i(166));return It(t),null}if(e=Br(Pn.current),fo(t)){l=t.stateNode,s=t.type;var h=t.memoizedProps;switch(l[In]=t,l[li]=h,e=(t.mode&1)!==0,s){case"dialog":et("cancel",l),et("close",l);break;case"iframe":case"object":case"embed":et("load",l);break;case"video":case"audio":for(u=0;u<ii.length;u++)et(ii[u],l);break;case"source":et("error",l);break;case"img":case"image":case"link":et("error",l),et("load",l);break;case"details":et("toggle",l);break;case"input":je(l,h),et("invalid",l);break;case"select":l._wrapperState={wasMultiple:!!h.multiple},et("invalid",l);break;case"textarea":Ge(l,h),et("invalid",l)}_n(s,h),u=null;for(var v in h)if(h.hasOwnProperty(v)){var b=h[v];v==="children"?typeof b=="string"?l.textContent!==b&&(h.suppressHydrationWarning!==!0&&ro(l.textContent,b,e),u=["children",b]):typeof b=="number"&&l.textContent!==""+b&&(h.suppressHydrationWarning!==!0&&ro(l.textContent,b,e),u=["children",""+b]):c.hasOwnProperty(v)&&b!=null&&v==="onScroll"&&et("scroll",l)}switch(s){case"input":We(l),Oe(l,h,!0);break;case"textarea":We(l),vn(l);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(l.onclick=so)}l=u,t.updateQueue=l,l!==null&&(t.flags|=4)}else{v=u.nodeType===9?u:u.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=wn(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=v.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=v.createElement(s,{is:l.is}):(e=v.createElement(s),s==="select"&&(v=e,l.multiple?v.multiple=!0:l.size&&(v.size=l.size))):e=v.createElementNS(e,s),e[In]=t,e[li]=l,od(e,t,!1,!1),t.stateNode=e;e:{switch(v=cn(s,l),s){case"dialog":et("cancel",e),et("close",e),u=l;break;case"iframe":case"object":case"embed":et("load",e),u=l;break;case"video":case"audio":for(u=0;u<ii.length;u++)et(ii[u],e);u=l;break;case"source":et("error",e),u=l;break;case"img":case"image":case"link":et("error",e),et("load",e),u=l;break;case"details":et("toggle",e),u=l;break;case"input":je(e,l),u=de(e,l),et("invalid",e);break;case"option":u=l;break;case"select":e._wrapperState={wasMultiple:!!l.multiple},u=U({},l,{value:void 0}),et("invalid",e);break;case"textarea":Ge(e,l),u=Le(e,l),et("invalid",e);break;default:u=l}_n(s,u),b=u;for(h in b)if(b.hasOwnProperty(h)){var $=b[h];h==="style"?qn(e,$):h==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Nr(e,$)):h==="children"?typeof $=="string"?(s!=="textarea"||$!=="")&&Ut(e,$):typeof $=="number"&&Ut(e,""+$):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(c.hasOwnProperty(h)?$!=null&&h==="onScroll"&&et("scroll",e):$!=null&&C(e,h,$,v))}switch(s){case"input":We(e),Oe(e,l,!1);break;case"textarea":We(e),vn(e);break;case"option":l.value!=null&&e.setAttribute("value",""+ie(l.value));break;case"select":e.multiple=!!l.multiple,h=l.value,h!=null?pe(e,!!l.multiple,h,!1):l.defaultValue!=null&&pe(e,!!l.multiple,l.defaultValue,!0);break;default:typeof u.onClick=="function"&&(e.onclick=so)}switch(s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}}l&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return It(t),null;case 6:if(e&&t.stateNode!=null)ld(e,t,e.memoizedProps,l);else{if(typeof l!="string"&&t.stateNode===null)throw Error(i(166));if(s=Br(pi.current),Br(Pn.current),fo(t)){if(l=t.stateNode,s=t.memoizedProps,l[In]=t,(h=l.nodeValue!==s)&&(e=on,e!==null))switch(e.tag){case 3:ro(l.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ro(l.nodeValue,s,(e.mode&1)!==0)}h&&(t.flags|=4)}else l=(s.nodeType===9?s:s.ownerDocument).createTextNode(l),l[In]=t,t.stateNode=l}return It(t),null;case 13:if(tt(st),l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rt&&an!==null&&(t.mode&1)!==0&&(t.flags&128)===0)du(),ks(),t.flags|=98560,h=!1;else if(h=fo(t),l!==null&&l.dehydrated!==null){if(e===null){if(!h)throw Error(i(318));if(h=t.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(i(317));h[In]=t}else ks(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;It(t),h=!1}else Sn!==null&&(El(Sn),Sn=null),h=!0;if(!h)return t.flags&65536?t:null}return(t.flags&128)!==0?(t.lanes=s,t):(l=l!==null,l!==(e!==null&&e.memoizedState!==null)&&l&&(t.child.flags|=8192,(t.mode&1)!==0&&(e===null||(st.current&1)!==0?mt===0&&(mt=3):Rl())),t.updateQueue!==null&&(t.flags|=4),It(t),null);case 4:return Cs(),yl(e,t),e===null&&oi(t.stateNode.containerInfo),It(t),null;case 10:return Ha(t.type._context),It(t),null;case 17:return Kt(t.type)&&oo(),It(t),null;case 19:if(tt(st),h=t.memoizedState,h===null)return It(t),null;if(l=(t.flags&128)!==0,v=h.rendering,v===null)if(l)vi(h,!1);else{if(mt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(v=vo(e),v!==null){for(t.flags|=128,vi(h,!1),l=v.updateQueue,l!==null&&(t.updateQueue=l,t.flags|=4),t.subtreeFlags=0,l=s,s=t.child;s!==null;)h=s,e=l,h.flags&=14680066,v=h.alternate,v===null?(h.childLanes=0,h.lanes=e,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=v.childLanes,h.lanes=v.lanes,h.child=v.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=v.memoizedProps,h.memoizedState=v.memoizedState,h.updateQueue=v.updateQueue,h.type=v.type,e=v.dependencies,h.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return Ze(st,st.current&1|2),t.child}e=e.sibling}h.tail!==null&&nt()>Ts&&(t.flags|=128,l=!0,vi(h,!1),t.lanes=4194304)}else{if(!l)if(e=vo(v),e!==null){if(t.flags|=128,l=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),vi(h,!0),h.tail===null&&h.tailMode==="hidden"&&!v.alternate&&!rt)return It(t),null}else 2*nt()-h.renderingStartTime>Ts&&s!==1073741824&&(t.flags|=128,l=!0,vi(h,!1),t.lanes=4194304);h.isBackwards?(v.sibling=t.child,t.child=v):(s=h.last,s!==null?s.sibling=v:t.child=v,h.last=v)}return h.tail!==null?(t=h.tail,h.rendering=t,h.tail=t.sibling,h.renderingStartTime=nt(),t.sibling=null,s=st.current,Ze(st,l?s&1|2:s&1),t):(It(t),null);case 22:case 23:return Tl(),l=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(t.flags|=8192),l&&(t.mode&1)!==0?(ln&1073741824)!==0&&(It(t),t.subtreeFlags&6&&(t.flags|=8192)):It(t),null;case 24:return null;case 25:return null}throw Error(i(156,t.tag))}function dh(e,t){switch(Fa(t),t.tag){case 1:return Kt(t.type)&&oo(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Cs(),tt(Gt),tt(At),Za(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ya(t),null;case 13:if(tt(st),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ks()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return tt(st),null;case 4:return Cs(),null;case 10:return Ha(t.type._context),null;case 22:case 23:return Tl(),null;case 24:return null;default:return null}}var No=!1,Pt=!1,fh=typeof WeakSet=="function"?WeakSet:Set,he=null;function Es(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(l){ot(e,t,l)}else s.current=null}function vl(e,t,s){try{s()}catch(l){ot(e,t,l)}}var cd=!1;function ph(e,t){if(Ta=Gi,e=Bc(),ka(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var l=s.getSelection&&s.getSelection();if(l&&l.rangeCount!==0){s=l.anchorNode;var u=l.anchorOffset,h=l.focusNode;l=l.focusOffset;try{s.nodeType,h.nodeType}catch{s=null;break e}var v=0,b=-1,$=-1,F=0,Y=0,q=e,K=null;t:for(;;){for(var ue;q!==s||u!==0&&q.nodeType!==3||(b=v+u),q!==h||l!==0&&q.nodeType!==3||($=v+l),q.nodeType===3&&(v+=q.nodeValue.length),(ue=q.firstChild)!==null;)K=q,q=ue;for(;;){if(q===e)break t;if(K===s&&++F===u&&(b=v),K===h&&++Y===l&&($=v),(ue=q.nextSibling)!==null)break;q=K,K=q.parentNode}q=ue}s=b===-1||$===-1?null:{start:b,end:$}}else s=null}s=s||{start:0,end:0}}else s=null;for(Ra={focusedElem:e,selectionRange:s},Gi=!1,he=t;he!==null;)if(t=he,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,he=e;else for(;he!==null;){t=he;try{var ge=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(ge!==null){var xe=ge.memoizedProps,ct=ge.memoizedState,I=t.stateNode,R=I.getSnapshotBeforeUpdate(t.elementType===t.type?xe:jn(t.type,xe),ct);I.__reactInternalSnapshotBeforeUpdate=R}break;case 3:var O=t.stateNode.containerInfo;O.nodeType===1?O.textContent="":O.nodeType===9&&O.documentElement&&O.removeChild(O.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(te){ot(t,t.return,te)}if(e=t.sibling,e!==null){e.return=t.return,he=e;break}he=t.return}return ge=cd,cd=!1,ge}function wi(e,t,s){var l=t.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var u=l=l.next;do{if((u.tag&e)===e){var h=u.destroy;u.destroy=void 0,h!==void 0&&vl(t,s,h)}u=u.next}while(u!==l)}}function Eo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var l=s.create;s.destroy=l()}s=s.next}while(s!==t)}}function wl(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function ud(e){var t=e.alternate;t!==null&&(e.alternate=null,ud(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[In],delete t[li],delete t[Pa],delete t[Jp],delete t[Yp])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function dd(e){return e.tag===5||e.tag===3||e.tag===4}function fd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||dd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function _l(e,t,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=so));else if(l!==4&&(e=e.child,e!==null))for(_l(e,t,s),e=e.sibling;e!==null;)_l(e,t,s),e=e.sibling}function xl(e,t,s){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(xl(e,t,s),e=e.sibling;e!==null;)xl(e,t,s),e=e.sibling}var St=null,bn=!1;function hr(e,t,s){for(s=s.child;s!==null;)pd(e,t,s),s=s.sibling}function pd(e,t,s){if(rn&&typeof rn.onCommitFiberUnmount=="function")try{rn.onCommitFiberUnmount(Mn,s)}catch{}switch(s.tag){case 5:Pt||Es(s,t);case 6:var l=St,u=bn;St=null,hr(e,t,s),St=l,bn=u,St!==null&&(bn?(e=St,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):St.removeChild(s.stateNode));break;case 18:St!==null&&(bn?(e=St,s=s.stateNode,e.nodeType===8?Ia(e.parentNode,s):e.nodeType===1&&Ia(e,s),Xs(e)):Ia(St,s.stateNode));break;case 4:l=St,u=bn,St=s.stateNode.containerInfo,bn=!0,hr(e,t,s),St=l,bn=u;break;case 0:case 11:case 14:case 15:if(!Pt&&(l=s.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){u=l=l.next;do{var h=u,v=h.destroy;h=h.tag,v!==void 0&&((h&2)!==0||(h&4)!==0)&&vl(s,t,v),u=u.next}while(u!==l)}hr(e,t,s);break;case 1:if(!Pt&&(Es(s,t),l=s.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=s.memoizedProps,l.state=s.memoizedState,l.componentWillUnmount()}catch(b){ot(s,t,b)}hr(e,t,s);break;case 21:hr(e,t,s);break;case 22:s.mode&1?(Pt=(l=Pt)||s.memoizedState!==null,hr(e,t,s),Pt=l):hr(e,t,s);break;default:hr(e,t,s)}}function hd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new fh),t.forEach(function(l){var u=kh.bind(null,e,l);s.has(l)||(s.add(l),l.then(u,u))})}}function Cn(e,t){var s=t.deletions;if(s!==null)for(var l=0;l<s.length;l++){var u=s[l];try{var h=e,v=t,b=v;e:for(;b!==null;){switch(b.tag){case 5:St=b.stateNode,bn=!1;break e;case 3:St=b.stateNode.containerInfo,bn=!0;break e;case 4:St=b.stateNode.containerInfo,bn=!0;break e}b=b.return}if(St===null)throw Error(i(160));pd(h,v,u),St=null,bn=!1;var $=u.alternate;$!==null&&($.return=null),u.return=null}catch(F){ot(u,t,F)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)md(t,e),t=t.sibling}function md(e,t){var s=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Cn(t,e),On(e),l&4){try{wi(3,e,e.return),Eo(3,e)}catch(xe){ot(e,e.return,xe)}try{wi(5,e,e.return)}catch(xe){ot(e,e.return,xe)}}break;case 1:Cn(t,e),On(e),l&512&&s!==null&&Es(s,s.return);break;case 5:if(Cn(t,e),On(e),l&512&&s!==null&&Es(s,s.return),e.flags&32){var u=e.stateNode;try{Ut(u,"")}catch(xe){ot(e,e.return,xe)}}if(l&4&&(u=e.stateNode,u!=null)){var h=e.memoizedProps,v=s!==null?s.memoizedProps:h,b=e.type,$=e.updateQueue;if(e.updateQueue=null,$!==null)try{b==="input"&&h.type==="radio"&&h.name!=null&&ke(u,h),cn(b,v);var F=cn(b,h);for(v=0;v<$.length;v+=2){var Y=$[v],q=$[v+1];Y==="style"?qn(u,q):Y==="dangerouslySetInnerHTML"?Nr(u,q):Y==="children"?Ut(u,q):C(u,Y,q,F)}switch(b){case"input":Ee(u,h);break;case"textarea":zt(u,h);break;case"select":var K=u._wrapperState.wasMultiple;u._wrapperState.wasMultiple=!!h.multiple;var ue=h.value;ue!=null?pe(u,!!h.multiple,ue,!1):K!==!!h.multiple&&(h.defaultValue!=null?pe(u,!!h.multiple,h.defaultValue,!0):pe(u,!!h.multiple,h.multiple?[]:"",!1))}u[li]=h}catch(xe){ot(e,e.return,xe)}}break;case 6:if(Cn(t,e),On(e),l&4){if(e.stateNode===null)throw Error(i(162));u=e.stateNode,h=e.memoizedProps;try{u.nodeValue=h}catch(xe){ot(e,e.return,xe)}}break;case 3:if(Cn(t,e),On(e),l&4&&s!==null&&s.memoizedState.isDehydrated)try{Xs(t.containerInfo)}catch(xe){ot(e,e.return,xe)}break;case 4:Cn(t,e),On(e);break;case 13:Cn(t,e),On(e),u=e.child,u.flags&8192&&(h=u.memoizedState!==null,u.stateNode.isHidden=h,!h||u.alternate!==null&&u.alternate.memoizedState!==null||(jl=nt())),l&4&&hd(e);break;case 22:if(Y=s!==null&&s.memoizedState!==null,e.mode&1?(Pt=(F=Pt)||Y,Cn(t,e),Pt=F):Cn(t,e),On(e),l&8192){if(F=e.memoizedState!==null,(e.stateNode.isHidden=F)&&!Y&&(e.mode&1)!==0)for(he=e,Y=e.child;Y!==null;){for(q=he=Y;he!==null;){switch(K=he,ue=K.child,K.tag){case 0:case 11:case 14:case 15:wi(4,K,K.return);break;case 1:Es(K,K.return);var ge=K.stateNode;if(typeof ge.componentWillUnmount=="function"){l=K,s=K.return;try{t=l,ge.props=t.memoizedProps,ge.state=t.memoizedState,ge.componentWillUnmount()}catch(xe){ot(l,s,xe)}}break;case 5:Es(K,K.return);break;case 22:if(K.memoizedState!==null){vd(q);continue}}ue!==null?(ue.return=K,he=ue):vd(q)}Y=Y.sibling}e:for(Y=null,q=e;;){if(q.tag===5){if(Y===null){Y=q;try{u=q.stateNode,F?(h=u.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(b=q.stateNode,$=q.memoizedProps.style,v=$!=null&&$.hasOwnProperty("display")?$.display:null,b.style.display=Vs("display",v))}catch(xe){ot(e,e.return,xe)}}}else if(q.tag===6){if(Y===null)try{q.stateNode.nodeValue=F?"":q.memoizedProps}catch(xe){ot(e,e.return,xe)}}else if((q.tag!==22&&q.tag!==23||q.memoizedState===null||q===e)&&q.child!==null){q.child.return=q,q=q.child;continue}if(q===e)break e;for(;q.sibling===null;){if(q.return===null||q.return===e)break e;Y===q&&(Y=null),q=q.return}Y===q&&(Y=null),q.sibling.return=q.return,q=q.sibling}}break;case 19:Cn(t,e),On(e),l&4&&hd(e);break;case 21:break;default:Cn(t,e),On(e)}}function On(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(dd(s)){var l=s;break e}s=s.return}throw Error(i(160))}switch(l.tag){case 5:var u=l.stateNode;l.flags&32&&(Ut(u,""),l.flags&=-33);var h=fd(e);xl(e,h,u);break;case 3:case 4:var v=l.stateNode.containerInfo,b=fd(e);_l(e,b,v);break;default:throw Error(i(161))}}catch($){ot(e,e.return,$)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function hh(e,t,s){he=e,gd(e)}function gd(e,t,s){for(var l=(e.mode&1)!==0;he!==null;){var u=he,h=u.child;if(u.tag===22&&l){var v=u.memoizedState!==null||No;if(!v){var b=u.alternate,$=b!==null&&b.memoizedState!==null||Pt;b=No;var F=Pt;if(No=v,(Pt=$)&&!F)for(he=u;he!==null;)v=he,$=v.child,v.tag===22&&v.memoizedState!==null?wd(u):$!==null?($.return=v,he=$):wd(u);for(;h!==null;)he=h,gd(h),h=h.sibling;he=u,No=b,Pt=F}yd(e)}else(u.subtreeFlags&8772)!==0&&h!==null?(h.return=u,he=h):yd(e)}}function yd(e){for(;he!==null;){var t=he;if((t.flags&8772)!==0){var s=t.alternate;try{if((t.flags&8772)!==0)switch(t.tag){case 0:case 11:case 15:Pt||Eo(5,t);break;case 1:var l=t.stateNode;if(t.flags&4&&!Pt)if(s===null)l.componentDidMount();else{var u=t.elementType===t.type?s.memoizedProps:jn(t.type,s.memoizedProps);l.componentDidUpdate(u,s.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var h=t.updateQueue;h!==null&&vu(t,h,l);break;case 3:var v=t.updateQueue;if(v!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}vu(t,v,s)}break;case 5:var b=t.stateNode;if(s===null&&t.flags&4){s=b;var $=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&s.focus();break;case"img":$.src&&(s.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var F=t.alternate;if(F!==null){var Y=F.memoizedState;if(Y!==null){var q=Y.dehydrated;q!==null&&Xs(q)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Pt||t.flags&512&&wl(t)}catch(K){ot(t,t.return,K)}}if(t===e){he=null;break}if(s=t.sibling,s!==null){s.return=t.return,he=s;break}he=t.return}}function vd(e){for(;he!==null;){var t=he;if(t===e){he=null;break}var s=t.sibling;if(s!==null){s.return=t.return,he=s;break}he=t.return}}function wd(e){for(;he!==null;){var t=he;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Eo(4,t)}catch($){ot(t,s,$)}break;case 1:var l=t.stateNode;if(typeof l.componentDidMount=="function"){var u=t.return;try{l.componentDidMount()}catch($){ot(t,u,$)}}var h=t.return;try{wl(t)}catch($){ot(t,h,$)}break;case 5:var v=t.return;try{wl(t)}catch($){ot(t,v,$)}}}catch($){ot(t,t.return,$)}if(t===e){he=null;break}var b=t.sibling;if(b!==null){b.return=t.return,he=b;break}he=t.return}}var mh=Math.ceil,$o=j.ReactCurrentDispatcher,kl=j.ReactCurrentOwner,mn=j.ReactCurrentBatchConfig,Ve=0,vt=null,dt=null,jt=0,ln=0,$s=cr(0),mt=0,_i=null,Wr=0,To=0,Sl=0,xi=null,Jt=null,jl=0,Ts=1/0,Xn=null,Ro=!1,bl=null,mr=null,Ao=!1,gr=null,Mo=0,ki=0,Cl=null,Io=-1,Po=0;function Dt(){return(Ve&6)!==0?nt():Io!==-1?Io:Io=nt()}function yr(e){return(e.mode&1)===0?1:(Ve&2)!==0&&jt!==0?jt&-jt:Zp.transition!==null?(Po===0&&(Po=Gs()),Po):(e=G,e!==0||(e=window.event,e=e===void 0?16:xc(e.type)),e)}function Nn(e,t,s,l){if(50<ki)throw ki=0,Cl=null,Error(i(185));sr(e,s,l),((Ve&2)===0||e!==vt)&&(e===vt&&((Ve&2)===0&&(To|=s),mt===4&&vr(e,jt)),Yt(e,l),s===1&&Ve===0&&(t.mode&1)===0&&(Ts=nt()+500,lo&&dr()))}function Yt(e,t){var s=e.callbackNode;Wi(e,t);var l=Pr(e,e===vt?jt:0);if(l===0)s!==null&&Ar(s),e.callbackNode=null,e.callbackPriority=0;else if(t=l&-l,e.callbackPriority!==t){if(s!=null&&Ar(s),t===1)e.tag===0?Xp(xd.bind(null,e)):ou(xd.bind(null,e)),Kp(function(){(Ve&6)===0&&dr()}),s=null;else{switch(Ie(l)){case 1:s=os;break;case 4:s=zi;break;case 16:s=as;break;case 536870912:s=nr;break;default:s=as}s=$d(s,_d.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function _d(e,t){if(Io=-1,Po=0,(Ve&6)!==0)throw Error(i(327));var s=e.callbackNode;if(Rs()&&e.callbackNode!==s)return null;var l=Pr(e,e===vt?jt:0);if(l===0)return null;if((l&30)!==0||(l&e.expiredLanes)!==0||t)t=Lo(e,l);else{t=l;var u=Ve;Ve|=2;var h=Sd();(vt!==e||jt!==t)&&(Xn=null,Ts=nt()+500,Hr(e,t));do try{vh();break}catch(b){kd(e,b)}while(!0);Va(),$o.current=h,Ve=u,dt!==null?t=0:(vt=null,jt=0,t=mt)}if(t!==0){if(t===2&&(u=ls(e),u!==0&&(l=u,t=Nl(e,u))),t===1)throw s=_i,Hr(e,0),vr(e,l),Yt(e,nt()),s;if(t===6)vr(e,l);else{if(u=e.current.alternate,(l&30)===0&&!gh(u)&&(t=Lo(e,l),t===2&&(h=ls(e),h!==0&&(l=h,t=Nl(e,h))),t===1))throw s=_i,Hr(e,0),vr(e,l),Yt(e,nt()),s;switch(e.finishedWork=u,e.finishedLanes=l,t){case 0:case 1:throw Error(i(345));case 2:Gr(e,Jt,Xn);break;case 3:if(vr(e,l),(l&130023424)===l&&(t=jl+500-nt(),10<t)){if(Pr(e,0)!==0)break;if(u=e.suspendedLanes,(u&l)!==l){Dt(),e.pingedLanes|=e.suspendedLanes&u;break}e.timeoutHandle=Ma(Gr.bind(null,e,Jt,Xn),t);break}Gr(e,Jt,Xn);break;case 4:if(vr(e,l),(l&4194240)===l)break;for(t=e.eventTimes,u=-1;0<l;){var v=31-Ht(l);h=1<<v,v=t[v],v>u&&(u=v),l&=~h}if(l=u,l=nt()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*mh(l/1960))-l,10<l){e.timeoutHandle=Ma(Gr.bind(null,e,Jt,Xn),l);break}Gr(e,Jt,Xn);break;case 5:Gr(e,Jt,Xn);break;default:throw Error(i(329))}}}return Yt(e,nt()),e.callbackNode===s?_d.bind(null,e):null}function Nl(e,t){var s=xi;return e.current.memoizedState.isDehydrated&&(Hr(e,t).flags|=256),e=Lo(e,t),e!==2&&(t=Jt,Jt=s,t!==null&&El(t)),e}function El(e){Jt===null?Jt=e:Jt.push.apply(Jt,e)}function gh(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var l=0;l<s.length;l++){var u=s[l],h=u.getSnapshot;u=u.value;try{if(!kn(h(),u))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function vr(e,t){for(t&=~Sl,t&=~To,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Ht(t),l=1<<s;e[s]=-1,t&=~l}}function xd(e){if((Ve&6)!==0)throw Error(i(327));Rs();var t=Pr(e,0);if((t&1)===0)return Yt(e,nt()),null;var s=Lo(e,t);if(e.tag!==0&&s===2){var l=ls(e);l!==0&&(t=l,s=Nl(e,l))}if(s===1)throw s=_i,Hr(e,0),vr(e,t),Yt(e,nt()),s;if(s===6)throw Error(i(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Gr(e,Jt,Xn),Yt(e,nt()),null}function $l(e,t){var s=Ve;Ve|=1;try{return e(t)}finally{Ve=s,Ve===0&&(Ts=nt()+500,lo&&dr())}}function Vr(e){gr!==null&&gr.tag===0&&(Ve&6)===0&&Rs();var t=Ve;Ve|=1;var s=mn.transition,l=G;try{if(mn.transition=null,G=1,e)return e()}finally{G=l,mn.transition=s,Ve=t,(Ve&6)===0&&dr()}}function Tl(){ln=$s.current,tt($s)}function Hr(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,Gp(s)),dt!==null)for(s=dt.return;s!==null;){var l=s;switch(Fa(l),l.tag){case 1:l=l.type.childContextTypes,l!=null&&oo();break;case 3:Cs(),tt(Gt),tt(At),Za();break;case 5:Ya(l);break;case 4:Cs();break;case 13:tt(st);break;case 19:tt(st);break;case 10:Ha(l.type._context);break;case 22:case 23:Tl()}s=s.return}if(vt=e,dt=e=wr(e.current,null),jt=ln=t,mt=0,_i=null,Sl=To=Wr=0,Jt=xi=null,Dr!==null){for(t=0;t<Dr.length;t++)if(s=Dr[t],l=s.interleaved,l!==null){s.interleaved=null;var u=l.next,h=s.pending;if(h!==null){var v=h.next;h.next=u,l.next=v}s.pending=l}Dr=null}return e}function kd(e,t){do{var s=dt;try{if(Va(),wo.current=So,_o){for(var l=it.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}_o=!1}if(Ur=0,yt=ht=it=null,hi=!1,mi=0,kl.current=null,s===null||s.return===null){mt=1,_i=t,dt=null;break}e:{var h=e,v=s.return,b=s,$=t;if(t=jt,b.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var F=$,Y=b,q=Y.tag;if((Y.mode&1)===0&&(q===0||q===11||q===15)){var K=Y.alternate;K?(Y.updateQueue=K.updateQueue,Y.memoizedState=K.memoizedState,Y.lanes=K.lanes):(Y.updateQueue=null,Y.memoizedState=null)}var ue=Ku(v);if(ue!==null){ue.flags&=-257,Qu(ue,v,b,h,t),ue.mode&1&&Gu(h,F,t),t=ue,$=F;var ge=t.updateQueue;if(ge===null){var xe=new Set;xe.add($),t.updateQueue=xe}else ge.add($);break e}else{if((t&1)===0){Gu(h,F,t),Rl();break e}$=Error(i(426))}}else if(rt&&b.mode&1){var ct=Ku(v);if(ct!==null){(ct.flags&65536)===0&&(ct.flags|=256),Qu(ct,v,b,h,t),Ua(Ns($,b));break e}}h=$=Ns($,b),mt!==4&&(mt=2),xi===null?xi=[h]:xi.push(h),h=v;do{switch(h.tag){case 3:h.flags|=65536,t&=-t,h.lanes|=t;var I=Vu(h,$,t);yu(h,I);break e;case 1:b=$;var R=h.type,O=h.stateNode;if((h.flags&128)===0&&(typeof R.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(mr===null||!mr.has(O)))){h.flags|=65536,t&=-t,h.lanes|=t;var te=Hu(h,b,t);yu(h,te);break e}}h=h.return}while(h!==null)}bd(s)}catch(Se){t=Se,dt===s&&s!==null&&(dt=s=s.return);continue}break}while(!0)}function Sd(){var e=$o.current;return $o.current=So,e===null?So:e}function Rl(){(mt===0||mt===3||mt===2)&&(mt=4),vt===null||(Wr&268435455)===0&&(To&268435455)===0||vr(vt,jt)}function Lo(e,t){var s=Ve;Ve|=2;var l=Sd();(vt!==e||jt!==t)&&(Xn=null,Hr(e,t));do try{yh();break}catch(u){kd(e,u)}while(!0);if(Va(),Ve=s,$o.current=l,dt!==null)throw Error(i(261));return vt=null,jt=0,mt}function yh(){for(;dt!==null;)jd(dt)}function vh(){for(;dt!==null&&!is();)jd(dt)}function jd(e){var t=Ed(e.alternate,e,ln);e.memoizedProps=e.pendingProps,t===null?bd(e):dt=t,kl.current=null}function bd(e){var t=e;do{var s=t.alternate;if(e=t.return,(t.flags&32768)===0){if(s=uh(s,t,ln),s!==null){dt=s;return}}else{if(s=dh(s,t),s!==null){s.flags&=32767,dt=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{mt=6,dt=null;return}}if(t=t.sibling,t!==null){dt=t;return}dt=t=e}while(t!==null);mt===0&&(mt=5)}function Gr(e,t,s){var l=G,u=mn.transition;try{mn.transition=null,G=1,wh(e,t,s,l)}finally{mn.transition=u,G=l}return null}function wh(e,t,s,l){do Rs();while(gr!==null);if((Ve&6)!==0)throw Error(i(327));s=e.finishedWork;var u=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(i(177));e.callbackNode=null,e.callbackPriority=0;var h=s.lanes|s.childLanes;if(Vi(e,h),e===vt&&(dt=vt=null,jt=0),(s.subtreeFlags&2064)===0&&(s.flags&2064)===0||Ao||(Ao=!0,$d(as,function(){return Rs(),null})),h=(s.flags&15990)!==0,(s.subtreeFlags&15990)!==0||h){h=mn.transition,mn.transition=null;var v=G;G=1;var b=Ve;Ve|=4,kl.current=null,ph(e,s),md(s,e),Fp(Ra),Gi=!!Ta,Ra=Ta=null,e.current=s,hh(s),la(),Ve=b,G=v,mn.transition=h}else e.current=s;if(Ao&&(Ao=!1,gr=e,Mo=u),h=e.pendingLanes,h===0&&(mr=null),ua(s.stateNode),Yt(e,nt()),t!==null)for(l=e.onRecoverableError,s=0;s<t.length;s++)u=t[s],l(u.value,{componentStack:u.stack,digest:u.digest});if(Ro)throw Ro=!1,e=bl,bl=null,e;return(Mo&1)!==0&&e.tag!==0&&Rs(),h=e.pendingLanes,(h&1)!==0?e===Cl?ki++:(ki=0,Cl=e):ki=0,dr(),null}function Rs(){if(gr!==null){var e=Ie(Mo),t=mn.transition,s=G;try{if(mn.transition=null,G=16>e?16:e,gr===null)var l=!1;else{if(e=gr,gr=null,Mo=0,(Ve&6)!==0)throw Error(i(331));var u=Ve;for(Ve|=4,he=e.current;he!==null;){var h=he,v=h.child;if((he.flags&16)!==0){var b=h.deletions;if(b!==null){for(var $=0;$<b.length;$++){var F=b[$];for(he=F;he!==null;){var Y=he;switch(Y.tag){case 0:case 11:case 15:wi(8,Y,h)}var q=Y.child;if(q!==null)q.return=Y,he=q;else for(;he!==null;){Y=he;var K=Y.sibling,ue=Y.return;if(ud(Y),Y===F){he=null;break}if(K!==null){K.return=ue,he=K;break}he=ue}}}var ge=h.alternate;if(ge!==null){var xe=ge.child;if(xe!==null){ge.child=null;do{var ct=xe.sibling;xe.sibling=null,xe=ct}while(xe!==null)}}he=h}}if((h.subtreeFlags&2064)!==0&&v!==null)v.return=h,he=v;else e:for(;he!==null;){if(h=he,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:wi(9,h,h.return)}var I=h.sibling;if(I!==null){I.return=h.return,he=I;break e}he=h.return}}var R=e.current;for(he=R;he!==null;){v=he;var O=v.child;if((v.subtreeFlags&2064)!==0&&O!==null)O.return=v,he=O;else e:for(v=R;he!==null;){if(b=he,(b.flags&2048)!==0)try{switch(b.tag){case 0:case 11:case 15:Eo(9,b)}}catch(Se){ot(b,b.return,Se)}if(b===v){he=null;break e}var te=b.sibling;if(te!==null){te.return=b.return,he=te;break e}he=b.return}}if(Ve=u,dr(),rn&&typeof rn.onPostCommitFiberRoot=="function")try{rn.onPostCommitFiberRoot(Mn,e)}catch{}l=!0}return l}finally{G=s,mn.transition=t}}return!1}function Cd(e,t,s){t=Ns(s,t),t=Vu(e,t,1),e=pr(e,t,1),t=Dt(),e!==null&&(sr(e,1,t),Yt(e,t))}function ot(e,t,s){if(e.tag===3)Cd(e,e,s);else for(;t!==null;){if(t.tag===3){Cd(t,e,s);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(mr===null||!mr.has(l))){e=Ns(s,e),e=Hu(t,e,1),t=pr(t,e,1),e=Dt(),t!==null&&(sr(t,1,e),Yt(t,e));break}}t=t.return}}function _h(e,t,s){var l=e.pingCache;l!==null&&l.delete(t),t=Dt(),e.pingedLanes|=e.suspendedLanes&s,vt===e&&(jt&s)===s&&(mt===4||mt===3&&(jt&130023424)===jt&&500>nt()-jl?Hr(e,0):Sl|=s),Yt(e,t)}function Nd(e,t){t===0&&((e.mode&1)===0?t=1:(t=Ir,Ir<<=1,(Ir&130023424)===0&&(Ir=4194304)));var s=Dt();e=Qn(e,t),e!==null&&(sr(e,t,s),Yt(e,s))}function xh(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Nd(e,s)}function kh(e,t){var s=0;switch(e.tag){case 13:var l=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(i(314))}l!==null&&l.delete(t),Nd(e,s)}var Ed;Ed=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||Gt.current)Qt=!0;else{if((e.lanes&s)===0&&(t.flags&128)===0)return Qt=!1,ch(e,t,s);Qt=(e.flags&131072)!==0}else Qt=!1,rt&&(t.flags&1048576)!==0&&au(t,uo,t.index);switch(t.lanes=0,t.tag){case 2:var l=t.type;Co(e,t),e=t.pendingProps;var u=ws(t,At.current);bs(t,s),u=tl(null,t,l,e,u,s);var h=nl();return t.flags|=1,typeof u=="object"&&u!==null&&typeof u.render=="function"&&u.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Kt(l)?(h=!0,ao(t)):h=!1,t.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,Qa(t),u.updater=jo,t.stateNode=u,u._reactInternals=t,ll(t,l,e,s),t=fl(null,t,l,!0,h,s)):(t.tag=0,rt&&h&&za(t),Ft(null,t,u,s),t=t.child),t;case 16:l=t.elementType;e:{switch(Co(e,t),e=t.pendingProps,u=l._init,l=u(l._payload),t.type=l,u=t.tag=jh(l),e=jn(l,e),u){case 0:t=dl(null,t,l,e,s);break e;case 1:t=ed(null,t,l,e,s);break e;case 11:t=Ju(null,t,l,e,s);break e;case 14:t=Yu(null,t,l,jn(l.type,e),s);break e}throw Error(i(306,l,""))}return t;case 0:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:jn(l,u),dl(e,t,l,u,s);case 1:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:jn(l,u),ed(e,t,l,u,s);case 3:e:{if(td(t),e===null)throw Error(i(387));l=t.pendingProps,h=t.memoizedState,u=h.element,gu(e,t),yo(t,l,null,s);var v=t.memoizedState;if(l=v.element,h.isDehydrated)if(h={element:l,isDehydrated:!1,cache:v.cache,pendingSuspenseBoundaries:v.pendingSuspenseBoundaries,transitions:v.transitions},t.updateQueue.baseState=h,t.memoizedState=h,t.flags&256){u=Ns(Error(i(423)),t),t=nd(e,t,l,s,u);break e}else if(l!==u){u=Ns(Error(i(424)),t),t=nd(e,t,l,s,u);break e}else for(an=lr(t.stateNode.containerInfo.firstChild),on=t,rt=!0,Sn=null,s=hu(t,null,l,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ks(),l===u){t=Yn(e,t,s);break e}Ft(e,t,l,s)}t=t.child}return t;case 5:return wu(t),e===null&&Ba(t),l=t.type,u=t.pendingProps,h=e!==null?e.memoizedProps:null,v=u.children,Aa(l,u)?v=null:h!==null&&Aa(l,h)&&(t.flags|=32),qu(e,t),Ft(e,t,v,s),t.child;case 6:return e===null&&Ba(t),null;case 13:return rd(e,t,s);case 4:return Ja(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=Ss(t,null,l,s):Ft(e,t,l,s),t.child;case 11:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:jn(l,u),Ju(e,t,l,u,s);case 7:return Ft(e,t,t.pendingProps,s),t.child;case 8:return Ft(e,t,t.pendingProps.children,s),t.child;case 12:return Ft(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(l=t.type._context,u=t.pendingProps,h=t.memoizedProps,v=u.value,Ze(ho,l._currentValue),l._currentValue=v,h!==null)if(kn(h.value,v)){if(h.children===u.children&&!Gt.current){t=Yn(e,t,s);break e}}else for(h=t.child,h!==null&&(h.return=t);h!==null;){var b=h.dependencies;if(b!==null){v=h.child;for(var $=b.firstContext;$!==null;){if($.context===l){if(h.tag===1){$=Jn(-1,s&-s),$.tag=2;var F=h.updateQueue;if(F!==null){F=F.shared;var Y=F.pending;Y===null?$.next=$:($.next=Y.next,Y.next=$),F.pending=$}}h.lanes|=s,$=h.alternate,$!==null&&($.lanes|=s),Ga(h.return,s,t),b.lanes|=s;break}$=$.next}}else if(h.tag===10)v=h.type===t.type?null:h.child;else if(h.tag===18){if(v=h.return,v===null)throw Error(i(341));v.lanes|=s,b=v.alternate,b!==null&&(b.lanes|=s),Ga(v,s,t),v=h.sibling}else v=h.child;if(v!==null)v.return=h;else for(v=h;v!==null;){if(v===t){v=null;break}if(h=v.sibling,h!==null){h.return=v.return,v=h;break}v=v.return}h=v}Ft(e,t,u.children,s),t=t.child}return t;case 9:return u=t.type,l=t.pendingProps.children,bs(t,s),u=pn(u),l=l(u),t.flags|=1,Ft(e,t,l,s),t.child;case 14:return l=t.type,u=jn(l,t.pendingProps),u=jn(l.type,u),Yu(e,t,l,u,s);case 15:return Xu(e,t,t.type,t.pendingProps,s);case 17:return l=t.type,u=t.pendingProps,u=t.elementType===l?u:jn(l,u),Co(e,t),t.tag=1,Kt(l)?(e=!0,ao(t)):e=!1,bs(t,s),Uu(t,l,u),ll(t,l,u,s),fl(null,t,l,!0,e,s);case 19:return id(e,t,s);case 22:return Zu(e,t,s)}throw Error(i(156,t.tag))};function $d(e,t){return gt(e,t)}function Sh(e,t,s,l){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gn(e,t,s,l){return new Sh(e,t,s,l)}function Al(e){return e=e.prototype,!(!e||!e.isReactComponent)}function jh(e){if(typeof e=="function")return Al(e)?1:0;if(e!=null){if(e=e.$$typeof,e===le)return 11;if(e===se)return 14}return 2}function wr(e,t){var s=e.alternate;return s===null?(s=gn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function Oo(e,t,s,l,u,h){var v=2;if(l=e,typeof e=="function")Al(e)&&(v=1);else if(typeof e=="string")v=5;else e:switch(e){case V:return Kr(s.children,u,h,t);case Q:v=8,u|=8;break;case me:return e=gn(12,s,t,u|2),e.elementType=me,e.lanes=h,e;case H:return e=gn(13,s,t,u),e.elementType=H,e.lanes=h,e;case ae:return e=gn(19,s,t,u),e.elementType=ae,e.lanes=h,e;case we:return zo(s,u,h,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case oe:v=10;break e;case X:v=9;break e;case le:v=11;break e;case se:v=14;break e;case ye:v=16,l=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return t=gn(v,s,t,u),t.elementType=e,t.type=l,t.lanes=h,t}function Kr(e,t,s,l){return e=gn(7,e,l,t),e.lanes=s,e}function zo(e,t,s,l){return e=gn(22,e,l,t),e.elementType=we,e.lanes=s,e.stateNode={isHidden:!1},e}function Ml(e,t,s){return e=gn(6,e,null,t),e.lanes=s,e}function Il(e,t,s){return t=gn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bh(e,t,s,l,u){this.tag=t,this.containerInfo=e,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=l,this.onRecoverableError=u,this.mutableSourceEagerHydrationData=null}function Pl(e,t,s,l,u,h,v,b,$){return e=new bh(e,t,s,b,$),t===1?(t=1,h===!0&&(t|=8)):t=0,h=gn(3,null,null,t),e.current=h,h.stateNode=e,h.memoizedState={element:l,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qa(h),e}function Ch(e,t,s){var l=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:l==null?null:""+l,children:e,containerInfo:t,implementation:s}}function Td(e){if(!e)return ur;e=e._reactInternals;e:{if(ft(e)!==e||e.tag!==1)throw Error(i(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Kt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(i(171))}if(e.tag===1){var s=e.type;if(Kt(s))return su(e,s,t)}return t}function Rd(e,t,s,l,u,h,v,b,$){return e=Pl(s,l,!0,e,u,h,v,b,$),e.context=Td(null),s=e.current,l=Dt(),u=yr(s),h=Jn(l,u),h.callback=t??null,pr(s,h,u),e.current.lanes=u,sr(e,u,l),Yt(e,l),e}function Fo(e,t,s,l){var u=t.current,h=Dt(),v=yr(u);return s=Td(s),t.context===null?t.context=s:t.pendingContext=s,t=Jn(h,v),t.payload={element:e},l=l===void 0?null:l,l!==null&&(t.callback=l),e=pr(u,t,v),e!==null&&(Nn(e,u,v,h),go(e,u,v)),v}function Do(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ad(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Ll(e,t){Ad(e,t),(e=e.alternate)&&Ad(e,t)}function Nh(){return null}var Md=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ol(e){this._internalRoot=e}Bo.prototype.render=Ol.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));Fo(e,t,null,null)},Bo.prototype.unmount=Ol.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vr(function(){Fo(null,e,null,null)}),t[Vn]=null}};function Bo(e){this._internalRoot=e}Bo.prototype.unstable_scheduleHydration=function(e){if(e){var t=Un();e={blockedOn:null,target:e,priority:t};for(var s=0;s<ir.length&&t!==0&&t<ir[s].priority;s++);ir.splice(s,0,e),s===0&&wc(e)}};function zl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Uo(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Id(){}function Eh(e,t,s,l,u){if(u){if(typeof l=="function"){var h=l;l=function(){var F=Do(v);h.call(F)}}var v=Rd(t,l,e,0,null,!1,!1,"",Id);return e._reactRootContainer=v,e[Vn]=v.current,oi(e.nodeType===8?e.parentNode:e),Vr(),v}for(;u=e.lastChild;)e.removeChild(u);if(typeof l=="function"){var b=l;l=function(){var F=Do($);b.call(F)}}var $=Pl(e,0,!1,null,null,!1,!1,"",Id);return e._reactRootContainer=$,e[Vn]=$.current,oi(e.nodeType===8?e.parentNode:e),Vr(function(){Fo(t,$,s,l)}),$}function Wo(e,t,s,l,u){var h=s._reactRootContainer;if(h){var v=h;if(typeof u=="function"){var b=u;u=function(){var $=Do(v);b.call($)}}Fo(t,v,e,u)}else v=Eh(s,t,e,u,l);return Do(v)}De=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=rr(t.pendingLanes);s!==0&&(M(t,s|1),Yt(t,nt()),(Ve&6)===0&&(Ts=nt()+500,dr()))}break;case 13:Vr(function(){var l=Qn(e,1);if(l!==null){var u=Dt();Nn(l,e,1,u)}}),Ll(e,1)}},Pe=function(e){if(e.tag===13){var t=Qn(e,134217728);if(t!==null){var s=Dt();Nn(t,e,134217728,s)}Ll(e,134217728)}},xt=function(e){if(e.tag===13){var t=yr(e),s=Qn(e,t);if(s!==null){var l=Dt();Nn(s,e,t,l)}Ll(e,t)}},Un=function(){return G},Wn=function(e,t){var s=G;try{return G=e,t()}finally{G=s}},Zr=function(e,t,s){switch(t){case"input":if(Ee(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var l=s[t];if(l!==e&&l.form===e.form){var u=io(l);if(!u)throw Error(i(90));ee(l),Ee(l,u)}}}break;case"textarea":zt(e,s);break;case"select":t=s.value,t!=null&&pe(e,!!s.multiple,t,!1)}},Fe=$l,Wt=Vr;var $h={usingClientEntryPoint:!1,Events:[ci,ys,io,Pi,An,$l]},Si={findFiberByHostInstance:Lr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Th={bundleType:Si.bundleType,version:Si.version,rendererPackageName:Si.rendererPackageName,rendererConfig:Si.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ut(e),e===null?null:e.stateNode},findFiberByHostInstance:Si.findFiberByHostInstance||Nh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vo.isDisabled&&Vo.supportsFiber)try{Mn=Vo.inject(Th),rn=Vo}catch{}}return Xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=$h,Xt.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zl(t))throw Error(i(200));return Ch(e,t,null,s)},Xt.createRoot=function(e,t){if(!zl(e))throw Error(i(299));var s=!1,l="",u=Md;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onRecoverableError!==void 0&&(u=t.onRecoverableError)),t=Pl(e,1,!1,null,null,s,!1,l,u),e[Vn]=t.current,oi(e.nodeType===8?e.parentNode:e),new Ol(t)},Xt.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=ut(t),e=e===null?null:e.stateNode,e},Xt.flushSync=function(e){return Vr(e)},Xt.hydrate=function(e,t,s){if(!Uo(t))throw Error(i(200));return Wo(null,e,t,!0,s)},Xt.hydrateRoot=function(e,t,s){if(!zl(e))throw Error(i(405));var l=s!=null&&s.hydratedSources||null,u=!1,h="",v=Md;if(s!=null&&(s.unstable_strictMode===!0&&(u=!0),s.identifierPrefix!==void 0&&(h=s.identifierPrefix),s.onRecoverableError!==void 0&&(v=s.onRecoverableError)),t=Rd(t,null,e,1,s??null,u,!1,h,v),e[Vn]=t.current,oi(e),l)for(e=0;e<l.length;e++)s=l[e],u=s._getVersion,u=u(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,u]:t.mutableSourceEagerHydrationData.push(s,u);return new Bo(t)},Xt.render=function(e,t,s){if(!Uo(t))throw Error(i(200));return Wo(null,e,t,!1,s)},Xt.unmountComponentAtNode=function(e){if(!Uo(e))throw Error(i(40));return e._reactRootContainer?(Vr(function(){Wo(null,null,e,!1,function(){e._reactRootContainer=null,e[Vn]=null})}),!0):!1},Xt.unstable_batchedUpdates=$l,Xt.unstable_renderSubtreeIntoContainer=function(e,t,s,l){if(!Uo(s))throw Error(i(200));if(e==null||e._reactInternals===void 0)throw Error(i(38));return Wo(e,t,s,!1,l)},Xt.version="18.3.1-next-f1338f8080-20240426",Xt}var Ud;function Sf(){if(Ud)return Bl.exports;Ud=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(r){console.error(r)}}return n(),Bl.exports=Fh(),Bl.exports}var Wd;function Dh(){if(Wd)return Ho;Wd=1;var n=Sf();return Ho.createRoot=n.createRoot,Ho.hydrateRoot=n.hydrateRoot,Ho}var Bh=Dh();const Uh=kf(Bh),jf=[{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"]}];jf.map(n=>({id:n.id,label:n.label}));function Wh(n){return`theme-${String(n||"").trim()||"dark"}`}function Vd(n){try{const r=document.documentElement,i=Array.from(r.classList).filter(a=>a.startsWith("theme-"));for(const a of i)r.classList.remove(a);r.classList.add(Wh(n))}catch{}}const tc=[{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}],nc=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function Vh(n){const r=String(n).trim();return tc.find(i=>i.id===r)||tc[1]}function Hh(n){const r=String(n).trim();return nc.find(i=>i.id===r)||nc[1]}function Hd(n){try{const r=document.documentElement,i=Vh(n.font_scale||"md"),a=Hh(n.header_density||"standard");r.style.setProperty("--font-scale",String(i.scale)),r.style.setProperty("--header-density",String(a.density))}catch{}}var bf=Sf();function As(...n){return n.filter(Boolean).join(" ")}function Cr({value:n,options:r,placeholder:i="Select…",disabled:a=!1,loading:c=!1,searchable:d=!0,searchPlaceholder:f="Search…",allowCustom:m=!1,clearable:p=!1,minPopoverWidth:g=240,variant:y="panel",className:_,triggerClassName:w,ariaLabel:k,id:T,includeValueOption:N=!1,onOpen:A,customOptionLabel:S,validateCustomValue:P,onChange:C,renderOption:j,renderValue:L}){const W=x.useRef(null),V=x.useRef(null),Q=x.useRef(null),me=x.useRef(A),oe=x.useId(),X=T||`af-select-${oe.replace(/[^a-zA-Z0-9_-]/g,"")}`,le=`${X}-listbox`,[H,ae]=x.useState(!1),[se,ye]=x.useState(""),[we,J]=x.useState(0),[ne,U]=x.useState("bottom"),[E,D]=x.useState({left:0,top:0,width:0});x.useEffect(()=>{me.current=A},[A]);const z=x.useMemo(()=>{if(!N)return r;const B=String(n??"").trim();return!B||r.some(pe=>pe.value===B)?r:[...r,{value:B,label:B}]},[N,r,n]),re=x.useMemo(()=>{const B=String(n??"");return z.find(pe=>pe.value===B)||null},[z,n]),ce=x.useMemo(()=>(re==null?void 0:re.label)||String(n||"").trim()||"",[re,n]),ve=x.useMemo(()=>{const B=se.trim().toLowerCase();return B?z.filter(pe=>pe.label.toLowerCase().includes(B)||pe.value.toLowerCase().includes(B)):z},[z,se]),_e=x.useMemo(()=>{if(!m)return null;const B=se.trim();if(!B||z.some(Ge=>Ge.value===B))return null;const Le=(P==null?void 0:P(B,{options:z}))||"";return{value:B,label:S?S(B):`Use "${B}"`,disabled:!!Le,reason:Le}},[m,S,z,se,P]),ie=x.useMemo(()=>{const B=_e?[_e,...ve]:ve;if(B.length>0)return B;const pe=String(n??"").trim();return c&&pe?[{value:pe,label:ce||pe}]:B},[_e,ve,c,ce,n]),$e=x.useCallback(()=>{const B=W.current;if(!B)return;const pe=B.getBoundingClientRect(),Le=Math.max(pe.width,g),Ge=Math.max(8,Math.min(pe.left,window.innerWidth-Le-8)),zt=window.innerHeight-pe.bottom,vn=pe.top,wn=zt>=220||zt>=vn?"bottom":"top";U(wn);const $n=wn==="bottom"?pe.bottom+6:pe.top-6;D({left:Ge,top:$n,width:Le})},[g]),Ue=x.useCallback(()=>{ae(!1),ye("")},[]);x.useEffect(()=>{var B;H&&((B=me.current)==null||B.call(me))},[H]),x.useEffect(()=>{if(!H)return;$e();const B=()=>$e();return window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[H,$e]),x.useEffect(()=>{if(!H)return;const B=pe=>{var Ge,zt;const Le=pe.target;Le&&((Ge=W.current)!=null&&Ge.contains(Le)||(zt=V.current)!=null&&zt.contains(Le)||Ue())};return document.addEventListener("mousedown",B,!0),()=>document.removeEventListener("mousedown",B,!0)},[H,Ue]),x.useEffect(()=>{if(!H)return;const B=Math.max(0,ie.findIndex(pe=>pe.value===n));J(B===-1?0:B),d&&setTimeout(()=>{var pe;return(pe=Q.current)==null?void 0:pe.focus()},0)},[H,d,n,ie]);const We=B=>{var Le;const pe=ie.find(Ge=>Ge.value===B);pe!=null&&pe.disabled||(C(B),Ue(),(Le=W.current)==null||Le.focus())},ee=B=>{var pe,Le;if(B.key==="Escape")return B.preventDefault(),Ue(),(pe=W.current)==null||pe.focus(),!0;if(B.key==="Tab")return Ue(),(Le=W.current)==null||Le.focus(),!1;if(B.key==="ArrowDown")return B.preventDefault(),J(Ge=>Math.min(Ge+1,Math.max(0,ie.length-1))),!0;if(B.key==="ArrowUp")return B.preventDefault(),J(Ge=>Math.max(Ge-1,0)),!0;if(B.key==="Home")return B.preventDefault(),J(0),!0;if(B.key==="End")return B.preventDefault(),J(Math.max(0,ie.length-1)),!0;if(B.key==="Enter"){B.preventDefault();const Ge=ie[we];return Ge&&We(Ge.value),!0}return!1},Z=B=>{if(!a){if(H){if(ee(B))return;if(B.key===" "&&!d){B.preventDefault();const pe=ie[we];pe&&We(pe.value)}return}(B.key==="Enter"||B.key===" "||B.key==="ArrowDown"||B.key==="ArrowUp")&&(B.preventDefault(),ae(!0))}},de=!!String(n||"").trim(),je=de?ce:i,ke=_e!=null&&_e.disabled?_e.reason||"Unavailable":"",Ee=H&&ie.length>0?`${X}-opt-${we}`:void 0,Oe=o.jsx("span",{className:As("af-select-value",!de&&"af-select-value--placeholder"),children:c&&!de?"Loading…":je}),qe=L?L(re,String(n||"")):Oe;return o.jsxs("span",{className:As("af-select",y==="pin"?"af-select--pin":"af-select--panel",_),children:[o.jsxs("button",{ref:W,id:X,type:"button",className:As("af-select-trigger",p&&de&&"af-select-trigger--clearable",w),disabled:a,onMouseDown:B=>B.stopPropagation(),onClick:B=>{B.stopPropagation(),!a&&ae(pe=>!pe)},onKeyDown:Z,role:d?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":H,"aria-controls":H?le:void 0,"aria-activedescendant":d?void 0:Ee,"aria-label":k,children:[qe,o.jsx("span",{className:As("af-select-caret",H&&"af-select-caret--open"),children:"▾"})]}),p&&de?o.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:a,onMouseDown:B=>{B.preventDefault(),B.stopPropagation()},onClick:B=>{var pe;B.preventDefault(),B.stopPropagation(),C(""),Ue(),(pe=W.current)==null||pe.focus()},title:"Clear",children:"×"}):null,H?bf.createPortal(o.jsxs("div",{ref:V,className:As("af-select-popover",ne==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${E.left}px`,top:`${E.top}px`,width:`${E.width}px`},onMouseDown:B=>B.stopPropagation(),onClick:B=>B.stopPropagation(),onWheel:B=>B.stopPropagation(),onKeyDown:ee,tabIndex:-1,children:[d?o.jsxs("div",{className:"af-select-search",children:[o.jsx("input",{ref:Q,className:"af-select-search-input",value:se,onChange:B=>ye(B.target.value),placeholder:f,onKeyDown:ee,role:"combobox","aria-expanded":!0,"aria-controls":le,"aria-activedescendant":Ee,"aria-invalid":!!ke,"aria-describedby":ke?`${X}-custom-error`:void 0}),ke?o.jsx("div",{id:`${X}-custom-error`,className:"af-select-custom-error",role:"alert",children:ke}):null]}):null,o.jsx("div",{className:"af-select-options",role:"listbox",id:le,"aria-label":k,children:c&&ie.length===0?o.jsx("div",{className:"af-select-empty",children:"Loading…"}):ie.length===0?o.jsx("div",{className:"af-select-empty",children:"No results"}):ie.map((B,pe)=>{var $n;const Le=B.value===n,Ge=pe===we,zt=String(B.group||"").trim(),vn=pe>0?String((($n=ie[pe-1])==null?void 0:$n.group)||"").trim():"",wn=!!zt&&zt!==vn;return o.jsxs(_t.Fragment,{children:[wn?o.jsx("div",{className:"af-select-group",role:"presentation",children:zt}):null,o.jsx("div",{id:`${X}-opt-${pe}`,role:"option","aria-selected":Le,className:As("af-select-option",Le&&"af-select-option--selected",Ge&&"af-select-option--highlighted",B.disabled&&"af-select-option--disabled"),title:B.disabled?B.reason||"Unavailable":void 0,onMouseEnter:()=>J(pe),onMouseDown:Tn=>{Tn.preventDefault(),Tn.stopPropagation()},onClick:()=>We(B.value),"aria-disabled":B.disabled?!0:void 0,children:j?j(B,{selected:Le,highlighted:Ge}):o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"af-select-option-label",children:[o.jsx("span",{children:B.label}),B.reason?o.jsx("small",{className:"af-select-option-reason",children:B.reason}):null]}),Le?o.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},B.value)})})]}),document.body):null]})}function Gh(n){const r=new Set,i=[];for(const a of n||[]){if(!a||typeof a!="object")continue;const c=String(a.name||"").trim();!c||r.has(c)||(r.add(c),i.push({name:c,display_name:typeof a.display_name=="string"?a.display_name:void 0}))}return i.sort((a,c)=>a.name.localeCompare(c.name)),i}function Kh(n){const r=new Set,i=[];for(const a of n||[]){const c=String(a||"").trim();!c||r.has(c)||(r.add(c),i.push(c))}return i.sort(),i}function Qh(n){const r=n.disabled===!0,i=n.layout||"stack",a=n.allowGatewayDefault!==!1,c=String(n.gatewayDefaultLabel||"(gateway default)"),d=String(n.providerLabel||"Provider"),f=String(n.modelLabel||"Model"),m=String(n.providerPlaceholder||"(select)"),p=String(n.modelPlaceholder||"(select)"),g=String(n.provider||"").trim(),y=String(n.model||"").trim(),_=Gh(n.providers),w=Kh(n.models),k=r||!!n.loadingProviders,T=r||!!n.loadingModels,N=[...a?[{value:"",label:c}]:[],..._.map(S=>({value:S.name,label:S.display_name?`${S.display_name} (${S.name})`:S.name}))],A=[...a?[{value:"",label:c}]:[],...w.map(S=>({value:S,label:S}))];return o.jsxs("div",{className:n.className,style:i==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[o.jsxs("div",{style:i==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[o.jsx("label",{children:d}),o.jsx(Cr,{value:g,options:N,placeholder:a?c:m,disabled:k,loading:!!n.loadingProviders,searchable:!0,allowCustom:n.allowCustomProvider===!0,clearable:a,variant:"panel",triggerClassName:n.selectClassName,ariaLabel:d,onChange:S=>n.onChange({provider:String(S||"").trim(),model:""})}),n.loadingProviders?o.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,n.providerError?o.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:n.providerError}):null]}),o.jsxs("div",{style:i==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[o.jsx("label",{children:f}),o.jsx(Cr,{value:y,options:A,placeholder:a?c:p,disabled:T,loading:!!n.loadingModels,searchable:!0,allowCustom:n.allowCustomModel===!0,clearable:a,variant:"panel",triggerClassName:n.selectClassName,ariaLabel:f,onChange:S=>n.onChange({provider:g,model:String(S||"").trim()})}),n.loadingModels?o.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,n.modelError?o.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:n.modelError}):null]})]})}function Cf(n){if(n===!1||n&&typeof n=="object"&&n.mode==="off")return!1;if(!n||typeof n!="object")return;const r=n;if(!(r.mode!=="native_mtp"||!Number.isInteger(r.num_draft_tokens)||Number(r.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(r.num_draft_tokens),require_acceleration:!0}}function Jh(n){var i;const r=(i=n==null?void 0:n.execution)==null?void 0:i.speculation;return!r||typeof r.supported!="boolean"?null:{supported:r.supported,ready:typeof r.ready=="boolean"?r.ready:null,reason:typeof r.reason=="string"?r.reason:null,supported_depths:r.supported&&Array.isArray(r.supported_depths)?[...new Set(r.supported_depths.filter(a=>typeof a=="number"&&Number.isInteger(a)&&a>0))]:[],default:Object.prototype.hasOwnProperty.call(r,"effective_default")?r.effective_default:r.default,requires_reload:typeof r.requires_reload=="boolean"?r.requires_reload:null}}function Gd(n){const r=Cf(n);return r===!1?"off":r?String(r.num_draft_tokens):""}function Yh(n){if(n==="off")return!1;if(!(!/^\d+$/.test(n)||Number(n)<1))return{mode:"native_mtp",num_draft_tokens:Number(n),require_acceleration:!0}}function Xh(n){const r=Jh(n.capabilities),i=Gd(n.value),a=(r==null?void 0:r.supported_depths.map(String))||[],c=Gd(r==null?void 0:r.default),d=n.inheritLabel||"Workflow / Gateway default",f=c?`${d} (${c==="off"?"Off":`depth ${c}`})`:d,m=n.error||(n.loading?"Checking MTP capability…":r?r.reason||(r.requires_reload?"Model reload required before MTP can run.":r.ready===!1?"MTP is supported but not ready on this instance.":r.ready===null&&r.supported?"MTP support verified; loaded-instance readiness is unknown.":r.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return o.jsxs("div",{className:"af-pmp__speculation",children:[o.jsx("label",{children:"MTP depth"}),o.jsx(Cr,{ariaLabel:"MTP depth",value:i,placeholder:f,disabled:n.disabled||n.loading,options:[{value:"",label:f},{value:"off",label:"Off"},...a.map(p=>({value:p,label:`Depth ${p}`})),...i&&i!=="off"&&!a.includes(i)?[{value:i,label:`Depth ${i} (saved; not available)`}]:[]],onChange:p=>n.onChange(Yh(p))}),m?o.jsx("div",{role:"status",className:"af-pmp__hint",children:m}):null]})}function dc(n){var J,ne;const r=n.disabled===!0,i=n.value||{provider:"",model:""},a=!String(i.provider||"").trim()&&!String(i.model||"").trim(),[c,d]=x.useState(!a),f=a&&!c,m=x.useRef(a);x.useEffect(()=>{a&&!m.current&&d(!1),m.current=a},[a]);const[p,g]=x.useState([]),[y,_]=x.useState(!1),[w,k]=x.useState(""),[T,N]=x.useState([]),[A,S]=x.useState(!1),[P,C]=x.useState(""),j=x.useRef(n);j.current=n,x.useEffect(()=>{if(f||r)return;let U=!0;return _(!0),(async()=>{try{const E=await j.current.fetchProviders();if(!U)return;g(Array.isArray(E)?E:[]),k("")}catch(E){if(!U)return;g([]),k(`#FALLBACK provider discovery failed: ${String((E==null?void 0:E.message)||E)}`)}finally{U&&_(!1)}})(),()=>{U=!1}},[f,r]);const L=String(i.provider||"").trim();x.useEffect(()=>{if(!L||r){N([]),C(""),S(!1);return}let U=!0;return N([]),S(!0),C(""),(async()=>{try{const E=await j.current.fetchModels(L);if(!U)return;N(Array.isArray(E)?E:[])}catch(E){if(!U)return;N([]),C(`#FALLBACK model discovery failed: ${String((E==null?void 0:E.message)||E)}`)}finally{U&&S(!1)}})(),()=>{U=!1}},[L,r]);const W=x.useMemo(()=>{const U=[...p];return L&&!U.some(E=>E.name===L)&&U.unshift({name:L}),U},[p,L]),V=String(i.model||"").trim(),Q=x.useMemo(()=>{const U=[...T];return V&&!U.includes(V)&&U.unshift(V),U},[T,V]),me=n.defaultModeLabel||"Gateway default",oe=n.customModeLabel||"Custom",X=L||((J=n.effectiveDefault)==null?void 0:J.provider)||"",le=V||(L?"":(ne=n.effectiveDefault)==null?void 0:ne.model)||"",[H,ae]=x.useState({levels:[],error:"",loading:!1}),se=!!n.fetchModelCapabilities,[ye,we]=x.useState();return x.useEffect(()=>{let U=!0;if(we(void 0),ae({levels:[],error:"",loading:se&&!!le}),!(!se||!le||r))return j.current.fetchModelCapabilities(le,X).then(E=>{var ce;if(!U)return;if(E!=null&&E.error)throw new Error(String(E.error));we(E);const D=(E==null?void 0:E.capabilities)||E||{},z=D.reasoning_levels||D.thinking_levels,re=Array.isArray(z)?[...new Set(z.filter(ve=>typeof ve=="string"&&!!ve.trim()))]:[];!re.length&&D.thinking_support===!0&&((ce=D.thinking_control)!=null&&ce.prompt_disable_token)&&re.push("off","auto"),ae({levels:re,error:"",loading:!1})}).catch(E=>{U&&ae({levels:[],error:`Reasoning options unavailable: ${String((E==null?void 0:E.message)||E)}`,loading:!1})}),()=>{U=!1}},[X,le,se,r]),o.jsxs("div",{className:`af-pmp${n.className?` ${n.className}`:""}`,children:[o.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":f,className:`af-pmp__seg-btn${f?" is-active":""}`,onClick:()=>{d(!1),n.onChange({...i,provider:"",model:"",...se?{reasoning:""}:{}})},disabled:r,children:me}),o.jsx("button",{type:"button",role:"tab","aria-selected":!f,className:`af-pmp__seg-btn${f?"":" is-active"}`,onClick:()=>{d(!0)},disabled:r,children:oe})]}),f?o.jsx("div",{className:"af-pmp__hint",children:n.defaultHint||"The gateway picks its configured default provider and model for this task."}):o.jsx(Qh,{provider:L,model:V,providers:W,models:Q,disabled:r,loadingProviders:y,loadingModels:A,providerError:w||void 0,modelError:P||void 0,providerLabel:n.providerLabel,modelLabel:n.modelLabel,allowGatewayDefault:!1,allowCustomProvider:n.allowCustom!==!1,allowCustomModel:n.allowCustom!==!1,onChange:U=>n.onChange({...i,provider:U.provider,model:U.model,...se?{reasoning:""}:{}})}),se&&(H.levels.length>0||i.reasoning)?o.jsxs("div",{className:"af-pmp__reasoning",children:[o.jsx("label",{children:n.reasoningLabel||"Reasoning effort"}),o.jsx(Cr,{ariaLabel:n.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:i.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...H.levels.map(U=>({value:U,label:U})),...i.reasoning&&!H.levels.includes(i.reasoning)?[{value:i.reasoning,label:`${i.reasoning} (saved; not advertised)`}]:[]],disabled:r||H.loading,onChange:U=>n.onChange({...i,reasoning:U})})]}):null,H.error?o.jsx("div",{role:"status",className:"af-pmp__hint",children:H.error}):null,n.enableSpeculation?o.jsx(Xh,{value:i.speculation,onChange:U=>n.onChange({...i,speculation:U}),capabilities:ye,disabled:r,loading:H.loading,error:H.error?H.error.replace("Reasoning options","MTP options"):void 0}):null]})}function Kd(...n){return n.filter(Boolean).join(" ")}function Zh({kicker:n="AbstractGateway connection",title:r="Connect to AbstractGateway",description:i="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:a="Gateway token missing",statusTone:c="warn",tokenSourceLabel:d="token: missing",showGatewayUrl:f=!1,gatewayUrl:m="",gatewayUrlPlaceholder:p="http://127.0.0.1:8080",onGatewayUrlChange:g,userId:y,userPlaceholder:_="admin",onUserIdChange:w,token:k,tokenPlaceholder:T="Paste Gateway user token",showToken:N=!1,onTokenChange:A,onShowTokenChange:S,remember:P=!1,rememberLabel:C="Remember this browser",onRememberChange:j,loading:L=!1,submitting:W=!1,submitDisabled:V=!1,submitLabel:Q="Sign in",submittingLabel:me="Signing in...",closeLabel:oe="Close",signOutLabel:X="Sign out",showClose:le=!1,showSignOut:H=!1,error:ae,message:se,className:ye,onSubmit:we,onClose:J,onSignOut:ne}){const U=L||W,E=U||V||!String(y||"").trim()||!String(k||"").trim(),D=z=>{z.preventDefault(),!E&&we()};return o.jsxs("form",{className:Kd("af-gateway-signin",ye),onSubmit:D,children:[o.jsxs("div",{className:"af-gateway-signin__hero",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-gateway-signin__kicker",children:n}),o.jsx("h2",{children:r}),i?o.jsx("p",{children:i}):null]}),o.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),o.jsxs("div",{className:"af-gateway-signin__status-row",children:[o.jsx("span",{className:Kd("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:a}),d?o.jsx("span",{className:"af-gateway-signin__source",children:d}):null]}),o.jsxs("div",{className:"af-gateway-signin__form",children:[f?o.jsxs(o.Fragment,{children:[o.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),o.jsx("input",{id:"gateway-session-url",value:m,onChange:z=>g==null?void 0:g(z.target.value),placeholder:p,autoComplete:"url",disabled:U})]}):null,o.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),o.jsx("input",{id:"gateway-session-user",value:y,onChange:z=>w(z.target.value),placeholder:_,autoComplete:"username",disabled:U}),o.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),o.jsxs("div",{className:"af-gateway-signin__token-input",children:[o.jsx("input",{id:"gateway-session-token",type:N?"text":"password",value:k,onChange:z=>A(z.target.value),placeholder:T,autoComplete:"current-password",disabled:U}),o.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>S==null?void 0:S(!N),disabled:U,children:N?"Hide":"Show"})]}),o.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),o.jsxs("label",{className:"af-gateway-signin__checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!P,onChange:z=>j==null?void 0:j(z.target.checked),disabled:U}),C]})]}),ae?o.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:ae}):null,!ae&&se?o.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:se}):null,o.jsxs("div",{className:"af-gateway-signin__actions",children:[le?o.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:J,disabled:U,children:oe}):null,H?o.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(ne==null?void 0:ne()),disabled:U,children:X}):null,o.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:E,children:W?me:Q})]})]})}function qh(n){return n==="light"?"Light":"Dark"}function em(n){const r=n.themes&&n.themes.length?n.themes:jf,i=n.showSwatches!==!1,a=n.variant||"panel",c=x.useMemo(()=>{const f={};for(const m of r)f[m.id]=m;return f},[r]),d=x.useMemo(()=>r.map(f=>({value:f.id,label:f.label,group:qh(f.group)})),[r]);return o.jsx(Cr,{value:n.value,options:d,placeholder:n.placeholder||"Select theme…",disabled:n.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:a,className:n.className,triggerClassName:n.triggerClassName,onChange:f=>n.onChange(String(f||"").trim()),renderValue:(f,m)=>{const p=String(m||"").trim(),g=c[p],y=(g==null?void 0:g.label)||p||n.placeholder||"Select theme…",_=(g==null?void 0:g.swatches)||null,w=!p;return o.jsxs("span",{className:"af-theme-value",children:[o.jsx("span",{className:`af-theme-label ${w?"af-theme-label--placeholder":""}`.trim(),children:y}),i&&_?o.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:_.map((k,T)=>o.jsx("span",{className:"af-theme-swatch",style:{background:k}},`${p}:${T}`))}):null]})},renderOption:(f,m)=>{const p=String(f.value||"").trim(),g=c[p],y=(g==null?void 0:g.swatches)||null;return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"af-theme-option-label",children:f.label}),o.jsxs("span",{className:"af-theme-option-right",children:[i&&y?o.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:y.map((_,w)=>o.jsx("span",{className:"af-theme-swatch",style:{background:_}},`${p}:${w}`))}):null,m.selected?o.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function tm(n){const r=n.scales&&n.scales.length?n.scales:tc,i=n.variant||"panel",a=x.useMemo(()=>r.map(c=>({value:c.id,label:c.label})),[r]);return o.jsx(Cr,{value:n.value,options:a,placeholder:n.placeholder||"Font size…",disabled:n.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:i,className:n.className,triggerClassName:n.triggerClassName,onChange:c=>n.onChange(String(c||"").trim())})}function nm(n){const r=n.densities&&n.densities.length?n.densities:nc,i=n.variant||"panel",a=x.useMemo(()=>r.map(c=>({value:c.id,label:c.label})),[r]);return o.jsx(Cr,{value:n.value,options:a,placeholder:n.placeholder||"Header size…",disabled:n.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:i,className:n.className,triggerClassName:n.triggerClassName,onChange:c=>n.onChange(String(c||"").trim())})}const rm=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function sm(n){switch(n){case"chat":return o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 5v14"}),o.jsx("path",{d:"M5 12h14"})]});case"history":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),o.jsx("path",{d:"M3 3v5h5"}),o.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),o.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M4 6h16"}),o.jsx("circle",{cx:"8",cy:"6",r:"2"}),o.jsx("path",{d:"M4 12h16"}),o.jsx("circle",{cx:"16",cy:"12",r:"2"}),o.jsx("path",{d:"M4 18h16"}),o.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"8",r:"4"}),o.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 2v3"}),o.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),o.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),o.jsx("path",{d:"M9 17h6"})]});case"paperclip":return o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),o.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),o.jsx("path",{d:"M12 18v4"}),o.jsx("path",{d:"M8 22h8"})]});case"speaker":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),o.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),o.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),o.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),o.jsx("path",{d:"M7 9l3 3-3 3"}),o.jsx("path",{d:"M12 15h5"})]});case"edit":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 20h9"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),o.jsx("path",{d:"M7 10l5 5 5-5"}),o.jsx("path",{d:"M12 15V3"})]});case"loader":return o.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M12 16v-4"}),o.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 3l10 18H2L12 3z"}),o.jsx("path",{d:"M12 9v4"}),o.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"10"}),o.jsx("path",{d:"M15 9l-6 6"}),o.jsx("path",{d:"M9 9l6 6"})]});case"copy":return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),o.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return o.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M18 6L6 18"}),o.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return o.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return o.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M3 6h18"}),o.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M6 6l1 16h10l1-16"}),o.jsx("path",{d:"M10 11v6"}),o.jsx("path",{d:"M14 11v6"})]});case"send":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M22 2L11 13"}),o.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M7 10v11"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M17 14V3"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M7 10v11"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M17 14V3"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),o.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),o.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),o.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),o.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),o.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),o.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),o.jsx("path",{d:"M8 4.5V2.2"}),o.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),o.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M2.5 4h11"}),o.jsx("path",{d:"M2.5 8h11"}),o.jsx("path",{d:"M2.5 12h7"})]});case"gear":return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),o.jsx("path",{d:"M8 1.6v2"}),o.jsx("path",{d:"M8 12.4v2"}),o.jsx("path",{d:"M1.6 8h2"}),o.jsx("path",{d:"M12.4 8h2"}),o.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),o.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),o.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),o.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),o.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 o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),o.jsx("path",{d:"M16 17l5-5-5-5"}),o.jsx("path",{d:"M21 12H9"})]});default:return null}}function fe({name:n,size:r=16,className:i,title:a,...c}){const d=a?void 0:!0,f=rm.has(n);return o.jsxs("svg",{width:r,height:r,viewBox:f?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:f?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:i,"aria-hidden":d,role:a?"img":"presentation",...c,children:[a?o.jsx("title",{children:a}):null,sm(n)]})}const im={autoApprove:["list_files","skim_folders","analyze_code","read_file","skim_files","search_files","open_attachment","web_search","skim_websearch","skim_url","fetch_url","list_email_accounts","list_emails","read_email","list_whatsapp_messages","read_whatsapp_message","send_email","send_whatsapp_message","send_telegram_message","send_telegram_artifact"],requireApproval:["write_file","edit_file","execute_command"]};function om(n){const r=new Set,i=[];for(const a of n||[]){if(!a)continue;const c=String(a.name||"").trim();!c||r.has(c)||(r.add(c),i.push({name:c,description:typeof a.description=="string"?a.description:void 0,toolset:typeof a.toolset=="string"?a.toolset:void 0,when_to_use:typeof a.when_to_use=="string"?a.when_to_use:void 0,default_approval:a.default_approval==="approve"||a.default_approval==="ask"?a.default_approval:void 0}))}return i.sort((a,c)=>{const d=String(a.toolset||""),f=String(c.toolset||"");return d!==f?d.localeCompare(f):a.name.localeCompare(c.name)}),i}function am(n,r){return n.default_approval?n.default_approval:r.requireApproval.includes(n.name)?"ask":r.autoApprove.includes(n.name)?"approve":"ask"}function lm(n,r,i){const a=String(n||"").trim().toLowerCase();if(!a&&!r&&!i)return null;let c;return a==="approval"||a==="local_approval"||a==="local-approval"?c={label:"APPROVAL",detail:"Safe tools auto-run; mutating tools ask for approval.",tone:"safe"}:a==="passthrough"?c={label:"PASSTHROUGH",detail:"All tools require approval before execution.",tone:"warn"}:a==="delegated"||a==="delegate"||a==="job"?c={label:"DELEGATED",detail:"Tool calls wait for external executors.",tone:"info"}:a==="local"||a==="local_all"||a==="local-all"?c={label:"LOCAL",detail:"All tools run locally; client policy may still require approval.",tone:"danger"}:c={label:"UNKNOWN",detail:"#FALLBACK: gateway tool mode not reported.",tone:"warn"},r&&(c={...c,label:r}),i&&(c={...c,detail:i}),c}function cm(n){var me,oe;const r=n.defaults||im,i=n.disabled===!0,a=n.title||"Tools",c=n.subtitle||"Default is all tools. Safe/read-only tools auto-approve; mutating tools ask for approval.",d=String(n.note||"").trim(),f=x.useMemo(()=>lm(n.toolMode,n.toolModeLabel,n.toolModeDetail),[n.toolMode,n.toolModeLabel,n.toolModeDetail]),m=x.useMemo(()=>om(n.tools),[n.tools]),p=x.useMemo(()=>m.map(X=>X.name),[m]),g=x.useMemo(()=>new Set(p),[p]),[y,_]=x.useState(""),w=x.useMemo(()=>{var ae;const X=Array.isArray((ae=n.value)==null?void 0:ae.selected)?n.value.selected:[],le=new Set,H=[];for(const se of X){const ye=String(se||"").trim();!ye||le.has(ye)||(le.add(ye),H.push(ye))}return H},[(me=n.value)==null?void 0:me.selected]),k=x.useMemo(()=>w.filter(X=>g.has(X)),[w,g]),T=x.useMemo(()=>w.filter(X=>!g.has(X)),[w,g]),N=((oe=n.value)==null?void 0:oe.mode)==="custom"?"custom":"all",A=x.useMemo(()=>{const X=y.trim().toLowerCase();return X?m.filter(le=>{const H=le.name.toLowerCase(),ae=(le.description||"").toLowerCase();return H.includes(X)||ae.includes(X)}):m},[m,y]),S=N==="all"?new Set(p):new Set(k),P=X=>{n.onChange(X)},C=X=>{i||P({...n.value,mode:X,selected:w})},j=(X,le)=>{if(i)return;const H=new Set(k);le?H.add(X):H.delete(X),P({...n.value,selected:[...T,...Array.from(H)],mode:"custom"})},L=(X,le)=>{var ae;if(i)return;const H={...((ae=n.value)==null?void 0:ae.approval)||{}};H[X]=le,P({...n.value,approval:H})},W=()=>{i||P({...n.value,selected:[...T,...p],mode:"custom"})},V=()=>{i||P({...n.value,selected:[...T],mode:"custom"})},Q=S.size;return o.jsxs("div",{className:`af-tool-policy ${n.className||""}`.trim(),children:[o.jsxs("div",{className:"af-tool-policy__header",children:[o.jsx("div",{className:"af-tool-policy__title",children:a}),o.jsx("div",{className:"af-tool-policy__subtitle",children:c}),f?o.jsxs("div",{className:`af-tool-policy__mode is-${f.tone}`,children:[o.jsx("div",{className:"af-tool-policy__mode-badge",children:"Tool mode"}),o.jsx("div",{className:"af-tool-policy__mode-value",children:f.label}),o.jsx("div",{className:"af-tool-policy__mode-detail",children:f.detail})]}):null,d?o.jsx("div",{className:"af-tool-policy__note",children:d}):null]}),o.jsxs("div",{className:"af-tool-policy__controls",children:[o.jsxs("div",{className:"af-tool-policy__segmented",role:"group","aria-label":"Tool allowlist mode",children:[o.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${N==="all"?"is-active":""}`.trim(),onClick:()=>C("all"),disabled:i,"aria-pressed":N==="all",children:"All tools"}),o.jsx("button",{type:"button",className:`af-tool-policy__seg-btn ${N==="custom"?"is-active":""}`.trim(),onClick:()=>C("custom"),disabled:i,"aria-pressed":N==="custom",children:"Custom allowlist"})]}),o.jsxs("div",{className:"af-tool-policy__count",children:[Q," / ",p.length," enabled"]}),o.jsxs("div",{className:"af-tool-policy__bulk",children:[o.jsx("button",{type:"button",onClick:W,disabled:i||N!=="custom",children:"Select all"}),o.jsx("button",{type:"button",onClick:V,disabled:i||N!=="custom",children:"Select none"})]})]}),o.jsx("div",{className:"af-tool-policy__filter",children:o.jsx("input",{type:"text",placeholder:"Filter tools...","aria-label":"Filter tools",value:y,onChange:X=>_(X.target.value),disabled:i})}),o.jsxs("div",{className:"af-tool-policy__list",children:[A.map(X=>{var ae,se;const le=S.has(X.name),H=((se=(ae=n.value)==null?void 0:ae.approval)==null?void 0:se[X.name])||am(X,r);return o.jsxs("div",{className:`af-tool-row ${le?"is-enabled":""}`.trim(),children:[o.jsx("label",{className:"af-tool-row__check",children:o.jsx("input",{type:"checkbox",checked:le,disabled:i||N!=="custom",onChange:ye=>j(X.name,ye.target.checked),"aria-label":`Enable ${X.name}`})}),o.jsxs("div",{className:"af-tool-row__meta",children:[o.jsxs("div",{className:"af-tool-row__title",children:[o.jsx("span",{className:"af-tool-row__name",children:X.name}),X.toolset?o.jsx("span",{className:"af-tool-row__badge",children:X.toolset}):null]}),X.description?o.jsx("div",{className:"af-tool-row__desc",children:X.description}):null,X.when_to_use?o.jsx("div",{className:"af-tool-row__hint",children:X.when_to_use}):null]}),o.jsx("div",{className:"af-tool-row__approval",children:o.jsxs("select",{value:H,disabled:i||!le,onChange:ye=>L(X.name,ye.target.value),"aria-label":`Approval mode for ${X.name}`,children:[o.jsx("option",{value:"approve",children:"Approve"}),o.jsx("option",{value:"ask",children:"Ask"})]})})]},X.name)}),A.length?null:o.jsx("div",{className:"af-tool-policy__empty",children:"No tools match the filter."})]})]})}async function rc(n="/api/connection/gateway"){const r=await fetch(n),i=await r.json().catch(()=>null);if(!r.ok){const a=i&&typeof i=="object"&&i.detail?String(i.detail):`HTTP ${r.status}`;throw new Error(a)}return i}async function um(n,r="/api/connection/gateway"){const i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),a=await i.json().catch(()=>null);if(!i.ok){const c=a&&typeof a=="object"&&a.detail?String(a.detail):`HTTP ${i.status}`;throw new Error(c)}return a}async function Nf(n="/api/connection/gateway"){const r=await fetch(n,{method:"DELETE"});if(!r.ok){const i=await r.json().catch(()=>({})),a=i&&typeof i=="object"&&i.detail?String(i.detail):`HTTP ${r.status}`;throw new Error(a)}}function Vl(n){let r=String(n||"").trim();for(let i=0;i<2&&r;i+=1){try{const d=JSON.parse(r);if(typeof d=="string"&&d!==r){r=d.trim();continue}}catch{}const a=r[0],c=r[r.length-1];if(a==='"'&&c==='"'||a==="'"&&c==="'"){r=r.slice(1,-1).trim();continue}break}return r.replace(/\/+$/,"")}function dm(n){var d,f;if(!n)return{label:"Signed out",tone:"warn"};if(!n.has_session)return{label:"Signed out",tone:"warn"};const r=n.gateway||{},i=(d=r.principal)==null?void 0:d.user_id,a=(f=r.principal)==null?void 0:f.runtime_id;if(r.ok&&i)return{label:`Signed in as ${i}${a?` · runtime ${a}`:""}`,tone:"ok"};if(r.ok)return{label:"Signed in",tone:"ok"};const c=r.error||r.detail;return typeof c=="string"&&c.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function fm(n){const r=n.connectionPath||"/api/connection/gateway",[i,a]=x.useState(!1),[c,d]=x.useState(!1),[f,m]=x.useState(null),[p,g]=x.useState(!1);x.useEffect(()=>{n.isOpen||g(!1)},[n.isOpen]);const[y,_]=x.useState(n.defaultGatewayUrl||"http://127.0.0.1:8080"),[w,k]=x.useState("admin"),[T,N]=x.useState(""),[A,S]=x.useState(!1),[P,C]=x.useState(!0),[j,L]=x.useState(""),[W,V]=x.useState(""),Q=x.useMemo(()=>dm(f),[f]),me=H=>{var ae;m(H),(ae=n.onStatusChange)==null||ae.call(n,H)},oe=x.useRef(!1);if(x.useEffect(()=>{var ae;if(!n.isOpen)return;const H=!oe.current;if(oe.current=!0,H&&n.initialStatus!==void 0&&n.initialStatus!==null){const se=n.initialStatus;me(se),typeof se.gateway_url=="string"&&se.gateway_url.trim()&&_(Vl(se.gateway_url));const ye=(ae=se.gateway)==null?void 0:ae.principal;ye!=null&&ye.user_id&&k(ye.user_id);return}a(!0),L(""),rc(r).then(se=>{var we;me(se),typeof se.gateway_url=="string"&&se.gateway_url.trim()&&_(Vl(se.gateway_url));const ye=(we=se.gateway)==null?void 0:we.principal;ye!=null&&ye.user_id&&k(ye.user_id)}).catch(se=>L(`Failed to load connection status: ${String((se==null?void 0:se.message)||se)}`)).finally(()=>a(!1))},[n.isOpen]),x.useEffect(()=>{if(!n.isOpen)return;const H=ae=>{ae.key==="Escape"&&!ae.defaultPrevented&&!n.blocking&&(ae.preventDefault(),n.onClose())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n.isOpen,n.blocking,n.onClose]),!n.isOpen||p)return null;const X=async()=>{d(!0),L(""),V("");try{const H=Vl(y);_(H);const ae=await um({gateway_url:H,gateway_user_id:w,gateway_token:T,persist:P},r);me(ae),N(""),g(!0),n.onClose()}catch(H){L(String((H==null?void 0:H.message)||H))}finally{d(!1)}},le=async()=>{d(!0),L(""),V("");try{await Nf(r),N("");const H=await rc(r).catch(()=>null);me(H),V("Signed out. This browser no longer holds a gateway session.")}catch(H){L(String((H==null?void 0:H.message)||H))}finally{d(!1)}};return o.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:H=>{!n.blocking&&H.target===H.currentTarget&&n.onClose()},children:o.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:o.jsx(Zh,{kicker:`${n.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:Q.label,statusTone:Q.tone,tokenSourceLabel:f!=null&&f.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:y,onGatewayUrlChange:H=>_(H),userId:w,onUserIdChange:k,token:T,tokenPlaceholder:f!=null&&f.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:A,onTokenChange:N,onShowTokenChange:S,remember:P,rememberLabel:"Keep this browser signed in",onRememberChange:C,loading:i,submitting:c,submittingLabel:"Signing in...",showClose:!n.blocking,onClose:n.onClose,showSignOut:!n.blocking&&!!(f!=null&&f.has_session),onSignOut:le,error:j,message:W,onSubmit:X})})})}function pm(n){return!!(n&&n.ok===!0&&n.has_session===!0)}function hm(n){const r=n||{},i=r.connectionPath||"/api/connection/gateway",a=r.variant||"dismissable",c=x.useRef(r.onStatusChange);c.current=r.onStatusChange;const d=x.useRef(a);d.current=a;const f=x.useRef(!!r.autoOpenMidSession);f.current=!!r.autoOpenMidSession;const[m,p]=x.useState(null),[g,y]=x.useState("loading"),[_,w]=x.useState(!1),k=x.useRef(!1),T=x.useRef(!1),N=x.useRef("loading"),A=x.useRef("none"),S=x.useRef(!1),P=x.useRef(0),C=x.useCallback(ae=>{var ye;P.current+=1,p(ae),(ye=c.current)==null||ye.call(c,ae);const se=pm(ae);if(se)y("connected"),N.current="connected",k.current=!1,A.current="none",T.current||w(!1);else if(ae!==null){const we=N.current;y("disconnected"),N.current="disconnected",we!=="disconnected"&&(A.current=S.current?"signout":we==="connected"?"mid":"boot");const J=d.current==="blocking"||A.current!=="mid"||f.current;!k.current&&J&&w(!0)}ae!==null&&(T.current=se)},[]),j=x.useCallback(async()=>{const ae=P.current;try{const se=await rc(i);if(P.current!==ae)return;C(se)}catch{if(P.current!==ae)return;C(null)}},[i,C]),[L,W]=x.useState(!1),[V,Q]=x.useState(null),me=x.useCallback(async()=>{W(!0),Q(null),P.current+=1;let ae=null;try{await Nf(i)}catch(se){ae=String((se==null?void 0:se.message)||se||"Sign-out request failed")}S.current=!0;try{await j()}finally{S.current=!1}Q(ae),W(!1)},[i,j]),oe=x.useRef(!1);x.useEffect(()=>{oe.current||(oe.current=!0,j())},[j]);const X=x.useCallback(()=>{w(!0)},[]),le=x.useCallback(()=>{const ae=N.current;a==="blocking"&&ae==="disconnected"||(ae==="disconnected"&&(k.current=!0),w(!1))},[a]),H=x.useMemo(()=>({isOpen:_,onClose:le,blocking:a==="blocking"&&g!=="connected",appName:r.appName,connectionPath:i,defaultGatewayUrl:r.defaultGatewayUrl,initialStatus:m,onStatusChange:C}),[_,le,a,g,r.appName,i,r.defaultGatewayUrl,m,C]);return{status:m,phase:g,connected:g==="connected",modalOpen:_,signingOut:L,signOutError:V,openModal:X,refresh:j,signOut:me,modalProps:H}}function sc(n){const r=n.closeOnEscape!==!1,i=x.useRef(null);return x.useEffect(()=>{if(!n.open||!r)return;const a=c=>{c.key!=="Escape"||c.defaultPrevented||(c.preventDefault(),n.onClose())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n.open,r,n.onClose]),x.useEffect(()=>{const a=i.current;a&&(n.open?a.removeAttribute("inert"):a.setAttribute("inert",""))},[n.open]),o.jsxs("div",{ref:i,className:`af-drawer${n.open?" af-drawer--open":""}${n.className?` ${n.className}`:""}`,style:{width:n.width||420,top:n.topOffset||0,display:n.open?void 0:"none"},role:"complementary","aria-label":n.label,"aria-hidden":n.open?void 0:!0,children:[n.title!==void 0?o.jsxs("div",{className:"af-drawer__header",children:[o.jsx("div",{className:"af-drawer__title",children:n.title}),o.jsxs("div",{className:"af-drawer__header-actions",children:[n.headerActions,o.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:n.onClose,children:"×"})]})]}):null,o.jsx("div",{className:"af-drawer__body",children:n.children})]})}function mm(n){const{connection:r}=n,i=r.phase,a=r.signingOut===!0,c=a?"Signing out…":i==="connected"?"Disconnect":i==="loading"?"Connecting…":"Connect",d=i==="connected"?"Disconnect from gateway":i==="loading"?"Checking gateway session…":"Connect to gateway";return o.jsxs("div",{className:`af-topbar${n.className?` ${n.className}`:""}`,role:"group","aria-label":"App actions",children:[n.assistant?o.jsx("button",{type:"button",className:`af-topbar__btn${n.assistant.open?" is-active":""}`,"aria-pressed":n.assistant.open,"aria-label":n.assistant.label||"Open assistant",title:n.assistant.label||"Assistant",onClick:n.assistant.onToggle,children:o.jsx(fe,{name:"sparkle",size:16})}):null,n.appearance?o.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":n.appearance.label||"Appearance (theme and typography)",title:n.appearance.label||"Appearance",onClick:n.appearance.onOpen,children:o.jsx(fe,{name:"contrast",size:16})}):null,n.extraActions,o.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${i}`,onClick:i==="connected"?r.onDisconnect:r.onConnect,disabled:a,title:d,"aria-label":d,children:[o.jsx("span",{className:`af-topbar__dot af-topbar__dot--${i}`,"aria-hidden":"true"}),o.jsx("span",{className:"af-topbar__pill-label",children:c})]})]})}const Zo={theme:"dark",font_scale:"md",header_density:"standard"};function gm(n){const r=n&&typeof n=="object"?n:{};return{theme:typeof r.theme=="string"&&r.theme?r.theme:Zo.theme,font_scale:typeof r.font_scale=="string"&&r.font_scale?r.font_scale:Zo.font_scale,header_density:typeof r.header_density=="string"&&r.header_density?r.header_density:Zo.header_density}}function ym(n){return`af_appearance_${n}_v1`}function vm(n,r){const i=ym(n),a=x.useMemo(()=>({...Zo,...(r==null?void 0:r.defaults)||{}}),[JSON.stringify((r==null?void 0:r.defaults)||{})]),[c,d]=x.useState(()=>{let f=a;try{const m=localStorage.getItem(i)??(r!=null&&r.legacyKey?localStorage.getItem(r.legacyKey):null);m&&(f=gm({...a,...JSON.parse(m)}))}catch{}try{Vd(f.theme),Hd({font_scale:f.font_scale,header_density:f.header_density})}catch{}return f});return x.useEffect(()=>{Vd(c.theme),Hd({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(i,JSON.stringify(c))}catch{}},[i,c]),[c,d]}function wm(n){return x.useEffect(()=>{if(!n.open)return;const r=i=>{i.key!=="Escape"||i.defaultPrevented||(i.preventDefault(),n.onClose())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n.open,n.onClose]),n.open?o.jsx("div",{className:"af-appearance-overlay",onClick:n.onClose,role:"presentation",children:o.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":n.title||"Appearance",onClick:r=>r.stopPropagation(),children:[o.jsx("div",{className:"af-appearance__title",children:n.title||"Appearance"}),o.jsx("div",{className:"af-appearance__note",children:n.note||"Stored locally in this browser, per app."}),o.jsxs("div",{className:"af-appearance__grid",children:[o.jsx("label",{className:"af-appearance__label",children:"Theme"}),o.jsx(em,{value:n.value.theme,onChange:r=>n.onChange({...n.value,theme:r})}),o.jsx("label",{className:"af-appearance__label",children:"Font size"}),o.jsx(tm,{value:n.value.font_scale,onChange:r=>n.onChange({...n.value,font_scale:r})}),o.jsx("label",{className:"af-appearance__label",children:"Header size"}),o.jsx(nm,{value:n.value.header_density,onChange:r=>n.onChange({...n.value,header_density:r})})]}),o.jsx("div",{className:"af-appearance__actions",children:o.jsx("button",{type:"button",className:"af-appearance__close",onClick:n.onClose,children:"Close"})})]})}):null}function _m(){var r;if(typeof window>"u")return!1;const n=navigator;return!!((r=n==null?void 0:n.mediaDevices)!=null&&r.getUserMedia)&&typeof window.MediaRecorder=="function"}function xm(){if(typeof window>"u")return!1;const n=window;return!!(n!=null&&n.AudioContext||n!=null&&n.webkitAudioContext)}function km(){const n=window.MediaRecorder,r=a=>{var c;try{return!!((c=n==null?void 0:n.isTypeSupported)!=null&&c.call(n,a))}catch{return!1}},i=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const a of i)if(r(a))return a;return""}async function Hl(n,r){var c;const i=r.slice(0),a=(c=n.decodeAudioData)==null?void 0:c.bind(n);if(typeof a!="function")throw new Error("decodeAudioData not available");try{const d=a(i);if(d&&typeof d.then=="function")return await d}catch{}return await new Promise((d,f)=>{try{a(i,d,f)}catch(m){f(m)}})}function Sm(n){const r=new Uint8Array(n);if(r.length<44)return null;const i=d=>String.fromCharCode(r[d],r[d+1],r[d+2],r[d+3]);if(i(0)!=="RIFF"||i(8)!=="WAVE")return null;const a=new DataView(n);let c=12;for(;c+8<=r.length;){const d=i(c),f=a.getUint32(c+4,!0);if(d==="data")return r.slice(0,c+8);c+=8+f+f%2}return null}function jm(n,r){const i=new Uint8Array(r),a=new Uint8Array(n.length+i.length);a.set(n,0),a.set(i,n.length);const c=new DataView(a.buffer);return c.setUint32(4,a.length-8,!0),c.setUint32(n.length-4,i.length,!0),a.buffer}function bm(n){const r=x.useRef(n);r.current=n;const i=ee=>{var Z,de;return(de=(Z=r.current).on_error)==null?void 0:de.call(Z,ee)},a=x.useMemo(()=>xm()&&(typeof n.tts=="function"||typeof n.tts_stream=="function"),[n.tts,n.tts_stream]),c=x.useMemo(()=>_m()&&typeof n.transcribe=="function",[n.transcribe]),[d,f]=x.useState({key:"",status:"idle"}),m=x.useRef(d),p=x.useCallback(ee=>{m.current=ee,f(Z=>Z.key===ee.key&&Z.status===ee.status?Z:ee)},[]),g=x.useRef(""),y=x.useRef(""),_=x.useRef(null),w=x.useRef(null),k=x.useRef(null),T=x.useRef(null),N=x.useRef(0),A=x.useRef(0),S=x.useRef(0),P=x.useRef([]),C=x.useRef(0),j=x.useRef(!0),L=x.useRef(!1),W=()=>{try{const ee=globalThis,Z=(ee==null?void 0:ee.AudioContext)||(ee==null?void 0:ee.webkitAudioContext);if(!Z)return null;if(!_.current){const ke=new Z,Ee=ke.createGain();Ee.gain.value=1,Ee.connect(ke.destination),_.current=ke,w.current=Ee}const de=_.current,je=w.current;if(!de||!je)return null;try{de.state==="suspended"&&de.resume()}catch{}return{ctx:de,gain:je}}catch{return null}},V=x.useCallback(()=>{const ee=k.current;if(k.current=null,!!ee){try{ee.onended=null}catch{}try{ee.stop()}catch{}try{ee.disconnect()}catch{}}},[]),Q=x.useCallback(()=>{V(),S.current+=1,P.current=[],C.current=0,j.current=!0,L.current=!1,y.current="",g.current="",T.current=null,N.current=0,A.current=0,p({key:"",status:"idle"})},[V,p]);x.useEffect(()=>()=>{var ee,Z;Q();try{(ee=w.current)==null||ee.disconnect()}catch{}try{(Z=_.current)==null||Z.close()}catch{}_.current=null,w.current=null,T.current=null},[]);const me=async(ee,Z,de)=>{const je=S.current,ke=W();if(!ke)throw new Error("TTS playback is not supported in this browser");const{ctx:Ee,gain:Oe}=ke;try{Ee.state==="suspended"&&await Ee.resume()}catch{}if(je!==S.current)return;V();const qe=Ee.createBufferSource();qe.buffer=Z,qe.connect(Oe);const B=Number.isFinite(Number(Z.duration))?Number(Z.duration):0,pe=Math.max(0,Math.min(Number(de||0),B>0?Math.max(0,B-.01):0));A.current=Ee.currentTime-pe,N.current=pe,k.current=qe,g.current=ee,qe.onended=()=>{k.current===qe&&(k.current=null,N.current=0,A.current=0,g.current="",p({key:"",status:"idle"}))},qe.start(0,pe),p({key:ee,status:"playing"})},oe=(ee,Z)=>{if(Z!==S.current)return;const de=W();if(!de)return;const je=P.current,ke=C.current;if(ke>=je.length){j.current&&(g.current="",N.current=0,A.current=0,p({key:"",status:"idle"}));return}const Ee=je[ke],{ctx:Oe,gain:qe}=de;V();const B=Oe.createBufferSource();B.buffer=Ee,B.connect(qe);const pe=Number.isFinite(Number(Ee.duration))?Number(Ee.duration):0,Le=Math.max(0,Math.min(Number(N.current||0),pe>0?Math.max(0,pe-.01):0));A.current=Oe.currentTime-Le,k.current=B,g.current=ee,B.onended=()=>{Z===S.current&&k.current===B&&(k.current=null,C.current=ke+1,N.current=0,oe(ee,Z))};try{Oe.state==="suspended"&&Oe.resume()}catch{}B.start(0,Le),p({key:ee,status:"playing"})},X=async(ee,Z,de)=>{const je=W();if(!je){i==null||i("TTS playback is not supported in this browser.");return}V();const ke=++S.current;P.current=[],C.current=0,j.current=!1,L.current=!1,T.current=null,N.current=0,A.current=0,g.current=ee,y.current=ee,p({key:ee,status:"loading"}),i==null||i("");let Ee=null;try{for await(const Oe of de(Z)){if(ke!==S.current)return;let qe;try{qe=await Hl(je.ctx,Oe),Ee||(Ee=Sm(Oe))}catch{if(!Ee)continue;try{qe=await Hl(je.ctx,jm(Ee,Oe))}catch{continue}}if(ke!==S.current)return;P.current.push(qe),!k.current&&!L.current&&(y.current="",oe(ee,ke))}if(ke!==S.current)return;if(j.current=!0,P.current.length===0){i==null||i("TTS stream produced no audio."),Q();return}!k.current&&!L.current&&oe(ee,ke)}catch(Oe){if(ke!==S.current)return;i==null||i(String((Oe==null?void 0:Oe.message)||Oe||"TTS stream failed")),Q()}},le=x.useCallback(async(ee,Z)=>{const de=String(ee||"").trim(),je=String(Z||"").trim();if(!de||!je)return;const ke=r.current.tts,Ee=r.current.tts_stream;if(typeof ke!="function"&&typeof Ee!="function"){i==null||i("TTS is not available.");return}const Oe=W();if(!Oe){i==null||i("TTS playback is not supported in this browser.");return}const qe=m.current,B=qe.key===de;if(B&&qe.status==="playing"){if(k.current){const Le=Math.max(0,Oe.ctx.currentTime-Number(A.current||0));N.current=Le}else N.current=0;L.current=!0,V(),p({key:de,status:"paused"});return}if(B&&qe.status==="paused"){if(P.current.length>0){i==null||i(""),L.current=!1,p({key:de,status:"playing"}),oe(de,S.current);return}const Le=T.current;if(Le){i==null||i(""),L.current=!1;try{await me(de,Le,N.current)}catch(Ge){i==null||i(String((Ge==null?void 0:Ge.message)||Ge||"TTS play failed")),p({key:"",status:"idle"})}return}}if(B&&qe.status==="loading")return;if(typeof Ee=="function"){await X(de,je,Ee);return}V(),S.current+=1;const pe=S.current;P.current=[],C.current=0,j.current=!0,L.current=!1,T.current=null,N.current=0,A.current=0,g.current=de,y.current=de,p({key:de,status:"loading"}),i==null||i("");try{const Le=await ke(je);if(y.current!==de||S.current!==pe)return;const Ge=await Hl(Oe.ctx,Le);if(y.current!==de||S.current!==pe)return;T.current=Ge,N.current=0,await me(de,Ge,0)}catch(Le){if(S.current!==pe)return;y.current===de&&(y.current="",g.current="",p({key:"",status:"idle"})),i==null||i(String((Le==null?void 0:Le.message)||Le||"TTS failed"))}},[]),[H,ae]=x.useState(!1),[se,ye]=x.useState(!1),we=x.useRef(!1),J=x.useRef(c);J.current=c;const ne=x.useCallback(ee=>{we.current=ee,ae(Z=>Z===ee?Z:ee)},[]),U=x.useRef(!1),E=x.useRef(null),D=x.useRef(null),z=x.useRef([]),re=x.useRef(""),ce=x.useRef(0),ve=x.useRef(!1);function _e(){var ee,Z;try{(Z=(ee=E.current)==null?void 0:ee.getTracks)==null||Z.call(ee).forEach(de=>{try{de.stop()}catch{}})}catch{}E.current=null}const ie=x.useCallback(()=>{ce.current+=1,ve.current=!1;const ee=D.current;if(ee){ee.onstop=null,ee.ondataavailable=null,ee.onerror=null;try{ee.stop()}catch{}}D.current=null,_e(),ne(!1),U.current=!1,ye(!1),z.current=[]},[ne]);x.useEffect(()=>()=>ie(),[ie]);async function $e(ee,Z){var ke,Ee;if(i==null||i(""),!ee||!ee.size||U.current)return;const de=r.current.transcribe;if(typeof de!="function"){i==null||i("Transcription is not available.");return}U.current=!0;const je=ce.current;ye(!0);try{const Oe=String(await de(ee,Z)||"").trim();je===ce.current&&Oe&&((Ee=(ke=r.current).on_transcript)==null||Ee.call(ke,Oe))}catch(Oe){je===ce.current&&(i==null||i(String((Oe==null?void 0:Oe.message)||Oe||"Transcription failed")))}finally{je===ce.current&&(U.current=!1,ye(!1))}}const Ue=x.useCallback(async()=>{if(i==null||i(""),!J.current){i==null||i("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(U.current||ve.current||we.current||D.current)return;z.current=[];const ee=ce.current;ve.current=!0;try{const Z=await navigator.mediaDevices.getUserMedia({audio:!0});if(ee!==ce.current){Z.getTracks().forEach(ke=>ke.stop());return}E.current=Z;const de=km();re.current=de;const je=de?new MediaRecorder(Z,{mimeType:de}):new MediaRecorder(Z);D.current=je,je.ondataavailable=ke=>{if(ee===ce.current)try{ke!=null&&ke.data&&z.current.push(ke.data)}catch{}},je.onerror=()=>{ee===ce.current&&(i==null||i("Recording failed."))},je.onstop=()=>{if(ee===ce.current){ne(!1),_e(),D.current=null;try{const ke=new Blob(z.current,{type:re.current||""});$e(ke,re.current)}catch(ke){i==null||i(String((ke==null?void 0:ke.message)||ke||"Failed to build recording"))}}},je.start(),ne(!0)}catch(Z){if(ee!==ce.current)return;_e(),D.current=null,ne(!1);const de=String((Z==null?void 0:Z.message)||Z||"Failed to access microphone");i==null||i(de.toLowerCase().includes("permission")?`Microphone permission denied: ${de}`:de)}finally{ee===ce.current&&(ve.current=!1)}},[]),We=x.useCallback(()=>{const ee=D.current;if(!(!we.current||!ee)){ne(!1);try{ee.stop()}catch(Z){i==null||i(String((Z==null?void 0:Z.message)||Z||"Failed to stop recording"))}}},[]);return x.useEffect(()=>{if(!H)return;const ee=()=>We();return window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",ee),()=>{window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",ee)}},[H]),{tts_supported:a,tts_playback:d,toggle_tts:le,stop_tts:Q,voice_ptt_supported:c,voice_ptt_recording:H,voice_ptt_busy:se,start_voice_ptt_recording:Ue,stop_voice_ptt_recording:We,cancel_voice_ptt_recording:ie}}const Go=n=>Array.isArray(n)?n.map(r=>typeof r=="string"?r:(r==null?void 0:r.id)||(r==null?void 0:r.name)).filter(Boolean):[];function Cm({value:n,onChange:r,fetchCatalog:i}){var A,S,P,C;const a=x.useRef(i);a.current=i;const[c,d]=x.useState({}),[f,m]=x.useState(""),[p,g]=x.useState(!1);x.useEffect(()=>{let j=!0;return g(!0),d({}),m(""),a.current(n.provider,n.model).then(L=>{j&&(d(L),m(L.error?String(L.error):""))}).catch(L=>{j&&m(String((L==null?void 0:L.message)||L))}).finally(()=>{j&&g(!1)}),()=>{j=!1}},[n.provider,n.model]);const y=Array.isArray(c.items)?c.items:[...Array.isArray(c.profiles)?c.profiles.map(j=>({...j,voice_kind:"profile"})):[],...Array.isArray(c.voices)?c.voices.map(j=>({...j,voice_kind:"voice"})):[]],_=j=>JSON.stringify([j.provider||"",j.model||"",j.voice_kind==="profile"?"profile":"voice",j.id]),w=y.find(j=>j.id===(n.profile||n.voice)&&j.voice_kind==="profile"==!!n.profile&&(!n.provider||!j.provider||j.provider===n.provider)&&(!n.model||!j.model||j.model===n.model)),k=w?_(w):n.profile||n.voice?JSON.stringify([n.provider||"",n.model||"",n.profile?"profile":"voice",n.profile||n.voice]):"",T=y.filter(j=>(j==null?void 0:j.id)&&(!n.provider||!j.provider||j.provider===n.provider)).map(j=>({value:_(j),label:`${j.label||j.name||j.id}${!n.provider&&j.provider?` · ${j.provider}`:""}`}));k&&!T.some(j=>j.value===k)&&T.unshift({value:k,label:`${n.profile||n.voice} (saved)`});const N=j=>r({...n,...j});return o.jsxs("div",{className:"af-voice-settings",children:[o.jsx("p",{children:"Speech is generated by your authenticated Gateway. Leave routing and voice unset to use its defaults."}),o.jsx(dc,{value:{provider:n.provider||"",model:n.model||""},onChange:j=>r({...n,...j,voice:"",profile:""}),fetchProviders:async()=>{const j=await a.current();if(j.error&&!Go(j.tts_providers||j.providers).length)throw new Error(j.error);return Go(j.tts_providers||j.providers).map(L=>({name:L}))},fetchModels:async j=>{var W;const L=await a.current(j);return Go(((W=L.tts_models_by_provider)==null?void 0:W[j])||L.tts_models||L.models)},providerLabel:"Speech provider",modelLabel:"Speech model"}),o.jsxs("label",{children:["Voice / profile",o.jsx(Cr,{ariaLabel:"AI voice",placeholder:"Gateway / provider default",value:k,disabled:p,options:[{value:"",label:"Gateway / provider default"},...T],onChange:j=>{if(!j){N({voice:"",profile:""});return}const[L,W,V,Q]=JSON.parse(j);N({provider:L||n.provider||"",model:W||(L&&L!==n.provider?"":n.model)||"",voice:V==="voice"?Q:"",profile:V==="profile"?Q:""})}})]}),p?o.jsx("p",{role:"status",children:"Loading available voices…"}):null,f?o.jsxs("p",{role:"alert",children:["Voice discovery unavailable: ",f,". Your saved choice is preserved."]}):null,o.jsxs("label",{children:["Speaking speed",o.jsxs("select",{"aria-label":"Speech speed",value:n.speed??"",onChange:j=>N({speed:j.target.value?Number(j.target.value):void 0}),children:[o.jsx("option",{value:"",children:"Gateway default"}),[.5,.75,1,1.25,1.5,2].map(j=>o.jsxs("option",{value:j,children:[j,"×"]},j))]})]}),(S=(A=c.controls)==null?void 0:A.quality_preset)!=null&&S.supported?o.jsxs("label",{children:["Quality",o.jsxs("select",{"aria-label":"Speech quality",value:n.quality_preset||"",onChange:j=>N({quality_preset:j.target.value}),children:[o.jsx("option",{value:"",children:"Gateway default"}),Go(c.controls.quality_preset.values).map(j=>o.jsx("option",{value:j,children:j},j))]})]}):null,(C=(P=c.controls)==null?void 0:P.instructions)!=null&&C.supported?o.jsxs("label",{children:["Delivery instructions",o.jsx("textarea",{"aria-label":"Voice delivery instructions",rows:3,placeholder:"For example: calm, clear, and conversational",value:n.instructions||"",onChange:j=>N({instructions:j.target.value})})]}):null,o.jsx("button",{type:"button",onClick:()=>r({}),children:"Reset to Gateway defaults"})]})}function Ef(n){const r=String(n??"").trim();if(!r||!(r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]")))return null;try{return JSON.parse(r)}catch{return null}}function Nm(n){if(n==null)return"";if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Em(n){const r=String(n.role||"message").trim()||"message",i=String(n.title||"").trim(),a=String(n.ts||"").trim(),c=[r];return i&&c.push(i),a&&c.push(a),c.join(" · ")}function $m(n){return n.endsWith(`
41
+ `)?n:`${n}
42
+ `}function Tm(n){return String(n||"").trimStart().startsWith("```")}function Rm(n,r){const a=[`# ${"Chat".trim()||"Chat"}`,""];for(const c of n){const d=Em(c);a.push(`## ${d}`,"");const f=String(c.content||""),m=Ef(f);m!==null&&!Tm(f)?a.push("```json",Nm(m).trimEnd(),"```",""):a.push($m(f).trimEnd(),""),a.push("---","")}for(;a.length&&!a[a.length-1].trim();)a.pop();return a.length&&a[a.length-1]==="---"&&a.pop(),`${a.join(`
43
+ `).trimEnd()}
44
+ `}async function fc(n){const r=String(n||"");if(!r)return!1;try{return await navigator.clipboard.writeText(r),!0}catch{try{const i=document.createElement("textarea");return i.value=r,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i),!0}catch{return!1}}}function Am(n){const r=String(n.filename).trim()||"export.txt",i=String(n.text||""),a=String(n.mime||"text/plain;charset=utf-8"),c=new Blob([i],{type:a}),d=URL.createObjectURL(c),f=document.createElement("a");f.href=d,f.download=r,document.body.appendChild(f),f.click(),f.remove(),window.setTimeout(()=>URL.revokeObjectURL(d),1e3)}const Mm=3,Im=Number.MAX_SAFE_INTEGER;function $f(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Tf(n){return Array.isArray(n)}function Pm(n){if(n==null)return"";if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Ds({kind:n,children:r}){return o.jsx("span",{className:`pc-json-token ${n}`,children:r})}function Lm(n){const r=JSON.stringify(n.value),i=r.length>96||r.includes("\\n")||r.includes("\\r")||r.includes("\\t"),[a,c]=x.useState(!i||n.expansionMode==="unfolded");return x.useEffect(()=>{i&&c(n.expansionMode==="unfolded")},[i,n.expansionMode,n.expansionVersion]),i?o.jsxs("span",{className:`pc-json-string ${a?"open":"collapsed"}`,children:[o.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>c(d=>!d),"aria-label":a?"Collapse string value":"Expand string value","aria-expanded":a,children:a?"▾":"▸"}),a?o.jsx("span",{className:"pc-json-token string pc-json-string__value",children:r}):o.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>c(!0),"aria-label":"Expand string value",children:[o.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:r}),o.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):o.jsx(Ds,{kind:"string",children:r})}function Om(n,r,i){return n===null?o.jsx(Ds,{kind:"null",children:"null"}):typeof n=="string"?o.jsx(Lm,{value:n,expansionMode:r,expansionVersion:i}):typeof n=="number"?o.jsx(Ds,{kind:"number",children:String(n)}):typeof n=="boolean"?o.jsx(Ds,{kind:"boolean",children:n?"true":"false"}):o.jsx(Ds,{kind:"string",children:JSON.stringify(String(n))})}function zm(n){return Tf(n)?n.length===1?"1 item":`${n.length} items`:$f(n)?Object.keys(n).length===1?"1 key":`${Object.keys(n).length} keys`:""}function Rf(n){const{label:r,value:i,depth:a,collapseAfterDepth:c,expansionMode:d,expansionVersion:f,trailingComma:m}=n,p=a*14,g=$f(i),y=Tf(i),_=g||y,w=a<c,[k,T]=x.useState(w);x.useEffect(()=>{T(w)},[w,f]);const N=r?o.jsxs(o.Fragment,{children:[o.jsx(Ds,{kind:"key",children:JSON.stringify(r)}),": "]}):null;if(!_)return o.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[N,Om(i,d,f),m?",":""]});const A=y?"[":"{",S=y?"]":"}",P=zm(i),C=k?`${A}`:`${A}…${S}${P?` (${P})`:""}`,j=y?i.map((L,W)=>({key:String(W),label:void 0,value:L})):Object.entries(i).map(([L,W])=>({key:L,label:L,value:W}));return o.jsxs("details",{className:"pc-json-viewer__details",open:k,onToggle:L=>T(L.currentTarget.open),children:[o.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:p},children:[N,o.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:k?"▾":"▸"}),o.jsx("span",{className:"pc-json-viewer__punct",children:C}),!k&&m?o.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),k?o.jsx("div",{className:"pc-json-viewer__children",children:j.length===0?o.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[o.jsx("span",{className:"pc-json-viewer__punct",children:S}),m?",":""]}):o.jsxs(o.Fragment,{children:[j.map((L,W)=>{const V=W===j.length-1;return o.jsx(Rf,{label:L.label,value:L.value,depth:a+1,collapseAfterDepth:c,expansionMode:d,expansionVersion:f,trailingComma:!V},`${a}:${r||"root"}:${L.key}`)}),o.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[o.jsx("span",{className:"pc-json-viewer__punct",children:S}),m?",":""]})]})}):null]})}function Fm(n){const r=n.trim();if(!r)return n;if(r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]"))try{return JSON.parse(r)}catch{return n}return n}function Us(n){const{value:r,className:i,showCopy:a=!0}=n,[c,d]=x.useState({mode:"folded",version:0}),f=typeof n.collapseAfterDepth=="number"&&(Number.isFinite(n.collapseAfterDepth)||n.collapseAfterDepth===1/0)&&n.collapseAfterDepth>=0?n.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(n.collapseAfterDepth):Mm,m=c.mode==="unfolded"?Im:f,p=x.useMemo(()=>typeof r=="string"?Fm(r):r,[r]),g=x.useMemo(()=>Pm(r),[r]),y=["pc-json-viewer",i].filter(Boolean).join(" ");x.useEffect(()=>{d(w=>({mode:"folded",version:w.version+1}))},[p]);const _=()=>{d(w=>({mode:w.mode==="unfolded"?"folded":"unfolded",version:w.version+1}))};return o.jsxs("div",{className:y,children:[o.jsxs("div",{className:"pc-json-viewer__toolbar",children:[o.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:_,"aria-expanded":c.mode==="unfolded",children:c.mode==="unfolded"?"Fold all":"Unfold all"}),a?o.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void fc(g),children:"Copy JSON"}):null]}),o.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:o.jsx(Rf,{value:p,depth:0,collapseAfterDepth:m,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function bi(n,r){const i=String(n??"");if(!r||!r.needles.length)return[i];const a=[],c=i.toLowerCase();let d=0;for(;d<i.length;){let f=-1,m="";for(let y=0;y<r.needlesLower.length;y++){const _=r.needlesLower[y];if(!_)continue;const w=c.indexOf(_,d);if(w===-1)continue;const k=r.needles[y]||"";k&&(f===-1||w<f||w===f&&k.length>m.length)&&(f=w,m=k)}if(f===-1||!m){a.push(i.slice(d));break}f>d&&a.push(i.slice(d,f));const p=r.hits===0&&r.id?r.id:void 0,g=i.slice(f,f+m.length);a.push(o.jsx("span",{id:p,className:r.className,children:g},`hl:${r.hits}`)),r.hits+=1,d=f+m.length}return a}function ic(n){const r=String(n||"").trim();if(r&&/^(https?:|mailto:|tel:|#|\/)/i.test(r))return r}function br(n,r){const i=[],a=String(n??"");let c=0,d="";const f=()=>{if(d){for(const m of bi(d,r))i.push(m);d=""}};for(;c<a.length;){const m=a[c];if(m==="!"&&a[c+1]==="["){const p=a.indexOf("]",c+2);if(p!==-1&&a[p+1]==="("){const g=a.indexOf(")",p+2);if(g!==-1){const y=a.slice(c+2,p),_=ic(a.slice(p+2,g));if(_){f(),i.push(o.jsxs("span",{className:"pc-md_image_inline",children:[o.jsx("img",{className:"pc-md_img",src:_,alt:y,loading:"lazy"}),y?o.jsx("span",{className:"pc-md_img_caption",children:r?bi(y,r):y}):null]},`img:${c}`)),c=g+1;continue}}}}if(m==="["){const p=a.indexOf("]",c+1);if(p!==-1&&a[p+1]==="("){const g=a.indexOf(")",p+2);if(g!==-1){const y=a.slice(c+1,p),_=ic(a.slice(p+2,g));if(_){f(),i.push(o.jsx("a",{className:"pc-md_link",href:_,target:_.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:br(y,r)},`link:${c}`)),c=g+1;continue}}}}if(m==="`"){const p=a.indexOf("`",c+1);if(p!==-1){f();const g=a.slice(c+1,p);i.push(o.jsx("code",{children:r?bi(g,r):g},`code:${c}`)),c=p+1;continue}}if(m==="*"&&a[c+1]==="*"){const p=a.indexOf("**",c+2);if(p!==-1){f();const g=a.slice(c+2,p);i.push(o.jsx("strong",{children:r?bi(g,r):g},`bold:${c}`)),c=p+2;continue}}if(m==="*"&&a[c+1]!=="*"){const p=a.indexOf("*",c+1);if(p!==-1){f();const g=a.slice(c+1,p);i.push(o.jsx("em",{children:r?bi(g,r):g},`em:${c}`)),c=p+1;continue}}d+=m,c+=1}return f(),i}function Dm(n){return String(n??"").replace(/\r\n/g,`
45
+ `).replace(/\r/g,`
46
+ `).split(`
47
+ `)}function qo(n){const i=String(n??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return i?{indent:i[1].replace(/\t/g," ").length,ordered:!!i[3],start:i[3]?Math.max(1,parseInt(i[3],10)||1):1,content:i[4]??""}:null}function Bm(n){const r=[];for(const c of n){const d=qo(c);d?r.push(d):r.length>0&&c.trim()&&(r[r.length-1].content+=` ${c.trim()}`)}const i=[],a=[];for(const c of r){for(;a.length>0&&c.indent<a[a.length-1].indent;)a.pop();let d=a.length>0?a[a.length-1]:null;if(d&&c.indent>d.indent){const f=d.node.items,m=f[f.length-1];if(m){const p={ordered:c.ordered,start:c.start,items:[]};m.children.push(p),a.push({indent:c.indent,node:p}),d=a[a.length-1]}}else if(d&&d.node.ordered!==c.ordered){a.pop();const f=a.length>0?a[a.length-1]:null,m={ordered:c.ordered,start:c.start,items:[]};if(f){const p=f.node.items,g=p[p.length-1];g?g.children.push(m):f.node.items.push({content:"",children:[m]})}else i.push(m);a.push({indent:c.indent,node:m}),d=a[a.length-1]}if(!d){const f={ordered:c.ordered,start:c.start,items:[]};i.push(f),a.push({indent:c.indent,node:f}),d=a[a.length-1]}d.node.items.push({content:c.content,children:[]})}return i}function Af(n,r,i){const a=n.items.map((c,d)=>o.jsxs("li",{children:[br(c.content,r),c.children.map((f,m)=>Af(f,r,`${i}:${d}:${m}`))]},`${i}:li:${d}`));return n.ordered?o.jsx("ol",{className:"pc-md_ol",start:n.start!==1?n.start:void 0,children:a},i):o.jsx("ul",{className:"pc-md_ul",children:a},i)}function Um(n,r,i){return Bm(n).map((a,c)=>Af(a,r,`${i}:${c}`))}function Qd(n){let r=String(n??"").trim();return r?(r.startsWith("|")&&(r=r.slice(1)),r.endsWith("|")&&(r=r.slice(0,-1)),r.split("|").map(i=>String(i??"").trim())):[]}function Jd(n){let r=String(n??"").trim();if(!r)return!1;r.startsWith("|")&&(r=r.slice(1)),r.endsWith("|")&&(r=r.slice(0,-1));const i=r.split("|").map(a=>String(a??"").trim());return i.length<2?!1:i.every(a=>/^:?-{3,}:?$/.test(a))}function Wm({text:n,className:r,highlight:i,highlights:a,highlightClassName:c,highlightId:d}){const f=Dm(n),m=[],p=[];Array.isArray(a)&&p.push(...a),typeof i=="string"&&i.trim()&&p.push(i);const g=Array.from(new Set(p.map(k=>String(k??"").trim()).filter(Boolean))).filter(k=>k.length>=4),y=g.length?{needles:g,needlesLower:g.map(k=>k.toLowerCase()),className:c||"pc-md_hl",id:d,hits:0}:null;let _=0;for(;_<f.length;){const k=String(f[_]??"");if(!k.trim()){_+=1;continue}const T=k.trim();if(/^([-_*])(\s*\1){2,}$/.test(T)){m.push(o.jsx("hr",{className:"pc-md_hr"},`hr:${_}`)),_+=1;continue}const N=k.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(N){const P=ic(N[2]||"");if(P){const C=N[1]||"";m.push(o.jsxs("figure",{className:"pc-md_figure",children:[o.jsx("img",{className:"pc-md_img",src:P,alt:C,loading:"lazy"}),C?o.jsx("figcaption",{children:br(C,y)}):null]},`figure:${_}`)),_+=1;continue}}if(k.trim().startsWith("```")){const C=k.trim().replace(/```/g,"").trim(),j=[];for(_+=1;_<f.length&&!String(f[_]??"").trim().startsWith("```");)j.push(String(f[_]??"")),_+=1;_<f.length&&(_+=1);const L=j.join(`
48
+ `);m.push(o.jsx("pre",{className:"pc-md_pre",children:o.jsx("code",{className:C?`language-${C}`:void 0,children:L})},`pre:${_}`));continue}const A=k.match(/^(#{1,5})\s+(.*)$/);if(A){const P=A[1].length,C=A[2]||"",j=br(C,y);P===1?m.push(o.jsx("h1",{children:j},`h1:${_}`)):P===2?m.push(o.jsx("h2",{children:j},`h2:${_}`)):P===3?m.push(o.jsx("h3",{children:j},`h3:${_}`)):P===4?m.push(o.jsx("h4",{children:j},`h4:${_}`)):m.push(o.jsx("h5",{children:j},`h5:${_}`)),_+=1;continue}if(k.trimStart().startsWith(">")){const P=[];for(;_<f.length&&String(f[_]??"").trimStart().startsWith(">");){const j=String(f[_]??"").trimStart();P.push(j.replace(/^>\s?/,"")),_+=1}m.push(o.jsx("blockquote",{className:"pc-md_quote",children:P.map((C,j)=>o.jsxs(_t.Fragment,{children:[br(C,y),j<P.length-1?o.jsx("br",{}):null]},`q:${_}:${j}`))},`quote:${_}`));continue}if(k.includes("|")&&_+1<f.length&&Jd(String(f[_+1]??""))){const P=Qd(k),C=Math.max(1,P.length),j=[];for(_+=2;_<f.length;){const L=String(f[_]??"");if(!L.trim()||!L.includes("|"))break;const W=Qd(L),V=[];for(let Q=0;Q<C;Q++)V.push(W[Q]??"");j.push(V),_+=1}m.push(o.jsx("div",{className:"pc-md_table_wrap",children:o.jsxs("table",{className:"pc-md_table",children:[o.jsx("thead",{children:o.jsx("tr",{children:P.slice(0,C).map((L,W)=>o.jsx("th",{children:br(L,y)},`th:${_}:${W}`))})}),o.jsx("tbody",{children:j.map((L,W)=>o.jsx("tr",{children:L.map((V,Q)=>o.jsx("td",{children:br(V,y)},`td:${_}:${W}:${Q}`))},`tr:${_}:${W}`))})]})},`table:${_}`));continue}if(qo(k)){const P=[];for(;_<f.length;){const C=String(f[_]??"");if(!C.trim()||C.trimStart().startsWith("```"))break;if(qo(C)||/^\s{2,}\S/.test(C)){P.push(C),_+=1;continue}break}m.push(o.jsx(_t.Fragment,{children:Um(P,y,`list:${_}`)},`list:${_}`));continue}const S=[];for(;_<f.length&&String(f[_]??"").trim()&&!(S.length>0&&qo(String(f[_]??"")));){const P=String(f[_]??"");if(S.length>0&&P.includes("|")&&_+1<f.length&&Jd(String(f[_+1]??"")))break;S.push(P),_+=1}m.push(o.jsx("p",{className:"pc-md_p",children:S.map((P,C)=>o.jsxs(_t.Fragment,{children:[br(P,y),C<S.length-1?o.jsx("br",{}):null]},`pl:${_}:${C}`))},`p:${_}`))}const w=["pc-md",r].filter(Boolean).join(" ");return o.jsx("div",{className:w,children:m})}function Vm(n){const r=String(n.text??""),i=x.useMemo(()=>Ef(r),[r]),a=["pc-chat-content",n.className].filter(Boolean).join(" ");return i!==null?o.jsx("div",{className:a,children:o.jsx(Us,{value:i,collapseAfterDepth:n.jsonCollapseAfterDepth})}):n.renderMarkdown?o.jsx("div",{className:a,children:n.renderMarkdown(r)}):o.jsx("div",{className:a,children:o.jsx(Wm,{text:r})})}function Mf(n){if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}}function If(n){const r=Mf(n);if(!r||typeof r!="object"||Array.isArray(r))return{label:"input",value:r==null?"":String(r)};const i=Object.entries(r),c=["command","query","url","file_path","path","pattern","name"].map(d=>i.find(([f])=>f===d)).find(Boolean)||i[0];return c?{label:c[0].replace(/_/g," "),value:typeof c[1]=="string"?c[1]:JSON.stringify(c[1])??""}:{label:"",value:""}}function Pf({tool:n,showCopy:r=!0}){const[i,a]=x.useState(!1),c=Mf(n.arguments),d=If(n.arguments),f=["file path","path"].includes(d.label)&&d.value.length>60?`${d.value.split(/[\\/]/).pop()} · ${d.value.slice(0,24)}…`:d.value,m=n.error&&/^File ['"].+['"] does not exist\.?$/.test(n.error)?"File not found. Expand for the exact path.":n.error&&n.error.length>180?`${n.error.slice(0,100)}…${n.error.slice(-70)}`:n.error,p={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},g=n.startedAt&&n.endedAt?Date.parse(n.endedAt)-Date.parse(n.startedAt):NaN,y=c&&typeof c=="object"&&!Array.isArray(c)?Object.entries(c):null;return o.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${n.status}`,children:[o.jsxs("summary",{className:"pc-tool-activity__summary",children:[o.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:o.jsx(fe,{name:n.status==="completed"?"check":n.status==="failed"?"x":n.status==="waiting"?"warning":"loader",size:15})}),o.jsx("strong",{children:n.name}),o.jsx("span",{className:"pc-tool-activity__preview",title:d.value,children:d.value?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"pc-tool-activity__key",children:d.label}),f]}):"No parameters"}),o.jsx("span",{className:"pc-tool-activity__status",children:p[n.status]}),Number.isFinite(g)&&g>=0?o.jsxs("span",{className:"pc-tool-activity__duration",children:[(g/1e3).toFixed(1),"s"]}):null,o.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:o.jsx(fe,{name:"chevronRight",size:13})}),n.error?o.jsx("span",{className:"pc-tool-activity__error",title:n.error,children:m}):null]}),o.jsxs("div",{className:"pc-tool-activity__detail",children:[n.error?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Error"}),o.jsx("pre",{className:"pc-tool-activity__output",children:n.error})]}):null,o.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[o.jsx("h4",{children:"Parameters"}),r?o.jsxs("button",{type:"button",onClick:async()=>a(await fc(JSON.stringify(n,null,2))),children:[o.jsx(fe,{name:"copy",size:13}),i?"Copied":"Copy details"]}):null]}),y?o.jsx("dl",{className:"pc-tool-activity__parameters",children:y.map(([_,w])=>o.jsxs(_t.Fragment,{children:[o.jsx("dt",{children:_}),o.jsx("dd",{children:w&&typeof w=="object"?o.jsx(Us,{value:w}):o.jsx("code",{children:typeof w=="string"?w:JSON.stringify(w)})})]},_))}):n.arguments===void 0?o.jsx("p",{children:"Arguments are unavailable in this ledger."}):o.jsx(Us,{value:c}),n.output!==void 0?o.jsxs(o.Fragment,{children:[o.jsx("h4",{children:"Result"}),typeof n.output=="string"?o.jsx("pre",{className:"pc-tool-activity__output",children:n.output}):o.jsx("div",{className:"pc-tool-activity__output",children:o.jsx(Us,{value:n.output})})]}):null]})]})}function Lf({tools:n,showCopy:r}){const i=a=>n.filter(c=>c.status===a).length;return o.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[o.jsxs("div",{className:"pc-tool-group__heading",children:[o.jsx(fe,{name:"terminal",size:14}),o.jsx("strong",{children:"Tools"}),o.jsxs("span",{children:[n.length," ",n.length===1?"call":"calls"]}),o.jsx("div",{}),i("running")?o.jsxs("span",{className:"pc-tool-group__running",children:[i("running")," running"]}):null,i("waiting")?o.jsxs("span",{className:"pc-tool-group__waiting",children:[i("waiting")," need approval"]}):null,i("failed")?o.jsxs("span",{className:"pc-tool-group__failed",children:[i("failed")," failed"]}):null,i("completed")?o.jsxs("span",{className:"pc-tool-group__completed",children:[i("completed")," done"]}):null]}),n.map(a=>o.jsx(Pf,{tool:a,showCopy:r},a.id))]})}const bt="not reported",Bt=n=>n===void 0?bt:Math.round(n).toLocaleString(),Zt=n=>{if(n===void 0)return bt;if(n<6e4)return`${(n/1e3).toFixed(1)}s`;const r=Math.round(n/1e3);return`${Math.floor(r/60)}m ${String(r%60).padStart(2,"0")}s`},Of=n=>n===void 0?bt:`${Math.round(n).toLocaleString()} tok/s`,Hm=(n,r)=>r>0?`${Math.round(n/r*100)}%`:"",Xr=(n,r,i=`${r}s`)=>`${n.toLocaleString()} ${n===1?r:i}`,Gm=n=>{const r=n.split("#")[0].replace(/\/+$/,"");return r.slice(r.lastIndexOf("/")+1)||n};function Km(n){const r=new Map;for(const i of n)i&&r.set(i,(r.get(i)||0)+1);return[...r].map(([i,a])=>a>1?`${i} ×${a}`:i).join(" · ")}function ta(n){const r=[],i=(n.models||[]).map(Gm),a=n.providers||[];return(i.length||a.length)&&r.push([i.join(", ")||"model not reported",a.join(", ")].filter(Boolean).join(" · ")),r.push("From the run ledger; summed across this turn and its child runs."),r}function Qm(n){const r=n.modelCalls||[],i=[],a=[{label:"Input",value:Bt(n.inputTokens)},{label:"Output",value:Bt(n.outputTokens)}];if(n.reasoningTokens!==void 0&&a.push({label:"Reasoning",value:Bt(n.reasoningTokens),hint:"part of output"}),a.push({label:"Total",value:Bt(n.totalTokens)}),i.push({heading:`Usage · ${Xr(n.llmCalls,"model call")}`,rows:a}),n.measuredCacheCalls){const d=n.cachedTokens||0,f=n.fedTokens||0,m=[{label:"Reused from cache",value:`${Bt(d)}${d+f?` (${Hm(d,d+f)})`:""}`},{label:"Newly processed",value:Bt(n.fedTokens)},{label:"Outcome",value:Km(r.map(p=>p.cacheOutcome))||(n.cacheOutcomes||[]).join(" · ")||bt},{label:"Backend",value:(n.cacheBackends||[]).join(", ")||bt}];n.measuredCacheCalls!==n.llmCalls&&m.push({label:"Measured on",value:`${n.measuredCacheCalls} of ${n.llmCalls} calls`}),i.push({heading:"Prompt cache",rows:m})}else n.llmCalls&&i.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:bt}]});const c=r.filter(d=>d.inputTokens!==void 0);return c.length===1&&r.length===1?i.push({heading:"Context",rows:[{label:"Prompt size",value:`${Bt(c[0].inputTokens)} tokens`}]}):c.length>1&&i.push({heading:"Context",rows:[{label:"First → last call",value:`${Bt(c[0].inputTokens)} → ${Bt(c[c.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),r.length>1&&i.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:r.map((d,f)=>[String(f+1),Bt(d.inputTokens),d.cachedTokens===void 0?"—":Bt(d.cachedTokens),d.fedTokens===void 0?"—":Bt(d.fedTokens),Bt(d.outputTokens),d.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:n.totalTokens===void 0?bt:`${n.totalTokens.toLocaleString()} total`,sections:i,footer:ta(n)}}function Ko(n,r,i,a){if(n===void 0)return bt;const c=[Zt(n)];return r!==void 0&&c.push(`${r.toLocaleString()} ${a}${i!==void 0?` at ${Of(i)}`:""}`),c.join(" · ")}function Jm(n){var g,y,_;const r=n.modelCalls||[],i=[],a=n.durationMs,c=[{label:"Wall clock",value:Zt(a)}];if(c.push({label:"Model",value:n.genTimeMs===void 0?bt:`${Zt(n.genTimeMs)} · ${Xr(n.timedCalls||0,"call")}${n.timedCalls!==n.llmCalls?` (of ${n.llmCalls})`:""}`}),c.push({label:"Tools",value:n.toolTimeMs!==void 0?`${Zt(n.toolTimeMs)} · ${Xr(n.toolBatches||0,"batch","batches")}`:n.toolCalls?bt:"none",hint:n.toolTimeIncludesApproval?"includes approval wait":void 0}),a!==void 0&&n.genTimeMs!==void 0){const w=a-n.genTimeMs-(n.toolTimeMs||0);c.push({label:"Orchestration",value:w>=0?Zt(w):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}i.push({heading:"Turn",rows:c});const d=[],f=n.ttftCalls||0,m=n.promptPhaseCalls||0;n.promptPhaseMs!==void 0?d.push({label:f&&f===m?"Prefill (TTFT)":"Prefill",value:Ko(n.promptPhaseMs,n.promptPhaseNewTokens,n.promptPhaseTokensPerSecond,"new tok"),hint:f===m?"measured time to first token":f?`TTFT measured on ${f} of ${m}; rest from provider rate`:"derived: prompt ÷ provider rate"}):n.prefillMs!==void 0&&n.prefillNewTokensPerSecond!==void 0?d.push({label:"Prefill",value:Ko(n.prefillMs,n.prefillNewTokens,n.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):n.prefillMs!==void 0?d.push({label:"Prefill",value:`${Zt(n.prefillMs)}${n.promptTokensPerSecond!==void 0?` at ${Of(n.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):d.push({label:"Prefill",value:bt}),n.cachedTokens&&(n.promptPhaseMs??n.prefillMs)!==void 0&&d.push({label:"Restored",value:`${n.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),d.push({label:"Generation",value:n.generationPhaseMs!==void 0?Ko(n.generationPhaseMs,n.generationPhaseTokens,n.generationPhaseTokensPerSecond,"tok"):Ko(n.decodeMs,n.outputTokens,n.generationTokensPerSecond,"tok")}),n.measuredSpeedCalls&&n.measuredSpeedCalls!==n.llmCalls&&d.push({label:"Speeds from",value:`${n.measuredSpeedCalls} of ${n.llmCalls} calls`}),i.push({heading:"Model",rows:d});const p=n.speculation;if(p){const w=(p.draftKinds||[]).map(T=>T.toUpperCase()).join(", "),k=[{label:"Mode",value:`${p.used?"on":"off"}${w?` · ${w}`:""}${(g=p.modes)!=null&&g.length?` (${p.modes.join(", ")})`:""}`,hint:p.calls!==n.llmCalls||p.used!==p.calls?`used on ${p.used} of ${n.llmCalls} calls`:void 0},{label:"Acceptance",value:p.acceptanceRate===void 0?bt:`${Math.round(p.acceptanceRate*100)}% · ${Bt(p.acceptedTokens)} of ${Bt(p.draftedTokens)} drafted`}];((y=p.draftLengths)!=null&&y.length||p.rounds!==void 0)&&k.push({label:"Draft length",value:`${(_=p.draftLengths)!=null&&_.length?`${p.draftLengths.join("/")} tok/round`:bt}${p.rounds!==void 0?` · ${p.rounds.toLocaleString()} rounds`:""}`}),i.push({heading:"Speculation",rows:k})}return n.slowestToolBatch&&i.push({heading:"Tools",rows:[{label:"Total",value:`${Zt(n.toolTimeMs)} · ${Xr(n.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Zt(n.slowestToolBatch.ms)} · ${zf(n.slowestToolBatch)}`}],note:n.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),r.length>1&&i.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:r.map((w,k)=>[String(k+1),w.promptMs===void 0?"—":`${Zt(w.promptMs)}${w.promptSource==="rate"?"*":""}`,w.promptNewTokensPerSecond===void 0?"—":Math.round(w.promptNewTokensPerSecond).toLocaleString(),w.generationMs===void 0?"—":Zt(w.generationMs),w.generationTokensPerSecond===void 0?"—":Math.round(w.generationTokensPerSecond).toLocaleString(),w.cacheOutcome||"—"])},note:r.some(w=>w.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:a===void 0?bt:`${Zt(a)} wall clock`,sections:i,footer:ta(n)}}function zf(n){return n.tools.length===1?`${n.tools[0]} ×${n.calls}`:`${Xr(n.calls,"call")} (${n.tools.join(", ")})`}function Ym(n){const r=[],i=(n.toolsWaiting||0)+(n.toolsRunning||0);if(!n.toolCalls&&!i)return r.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:r,footer:ta(n)};const a=[{label:"Succeeded",value:(n.toolCalls-(n.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(n.toolsFailed||0).toLocaleString()}];n.toolsRunning&&a.push({label:"Running",value:n.toolsRunning.toLocaleString()}),n.toolsWaiting&&a.push({label:"Awaiting approval",value:n.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),r.push({heading:"Outcome",rows:a});const c=Object.entries(n.toolBreakdown||{}).sort((m,p)=>p[1].calls-m[1].calls||m[0].localeCompare(p[0]));c.length&&r.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:c.map(([m,p])=>[m,p.calls.toLocaleString(),p.failed.toLocaleString(),p.ms!==void 0?`${Zt(p.ms)}${p.sharedBatches?" +shared":""}`:p.sharedBatches?"shared":bt])},note:c.some(([,m])=>m.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const d=c.filter(([,m])=>m.errors&&Object.keys(m.errors).length);d.length&&r.push({heading:"Failures",rows:d.map(([m,p])=>({label:m,value:Object.entries(p.errors).sort((g,y)=>y[1]-g[1]).map(([g,y])=>y>1?`${g} ×${y}`:g).join(" · ")}))});const f=[{label:"Tool time",value:n.toolTimeMs===void 0?bt:`${Zt(n.toolTimeMs)} · ${Xr(n.toolBatches||0,"batch","batches")}`}];return n.slowestToolBatch&&f.push({label:"Slowest batch",value:`${Zt(n.slowestToolBatch.ms)} · ${zf(n.slowestToolBatch)}`}),r.push({heading:"Timing",rows:f,note:n.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Xr(n.toolCalls,"call")}${n.toolsFailed?` · ${n.toolsFailed} failed`:""}`,sections:r,footer:ta(n)}}function Gl(n,r){return n==="tokens"?Qm(r):n==="time"?Jm(r):Ym(r)}function Xm(n){const r=n.detail;return o.jsxs("div",{ref:n.panelRef,id:n.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${r.kind}`,style:n.style,onMouseEnter:n.onMouseEnter,onMouseLeave:n.onMouseLeave,children:[o.jsxs("div",{className:"pc-stat-detail-head",children:[o.jsx("span",{className:"pc-stat-detail-title",children:r.title}),o.jsx("span",{className:"pc-stat-detail-headline",children:r.headline})]}),r.sections.map(i=>{var a;return o.jsxs("div",{className:"pc-stat-detail-section",children:[o.jsx("div",{className:"pc-stat-detail-heading",children:i.heading}),(a=i.rows)!=null&&a.length?o.jsx("dl",{className:"pc-stat-detail-rows",children:i.rows.map(c=>o.jsxs(_t.Fragment,{children:[o.jsx("dt",{children:c.label}),o.jsxs("dd",{children:[o.jsx("span",{className:c.value===bt?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:c.value}),c.hint?o.jsx("span",{className:"pc-stat-detail-hint",children:c.hint}):null]})]},c.label))}):null,i.table?o.jsxs("table",{className:"pc-stat-detail-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:i.table.columns.map(c=>o.jsx("th",{scope:"col",children:c},c))})}),o.jsx("tbody",{children:i.table.rows.map((c,d)=>o.jsx("tr",{children:c.map((f,m)=>o.jsx("td",{children:f},m))},d))})]}):null,i.note?o.jsx("p",{className:"pc-stat-detail-note",children:i.note}):null]},i.heading)}),o.jsx("div",{className:"pc-stat-detail-foot",children:r.footer.map(i=>o.jsx("div",{children:i},i))})]})}const Zn=8;function Zm(n){const[r,i]=x.useState(!!n.defaultOpen),[a,c]=x.useState(null),d=x.useRef(null),f=x.useRef(null),m=x.useRef(null),p=`pc-stat-${x.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,g=x.useCallback(()=>{m.current!==null&&window.clearTimeout(m.current),m.current=null},[]),y=x.useCallback(()=>{g(),i(!0)},[g]),_=x.useCallback(()=>{g(),m.current=window.setTimeout(()=>i(!1),120)},[g]);x.useEffect(()=>g,[g]),x.useLayoutEffect(()=>{if(!r){c(null);return}const N=()=>{const A=d.current,S=f.current;if(!A||!S)return;const P=A.getBoundingClientRect(),C=S.offsetWidth,j=S.offsetHeight,L=window.innerWidth,W=window.innerHeight,V=P.top-Zn-j,Q=P.bottom+Zn,me=V>=Zn?V:Q+j<=W-Zn?Q:Math.max(Zn,W-Zn-j),oe=Math.min(Math.max(Zn,P.left),Math.max(Zn,L-Zn-C));c({top:me,left:oe})};return N(),window.addEventListener("resize",N),window.addEventListener("scroll",N,!0),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0)}},[r]),x.useEffect(()=>{if(!r)return;const N=A=>{A.key==="Escape"&&i(!1)};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[r]);const w=typeof n.onClick=="function",k=w?"button":"span",T=r?o.jsx(Xm,{detail:n.detail,id:p,panelRef:f,onMouseEnter:g,onMouseLeave:_,style:{position:"fixed",top:(a==null?void 0:a.top)??0,left:(a==null?void 0:a.left)??0,visibility:a?"visible":"hidden"}}):null;return o.jsxs(o.Fragment,{children:[o.jsxs(k,{ref:d,...w?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",w?"pc-chat-stat--clickable":"",n.className].filter(Boolean).join(" "),"aria-label":`${n.label} — ${n.detail.title.toLowerCase()} details`,"aria-describedby":r?p:void 0,"data-stat-kind":n.detail.kind,onMouseEnter:y,onMouseLeave:_,onFocus:y,onBlur:()=>i(!1),onKeyDown:N=>{N.key==="Escape"&&i(!1)},onClick:w?()=>{var N;return(N=n.onClick)==null?void 0:N.call(n)}:void 0,children:[n.icon?o.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:n.icon}):null,o.jsx("span",{className:"pc-chat-stat-label",children:n.label})]}),T&&typeof document<"u"?bf.createPortal(T,document.body):T]})}function qm(n){const r=n.totalTokens!==void 0?Gl("tokens",n):null,i=Gl("tools",n),a=n.durationMs!==void 0?Gl("time",n):null;return[...r?[{label:`${n.totalTokens.toLocaleString()} tokens`,detail:r}]:[],{label:`${n.toolCalls} ${n.toolCalls===1?"tool":"tools"}`,detail:i},...n.changedFiles.length?[{label:`${n.changedFiles.length} ${n.changedFiles.length===1?"file":"files"} changed`,title:n.changedFiles.join(`
49
+ `)}]:[],...a?[{label:`${(n.durationMs/1e3).toFixed(n.durationMs<1e4?1:0)}s`,detail:a}]:[]]}function eg(n){const r=String(n.role||"").trim().toLowerCase()||"system",i=String(n.kind||"").trim().toLowerCase(),a=String(n.level||"").trim().toLowerCase();return r==="system"&&i==="report_bug"?{label:String(n.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:r==="system"&&i==="report_feature"?{label:String(n.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:r==="user"?{label:String(n.title||"").trim()||"You",icon:"user",variant:"user"}:r==="assistant"?{label:String(n.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(n.title||"").trim()||(a==="error"?"Error":a==="warn"?"Warning":"System"),icon:a==="error"?"error":a==="warn"?"warning":"info",variant:a==="error"?"error":a==="warn"?"warn":"status"}}function tg(n){var A;const r=n.message,i=x.useMemo(()=>eg(r),[r.kind,r.level,r.role,r.title]),a=String(r.ts||"").trim(),c=x.useMemo(()=>{if(!a)return"";const S=new Date(a);return Number.isFinite(S.getTime())?S.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[a]),[d,f]=x.useState("idle"),m=x.useRef(null);x.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const p=typeof n.onSpeakToggle=="function"&&i.variant==="assistant"&&!!String(r.content||"").trim(),g=p&&((A=n.getSpeakState)==null?void 0:A.call(n,r))||"idle",y=g==="loading"?"loader":g==="playing"?"pause":"speaker",_=g==="loading"?"Generating audio…":g==="playing"?"Pause":g==="paused"?"Resume":"Speak (TTS)",w=n.showCopy!==!1,k=Array.isArray(n.attachments)?n.attachments:[],T=r.statistics,N=x.useMemo(()=>Array.isArray(n.stats)?n.stats:T?qm(T):[],[n.stats,T]);return r.toolActivity?o.jsx(Pf,{tool:r.toolActivity,showCopy:n.showCopy}):o.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${i.variant}`,n.className].filter(Boolean).join(" "),children:[o.jsxs("div",{className:"pc-chat-header",children:[o.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:o.jsx(fe,{name:i.icon,size:14})}),o.jsx("span",{className:"pc-chat-role",children:i.label}),o.jsx("span",{className:"pc-chat-header-spacer"}),c?o.jsx("span",{className:"pc-chat-time",children:c}):null,o.jsxs("div",{className:"pc-chat-header-actions",children:[p?o.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":_,title:_,onClick:()=>{var S;return(S=n.onSpeakToggle)==null?void 0:S.call(n,r)},children:o.jsx(fe,{name:y,size:22})}):null,w?o.jsx("button",{className:`pc-chat-icon-btn ${d!=="idle"?`pc-chat-icon-btn--${d}`:""}`.trim(),type:"button","aria-label":"Copy message",title:d==="idle"?"Copy":d==="copied"?"Copied":"Copy failed",onClick:async()=>{const S=await fc(String(r.content||""));f(S?"copied":"failed"),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>f("idle"),900)},children:o.jsx(fe,{name:"copy",size:22})}):null]})]}),o.jsx("div",{className:"pc-chat-body",children:o.jsx(Vm,{text:String(r.content||""),renderMarkdown:n.renderMarkdown,jsonCollapseAfterDepth:n.jsonCollapseAfterDepth})}),k.length?o.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:k.slice(0,24).map((S,P)=>{const C=String(S.label||"").trim()||"attachment",j=String(S.target||"").trim(),L=String(S.title||"").trim(),W=!!S.disabled||typeof S.onClick!="function";return o.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:L||C,onClick:W?void 0:S.onClick,disabled:W,children:[o.jsx(fe,{name:"paperclip",size:14}),j?o.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${j}`,children:j}):null,o.jsx("span",{className:"pc-chat-attachment-name",children:C})]},S.id||`${C}:${P}`)})}):null,N.length?o.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:N.slice(0,12).map((S,P)=>{const C=String(S.label||"").trim();if(!C)return null;if(S.detail)return o.jsx(Zm,{label:C,detail:S.detail,icon:S.icon,onClick:S.onClick},S.id||`${C}:${P}`);const j=String(S.title||"").trim(),L=typeof S.onClick=="function",W=L?"button":"span";return o.jsxs(W,{...L?{type:"button"}:{},className:["pc-chat-stat",L?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:j||void 0,onClick:L?()=>{var V;return(V=S.onClick)==null?void 0:V.call(S)}:void 0,children:[S.icon?o.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:S.icon}):null,o.jsx("span",{className:"pc-chat-stat-label",children:C})]},S.id||`${C}:${P}`)})}):null]})}function ng(n,r){const i=Math.max(0,Math.trunc(r));return n.scrollHeight-n.scrollTop-n.clientHeight<=i}function rg(n){const r=typeof n.autoScrollThresholdPx=="number"&&Number.isFinite(n.autoScrollThresholdPx)?n.autoScrollThresholdPx:120,i=n.autoScroll!==!1,a=x.useRef(null),c=x.useRef(null),[d,f]=x.useState(!0),m=x.useMemo(()=>Array.isArray(n.messages)?n.messages:[],[n.messages]),p=x.useMemo(()=>{var _;const y=[];for(const w of m){const k=y[y.length-1];w.toolActivity&&((_=k==null?void 0:k[0])!=null&&_.toolActivity)&&k[0].runId===w.runId?k.push(w):y.push([w])}return y},[m]);x.useEffect(()=>{if(!i)return;const y=a.current;if(!y)return;const _=()=>{f(ng(y,r))};return y.addEventListener("scroll",_,{passive:!0}),_(),()=>y.removeEventListener("scroll",_)},[i,r]);const g=x.useMemo(()=>{let y=0;for(const _ of m)y+=String(_.content??"").length;return`${m.length}:${y}:${String(n.afterKey??"")}`},[m,n.afterKey]);return x.useEffect(()=>{if(!i||!d)return;const y=a.current;y&&(y.scrollTop=y.scrollHeight)},[i,d,g]),o.jsxs("div",{ref:a,className:["pc-chat-thread",n.className].filter(Boolean).join(" "),children:[m.length?null:n.empty||null,p.map((y,_)=>{var T;const w=y[0],k=String(w.id||"")||String(w.ts||"")+":"+String(w.role||"")+":"+_;return w.toolActivity?o.jsx(Lf,{tools:y.map(N=>N.toolActivity),showCopy:(T=n.messageProps)==null?void 0:T.showCopy},k):o.jsx(tg,{message:w,...n.messageProps||{}},k)}),n.after,o.jsx("div",{ref:c})]})}const sg=_t.forwardRef(function(r,i){const a=typeof r.rows=="number"&&Number.isFinite(r.rows)?Math.max(1,Math.trunc(r.rows)):3,c=!!r.disabled,d=!!r.busy,f=!c&&!d&&!!String(r.value||"").trim();return o.jsxs("div",{className:["pc-composer",r.className].filter(Boolean).join(" "),children:[r.leading,o.jsx("textarea",{ref:i,className:["pc-composer__textarea",r.textareaClassName].filter(Boolean).join(" "),value:r.value,onChange:m=>r.onChange(m.target.value),rows:a,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:r.placeholder||"","aria-label":r.ariaLabel||r.placeholder||"Message",disabled:c,autoFocus:!!r.autoFocus,onPaste:r.onPaste,onKeyDown:m=>{m.key!=="Enter"||m.shiftKey||m.nativeEvent.isComposing||m.keyCode===229||(m.preventDefault(),f&&r.onSubmit())}}),o.jsxs("div",{className:"pc-composer__row",children:[o.jsx("div",{className:"pc-composer__actions",children:r.actions}),o.jsx("button",{type:"button",className:r.sendButtonClassName||"pc-btn",disabled:!f,onClick:()=>r.onSubmit(),children:d?r.busyLabel||"Thinking…":r.sendLabel||"Send"})]}),r.overlay]})}),Ye=n=>n&&typeof n=="object"&&!Array.isArray(n)?n:{},oc=n=>Array.isArray(n)?n.map(Ye):[],Be=n=>typeof n=="string"?n:"",Ci=n=>Be(n.runtime_call_id||n.call_uid),Ni=n=>Be(n.call_id||n.id);function Ff(n,r){const i=r.record,a=Ye(i.effect);if(a.type!=="tool_calls")return[];const c=Ye(i.result),d=oc(Ye(a.payload).tool_calls),f=oc(c.results),m=d.length?d:f,p=[];return m.forEach((g,y)=>{let _=Ci(g)?f.filter(L=>Ci(L)===Ci(g)):[];!_.length&&Ni(g)&&d.filter(L=>Ni(L)===Ni(g)).length===1&&(_=f.filter(L=>Ni(L)===Ni(g)));const w=d.length?_.length===1?_[0]:d.length===f.length?f[y]:{}:g,k=Ci(g)||Ci(w)||`${Be(i.idempotency_key)||Be(i.step_id)||r.cursor}:${y}`,T=`${r.runId}:${k}`,N=n.get(T),A=Be(g.name||w.name)||(N==null?void 0:N.name);if(!A)return;const S=i.status==="completed"||i.status==="failed",P=i.status==="failed"||w.success===!1||!!w.error,C=g.arguments??w.arguments??(N==null?void 0:N.arguments),j={...N,id:T,runId:r.runId,name:A,arguments:C,status:S?P?"failed":"completed":i.status==="waiting"?"waiting":"running",...typeof w.success=="boolean"?{success:w.success}:{},...w.output!==void 0||w.result!==void 0?{output:w.output??w.result}:{},...w.error?{error:String(w.error)}:{},startedAt:(N==null?void 0:N.startedAt)||Be(i.started_at)||void 0,endedAt:S&&Be(i.ended_at)||(N==null?void 0:N.endedAt)};N&&["completed","failed"].includes(N.status)&&!S||(n.set(T,j),p.push(j))}),p}function Fs(n){if(n==null||n===""||typeof n=="boolean")return;const r=Number(n);return Number.isFinite(r)&&r>=0?r:void 0}function Fn(n,r){for(const i of r){const a=n==null?void 0:n[i];if(a==null||a===""||typeof a=="boolean")continue;const c=Number(a);if(Number.isFinite(c)&&c>=0)return Math.trunc(c)}}function Df(n){if(typeof n=="string")try{return Ye(JSON.parse(n))}catch{return{}}return Ye(n)}function Ms(n,r){if(r===void 0||r==="")return n;const i=n||[];return i.includes(r)||i.push(r),i}function ig(n){return Fn(n,["reasoning_tokens","thinking_tokens"])??Fn(Ye(n.completion_tokens_details),["reasoning_tokens"])??Fn(Ye(n.output_tokens_details),["reasoning_tokens"])}function og(n){const r=Ye(typeof n=="string"&&n.trim().startsWith("{")?Df(n):n);return Be(r.error_class)}function ag(n){const r=new Map;for(const i of n){const a=i.record;if(Ye(a.effect).type!=="emit_event")continue;const c=Ye(a.result);if(Be(c.name)!=="abstract.progress")continue;const d=Ye(c.payload);if(Be(d.kind)!=="llm"||!Be(d.step_id))continue;const f=`${Be(d.run_id)||i.runId}:${Be(d.step_id)}`,m=r.get(f)||{},p=Fs(d.ttft_s);p!==void 0&&(m.ttftS=p),m.provider=m.provider||Be(d.provider)||void 0,m.model=m.model||Be(d.model)||void 0,r.set(f,m)}return r}function ea(n){var N,A,S,P;const r=new Map,i=new Set,a=new Set,c={llmCalls:0,toolCalls:0,changedFiles:[]};let d=1/0,f=-1/0,m=!1,p=0,g=0,y=0;const _=ag(n),w=[],k=new Set;for(const C of n){const j=C.record,L=`${C.runId}:${j.step_id||C.cursor}:${j.status}`;if(i.has(L))continue;i.add(L);for(const ie of[j.started_at,j.ended_at]){const $e=Date.parse(Be(ie));Number.isFinite($e)&&(d=Math.min(d,$e),f=Math.max(f,$e))}for(const ie of Ff(r,C))ie.status==="waiting"&&k.add(ie.id);if(Ye(j.effect).type!=="llm_call"||j.status!=="completed")continue;c.llmCalls+=1;const W=Ye(j.result),V=Ye(W.output),Q=Ye(W.usage||W.token_usage||W.tokens||V.usage||V.token_usage||V.tokens),me=Fn(Q,["input_tokens","prompt_tokens","prompt","input","in"]),oe=Fn(Q,["output_tokens","completion_tokens","completion","output","out"]),X=Fn(Q,["total_tokens","total"])??(me!==void 0||oe!==void 0?(me||0)+(oe||0):void 0);X!==void 0&&(me===void 0||oe===void 0||me+oe!==X)&&(m=!0),me!==void 0&&(c.inputTokens=(c.inputTokens||0)+me),oe!==void 0&&(c.outputTokens=(c.outputTokens||0)+oe),X!==void 0&&(c.totalTokens=(c.totalTokens||0)+X);const le=Fs(W.gen_time??V.gen_time);le!==void 0&&(c.genTimeMs=(c.genTimeMs||0)+le,c.timedCalls=(c.timedCalls||0)+1);const H=Ye(W.metadata||V.metadata),ae=Ye(H.performance),se=Fs(ae.prompt_tokens_per_second),ye=Fs(ae.generation_tokens_per_second),we=Ye(H.prompt_cache),J=Fs(we.cached_tokens),ne=Fs(we.fed_tokens);if(se!==void 0||ye!==void 0){if(c.measuredSpeedCalls=(c.measuredSpeedCalls||0)+1,se!==void 0&&se>0&&(c.promptTokensPerSecond=(c.promptTokensPerSecond||0)+se,me!==void 0)){const ie=me/se*1e3;c.prefillMs=(c.prefillMs||0)+ie,ne!==void 0&&(p+=ne,g+=ie)}ye!==void 0&&ye>0&&(c.generationTokensPerSecond=(c.generationTokensPerSecond||0)+ye,oe!==void 0&&(c.decodeMs=(c.decodeMs||0)+oe/ye*1e3))}if(J!==void 0||ne!==void 0){c.measuredCacheCalls=(c.measuredCacheCalls||0)+1,c.cachedTokens=(c.cachedTokens||0)+(J||0),c.fedTokens=(c.fedTokens||0)+(ne||0);const ie=Be(we.outcome);if(ie){const $e=c.cacheOutcomes||[];$e.includes(ie)||$e.push(ie),c.cacheOutcomes=$e}}const U=Be(j.step_id)||void 0,E=U&&_.get(`${C.runId}:${U}`)||{},D=Ye(W.route),z={runId:C.runId};U&&(z.stepId=U),Be(j.started_at)&&(z.startedAt=Be(j.started_at));const re=Be(W.model||V.model)||Be(D.model)||E.model,ce=Be(D.provider)||Be(Ye(H._provider_request).provider)||E.provider||Be(W.provider);re&&(z.model=re),ce&&(z.provider=ce),re&&(c.models=Ms(c.models,re)),ce&&(c.providers=Ms(c.providers,ce)),(X===void 0||me!==void 0&&oe!==void 0&&me+oe===X)&&(me!==void 0&&(z.inputTokens=me),oe!==void 0&&(z.outputTokens=oe)),X!==void 0&&(z.totalTokens=X);const ve=ig(Q);ve!==void 0&&(z.reasoningTokens=ve,c.reasoningTokens=(c.reasoningTokens||0)+ve),J!==void 0&&(z.cachedTokens=J),ne!==void 0&&(z.fedTokens=ne),Be(we.outcome)&&(z.cacheOutcome=Be(we.outcome)),Be(we.backend)&&(z.cacheBackend=Be(we.backend),c.cacheBackends=Ms(c.cacheBackends,z.cacheBackend)),le!==void 0&&(z.genTimeMs=le),se!==void 0&&se>0&&(z.promptTokensPerSecond=se),ye!==void 0&&ye>0&&(z.generationTokensPerSecond=ye),E.ttftS!==void 0?(z.ttftMs=E.ttftS*1e3,z.promptMs=z.ttftMs,z.promptSource="ttft",c.ttftMs=(c.ttftMs||0)+z.ttftMs,c.ttftCalls=(c.ttftCalls||0)+1):z.promptTokensPerSecond!==void 0&&me!==void 0&&(z.promptMs=me/z.promptTokensPerSecond*1e3,z.promptSource="rate"),z.promptMs!==void 0&&(c.promptPhaseMs=(c.promptPhaseMs||0)+z.promptMs,c.promptPhaseCalls=(c.promptPhaseCalls||0)+1,ne!==void 0&&z.promptMs>0&&(z.promptNewTokensPerSecond=ne/(z.promptMs/1e3),c.promptPhaseNewTokens=(c.promptPhaseNewTokens||0)+ne,y+=z.promptMs)),z.ttftMs!==void 0&&le!==void 0&&le>=z.ttftMs?z.generationMs=le-z.ttftMs:z.generationTokensPerSecond!==void 0&&oe!==void 0&&(z.generationMs=oe/z.generationTokensPerSecond*1e3),z.generationMs!==void 0&&oe!==void 0&&(c.generationPhaseMs=(c.generationPhaseMs||0)+z.generationMs,c.generationPhaseTokens=(c.generationPhaseTokens||0)+oe);const _e=Ye(H.speculation);if(Object.keys(_e).length){const ie={};Be(_e.mode)&&(ie.mode=Be(_e.mode)),typeof _e.used=="boolean"&&(ie.used=_e.used),Be(_e.draft_kind)&&(ie.draftKind=Be(_e.draft_kind));const $e=Fn(_e,["accepted_tokens"]),Ue=Fn(_e,["drafted_tokens"]),We=Fn(_e,["rounds"]),ee=Fn(_e,["num_draft_tokens"]);$e!==void 0&&(ie.acceptedTokens=$e),Ue!==void 0&&(ie.draftedTokens=Ue),$e!==void 0&&Ue&&(ie.acceptanceRate=$e/Ue),We!==void 0&&(ie.rounds=We),ee!==void 0&&(ie.draftLength=ee),z.speculation=ie;const Z=c.speculation||(c.speculation={calls:0,used:0});Z.calls+=1,ie.used&&(Z.used+=1),ie.mode&&(Z.modes=Ms(Z.modes,ie.mode)),ie.draftKind&&(Z.draftKinds=Ms(Z.draftKinds,ie.draftKind)),$e!==void 0&&Ue!==void 0&&(Z.acceptedTokens=(Z.acceptedTokens||0)+$e,Z.draftedTokens=(Z.draftedTokens||0)+Ue),We!==void 0&&(Z.rounds=(Z.rounds||0)+We),ee!==void 0&&(Z.draftLengths=Ms(Z.draftLengths,ee))}w.push(z)}w.length&&(w.every(C=>C.startedAt)&&w.sort((C,j)=>Date.parse(C.startedAt)-Date.parse(j.startedAt)),c.modelCalls=w),y>0&&c.promptPhaseNewTokens!==void 0&&(c.promptPhaseTokensPerSecond=c.promptPhaseNewTokens/(y/1e3)),c.generationPhaseMs&&c.generationPhaseTokens!==void 0&&(c.generationPhaseTokensPerSecond=c.generationPhaseTokens/(c.generationPhaseMs/1e3)),(N=c.speculation)!=null&&N.draftedTokens&&(c.speculation.acceptanceRate=(c.speculation.acceptedTokens||0)/c.speculation.draftedTokens),c.measuredSpeedCalls&&(c.promptTokensPerSecond!==void 0&&(c.promptTokensPerSecond/=c.measuredSpeedCalls),c.generationTokensPerSecond!==void 0&&(c.generationTokensPerSecond/=c.measuredSpeedCalls)),g>0&&(c.prefillNewTokens=p,c.prefillNewTokensPerSecond=p/(g/1e3));const T=new Map;for(const C of r.values()){if(C.status==="waiting"){c.toolsWaiting=(c.toolsWaiting||0)+1;continue}if(C.status==="running"){c.toolsRunning=(c.toolsRunning||0)+1;continue}if(!["completed","failed"].includes(C.status))continue;c.toolCalls+=1;const j=C.status==="failed";j&&(c.toolsFailed=(c.toolsFailed||0)+1);const L=c.toolBreakdown||(c.toolBreakdown={}),W=L[C.name]||(L[C.name]={calls:0,failed:0});if(W.calls+=1,j){W.failed+=1;const X=og(C.output);X&&((W.errors||(W.errors={}))[X]=(((A=W.errors)==null?void 0:A[X])||0)+1)}const V=Date.parse(Be(C.startedAt)),Q=Date.parse(Be(C.endedAt));if(Number.isFinite(V)&&Number.isFinite(Q)&&Q>=V){const X=`${C.runId}|${C.startedAt}|${C.endedAt}`,le=T.get(X)||{ms:Q-V,calls:0,names:new Map,waited:!1};le.calls+=1,le.names.set(C.name,(le.names.get(C.name)||0)+1),k.has(C.id)&&(le.waited=!0),T.set(X,le)}if(C.success!==!0||!["write_file","create_file","save_file","edit_file","update_file","replace_in_file","delete_file","remove_file","move_file","rename_file","copy_file"].includes(C.name))continue;const me=Df(C.arguments),oe=Be(me.destination||me.destination_path||me.file_path||me.path||me.filename);oe&&a.add(oe)}for(const C of T.values()){c.toolBatches=(c.toolBatches||0)+1,c.toolTimeMs=(c.toolTimeMs||0)+C.ms,C.waited&&(c.toolTimeIncludesApproval=!0);const j=[...C.names.keys()].sort();(!c.slowestToolBatch||C.ms>c.slowestToolBatch.ms)&&(c.slowestToolBatch={ms:C.ms,calls:C.calls,tools:j});const L=(S=c.toolBreakdown)==null?void 0:S[j[0]];if(j.length===1&&L)L.ms=(L.ms||0)+C.ms;else for(const W of j){const V=(P=c.toolBreakdown)==null?void 0:P[W];V&&(V.sharedBatches=(V.sharedBatches||0)+1)}}return c.changedFiles=[...a],m&&(delete c.inputTokens,delete c.outputTokens),Number.isFinite(d)&&Number.isFinite(f)&&(c.durationMs=Math.max(0,f-d)),{tools:[...r.values()],statistics:c}}function lg(n){const r=Ye(Ye(n).ledgers);return Object.entries(r).flatMap(([i,a])=>oc(Ye(a).items).map((c,d)=>({runId:i,cursor:Number(c.cursor)||d+1,record:Object.keys(Ye(c.record)).length?Ye(c.record):c})))}const Kl=n=>n&&typeof n=="object"&&!Array.isArray(n)?n:{};function cg(n){var N,A,S,P;const{tools:r,statistics:i}=ea(n.records),a={toolCalls:i.toolCalls,totalTokens:i.totalTokens,startedAt:String(((N=n.run)==null?void 0:N.created_at)||"")||void 0},c=(C,j,L)=>({...a,label:C,detail:j,tone:L});if(n.loading)return c("Loading conversation","Restoring saved activity","neutral");if(["completed","failed","cancelled"].includes(n.status))return c(n.status==="completed"?"Completed":n.status==="failed"?"Run failed":"Stopped","",n.status==="failed"?"error":n.status==="completed"?"success":"neutral");if((n.connection==="reconnecting"||n.connection==="disconnected")&&(!((A=n.records)!=null&&A.length)||!!n.error))return c(n.connection==="reconnecting"?"Reconnecting":"Disconnected",String(n.error||"Live activity is unavailable"),"waiting");if(n.status==="paused"||((S=n.run)==null?void 0:S.paused)===!0)return c("Paused","Resume when you’re ready","waiting");const d=Kl((P=n.interaction)==null?void 0:P.wait),f=Kl(d.details),m=f.kind==="tool_approval"||f.mode==="approval_required",p=m&&n.toolApprovalGranted===!0;if(m&&!p)return c("Approval needed","Review the tool requests below","waiting");if(!m&&["user","ask_user"].includes(d.reason))return c("Your answer is needed",String(d.prompt||"The workflow has a question for you"),"waiting");if(!m&&(d.reason==="event"||String(d.wait_key||"").startsWith("evt:")))return c("Waiting for an event",String(d.prompt||"Listening for the workflow’s trigger"),"waiting");const g=r.filter(C=>{var j;return C.status==="running"||p&&C.status==="waiting"&&C.runId===((j=n.interaction)==null?void 0:j.runId)});if(g.length)return c(g.length===1?"Running a tool":`Running ${g.length} tools`,[...new Set(g.map(C=>C.name))].join(" · "),"working");const y=new Map;for(const C of n.records){const j=`${C.runId}:${C.record.step_id||C.record.idempotency_key||C.cursor}`,L=y.get(j);L&&["completed","failed"].includes(String(L.record.status))||y.set(j,C)}if([...y.values()].reverse().find(C=>Kl(C.record.effect).type==="llm_call"&&["started","running"].includes(String(C.record.status))))return c("Thinking","Generating the next response","working");const w=n.displayStatus.trim(),k=!/^(completed|complete|done|finished|ready|success|succeeded|failed|running|working|waiting|thinking|idle|paused|stopped|cancelled)$/i.test(w)&&!w.startsWith("{")?w:"",T=r[r.length-1];return c(n.status==="idle"?"Ready":"Working",k||(T?`Last tool: ${T.name} · ${T.status==="failed"?"failed":T.status==="completed"?"done":"waiting"}`:"Following the workflow"),n.status==="idle"?"neutral":"working")}function Qo(n){if(!n)return!1;for(let r=0;r<n.length;r+=1)if(n[r]==="Files")return!0;return!1}function Yd(n){var a;const r=n==null?void 0:n.items;if(!r||!r.length)return null;let i=0;for(let c=0;c<r.length;c+=1)((a=r[c])==null?void 0:a.kind)==="file"&&(i+=1);return i>0?i:null}function Xd(n){return n===1?"Drop file to attach":typeof n=="number"&&n>1?`Drop ${n} files to attach`:"Drop files to attach"}function Bf(n){const r=[],i=[],a=n==null?void 0:n.items;if(a&&a.length){for(let d=0;d<a.length;d+=1){const f=a[d];if(!f||f.kind!=="file")continue;const m=typeof f.webkitGetAsEntry=="function"?f.webkitGetAsEntry():null,p=typeof f.getAsFile=="function"?f.getAsFile():null;m!=null&&m.isDirectory?i.push(m.name||(p==null?void 0:p.name)||"folder"):p&&r.push(p)}return{files:r,folders:i}}const c=n==null?void 0:n.files;if(c)for(let d=0;d<c.length;d+=1)c[d]&&r.push(c[d]);return{files:r,folders:i}}function ug(n){return n.length?n.length===1?`"${n[0]}" is a folder. Folders are not supported: drop the files inside it instead.`:`${n.length} folders were dropped. Folders are not supported: drop the files inside them instead.`:""}const dg={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function Ei(n){return String(n).padStart(2,"0")}function fg(n,r,i){const a=String(n||"").trim();if(a&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(a))return a;const c=dg[String(r||"").toLowerCase()]||a.split(".").pop()||"bin",d=`${i.getFullYear()}-${Ei(i.getMonth()+1)}-${Ei(i.getDate())} at ${Ei(i.getHours())}.${Ei(i.getMinutes())}.${Ei(i.getSeconds())}`;return`${String(r||"").startsWith("image/")||!a?"Pasted image":"Pasted file"} ${d}.${c}`}function pg(n,r=new Date){if(!n)return[];const i=n.types?Array.from(n.types):[];if(i.includes("text/plain")&&i.includes("text/html"))return[];const{files:a}=Bf(n);return a.map(c=>{const d=fg(c.name,c.type,r);return d===c.name?c:new File([c],d,{type:c.type,lastModified:c.lastModified})})}class hg{constructor(r=1200){this.staleMs=r,this.depth=0,this.lastSeen=0}enter(r){this.depth+=1,this.lastSeen=r}over(r){this.depth===0&&(this.depth=1),this.lastSeen=r}leave(r){return this.depth=Math.max(0,this.depth-1),this.lastSeen=r,this.depth>0}reset(){this.depth=0}active(r){return this.depth>0&&r-this.lastSeen<this.staleMs}}function mg(n,r){if(n.kind==="ask-user"){if(r.kind==="choice"||r.kind==="free-text")return n.onSubmit(r.answer);throw new Error("Invalid submission for ask-user interaction")}if(n.kind==="tool-approval"){if(r.kind==="approve")return n.onApprove();if(r.kind==="deny")return n.onDeny();if(r.kind==="approve-all"&&n.onApproveAll)return n.onApproveAll();throw new Error("Invalid submission for tool-approval interaction")}if(r.kind==="event")return n.onSend(r.payload);throw new Error("Invalid submission for event-wait interaction")}function gg(n){return(n instanceof Error?n.message:String(n||"Unknown error")).trim()||"Unknown error"}function yg(n){return o.jsxs("div",{className:"pc-workflow-interaction__error",role:"alert",children:[o.jsxs("span",{children:["Could not complete that action: ",n.message]}),o.jsx("button",{type:"button",className:"pc-workflow-interaction__retry",onClick:n.onRetry,disabled:n.disabled,children:"Try again"})]})}function vg(n){var V;const r=n.interaction,[i,a]=x.useState(""),[c,d]=x.useState(()=>r.kind==="event-wait"&&r.initialPayload||""),[f,m]=x.useState(null),[p,g]=x.useState(!1),[y,_]=x.useState(""),[w,k]=x.useState(null),T=`${r.kind}:${r.id}`,N=x.useRef(T),A=x.useRef(!1),S=x.useRef(!1),P=x.useRef(!0),C=x.useRef(0);N.current!==T&&(N.current=T,A.current=!1,S.current=!1,C.current+=1);const j=!!n.disabled||f!==null||p||A.current||S.current,L=async(Q,me)=>{var le;if(n.disabled||A.current||S.current)return;const oe=T,X=++C.current;A.current=!0,k(null),_(""),m(Q);try{if(await me(),!P.current||N.current!==oe||C.current!==X)return;S.current=!0,g(!0),_("Response sent. Waiting for the workflow to continue.")}catch(H){if(!P.current||N.current!==oe||C.current!==X)return;k({submission:Q,message:gg(H)}),_("The action failed. You can try again."),(le=n.onError)==null||le.call(n,H)}finally{if(!P.current||N.current!==oe||C.current!==X)return;A.current=!1,m(null)}};x.useEffect(()=>{a(""),d(r.kind==="event-wait"&&r.initialPayload||""),k(null),m(null),g(!1),_("")},[T]),x.useEffect(()=>(P.current=!0,()=>{P.current=!1,C.current+=1,A.current=!1}),[]);const W=()=>{w&&L(w.submission,()=>mg(r,w.submission))};return o.jsxs("section",{className:"pc-workflow-interaction","aria-labelledby":`pc-workflow-interaction-${T}`,children:[o.jsxs("div",{className:"pc-workflow-interaction__heading",children:[o.jsx(fe,{name:r.kind==="tool-approval"?"warning":r.kind==="event-wait"?"history":"info",size:16}),o.jsxs("div",{children:[o.jsx("h3",{tabIndex:-1,id:`pc-workflow-interaction-${T}`,children:r.title||(r.kind==="tool-approval"?"Tool approval required":"Input required")}),r.description?o.jsx("div",{className:"pc-workflow-interaction__description",children:r.description}):null]})]}),r.kind==="ask-user"?o.jsxs("div",{className:"pc-workflow-interaction__body",children:[o.jsx("div",{className:"pc-workflow-interaction__prompt",children:r.prompt}),(V=r.choices)!=null&&V.length?o.jsx("div",{className:"pc-workflow-interaction__choices","aria-label":"Choices",children:r.choices.map(Q=>o.jsxs("button",{type:"button",className:"pc-workflow-interaction__choice",disabled:j||Q.disabled,onClick:()=>void L({kind:"choice",answer:Q.id},()=>r.onSubmit(Q.id)),children:[o.jsx("span",{children:Q.label}),Q.description?o.jsx("small",{children:Q.description}):null]},Q.id))}):null,r.allowFreeText!==!1?o.jsxs("div",{className:"pc-workflow-interaction__entry",children:[o.jsx("textarea",{"aria-label":"Response",value:i,onChange:Q=>a(Q.target.value),placeholder:r.freeTextPlaceholder||"Type a response",rows:2,disabled:j,onKeyDown:Q=>{Q.key!=="Enter"||Q.shiftKey||Q.nativeEvent.isComposing||Q.keyCode===229||(Q.preventDefault(),i.trim()&&L({kind:"free-text",answer:i},()=>r.onSubmit(i)))}},`${T}:text`),o.jsx("button",{type:"button",className:"pc-btn",disabled:j||!i.trim(),onClick:()=>void L({kind:"free-text",answer:i},()=>r.onSubmit(i)),children:(f==null?void 0:f.kind)==="free-text"?"Sending…":r.submitLabel||"Submit"})]}):null]}):r.kind==="tool-approval"?o.jsxs("div",{className:"pc-workflow-interaction__body",children:[o.jsxs("div",{className:"pc-workflow-interaction__prompt",children:["Allow ",o.jsx("strong",{children:r.toolName})," to run?"]}),r.detail?o.jsx("div",{className:"pc-workflow-interaction__detail",children:r.detail}):null,o.jsxs("div",{className:"pc-workflow-interaction__buttons",children:[o.jsx("button",{type:"button",className:"pc-workflow-interaction__deny",disabled:j,onClick:()=>void L({kind:"deny"},r.onDeny),children:(f==null?void 0:f.kind)==="deny"?"Denying…":r.denyLabel||"Deny"}),o.jsx("button",{type:"button",className:"pc-btn",disabled:j,onClick:()=>void L({kind:"approve"},r.onApprove),children:(f==null?void 0:f.kind)==="approve"?"Approving…":r.approveLabel||"Approve"}),r.onApproveAll?o.jsx("button",{type:"button",className:"pc-workflow-interaction__allow-all",disabled:j,onClick:()=>void L({kind:"approve-all"},r.onApproveAll),children:(f==null?void 0:f.kind)==="approve-all"?"Approving…":r.approveAllLabel||"Allow all"}):null]}),r.onApproveAll&&r.approveAllDescription?o.jsx("p",{className:"pc-workflow-interaction__scope",children:r.approveAllDescription}):null]}):o.jsxs("div",{className:"pc-workflow-interaction__body",children:[o.jsx("div",{className:"pc-workflow-interaction__prompt",children:r.prompt}),o.jsxs("label",{className:"pc-workflow-interaction__entry",children:[o.jsx("span",{children:r.payloadLabel||(r.eventName?`Payload for ${r.eventName}`:"Event payload")}),o.jsx("textarea",{value:c,onChange:Q=>d(Q.target.value),placeholder:r.payloadPlaceholder||"Enter payload",rows:2,"aria-label":r.payloadLabel||(r.eventName?`Payload for ${r.eventName}`:"Event payload"),disabled:j},`${T}:payload`)]}),o.jsx("div",{className:"pc-workflow-interaction__buttons",children:o.jsx("button",{type:"button",className:"pc-btn",disabled:j,onClick:()=>void L({kind:"event",payload:c},()=>r.onSend(c)),children:(f==null?void 0:f.kind)==="event"?"Sending…":r.sendLabel||"Send event"})})]}),w?o.jsx(yg,{message:w.message,onRetry:W,disabled:j}):null,o.jsx("div",{className:"pc-workflow-interaction__outcome","aria-live":"polite",children:y})]})}function Jo(n){return(n instanceof Error?n.message:String(n||"Unknown error")).trim()||"Unknown error"}function wg(n){const[r,i]=x.useState(!1),[a,c]=x.useState(!1),[d,f]=x.useState(!1),[m,p]=x.useState(null),g=x.useRef(!0),y=x.useRef(!1),_=x.useRef(!1),w=x.useRef(!1),k=x.useRef(0),T=x.useRef(0),N=x.useRef(0);x.useEffect(()=>(g.current=!0,()=>{g.current=!1,k.current+=1,T.current+=1,N.current+=1,y.current=!1,_.current=!1,w.current=!1}),[]);const A=!!n.blockedNotice,S=!!n.disabled||A,P=!!n.busy||r,C=r||!!n.busy&&!n.sendWhileBusy,j=n.stopState||null,L=(j==null?void 0:j.phase)==="stopping",W=typeof n.onFiles=="function",V=x.useRef(null),[Q,me]=x.useState(null),[oe,X]=x.useState(""),le=x.useRef(n.onFiles);le.current=n.onFiles;const H=x.useRef(S);H.current=S;const ae=async(z,re)=>{const ce=le.current;if(ce){if(H.current){p({action:"attach",message:"attachments are unavailable right now."});return}if(re.length)p({action:"attach",message:ug(re)});else if(z.length)p(null);else{p({action:"attach",message:"the drop contained no files."});return}if(z.length){X(`Attaching ${z.length} ${z.length===1?"file":"files"}…`);try{await ce(z)}catch(ve){g.current&&p({action:"attach",message:Jo(ve)})}}}},se=x.useRef(ae);se.current=ae,x.useEffect(()=>{if(!W||typeof window>"u")return;const z=new hg;let re=0;const ce=Z=>!!(V.current&&Z instanceof Node&&V.current.contains(Z)),ve=()=>{z.reset(),re&&window.clearInterval(re),re=0,me(null)},_e=()=>{re||(re=window.setInterval(()=>{z.active(Date.now())||ve()},250))},ie=Z=>{var ke;if(!Qo((ke=Z.dataTransfer)==null?void 0:ke.types))return;z.enter(Date.now());const de=ce(Z.target),je=Yd(Z.dataTransfer);me(Ee=>Ee&&Ee.over===de&&Ee.count===(je??Ee.count)?Ee:{count:je??(Ee==null?void 0:Ee.count)??null,over:de}),_e()},$e=Z=>{var je;if(!Qo((je=Z.dataTransfer)==null?void 0:je.types))return;Z.preventDefault(),z.over(Date.now());const de=ce(Z.target);Z.dataTransfer&&(Z.dataTransfer.dropEffect=de&&!H.current?"copy":"none"),me(ke=>ke&&ke.over===de?ke:{count:(ke==null?void 0:ke.count)??Yd(Z.dataTransfer),over:de}),_e()},Ue=Z=>{var de;Qo((de=Z.dataTransfer)==null?void 0:de.types)&&(z.leave(Date.now())||ve())},We=Z=>{var Oe;if(!Qo((Oe=Z.dataTransfer)==null?void 0:Oe.types))return;const de=ce(Z.target),je=Z.defaultPrevented&&!de;if(Z.preventDefault(),ve(),je)return;if(!de){p({action:"attach",message:"drop files on the conversation to attach them."});return}const{files:ke,folders:Ee}=Bf(Z.dataTransfer);se.current(ke,Ee)},ee=Z=>{Z.key==="Escape"&&z.depth>0&&ve()};return window.addEventListener("dragenter",ie),window.addEventListener("dragover",$e),window.addEventListener("dragleave",Ue),window.addEventListener("drop",We),window.addEventListener("dragend",ve),window.addEventListener("blur",ve),window.addEventListener("keydown",ee),()=>{window.removeEventListener("dragenter",ie),window.removeEventListener("dragover",$e),window.removeEventListener("dragleave",Ue),window.removeEventListener("drop",We),window.removeEventListener("dragend",ve),window.removeEventListener("blur",ve),window.removeEventListener("keydown",ee),re&&window.clearInterval(re)}},[W]);const ye=z=>{if(!W||S)return;const re=pg(z.clipboardData);re.length&&(z.preventDefault(),ae(re,[]))},we=Q?o.jsxs("div",{className:["pc-workflow-chat__dropzone",Q.over?"is-over":"",S?"is-disabled":""].filter(Boolean).join(" "),"aria-hidden":"true",children:[o.jsx("span",{className:"pc-workflow-chat__dropzone-icon",children:o.jsx(fe,{name:"paperclip",size:18})}),o.jsxs("span",{className:"pc-workflow-chat__dropzone-text",children:[o.jsx("strong",{children:S?"Attachments are unavailable right now":Xd(Q.count)}),S?null:o.jsx("span",{children:Q.over?"Release to upload to this conversation":"Drop anywhere on the conversation"})]})]}):null,J=Q?S?"Attachments are unavailable right now":Xd(Q.count):oe,ne=async()=>{const z=String(n.draft||"");if(S||y.current||!n.sendWhileBusy&&n.busy||!z.trim())return;const re=++k.current;y.current=!0,p(null),i(!0);try{await n.onSend(z)}catch(ce){g.current&&k.current===re&&p({action:"send",message:Jo(ce)})}finally{g.current&&k.current===re&&(y.current=!1,i(!1))}},U=async()=>{if(S||_.current||!n.onCancel)return;const z=++T.current;_.current=!0,p(null),c(!0);try{await n.onCancel()}catch(re){g.current&&T.current===z&&p({action:"cancel",message:Jo(re)})}finally{g.current&&T.current===z&&(_.current=!1,c(!1))}},E=async()=>{if(S||w.current||!n.onAttach)return;const z=++N.current;w.current=!0,p(null),f(!0);try{await n.onAttach()}catch(re){g.current&&N.current===z&&p({action:"attach",message:Jo(re)})}finally{g.current&&N.current===z&&(w.current=!1,f(!1))}},D=()=>{m&&(m.action==="send"&&ne(),m.action==="cancel"&&U(),m.action==="attach"&&E())};return o.jsxs("section",{ref:V,className:["pc-workflow-chat",Q?"pc-workflow-chat--dragging":"",Q!=null&&Q.over?"pc-workflow-chat--drag-over":"",n.className].filter(Boolean).join(" "),"aria-label":"Workflow chat",children:[n.header?o.jsx("header",{className:"pc-workflow-chat__header",children:n.header}):null,o.jsx("div",{className:"pc-workflow-chat__transcript",children:o.jsx(rg,{messages:Array.isArray(n.messages)?n.messages:[],empty:n.emptyState,autoScroll:!0,messageProps:{...n.messageProps,...n.renderMarkdown?{renderMarkdown:n.renderMarkdown}:{}},after:o.jsxs(o.Fragment,{children:[n.interaction?o.jsx(vg,{interaction:n.interaction,disabled:S}):null,A?o.jsx("div",{className:"pc-workflow-chat__blocked",role:"status",children:n.blockedNotice}):null]}),afterKey:`${n.interaction?`${n.interaction.kind}:${n.interaction.id}`:""}:${A?"blocked":""}`})}),m?o.jsxs("div",{className:"pc-workflow-chat__error",role:"alert",children:[o.jsxs("span",{children:["Could not ",m.action==="send"?"send this message":m.action==="attach"?"attach a file":"stop the run",": ",m.message]}),o.jsx("button",{type:"button",onClick:D,disabled:S,children:"Try again"})]}):null,o.jsxs("div",{className:"pc-workflow-chat__composer",children:[o.jsx(sg,{value:n.draft,onChange:n.onDraftChange,onSubmit:()=>void ne(),placeholder:n.placeholder||"Send a message",ariaLabel:"Message",disabled:S,busy:C,sendLabel:n.sendLabel,busyLabel:n.busyLabel,rows:2,leading:n.attachments?o.jsx("div",{className:"pc-workflow-chat__attachments",children:n.attachments}):null,overlay:we,onPaste:W?ye:void 0,actions:o.jsxs(o.Fragment,{children:[n.onAttach?o.jsxs("button",{type:"button",className:"pc-workflow-chat__icon-button","aria-label":"Attach file",title:"Attach file",disabled:S||d,onClick:()=>void E(),children:[o.jsx(fe,{name:"paperclip",size:16}),o.jsx("span",{children:d?"Attaching…":"Attach"})]}):null,n.composerExtras,P&&n.onCancel?o.jsxs("button",{type:"button",className:"pc-workflow-chat__stop",disabled:S||a||L,onClick:()=>void U(),children:[o.jsx(fe,{name:"x",size:14}),o.jsx("span",{children:a||L?"Stopping…":"Stop"})]}):j?o.jsx("span",{className:`pc-workflow-chat__stop-state pc-workflow-chat__stop-state--${j.phase}`,role:"status","aria-live":"polite",children:j.label}):null]})}),W?o.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:J}):null]}),n.footer?o.jsx("footer",{className:"pc-workflow-chat__footer",children:n.footer}):null]})}function _g(n){return n.toolApprovalGranted?null:n.interaction}const Zd={messages:[],records:[],run:null,interaction:null,status:"idle",displayStatus:"",loading:!1,error:null,connection:"idle",toolApprovalGranted:!1,stop:null};function Me(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Re(n){return typeof n=="string"?n.trim():n==null?"":typeof n=="number"||typeof n=="boolean"?String(n):""}function Ti(n){return Array.isArray(n)?n:[]}function zn(n){return Re(n==null?void 0:n.status).toLowerCase()||"unknown"}function Lt(n){return["completed","failed","cancelled"].includes(n.toLowerCase())}function kr(n){const r=Me(n),i=Number((r==null?void 0:r.status)??(r==null?void 0:r.statusCode));return i===401||i===403}function xg(n){const r=Me(n);return Number((r==null?void 0:r.status)??(r==null?void 0:r.statusCode))}function Ql(n){const r=i=>{if(Array.isArray(i))return i.map(r);const a=Me(i);if(!a)return i;const c={};for(const d of Object.keys(a).sort())c[d]=r(a[d]);return c};try{return JSON.stringify(r(n))}catch{return"[unserializable]"}}function ac(n){if(typeof n=="string")return n.trim();const r=Me(n);if(!r)return"";for(const i of["answer","response","message","text","content","output"]){const a=r[i];if(typeof a=="string"&&a.trim())return a.trim()}return""}function Is(n){const r=ac(n);if(r)return r;if(!Me(n)&&!Array.isArray(n))return"";try{return JSON.stringify(n,null,2)}catch{return""}}function qd(n){if(!n)return"";for(const a of["prompt","request","task","message","query","input"]){const c=Re(n[a]);if(c)return c}const r=Me(n.context);for(const a of["task","message"]){const c=Re(r==null?void 0:r[a]);if(c)return c}const i=Ti(r==null?void 0:r.messages);for(let a=i.length-1;a>=0;a-=1){const c=Me(i[a]);if(Re(c==null?void 0:c.role).toLowerCase()!=="user")continue;const d=Re(c==null?void 0:c.content);if(d)return d}return""}function Uf(n){const r=Me(n.result);return Me(r==null?void 0:r.wait)}function lc(n){return Me(n.effect)||{}}function kg(n,r){return Re(n.run_id)||r}function ef(n){return Re(n.ended_at)||Re(n.started_at)||void 0}function tf(n){const r=new Set,i=g=>{const y=Re(g);y&&r.add(y)},a=Me(n.result);i(a==null?void 0:a.sub_run_id),i(a==null?void 0:a.subRunId),i(a==null?void 0:a.child_run_id);const c=lc(n),d=Me(c.payload);Re(c.type)==="start_subworkflow"&&(i(d==null?void 0:d.sub_run_id),i(d==null?void 0:d.subRunId),i(d==null?void 0:d.child_run_id));const f=Uf(n),m=Me(f==null?void 0:f.details);i(m==null?void 0:m.sub_run_id),i(m==null?void 0:m.subRunId),i(m==null?void 0:m.child_run_id);const p=Re(f==null?void 0:f.wait_key);return p.startsWith("subworkflow:")&&i(p.slice(12)),[...r]}class Sg{constructor(r,i={}){this.transport=r,this.options=i,this.snapshot={...Zd},this.subscribers=new Set,this.controller=null,this.generation=0,this.rootRunId="",this.cursors=new Map,this.seenRecords=new Set,this.seenMessages=new Set,this.watchedRuns=new Set,this.childCatchUpAttempts=new Map,this.runStates=new Map,this.historicalRuns=new Map,this.historicalRunFailures=new Map,this.commandIds=new Map,this.toolActivities=new Map,this.historicalEvidence=new Map,this.approvedWaits=new Set,this.grantedToolWaits=new Set,this.approvalEpoch=0,this.toolApprovalPolicy=null,this.toolApprovalSuspended=!1,this.toolApprovalStopped=!1,this.displayStatusAt=-1/0,this.stopRequested=!1,this.stopFollowing=!1,this.openLlmSteps=new Set,this.forcedStop=null}subscribe(r){return this.subscribers.add(r),()=>this.subscribers.delete(r)}getSnapshot(){return this.snapshot}reset(){var r;this.toolApprovalSuspended=!1,this.toolApprovalStopped=!1,this.approvalEpoch+=1,this.displayStatusAt=-1/0,this.stopRequested=!1,this.stopFollowing=!1,this.openLlmSteps.clear(),this.forcedStop=null,this.generation+=1,(r=this.controller)==null||r.abort(),this.controller=null,this.rootRunId="",this.cursors.clear(),this.seenRecords.clear(),this.seenMessages.clear(),this.watchedRuns.clear(),this.childCatchUpAttempts.clear(),this.runStates.clear(),this.historicalRuns.clear(),this.historicalRunFailures.clear(),this.commandIds.clear(),this.toolActivities.clear(),this.historicalEvidence.clear(),this.approvedWaits.clear(),this.grantedToolWaits.clear(),this.set({...Zd})}dispose(){this.reset(),this.subscribers.clear()}async load(r){var d;const i=Re(r);if(this.reset(),!i)return;const a=++this.generation,c=new AbortController;this.controller=c,this.rootRunId=i,this.set({...this.snapshot,loading:!0,status:"loading",error:null,connection:"connecting"});try{const[f,m]=await Promise.all([this.transport.getRun(i,c.signal),this.transport.getHistory(i,c.signal)]);if(!this.live(a))return;const p=Me(f),g=Me(p==null?void 0:p.waiting),y=zn(p);if(await this.ingestHistory(m,i,a),!this.live(a))return;if(this.set({...this.snapshot,run:p,status:y,loading:!1,...g&&!Lt(y)?{interaction:{runId:i,wait:g,...((d=this.snapshot.interaction)==null?void 0:d.runId)===i&&Re(this.snapshot.interaction.wait.wait_key)===Re(g.wait_key)?{stepId:this.snapshot.interaction.stepId}:{}}}:{}}),p&&this.updateRunState(i,p),g)for(const _ of tf({result:{wait:g}}))_!==i&&this.catchUpAndWatch(_,a);await this.catchUpAndWatch(i,a),this.pollRootLifecycle(i,a)}catch(f){!c.signal.aborted&&this.live(a)&&this.fail(f)}}async sendCommand(r,i={}){var y,_;r==="cancel"&&(this.toolApprovalStopped=!0,this.revokeToolApproval(),this.stopRequested=!0,this.recomputeStop());const a=Re(i.wait_key),c=r==="resume"?a?this.interactionRunId()||this.rootRunId:this.rootRunId:r==="emit_event"?this.interactionRunId()||this.rootRunId:this.rootRunId;if(!c)throw new Error("No workflow run is loaded");const d=r==="resume"&&a&&((y=this.snapshot.interaction)==null?void 0:y.stepId)||"",f=`${c}\0${r}\0${d}\0${Ql(i)}`;let m=this.commandIds.get(f);m||(m=this.newCommandId(),this.commandIds.set(f,m));const p=this.generation,g=(_=this.controller)==null?void 0:_.signal;try{const w=await this.transport.submitCommand({command_id:m,run_id:c,type:r,payload:i,...this.options.clientId?{client_id:this.options.clientId}:{}},g);if(!this.live(p))return w;const k=Me(w);if(k&&k.accepted===!1)throw r==="cancel"&&(this.stopRequested=!1,this.recomputeStop()),new Error(Re(k.detail)||"Gateway did not accept the command");return this.commandIds.delete(f),c===this.rootRunId&&["pause","resume","cancel"].includes(r)&&this.refreshRunState(c,p),w}catch(w){throw this.live(p)&&this.fail(w,!1),w}}resume(r){const i=this.requireInteraction();return this.sendCommand("resume",{wait_key:Re(i.wait.wait_key),payload:{response:r}})}approve(r,i){const a=this.requireInteraction();if(Lt(this.snapshot.status))throw new Error("This run has already ended.");if(i&&(a.runId!==i.runId||Re(a.wait.wait_key)!==i.waitKey||i.stepId!==void 0&&a.stepId!==i.stepId))throw new Error("This approval request has changed. Review the current request before deciding.");if(r&&this.toolApprovalPolicy&&!this.toolCallsMatch(a,this.toolApprovalPolicy.enabledTools))throw new Error("This request includes an unavailable or unselected tool. It cannot be authorized. Deny this request or stop the run and change Tools settings.");const c=this.generation;return this.sendCommand("resume",{wait_key:Re(a.wait.wait_key),payload:{approved:!!r}}).then(d=>{if(!this.live(c))return d;const f=this.occurrenceKey(a);return this.approvedWaits.add(f),r&&this.isToolApproval(a)&&!this.grantedToolWaits.has(f)&&(this.grantedToolWaits.add(f),this.set({...this.snapshot})),d})}async approveWithPolicyChange(r,i){const a=this.generation,c=this.approvalEpoch;if(!this.isToolApproval(this.requireInteraction()))throw new Error("This is not a tool approval request.");await this.approve(!0,r),!(!this.live(a)||c!==this.approvalEpoch||this.toolApprovalStopped||Lt(this.snapshot.status))&&i()}async allowAllToolsForRun(r){const i=this.generation,a=this.approvalEpoch,c=this.requireInteraction();if(!this.isToolApproval(c))throw new Error("This is not a tool approval request.");await this.approve(!0,r),!(!this.live(i)||a!==this.approvalEpoch||Lt(this.snapshot.status))&&(this.approvedWaits.add(`${r.runId}:${r.waitKey}${c.stepId?`:${c.stepId}`:""}`),this.set({...this.snapshot,autoApproveTools:!0}))}revokeToolApproval(){this.approvalEpoch+=1,this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1})}setToolApprovalPolicy(r){Ql(r)!==Ql(this.toolApprovalPolicy)&&(this.approvalEpoch+=1,this.toolApprovalSuspended=!1,this.toolApprovalPolicy=r?{enabledTools:[...r.enabledTools],autoApproveTools:[...r.autoApproveTools]}:null,this.set({...this.snapshot}))}occurrenceKey(r){return`${r.runId}:${Re(r.wait.wait_key)}${r.stepId?`:${r.stepId}`:""}`}coveredByStandingPermission(r,i){var a;return r.loading||this.toolApprovalStopped||this.toolApprovalSuspended||!this.toolApprovalPolicy&&!r.autoApproveTools||Lt(r.status)||((a=r.run)==null?void 0:a.paused)===!0||r.status==="paused"||!i||!this.isToolApproval(i)||this.toolApprovalPolicy&&(!this.toolCallsMatch(i,this.toolApprovalPolicy.enabledTools)||!this.toolCallsMatch(i,this.toolApprovalPolicy.autoApproveTools))?!1:!!Re(i.wait.wait_key)}present(r){const i=r.interaction,a=i?this.occurrenceKey(i):"",c=!!(i&&this.isToolApproval(i)&&(this.grantedToolWaits.has(a)||!this.approvedWaits.has(a)&&this.coveredByStandingPermission({...r,loading:!1},i)));if(!c&&!this.snapshot.toolApprovalGranted&&!r.toolApprovalGranted)return r.toolApprovalGranted===!1?r:{...r,toolApprovalGranted:!1};let d=!1;const f=r.messages.map(m=>{var y;const p=m.toolActivity;if(!p||((y=this.toolActivities.get(p.id))==null?void 0:y.status)!=="waiting")return m;const g=c&&p.runId===(i==null?void 0:i.runId)?"running":"waiting";return p.status===g?m:(d=!0,this.toolMessage({...p,status:g}))});return{...r,toolApprovalGranted:c,...d?{messages:f}:{}}}toolCallsMatch(r,i){var c;const a=Ti((c=Me(r.wait.details))==null?void 0:c.tool_calls);return a.length>0&&a.every(d=>{var m;const f=Re((m=Me(d))==null?void 0:m.name);return!!f&&i.includes(f)})}isToolApproval(r){const i=Me(r.wait.details);return(i==null?void 0:i.mode)==="approval_required"||(i==null?void 0:i.kind)==="tool_approval"}autoApproveCurrentWait(){const r=this.snapshot.interaction;if(!this.coveredByStandingPermission(this.snapshot,r))return;const i={runId:r.runId,waitKey:Re(r.wait.wait_key),stepId:r.stepId},a=this.occurrenceKey(r);if(this.approvedWaits.has(a))return;this.approvedWaits.add(a),this.grantedToolWaits.add(a);const c=this.generation,d=this.approvalEpoch;this.approve(!0,i).catch(f=>{if(this.live(c)){if(this.grantedToolWaits.delete(a),d!==this.approvalEpoch){this.set({...this.snapshot});return}this.toolApprovalSuspended=!0,this.set({...this.snapshot,autoApproveTools:!1}),this.fail(f,!1)}})}emitEvent(r){return this.sendCommand("emit_event",r)}cancel(){return this.sendCommand("cancel",{})}requireInteraction(){if(!this.snapshot.interaction)throw new Error("This workflow is not waiting for input");if(!Re(this.snapshot.interaction.wait.wait_key))throw new Error("The workflow wait has no wait_key");return this.snapshot.interaction}interactionRunId(){var r;return((r=this.snapshot.interaction)==null?void 0:r.runId)||""}live(r){var i;return r===this.generation&&!((i=this.controller)!=null&&i.signal.aborted)}set(r){this.snapshot=this.present(r);for(const i of this.subscribers)i();this.autoApproveCurrentWait()}async catchUpAndWatch(r,i){var a;if(!(!this.live(i)||this.watchedRuns.has(r))){this.watchedRuns.add(r);try{if(r!==this.rootRunId)try{const c=Me(await this.transport.getRun(r,(a=this.controller)==null?void 0:a.signal));if(!this.live(i))return;c&&this.updateRunState(r,c)}catch(c){if(!this.live(i))return;if(kr(c))throw c;this.fail(c,!1)}if(await this.catchUp(r,i),!this.live(i)||Lt(zn(this.runStates.get(r)||null)))return;this.childCatchUpAttempts.delete(r),this.watch(r,i)}catch(c){if(!this.live(i))return;if(this.watchedRuns.delete(r),r===this.rootRunId)throw c;if(kr(c)){this.fail(c);return}const d=(this.childCatchUpAttempts.get(r)||0)+1;if(this.childCatchUpAttempts.set(r,d),this.fail(c,!1),d>=5)return;await this.waitForRetry(Math.min(2e3,150*2**(d-1))),this.live(i)&&this.catchUpAndWatch(r,i)}}}async catchUp(r,i){var a;for(let c=0;c<100&&this.live(i);c+=1){const d=this.cursors.get(r)||0,f=await this.transport.getLedger(r,d,(a=this.controller)==null?void 0:a.signal);if(!this.live(i))return;const m=Me(f),p=Array.isArray(f)?f:Ti(m==null?void 0:m.items);for(const y of p)this.ingestItem(r,y);const g=Number(m==null?void 0:m.next_after);if(!p.length||!Number.isFinite(g)||g<=d)break;this.cursors.set(r,g)}}async watch(r,i){var c;let a=0;for(;this.live(i)&&!Lt(zn(this.runStates.get(r)||null));){const d=this.cursors.get(r)||0;this.set({...this.snapshot,connection:a?"reconnecting":"connecting"});try{let f=!1;const m=()=>{!this.live(i)||f||(f=!0,this.set({...this.snapshot,connection:"connected",error:null}))};if(await this.transport.streamLedger(r,d,g=>{this.live(i)&&(m(),this.ingestItem(r,g))},this.controller.signal,m),!this.live(i)||(await this.catchUp(r,i),!this.live(i)))return;const p=Me(await this.transport.getRun(r,(c=this.controller)==null?void 0:c.signal));if(!this.live(i))return;p&&this.updateRunState(r,p),a+=1}catch(f){if(!this.live(i))return;if(a+=1,this.fail(f,!1),kr(f)){this.set({...this.snapshot,connection:"disconnected"});return}}if(a>=5||!this.live(i))break;await this.waitForRetry(Math.min(2e3,150*2**(a-1)))}if(this.live(i)){if(Lt(zn(this.runStates.get(r)||null))){this.set({...this.snapshot,connection:"disconnected"});return}this.set({...this.snapshot,connection:"disconnected",error:this.snapshot.error||"Ledger stream reconnect limit reached. Reconnect the workflow to continue."})}}async ingestHistory(r,i,a){const c=Me(r);if(!c)return;const d=Me(c.session),f=Ti(d==null?void 0:d.turns).map(Me).filter(g=>!!g);if(await this.hydrateHistoricalSessionRuns(f,i,a),!this.live(a))return;for(const g of f){const y=Re(g==null?void 0:g.run_id)||i;this.ingestSessionTurn(g,i,y!==i&&this.historicalRuns.get(y)||null)}const m=`turn:${i}:user`;if(!this.seenMessages.has(m)){const g=qd(Me(c.input_data));g&&this.addMessage({id:m,role:"user",content:g})}const p=Me(c.ledgers);if(p)for(const[g,y]of Object.entries(p)){const _=Me(y);for(const w of Ti(_==null?void 0:_.items))this.ingestItem(g,w)}}ingestSessionTurn(r,i,a){if(!r)return;const c=Re(r.run_id)||i,d=Me(r.input_data)||Me(r.input)||{},f=Re(r.prompt)||qd(d);f&&this.addMessage({id:`turn:${c}:user`,role:"user",content:f,ts:Re(r.created_at)||void 0});const m=this.historicalRunFailures.get(c);if(m){const _=Re(r.answer)||ac(r.output),w=m.missing?"is unavailable because the run no longer exists":"could not be restored",k=_?` Saved reply (not verified as the final result): ${_}`:"";this.addMessage({id:`history:${c}:unavailable`,role:"system",level:"warn",title:"History",content:`The final output for an earlier turn ${w}.${k}`});return}const g=(a&&Lt(zn(a))?Is(a.output):"")||(a?Re(r.answer)||ac(r.output):""),y=this.historicalEvidence.get(c);for(const _ of(y==null?void 0:y.tools)||[])this.upsertTool(_);g&&this.addRunAssistantMessage(c,{id:`final:${c}`,role:"assistant",content:g,runId:c,statistics:y==null?void 0:y.statistics,ts:Re(r.updated_at)||void 0})}async hydrateHistoricalSessionRuns(r,i,a){const c=[...new Set(r.map(p=>Re(p.run_id)).filter(p=>p&&p!==i&&!this.historicalRuns.has(p)&&!this.historicalRunFailures.has(p)))];if(!c.length||!this.live(a))return;let d=0,f=!1;const m=async()=>{var p,g,y;for(;!f&&this.live(a);){const _=c[d++];if(!_)return;try{const w=Me(await this.transport.getRun(_,(p=this.controller)==null?void 0:p.signal));if(!this.live(a))return;if(w){this.historicalRuns.set(_,w);try{const k=await this.transport.getHistory(_,(g=this.controller)==null?void 0:g.signal);if(!this.live(a))return;this.historicalEvidence.set(_,ea(lg(k)))}catch(k){if(!this.live(a))return;if(kr(k))throw k;this.fail(new Error(`Earlier turn activity could not be restored: ${k instanceof Error?k.message:String(k)}`),!1)}}else this.historicalRuns.set(_,null),this.historicalRunFailures.set(_,{missing:!1,detail:"gateway returned an invalid historical run snapshot"})}catch(w){if(!this.live(a))return;const k=xg(w)===404;this.historicalRuns.set(_,null),this.historicalRunFailures.set(_,{missing:k,detail:w instanceof Error?w.message:Re((y=Me(w))==null?void 0:y.detail)||"request failed"}),kr(w)&&(f=!0,this.fail(w))}}};if(await Promise.all(Array.from({length:Math.min(4,c.length)},()=>m())),f&&this.live(a))for(const p of c)!this.historicalRuns.has(p)&&!this.historicalRunFailures.has(p)&&(this.historicalRuns.set(p,null),this.historicalRunFailures.set(p,{missing:!1,detail:"authorization expired before this historical run could be restored"}))}ingestItem(r,i){const a=Me(i),c=Me(a==null?void 0:a.record)||a;if(!c)return;const d=kg(c,r),f=Number(a==null?void 0:a.cursor),m=Number.isFinite(f)&&f>0?f:(this.cursors.get(d)||0)+1,p=`${d}:${m}`;if(!this.seenRecords.has(p)){if(this.seenRecords.add(p),this.cursors.set(d,Math.max(this.cursors.get(d)||0,m)),this.set({...this.snapshot,records:[...this.snapshot.records,{cursor:m,record:c,runId:d}]}),this.foldRecord(d,c,p),this.snapshot.messages.some(g=>g.id===`final:${this.rootRunId}`)){const g=ea(this.snapshot.records).statistics;this.set({...this.snapshot,messages:this.snapshot.messages.map(y=>y.id===`final:${this.rootRunId}`?{...y,statistics:g}:y)})}for(const g of tf(c))g!==d&&this.catchUpAndWatch(g,this.generation)}}foldRecord(r,i,a){var y,_;const c=lc(i),d=Re(c.type).toLowerCase(),f=Me(i.result),m=Re(i.status).toLowerCase(),p=ef(i);if(this.foldStopEvidence(r,i,d,m),["llm_call","tool_calls"].includes(d)&&["started","running"].includes(m)){const w=Date.parse(p||"");(!Number.isFinite(w)||w>=this.displayStatusAt)&&(Number.isFinite(w)&&(this.displayStatusAt=w),this.snapshot.displayStatus&&this.set({...this.snapshot,displayStatus:""}))}if(d==="answer_user"&&m==="completed"){const w=Is(f)||Is(Me(c.payload));w&&this.addRunAssistantMessage(r,{id:`answer:${r}:${a}`,role:"assistant",content:w,ts:p})}if(d==="emit_event"&&m==="completed"){const w=Me(c.payload)||{},k=Me(f),T=Re(w.name)||Re(k==null?void 0:k.name),N=w.payload!==void 0?w.payload:k==null?void 0:k.payload;if(["abstract.message","abstractcode.message"].includes(T)){const A=Is(N);if(A){const S=Re((y=Me(N))==null?void 0:y.level).toLowerCase(),P=S==="error"?"error":["warn","warning"].includes(S)?"warn":"info";this.addMessage({id:`event:${r}:${a}`,role:"system",title:"Workflow",content:A,level:P,ts:p})}}if(["abstract.status","abstractcode.status"].includes(T)){const A=Me(N),S=A?A.status??A.text??A.value:N,P=Date.parse(p||"");!Lt(this.snapshot.status)&&typeof S=="string"&&(!Number.isFinite(P)||P>=this.displayStatusAt)&&(Number.isFinite(P)&&(this.displayStatusAt=P),this.set({...this.snapshot,displayStatus:S.trim()}))}if(["abstract.tool_execution","abstractcode.tool_execution","abstract.tool_result","abstractcode.tool_result"].includes(T)){const A=Is(N);A&&this.addMessage({id:`event:${r}:${a}`,role:"system",title:"Tool activity",content:A,ts:p})}}const g=Uf(i);if(m==="waiting"&&g&&!Lt(this.snapshot.status)&&!Lt(zn(this.runStates.get(r)||null))&&this.set({...this.snapshot,interaction:{runId:r,wait:g,...Re(i.step_id)?{stepId:Re(i.step_id)}:{}}}),d==="tool_calls")for(const w of Ff(this.toolActivities,{runId:r,cursor:this.cursors.get(r)||0,record:i}))this.upsertTool(w);d==="resume"&&(f==null?void 0:f.resumed)===!0&&((_=this.snapshot.interaction)==null?void 0:_.runId)===r&&(this.set({...this.snapshot,interaction:null}),this.refreshRunState(r,this.generation))}foldStopEvidence(r,i,a,c){let d=!1;if(a==="llm_call"){const f=Re(i.step_id);if(f){const m=`${r}:${f}`;c==="started"?(this.openLlmSteps.add(m),d=!0):["completed","failed","cancelled","waiting"].includes(c)&&(d=this.openLlmSteps.delete(m)||d)}}if(a==="emit_event"&&c==="completed"){const f=Me(lc(i).payload)||{},m=Me(i.result),p=Re(f.name)||Re(m==null?void 0:m.name),g=Me(f.payload!==void 0?f.payload:m==null?void 0:m.payload);p==="abstract.status"&&Re(g==null?void 0:g.killed_by)==="kill_switch"&&(this.forcedStop=g,d=!0)}d&&this.recomputeStop()}recomputeStop(){let r=null;this.forcedStop?r={phase:"forced",label:Re(this.forcedStop.text)||"Stop forced: inference killed",record:this.forcedStop}:this.stopRequested&&(r=this.snapshot.status==="cancelled"&&this.openLlmSteps.size===0?{phase:"stopped",label:"Stopped"}:{phase:"stopping",label:"Stopping…"});const i=this.snapshot.stop||null;((i==null?void 0:i.phase)!==(r==null?void 0:r.phase)||(i==null?void 0:i.label)!==(r==null?void 0:r.label))&&this.set({...this.snapshot,stop:r}),(r==null?void 0:r.phase)==="stopping"&&this.snapshot.status==="cancelled"&&this.followStop(this.generation)}async followStop(r){var i;if(!this.stopFollowing){this.stopFollowing=!0;try{let a=500,c=null;for(;this.live(r)&&((i=this.snapshot.stop)==null?void 0:i.phase)==="stopping";){if(await this.waitForRetry(a),!this.live(r))return;const d=[this.rootRunId,...[...this.watchedRuns].filter(m=>m!==this.rootRunId)];let f=!1;for(const m of d)try{await this.catchUp(m,r)}catch(p){f=!0,this.live(r)&&(this.fail(p,!1),c=this.snapshot.error)}!f&&c&&this.snapshot.error===c&&(this.set({...this.snapshot,error:null}),c=null),a=Math.min(5e3,a*2)}}finally{this.generation===r&&(this.stopFollowing=!1)}}}addMessage(r){const i=Re(r.id)||`${r.role}:${r.content}:${r.ts||""}`;this.seenMessages.has(i)||(this.seenMessages.add(i),this.set({...this.snapshot,messages:[...this.snapshot.messages,{...r,id:i}]}))}toolMessage(r){return{id:`tool:${r.id}`,role:"system",kind:"tool_activity",title:"Tool activity",runId:r.runId,toolActivity:r,content:JSON.stringify({tool:r.name,status:r.status,arguments:r.arguments,output:r.output,error:r.error},null,2),ts:r.endedAt||r.startedAt}}upsertTool(r){const i=this.toolMessage(r),a=this.snapshot.messages.findIndex(d=>d.id===i.id);if(a<0){this.addMessage(i);return}const c=[...this.snapshot.messages];c[a]=i,this.set({...this.snapshot,messages:c})}addRunAssistantMessage(r,i){const a=`answer:${r}:`,c=`final:${r}`;this.snapshot.messages.some(d=>d.role==="assistant"&&d.content===i.content&&(d.id===c||String(d.id||"").startsWith(a)))||this.addMessage(i)}fail(r,i=!0){var a,c,d;kr(r)&&(this.approvalEpoch+=1,this.toolApprovalStopped=!0,this.toolApprovalSuspended=!0,(c=(a=this.options).onAuthError)==null||c.call(a,r)),this.set({...this.snapshot,error:r instanceof Error?r.message:Re((d=Me(r))==null?void 0:d.detail)||String(r),...kr(r)?{autoApproveTools:!1}:{},...i?{connection:"disconnected"}:{}})}newCommandId(){const r=globalThis.crypto;return r&&typeof r.randomUUID=="function"?r.randomUUID():`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`}updateRunState(r,i){var d;if(this.runStates.set(r,i),r!==this.rootRunId){Lt(zn(i))&&((d=this.snapshot.interaction)==null?void 0:d.runId)===r&&this.set({...this.snapshot,interaction:null});return}const a=zn(i),c=Lt(a);if(c){const f=Is(i.output);f&&this.upsertFinal(r,f,ef(i))}this.set({...this.snapshot,run:i,status:a,...c?{interaction:null,autoApproveTools:!1,displayStatus:""}:{}}),(this.stopRequested||this.forcedStop)&&this.recomputeStop()}upsertFinal(r,i,a){const c=`final:${r}`;this.seenMessages.add(c);const d={id:c,role:"assistant",content:i,ts:a,runId:r,statistics:ea(this.snapshot.records).statistics},f=this.snapshot.messages.findIndex(p=>p.id===c||String(p.id||"").startsWith(`answer:${r}:`)&&p.content===i);if(f<0){this.set({...this.snapshot,messages:[...this.snapshot.messages,d]});return}const m=[...this.snapshot.messages];m[f]=d,this.set({...this.snapshot,messages:m})}async refreshRunState(r,i){var a;try{const c=Me(await this.transport.getRun(r,(a=this.controller)==null?void 0:a.signal));c&&this.live(i)&&this.updateRunState(r,c)}catch(c){this.live(i)&&this.fail(c,!1)}}async pollRootLifecycle(r,i){var a;for(;this.live(i)&&this.rootRunId===r&&!Lt(zn(this.runStates.get(r)||null));){if(await this.waitForRetry(2e3),!this.live(i)||this.rootRunId!==r||Lt(zn(this.runStates.get(r)||null)))return;try{const c=Me(await this.transport.getRun(r,(a=this.controller)==null?void 0:a.signal));c&&this.live(i)&&this.rootRunId===r&&this.updateRunState(r,c)}catch(c){if(!this.live(i))return;if(kr(c)){this.fail(c);return}this.fail(c,!1)}}}waitForRetry(r){var c;const i=(c=this.controller)==null?void 0:c.signal;if(!i||i.aborted)return Promise.resolve();const a=i;return new Promise(d=>{const f=setTimeout(p,r),m=()=>{clearTimeout(f),p()};function p(){a.removeEventListener("abort",m),d()}a.addEventListener("abort",m,{once:!0})})}}function jg(n){const r=x.useMemo(()=>new Sg(n.transport,{onAuthError:n.onAuthError,clientId:n.clientId}),[n.transport,n.onAuthError,n.clientId,n.authScopeKey]),i=x.useSyncExternalStore(c=>r.subscribe(c),()=>r.getSnapshot(),()=>r.getSnapshot()),a=String(n.runId||"").trim();return x.useEffect(()=>{r.setToolApprovalPolicy(n.enabled===!1?{enabledTools:[],autoApproveTools:[]}:n.toolApprovalPolicy??null)},[r,n.toolApprovalPolicy,n.enabled]),x.useEffect(()=>{if(n.enabled===!1||!a){r.reset();return}return r.load(a),()=>r.reset()},[r,a,n.enabled]),{controller:r,snapshot:i}}function Qr(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Ot(n){return typeof n=="string"?n.trim():n==null?"":typeof n=="number"||typeof n=="boolean"?String(n):""}function nf(n){return["session","workflow","run","global"].includes(n)?n:null}function Sr(n){return{scope:Ot(n==null?void 0:n.scope).toLowerCase(),name:Ot(n==null?void 0:n.name)||Ot(n==null?void 0:n.event_name),scopeId:Ot(n==null?void 0:n.scope_id)||Ot(n==null?void 0:n.scopeId),sessionId:Ot(n==null?void 0:n.session_id)||Ot(n==null?void 0:n.sessionId),workflowId:Ot(n==null?void 0:n.workflow_id)||Ot(n==null?void 0:n.workflowId),runId:Ot(n==null?void 0:n.run_id)||Ot(n==null?void 0:n.runId)}}function bg(n,r){const i=n.wait,a=Ot(i.wait_key),c=[Sr(i),Sr(Qr(i.details))];for(const d of r){if(d.runId!==n.runId)continue;const f=d.record,m=Qr(f.result),p=Qr(m==null?void 0:m.wait),g=Qr(f.effect),y=Qr(g==null?void 0:g.payload);Ot(p==null?void 0:p.wait_key)!==a&&Ot(y==null?void 0:y.wait_key)!==a||c.push(Sr(f),Sr(y),Sr(Qr(y==null?void 0:y.details)),Sr(p),Sr(Qr(p==null?void 0:p.details)))}return c}function Jl(n,r){return r.scopeId?r.scopeId:n==="session"?r.sessionId:n==="workflow"?r.workflowId:n==="run"?r.runId:"global"}function Wf(n,r,i){return{scope:n,scopeId:r,name:i,...n==="session"?{sessionId:r}:{},...n==="workflow"?{workflowId:r}:{},...n==="run"?{runId:r}:{}}}function Cg(n,r,i){if(!i)return null;const a=`evt:${r}:${i}:`;if(!n.startsWith(a))return null;const c=n.slice(a.length);return c?Wf(r,i,c):null}function Ng(n,r=[],i){if(!n)return{target:null,error:"No event wait is available."};const a=Ot(n.wait.wait_key),c=/^evt:(session|workflow|run|global):/.exec(a);if(!c)return{target:null,error:"The gateway did not provide a canonical event wait key."};const d=nf(c[1]);if(!d)return{target:null,error:"The event wait uses an unsupported scope."};const f=bg(n,Array.isArray(r)?r:[]),m=new Map;for(const w of f){const k=nf(w.scope);if(!k||!w.name)continue;if(k!==d)return{target:null,error:"Event metadata conflicts with the canonical wait scope."};const T=`evt:${k}:`,N=`:${w.name}`;if(!a.startsWith(T)||!a.endsWith(N)||a.length<=T.length+N.length)return{target:null,error:"Event metadata does not exactly match the canonical wait key."};const A=a.slice(T.length,-N.length),S=Jl(k,w);if(S&&S!==A)return{target:null,error:"Event metadata conflicts with the canonical wait target."};const P=Wf(k,A,w.name);m.set(`${P.scope}\0${P.scopeId}\0${P.name}`,P)}if(m.size>1)return{target:null,error:"Multiple event targets match this wait; routing is unavailable."};if(m.size===1)return{target:[...m.values()][0]};const p=new Set;d==="run"&&p.add(n.runId),d==="global"&&p.add("global");for(const w of f){const k=Jl(d,w);k&&p.add(k)}if(Ot(i==null?void 0:i.run_id)===n.runId){const w=Sr(i||null),k=Jl(d,w);k&&p.add(k)}const y=[...p].map(w=>Cg(a,d,w)).filter(w=>!!w),_=new Map(y.map(w=>[`${w.scope}\0${w.scopeId}\0${w.name}`,w]));return _.size===1?{target:[..._.values()][0]}:_.size>1?{target:null,error:"The event key is ambiguous for the available scope metadata."}:{target:null,error:"The gateway did not provide enough canonical event routing metadata."}}const Eg="abstractcode.agent.v1";function pc(n){return!!(n!=null&&n.interfaces.some(r=>[Eg,"abstractassistant.agent.v1"].includes(r)))}function Xe(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function na(n){return Array.isArray(n)?n:[]}function be(n){return typeof n!="string"?void 0:n.trim()||void 0}function Vf(n){return na(n).flatMap(r=>{const i=be(r);return i?[i]:[]})}function Mi(n,r=0){if(typeof n!="number"||!Number.isFinite(n))return;const i=Math.trunc(n);return i>=r?i:void 0}function hc(n,r){if(Array.isArray(n))return n;const i=Xe(n);if(!i)return[];for(const a of r)if(Array.isArray(i[a]))return i[a];return[]}function Hf(n){const r=Xe(n);return r?{...r}:void 0}function rf(n){const r=Hf(n.input_schema??n.inputSchema??n.inputs_schema);if(r)return r;const i=Xe(n.inputs);if(i&&("properties"in i||"type"in i||"$schema"in i))return{...i}}function $g(n){const r=be(n.bundle_version??n.bundleVersion??n.version);if(r)return r;const i=be(n.bundle_ref??n.bundleRef);if(!i)return;const a=i.lastIndexOf("@");return a>0&&a<i.length-1?i.slice(a+1):void 0}function Tg(n,r,i){return n?`${n}${r?`@${r}`:""}:${i}`:i}function sf(n,r,i){var m;const a=Xe(n),c=be((a==null?void 0:a.default_bundle_id)??(a==null?void 0:a.defaultBundleId)),d=hc(n,["items","bundles"]),f=[];for(const p of d){const g=Xe(p);if(!g)continue;const y=Xe(g.actions);if((y==null?void 0:y.can_run)===!1)continue;const _=(m=be(g.status))==null?void 0:m.toLowerCase();if(g.is_draft===!0||g.is_published===!1||g.version_channel==="draft"||_&&!["published","deprecated"].includes(_)||!i.includeDeprecated&&(_==="deprecated"||_==="deleted"||_==="disabled"))continue;const w=be(g.bundle_id??g.bundleId??g.id),k=$g(g);if(k&&/(?:^|[.\-])draft(?:[.\-]|$)/i.test(k))continue;const T=be(g.default_entrypoint??g.defaultEntrypoint),N=r==="private"&&(g.is_default===!0||g.isDefault===!0||!!w&&w===c);for(const A of na(g.entrypoints)){const S=Xe(A);if(!S||!i.includeDeprecated&&(S.deprecated===!0||S.enabled===!1))continue;const P=be(S.flow_id??S.flowId??S.id);if(!P)continue;const C=Vf(S.interfaces??S.interface_ids??S.interfaceIds);if(i.interfaceId&&!C.includes(i.interfaceId))continue;const j=be(S.workflow_id??S.workflowId)??Tg(w,k,P),L=T?T===P:na(g.entrypoints).length===1;f.push({id:`${r}:${j}`,workflowId:j,...w?{bundleId:w}:{},...k?{bundleVersion:k}:{},flowId:P,name:be(S.name??S.title)??P,description:be(S.description)??"",interfaces:C,...rf(S)?{inputSchema:rf(S)}:{},registryScope:r,isPreferredVersion:r==="tenant_catalog"?g.is_default===!0||g.default_version===k:g.latest_published_version===k,...N&&L?{isDefault:!0}:{}})}}return f}function Rg(n){var a;const r=new Map;for(const c of n){const d=c.bundleId||c.id;r.set(d,[...r.get(d)||[],c])}const i=[];for(const c of r.values()){const d=c.filter(g=>g.registryScope==="tenant_catalog"),f=d.length?d:c,m=[...f].sort((g,y)=>+!!y.isPreferredVersion-+!!g.isPreferredVersion||(y.bundleVersion||"").localeCompare(g.bundleVersion||"",void 0,{numeric:!0}))[0],p=(a=c.find(g=>g.isDefault))==null?void 0:a.flowId;for(const g of f.filter(y=>y.bundleVersion===m.bundleVersion))i.push({...g,isDefault:g.flowId===p})}return i.sort((c,d)=>+!!d.isDefault-+!!c.isDefault||c.name.localeCompare(d.name)||c.id.localeCompare(d.id))}function Ag(n,r){return r.some(i=>i.id!==n.id&&i.name===n.name)?`${n.name} · ${n.bundleId||n.flowId}`:n.name}function of(n,r,i={}){const a=[...sf(n,"private",i),...sf(r,"tenant_catalog",i)],c=new Map;for(const d of a)c.set(d.id,d);return[...c.values()].sort((d,f)=>+!!f.isDefault-+!!d.isDefault||d.name.localeCompare(f.name)||d.id.localeCompare(f.id))}function Mg(n){const r=Xe(n);if(!r)return;const i=Xe(r.workflow_selection??r.workflowSelection);if(i)return i;const a=Xe(r._runtime),c=Xe((a==null?void 0:a.workflow_policy)??(a==null?void 0:a.workflowPolicy));if(c)return c;const d=Xe(r.input_data??r.inputData),f=Xe(d==null?void 0:d._runtime);return Xe((f==null?void 0:f.workflow_policy)??(f==null?void 0:f.workflowPolicy))}function Ig(n,r){const i=Mg(r.inputData);if(i){const d=be(i.registry_scope??i.registryScope),f=be(i.bundle_id??i.bundleId),m=be(i.bundle_version??i.bundleVersion),p=be(i.flow_id??i.flowId);if((d==="private"||d==="tenant_catalog")&&f&&p){const g=n.filter(y=>(y.registryScope??"private")===d&&y.bundleId===f&&y.flowId===p&&(!m||y.bundleVersion===m));if(g.length===1)return g[0]}return}const a=be(r.runWorkflowId);if(!a)return;const c=n.filter(d=>(d.registryScope??"private")==="private"&&d.workflowId===a);return c.length===1?c[0]:void 0}function Pg(n){const r=Xe(n)??{},i=Xe(r.policy)??r,c=na(i.mounts??i.workspace_mounts).flatMap((f,m)=>{const p=Xe(f);if(!p)return[];const g=be(p.path??p.root),y=be(p.id??p.name)??g??`mount-${m+1}`;return[{id:y,label:be(p.label??p.name)??y,...g?{path:g}:{},readOnly:p.read_only===!0||p.readOnly===!0||p.writable===!1,raw:{...p}}]}),d=Mi(i.max_attachment_bytes??i.maxAttachmentBytes,1);return{raw:{...i},clientWorkspaceScopeOverrides:i.client_workspace_scope_overrides===!0||i.clientWorkspaceScopeOverrides===!0,allowedAccessModes:Vf(i.allowed_access_modes??i.allowedAccessModes),mounts:c,...d!==void 0?{maxAttachmentBytes:d}:{}}}function Lg(n){const r=hc(n,["items","tools"]),i=new Set,a=[];for(const c of r){const d=Xe(c);if(!d)continue;const f=be(d.name??d.tool_name??d.id);if(!f||i.has(f))continue;i.add(f);const m=d.enabled!==!1&&d.served_disabled!==!0&&d.servedDisabled!==!0,p=Mi(d.risk_rank??d.riskRank),g=Hf(d.input_schema??d.inputSchema??d.parameters);a.push({name:f,description:be(d.description)??"",...be(d.toolset)?{toolset:be(d.toolset)}:{},...be(d.tier)?{tier:be(d.tier)}:{},...be(d.approval_default??d.default_approval??d.approvalDefault??d.defaultApproval??d.approval)?{approval:be(d.approval_default??d.default_approval??d.approvalDefault??d.defaultApproval??d.approval)}:{},...p!==void 0?{riskRank:p}:{},enabled:m,servedDisabled:!m,...be(d.enable_gate??d.enableGate)?{enableGate:be(d.enable_gate??d.enableGate)}:{},...be(d.why_disabled??d.whyDisabled)?{whyDisabled:be(d.why_disabled??d.whyDisabled)}:{},...g?{inputSchema:g}:{},raw:{...d}})}return a.sort((c,d)=>c.name.localeCompare(d.name))}function Og(n){var a;const r=(a=be(n.status??n.state))==null?void 0:a.toLowerCase();return be(n.wait_reason??n.waitReason)||n.waiting===!0||r==="waiting"||r==="paused"?"waiting":r==="running"||r==="queued"||r==="pending"||r==="created"?"running":r==="failed"||r==="error"||r==="cancelled"||r==="canceled"?"failed":r==="completed"||r==="complete"||r==="done"?"done":"unknown"}const af={waiting:4,running:3,failed:2,done:1,unknown:0};function Ps(n){return be(n.updated_at??n.updatedAt??n.finished_at??n.finishedAt??n.created_at??n.createdAt)}function Ls(n){if(!n)return Number.NEGATIVE_INFINITY;const r=Date.parse(n);return Number.isFinite(r)?r:Number.NEGATIVE_INFINITY}function lf(n){var f;const r=be(n);if(r)return r;const i=Xe(n);if(!i)return;const a=be(i.prompt);if(a)return a;const c=Xe(i.input_data??i.inputData),d=["prompt","request","task","message","query","input"].map(m=>be(c==null?void 0:c[m])).find(Boolean);return d||be((f=Xe(c==null?void 0:c.context))==null?void 0:f.task)}function Yl(n,r={}){const i=Xe(n),a=(i==null?void 0:i.has_more)===!0||(i==null?void 0:i.hasMore)===!0,c=hc(n,["items","runs"]),d=new Map;c.forEach((m,p)=>{const g=Xe(m);if(!g||be(g.parent_run_id??g.parentRunId))return;const y=be(g.session_id??g.sessionId),_=be(g.run_id??g.runId??g.id);if(!y||!_)return;const w=d.get(y)??[];w.push({run:g,index:p}),d.set(y,w)});const f=[];for(const[m,p]of d){const g=[...p].sort((T,N)=>Ls(Ps(N.run))-Ls(Ps(T.run))||T.index-N.index),y=[...p].sort((T,N)=>{const A=be(T.run.created_at??T.run.createdAt)??Ps(T.run),S=be(N.run.created_at??N.run.createdAt)??Ps(N.run);return Ls(A)-Ls(S)||T.index-N.index}),_=g.flatMap(({run:T})=>{const N=be(T.run_id??T.runId??T.id);return N?[N]:[]});if(!_.length)continue;let w="unknown";for(const{run:T}of p){const N=Og(T);af[N]>af[w]&&(w=N)}let k;for(const{run:T}of y){const N=be(T.run_id??T.runId??T.id);if(k=(N?lf(r[N]):void 0)??lf(T),k)break}f.push({sessionId:m,state:w,...Ps(g[0].run)?{updatedAt:Ps(g[0].run)}:{},firstRunId:be(y[0].run.run_id??y[0].run.runId??y[0].run.id),latestRunId:_[0],runIds:_,turnCount:p.length,...k?{prompt:k}:{},truncated:a})}return f.sort((m,p)=>Ls(p.updatedAt)-Ls(m.updatedAt)||m.sessionId.localeCompare(p.sessionId))}function ra(n){return n?{...n}:{}}function Os(n){if(n!==void 0)return n.flatMap(r=>{const i=be(r);return i?[i]:[]})}function zg(n,r,i){var S,P,C,j,L,W,V,Q,me;const a=(oe,X)=>{var le,H;!pc(r.workflow)&&!((H=Xe((le=r.inputSchema)==null?void 0:le.properties))!=null&&H[oe])||X!==void 0&&i&&(n[oe]=X)},c=be((S=r.model)==null?void 0:S.provider),d=be((P=r.model)==null?void 0:P.model);if(!!c!=!!d)throw new Error("Choose both a provider and a model, or use the workflow / Gateway defaults.");a("provider",c),a("model",d),r.tools!==void 0&&a("tools",Os(r.tools)??[]);const f=Os(r.skills);f!=null&&f.length&&(n.skills=f);const m=be((C=r.workspace)==null?void 0:C.root),p=be((j=r.workspace)==null?void 0:j.accessMode),g=Os((L=r.workspace)==null?void 0:L.allowedPaths);m!==void 0&&(n.workspace_root=m),p!==void 0&&(n.workspace_access_mode=p),g!=null&&g.length&&(n.workspace_allowed_paths=g),a("system",be(r.system));const y=ra(Xe(n._runtime)),_=(oe,X)=>{X!==void 0&&i&&(y[oe]=X)};if(_("provider",c),_("model",d),_("thinking",be(r.reasoning)),_("speculation",r.speculation),_("system_prompt_extra",be(r.systemPromptExtra)),r.tools!==void 0){const oe=Os(r.tools)??[],X=Array.isArray(y.allowed_tools)?y.allowed_tools:null;y.allowed_tools=X?oe.filter(le=>X.includes(le)):oe}if(r.review!==void 0&&r.reviewCapable!==!1){_("review_mode",r.review.enabled);const oe=r.review.enabled?Mi(r.review.maxRounds,1):void 0;_("review_max_rounds",oe)}const w=Os((W=r.toolPolicy)==null?void 0:W.autoApproveTools),k=Os((V=r.toolPolicy)==null?void 0:V.requireApprovalTools);(((w==null?void 0:w.length)??0)>0||((k==null?void 0:k.length)??0)>0)&&_("tool_policy",{...w!=null&&w.length?{auto_approve_tools:w}:{},...k!=null&&k.length?{require_approval_tools:k}:{}}),r.promptCache!==void 0&&_("prompt_cache",r.promptCache),Object.keys(y).length&&(n._runtime=y);const T=ra(Xe(n._limits)),N=Mi((Q=r.limits)==null?void 0:Q.maxIterations,1),A=Mi((me=r.limits)==null?void 0:me.maxTokens,1);N!==void 0&&i&&(T.max_iterations=N),A!==void 0&&i&&(T.max_tokens=A),Object.keys(T).length&&(n._limits=T),a("max_iterations",N),r.gatingMode==="auto"&&a("gating_mode","auto")}function Fg(n){var a,c,d;const r=ra(n.schemaInputs),i=pc(n.workflow);if(n.promptProperty){const f=be(n.promptProperty);f&&((a=n.prompt)!=null&&a.trim())&&(r[f]=n.prompt)}if(i){const f=n.prompt??"";r.prompt=f;const m=ra(Xe(r.context));m.task=f,delete m.messages,r.use_context=!1,(c=n.messages)!=null&&c.length&&(m.messages=n.messages.map(p=>({role:p.role,content:p.content})),r.use_context=!0),(d=n.attachments)!=null&&d.length&&(m.attachments=n.attachments.map(p=>({...p}))),r.context=m,r.use_session_history=n.useSessionHistory??!0}return zg(r,n,!0),r}class Dg{constructor(){xr(this,"_buffer","");xr(this,"_current",{data_lines:[]})}push(r,i){for(this._buffer+=r;;){const a=this._buffer.indexOf(`
50
+ `);if(a===-1)return;const c=this._buffer.slice(0,a);this._buffer=this._buffer.slice(a+1);const d=c.endsWith("\r")?c.slice(0,-1):c;if(d.startsWith(":"))continue;if(d===""){if(this._current.data_lines.length>0||this._current.event||this._current.id){const g={id:this._current.id,event:this._current.event,data:this._current.data_lines.join(`
51
+ `)};i(g)}this._current={data_lines:[]};continue}const f=d.indexOf(":"),m=f===-1?d:d.slice(0,f),p=f===-1?"":d.slice(f+1).trimStart();m==="id"?this._current.id=p:m==="event"?this._current.event=p:m==="data"&&this._current.data_lines.push(p)}}}function Ke(n,r){const i=(n||"").trim().replace(/\/+$/,"");return i?`${i}${r}`:r}function Qe(n){var a;const r=(n||"").trim(),i={};r&&(i.Authorization=`Bearer ${r}`);try{const c=(a=document.cookie.split(";").map(d=>d.trim()).find(d=>d.startsWith("abstractcode_gateway_csrf=")))==null?void 0:a.slice(26);c&&(i["X-AbstractCode-CSRF"]=decodeURIComponent(c))}catch{}return i}function Bg(n){const r=n.headers.get("retry-after");if(!r)return;const i=Number(r);if(Number.isFinite(i)&&i>0)return i}async function Ug(n){var r;try{if(String(n.headers.get("content-type")||"").toLowerCase().includes("application/json")){const c=await n.json().catch(()=>null);if(c&&typeof c=="object"){const d=c.detail;if(typeof d=="string"&&d.trim())return d.trim();const f=(r=c.error)==null?void 0:r.message;if(typeof f=="string"&&f.trim())return f.trim();try{const m=JSON.stringify(c);if(m&&m!=="{}")return m}catch{}}}const a=await n.text();return a!=null&&a.trim()?a.trim():`${n.status}`}catch{return`${n.status}`}}class Gf extends Error{constructor(i,a){super(i);xr(this,"status");xr(this,"retry_after_s");xr(this,"body_text");this.name="GatewayHttpError",this.status=Number.isFinite(Number(a.status))?Number(a.status):0,this.retry_after_s=a.retry_after_s,this.body_text=a.body_text}}async function Je(n,r){const i=await Ug(n);throw new Gf(`${r}: ${i}`,{status:n.status,retry_after_s:Bg(n),body_text:i})}class Wg{constructor(r){xr(this,"_cfg");this._cfg={...r,base_url:(r.base_url||"").trim()}}async start_run(r,i,a){const c=String((a==null?void 0:a.bundle_id)||"").trim(),d=(a==null?void 0:a.session_id)===null||(a==null?void 0:a.session_id)===void 0?"":String(a.session_id||"").trim(),f=String(r||"").trim(),m={input_data:i||{}};c&&(m.bundle_id=c),f&&(m.flow_id=f),d&&(m.session_id=d);const p=await fetch(Ke(this._cfg.base_url,"/api/gateway/runs/start"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(m)});if(!p.ok)return await Je(p,"start_run failed");const g=await p.json(),y=g==null?void 0:g.run_id;if(typeof y!="string"||!y)throw new Error("start_run: missing run_id");return y}async get_run(r){const i=String(r||"").trim();if(!i)throw new Error("get_run: run_id is required");const a=await fetch(Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(i)}`),{headers:{...Qe(this._cfg.auth_token)}});return a.ok?await a.json():await Je(a,"get_run failed")}async get_run_history_bundle(r,i){const a=String(r||"").trim();if(!a)throw new Error("get_run_history_bundle: run_id is required");const c=new URLSearchParams;(i==null?void 0:i.include_subruns)===!1&&c.set("include_subruns","false"),(i==null?void 0:i.include_session)===!0&&c.set("include_session","true"),typeof(i==null?void 0:i.session_turn_limit)=="number"&&Number.isFinite(i.session_turn_limit)&&c.set("session_turn_limit",String(Math.max(1,Math.trunc(i.session_turn_limit)))),i!=null&&i.ledger_mode&&c.set("ledger_mode",String(i.ledger_mode)),typeof(i==null?void 0:i.ledger_max_items)=="number"&&Number.isFinite(i.ledger_max_items)&&c.set("ledger_max_items",String(Math.max(0,Math.trunc(i.ledger_max_items))));const d=Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/history_bundle?${c.toString()}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"get_run_history_bundle failed")}async list_runs(r){const i=new URLSearchParams,a=typeof(r==null?void 0:r.limit)=="number"?r.limit:50;i.set("limit",String(a));const c=String((r==null?void 0:r.status)||"").trim();c&&i.set("status",c);const d=String((r==null?void 0:r.workflow_id)||"").trim();d&&i.set("workflow_id",d);const f=String((r==null?void 0:r.session_id)||"").trim();f&&i.set("session_id",f),(r==null?void 0:r.root_only)===!0&&i.set("root_only","true"),(r==null?void 0:r.include_ledger_len)===!1&&i.set("include_ledger_len","false"),(r==null?void 0:r.include_metrics)===!0&&i.set("include_metrics","true");const m=Ke(this._cfg.base_url,`/api/gateway/runs?${i.toString()}`),p=await fetch(m,{headers:{...Qe(this._cfg.auth_token)}});return p.ok?await p.json():await Je(p,"list_runs failed")}async get_ledger(r,i){const a=String(r||"").trim();if(!a)throw new Error("get_ledger: run_id is required");const c=Number((i==null?void 0:i.after)||0),d=Number((i==null?void 0:i.limit)||0),f=Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/ledger?after=${encodeURIComponent(String(c))}&limit=${encodeURIComponent(String(d))}`),m=await fetch(f,{headers:{...Qe(this._cfg.auth_token)}});if(!m.ok)return await Je(m,"get_ledger failed");const p=await m.json(),g=Array.isArray(p==null?void 0:p.items)?p.items:[],y=typeof(p==null?void 0:p.next_after)=="number"?p.next_after:c;return{items:g,next_after:y}}async stream_ledger(r,i){var w;const a=String(r||"").trim();if(!a)throw new Error("stream_ledger: run_id is required");const c=Number((i==null?void 0:i.after)||0),d=i.on_step,f=i.signal,m=Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/ledger/stream?after=${encodeURIComponent(String(c))}`),p=await fetch(m,{headers:{Accept:"text/event-stream",...Qe(this._cfg.auth_token)},signal:f});if(!p.ok)return await Je(p,"stream_ledger failed");if(!p.body)throw new Error("stream_ledger: response body is missing");(w=i.on_open)==null||w.call(i);const g=p.body.getReader(),y=new TextDecoder("utf-8"),_=new Dg;for(;;){const{value:k,done:T}=await g.read();if(T)return;const N=y.decode(k,{stream:!0});_.push(N,A=>{if(!(A.event!=="step"||!A.data))try{const S=JSON.parse(A.data);S&&typeof S.cursor=="number"&&S.record&&d(S)}catch{}})}}async list_bundles(){const r=await fetch(Ke(this._cfg.base_url,"/api/gateway/bundles"),{headers:{...Qe(this._cfg.auth_token)}});return r.ok?await r.json():await Je(r,"list_bundles failed")}async reload_bundles(){const r=await fetch(Ke(this._cfg.base_url,"/api/gateway/bundles/reload"),{method:"POST",headers:{...Qe(this._cfg.auth_token)}});return r.ok?await r.json():await Je(r,"reload_bundles failed")}async upload_bundle(r,i){const a=(i==null?void 0:i.overwrite)===!0,c=(i==null?void 0:i.reload)!==!1,d=new FormData;d.set("overwrite",a?"true":"false"),d.set("reload",c?"true":"false"),d.set("file",r,r.name||"upload.flow");const f=await fetch(Ke(this._cfg.base_url,"/api/gateway/bundles/upload"),{method:"POST",headers:{...Qe(this._cfg.auth_token)},body:d});return f.ok?await f.json():await Je(f,"upload_bundle failed")}async discovery_tools(){const r=await fetch(Ke(this._cfg.base_url,"/api/gateway/discovery/tools"),{headers:{...Qe(this._cfg.auth_token)}});return r.ok?await r.json():await Je(r,"discovery_tools failed")}async discovery_providers(r){const i=(r==null?void 0:r.include_models)===!0,a=Ke(this._cfg.base_url,`/api/gateway/discovery/providers?include_models=${encodeURIComponent(String(i))}`),c=await fetch(a,{headers:{...Qe(this._cfg.auth_token)}});return c.ok?await c.json():await Je(c,"discovery_providers failed")}async discovery_provider_models(r){const i=String(r||"").trim();if(!i)throw new Error("discovery_provider_models: provider_name is required");const a=await fetch(Ke(this._cfg.base_url,`/api/gateway/discovery/providers/${encodeURIComponent(i)}/models`),{headers:{...Qe(this._cfg.auth_token)}});return a.ok?await a.json():await Je(a,"discovery_provider_models failed")}async discovery_model_capabilities(r,i=""){const a=String(r||"").trim();if(!a)throw new Error("discovery_model_capabilities: model_name is required");const c=new URLSearchParams({model_name:a});i.trim()&&c.set("provider",i.trim());const d=Ke(this._cfg.base_url,`/api/gateway/discovery/models/capabilities?${c}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"discovery_model_capabilities failed")}async workspace_policy(){const r=await fetch(Ke(this._cfg.base_url,"/api/gateway/workspace/policy"),{headers:{...Qe(this._cfg.auth_token)}});return r.ok?await r.json():await Je(r,"workspace_policy failed")}async files_search(r,i){const a=String(r||"").trim(),c=typeof(i==null?void 0:i.limit)=="number"&&Number.isFinite(i.limit)?Math.max(1,Math.trunc(i.limit)):20,d=new URLSearchParams;d.set("query",a),d.set("limit",String(c));const f=i==null?void 0:i.scope;if(f&&typeof f=="object"){const g=String(f.workspace_root||"").trim(),y=String(f.workspace_access_mode||"").trim(),_=String(f.workspace_allowed_paths||"").trim(),w=String(f.workspace_ignored_paths||"").trim();g&&d.set("workspace_root",g),y&&d.set("workspace_access_mode",y),_&&d.set("workspace_allowed_paths",_),w&&d.set("workspace_ignored_paths",w)}const m=Ke(this._cfg.base_url,`/api/gateway/files/search?${d.toString()}`),p=await fetch(m,{headers:{...Qe(this._cfg.auth_token)},signal:i==null?void 0:i.signal});return p.ok?await p.json():await Je(p,"files_search failed")}async list_run_artifacts(r,i){const a=String(r||"").trim();if(!a)throw new Error("list_run_artifacts: run_id is required");const c=typeof(i==null?void 0:i.limit)=="number"?i.limit:200,d=Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/artifacts?limit=${encodeURIComponent(String(c))}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"list_run_artifacts failed")}async get_run_artifact_blob(r,i,a){const c=String(r||"").trim(),d=String(i||"").trim();if(!c)throw new Error("get_run_artifact_blob: run_id is required");if(!d)throw new Error("get_run_artifact_blob: artifact_id is required");const f=Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(d)}/content`),m=await fetch(f,{headers:{...Qe(this._cfg.auth_token)}});if(!m.ok)return await Je(m,"get_run_artifact_blob failed");const p=await m.blob(),g=typeof(a==null?void 0:a.max_bytes)=="number"&&Number.isFinite(a.max_bytes)?Math.max(0,Math.trunc(a.max_bytes)):0;if(g>0&&p.size>g)throw new Error(`Artifact too large (${p.size} bytes > ${g} bytes)`);const y=String(m.headers.get("content-type")||"").trim()||"application/octet-stream";return{blob:p,content_type:y}}async get_run_artifact_text(r,i,a){const{blob:c}=await this.get_run_artifact_blob(r,i,a);return await c.text()}async attachments_ingest(r,i,a){const c=String(r||"").trim(),d=String(i||"").trim();if(!c)throw new Error("attachments_ingest: session_id is required");if(!d)throw new Error("attachments_ingest: path is required");const f={session_id:c,path:d},m=a==null?void 0:a.scope;if(m&&typeof m=="object"){const w=String(m.workspace_root||"").trim(),k=String(m.workspace_access_mode||"").trim(),T=String(m.workspace_allowed_paths||"").trim(),N=String(m.workspace_ignored_paths||"").trim();w&&(f.workspace_root=w),k&&(f.workspace_access_mode=k),T&&(f.workspace_allowed_paths=T),N&&(f.workspace_ignored_paths=N)}const p=await fetch(Ke(this._cfg.base_url,"/api/gateway/attachments/ingest"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(f)});if(!p.ok)return await Je(p,"attachments_ingest failed");const g=await p.json(),y=g==null?void 0:g.attachment;if(!y||typeof y!="object")throw new Error("attachments_ingest: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_ingest: missing attachment.$artifact");return y}async attachments_upload(r,i,a){const c=String(r||"").trim();if(!c)throw new Error("attachments_upload: session_id is required");if(!i)throw new Error("attachments_upload: file is required");const d=String((a==null?void 0:a.filename)||"").trim()||String((i==null?void 0:i.name)||"").trim()||"upload.bin",f=String((a==null?void 0:a.content_type)||"").trim()||String((i==null?void 0:i.type)||"").trim(),m=new FormData;m.append("session_id",c),m.append("file",i,d),m.append("filename",d),f&&m.append("content_type",f);const p=await fetch(Ke(this._cfg.base_url,"/api/gateway/attachments/upload"),{method:"POST",headers:{...Qe(this._cfg.auth_token)},body:m});if(!p.ok)return await Je(p,"attachments_upload failed");const g=await p.json(),y=g==null?void 0:g.attachment;if(!y||typeof y!="object")throw new Error("attachments_upload: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return y}async audio_transcribe(r,i){const a=String(r||"").trim();if(!a)throw new Error("audio_transcribe: run_id is required");const c={audio_artifact:i==null?void 0:i.audio_artifact,request_id:(i==null?void 0:i.request_id)||void 0},d=(i==null?void 0:i.language)===null||(i==null?void 0:i.language)===void 0?"":String(i.language||"").trim();d&&(c.language=d);const f=await fetch(Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/audio/transcribe`),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(c)});return f.ok?await f.json():await Je(f,"audio_transcribe failed")}async voice_tts(r,i){const a=String(r||"").trim();if(!a)throw new Error("voice_tts: run_id is required");const c={text:String((i==null?void 0:i.text)||"")},d=(i==null?void 0:i.voice)===null||(i==null?void 0:i.voice)===void 0?"":String(i.voice||"").trim(),f=(i==null?void 0:i.format)===null||(i==null?void 0:i.format)===void 0?"":String(i.format||"").trim(),m=(i==null?void 0:i.request_id)===null||(i==null?void 0:i.request_id)===void 0?"":String(i.request_id||"").trim();d&&(c.voice=d),f&&(c.format=f),m&&(c.request_id=m);const p=await fetch(Ke(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(a)}/voice/tts`),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(c)});return p.ok?await p.json():await Je(p,"voice_tts failed")}async submit_command(r){const i={command_id:String((r==null?void 0:r.command_id)||"").trim(),run_id:String((r==null?void 0:r.run_id)||"").trim(),type:String((r==null?void 0:r.type)||"").trim(),payload:r!=null&&r.payload&&typeof r.payload=="object"?r.payload:{}},a=String((r==null?void 0:r.ts)||"").trim();a&&(i.ts=a);const c=String((r==null?void 0:r.client_id)||"").trim();c&&(i.client_id=c);const d=await fetch(Ke(this._cfg.base_url,"/api/gateway/commands"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return d.ok?await d.json():await Je(d,"submit_command failed")}async bug_report_create(r){const i={session_id:String((r==null?void 0:r.session_id)||"").trim(),description:String((r==null?void 0:r.description)||"")},a=String((r==null?void 0:r.active_run_id)||"").trim();a&&(i.active_run_id=a);const c=String((r==null?void 0:r.workflow_id)||"").trim();c&&(i.workflow_id=c);const d=String((r==null?void 0:r.client)||"").trim();d&&(i.client=d);const f=String((r==null?void 0:r.client_version)||"").trim();f&&(i.client_version=f);const m=String((r==null?void 0:r.user_agent)||"").trim();m&&(i.user_agent=m);const p=String((r==null?void 0:r.url)||"").trim();p&&(i.url=p);const g=String((r==null?void 0:r.provider)||"").trim();g&&(i.provider=g);const y=String((r==null?void 0:r.model)||"").trim();y&&(i.model=y);const _=String((r==null?void 0:r.template)||"").trim();_&&(i.template=_);const w=r==null?void 0:r.context;w&&typeof w=="object"&&(i.context=w);const k=await fetch(Ke(this._cfg.base_url,"/api/gateway/bugs/report"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return k.ok?await k.json():await Je(k,"bug_report_create failed")}async feature_report_create(r){const i={session_id:String((r==null?void 0:r.session_id)||"").trim(),description:String((r==null?void 0:r.description)||"")},a=String((r==null?void 0:r.active_run_id)||"").trim();a&&(i.active_run_id=a);const c=String((r==null?void 0:r.workflow_id)||"").trim();c&&(i.workflow_id=c);const d=String((r==null?void 0:r.client)||"").trim();d&&(i.client=d);const f=String((r==null?void 0:r.client_version)||"").trim();f&&(i.client_version=f);const m=String((r==null?void 0:r.user_agent)||"").trim();m&&(i.user_agent=m);const p=String((r==null?void 0:r.url)||"").trim();p&&(i.url=p);const g=String((r==null?void 0:r.provider)||"").trim();g&&(i.provider=g);const y=String((r==null?void 0:r.model)||"").trim();y&&(i.model=y);const _=String((r==null?void 0:r.template)||"").trim();_&&(i.template=_);const w=r==null?void 0:r.context;w&&typeof w=="object"&&(i.context=w);const k=await fetch(Ke(this._cfg.base_url,"/api/gateway/features/report"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return k.ok?await k.json():await Je(k,"feature_report_create failed")}async prompt_cache_stats(r,i){const a=String(r||"").trim(),c=String(i||"").trim();if(!a||!c)throw new Error("prompt_cache_stats: provider and model are required");const d=Ke(this._cfg.base_url,`/api/gateway/prompt_cache/stats?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(c)}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"prompt_cache_stats failed")}async prompt_cache_capabilities(r,i){const a=String(r||"").trim(),c=String(i||"").trim();if(!a||!c)throw new Error("prompt_cache_capabilities: provider and model are required");const d=Ke(this._cfg.base_url,`/api/gateway/prompt_cache/capabilities?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(c)}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"prompt_cache_capabilities failed")}async prompt_cache_saved(r,i){const a=String(r||"").trim(),c=String(i||"").trim();if(!a||!c)throw new Error("prompt_cache_saved: provider and model are required");const d=Ke(this._cfg.base_url,`/api/gateway/prompt_cache/saved?provider=${encodeURIComponent(a)}&model=${encodeURIComponent(c)}`),f=await fetch(d,{headers:{...Qe(this._cfg.auth_token)}});return f.ok?await f.json():await Je(f,"prompt_cache_saved failed")}async prompt_cache_clear(r){const i={provider:String((r==null?void 0:r.provider)||"").trim(),model:String((r==null?void 0:r.model)||"").trim()},a=(r==null?void 0:r.key)===null||(r==null?void 0:r.key)===void 0?"":String(r.key||"").trim();a&&(i.key=a);const c=await fetch(Ke(this._cfg.base_url,"/api/gateway/prompt_cache/clear"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return c.ok?await c.json():await Je(c,"prompt_cache_clear failed")}async prompt_cache_save(r){const i={provider:String((r==null?void 0:r.provider)||"").trim(),model:String((r==null?void 0:r.model)||"").trim(),name:String((r==null?void 0:r.name)||"").trim(),key:String((r==null?void 0:r.key)||"").trim(),q8:!!(r!=null&&r.q8)},a=await fetch(Ke(this._cfg.base_url,"/api/gateway/prompt_cache/save"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return a.ok?await a.json():await Je(a,"prompt_cache_save failed")}async prompt_cache_load(r){const i={provider:String((r==null?void 0:r.provider)||"").trim(),model:String((r==null?void 0:r.model)||"").trim(),name:String((r==null?void 0:r.name)||"").trim(),key:String((r==null?void 0:r.key)||"").trim(),clear_existing:!!(r!=null&&r.clear_existing)},a=await fetch(Ke(this._cfg.base_url,"/api/gateway/prompt_cache/load"),{method:"POST",headers:{"Content-Type":"application/json",...Qe(this._cfg.auth_token)},body:JSON.stringify(i)});return a.ok?await a.json():await Je(a,"prompt_cache_load failed")}}async function Nt(n,r={}){if(!n.startsWith("/api/gateway/"))throw new Error("Gateway requests must use the app's authenticated proxy.");const i=new Headers(r.headers);i.set("Accept","application/json"),r.body&&!(r.body instanceof FormData)&&i.set("Content-Type","application/json");const a=document.cookie.split(";").map(d=>d.trim()).find(d=>d.startsWith("abstractcode_gateway_csrf="));a&&i.set("X-AbstractCode-CSRF",decodeURIComponent(a.slice(26)));const c=await fetch(n,{...r,headers:i,credentials:"same-origin"});if(!c.ok){const d=await c.text();let f=d;try{const m=JSON.parse(d);f=typeof m.detail=="string"?m.detail:JSON.stringify(m.detail||m)}catch{}throw new Gf(f||`Gateway request failed (${c.status})`,{status:c.status,body_text:d})}if(c.status!==204)return c.json()}const yn=new Wg({base_url:""});function En(n){return n instanceof Error?n.message:String(n)}function Yr(){return crypto.randomUUID()}async function Vg(n,r,i){const{blob:a}=await yn.get_run_artifact_blob(n,r),c=URL.createObjectURL(a),d=document.createElement("a");d.href=c,d.download=i.replace(/[\\/]/g,"_")||"artifact",d.click(),window.setTimeout(()=>URL.revokeObjectURL(c),1e3)}const en=n=>n&&typeof n=="object"&&!Array.isArray(n)?n:{};function Hg(n,r){const i=en(r);return Object.fromEntries(Object.keys(en(n.properties)).flatMap(a=>["_runtime","_limits"].includes(a)||!Object.prototype.hasOwnProperty.call(i,a)?[]:[[a,structuredClone(i[a])]]))}function cf(n){if(!n)return;const r=en(n.input_data_schema||n.input_schema||n.schema||n),i=Object.fromEntries(Object.entries(en(r.properties)).map(([a,c])=>[a,{...en(c)}]));for(const a of Array.isArray(n.inputs)?n.inputs:[])a!=null&&a.id&&(i[a.id]={...en(a.schema),...i[a.id],...a.type?{"x-abstract-type":a.type}:{},...a.label?{title:a.label}:{},...Object.prototype.hasOwnProperty.call(a,"default")?{default:a.default}:{}});for(const[a,c]of Object.entries(en(n.defaults)))i[a]={...i[a],default:c};return{...r,properties:i}}function Gg(n,r){var g;const i=en(r).nodes;if(!Array.isArray(i))throw new Error("The workflow input declarations could not be verified. Please retry.");const a=i.find(y=>{var _;return(((_=y==null?void 0:y.data)==null?void 0:_.nodeType)||(y==null?void 0:y.type))==="on_flow_start"});if(!a||!Array.isArray((g=a.data)==null?void 0:g.outputs))throw new Error("The workflow start inputs could not be verified. Please retry.");const c=a.data.outputs.filter(y=>typeof(y==null?void 0:y.id)=="string"&&y.id&&y.type!=="execution"&&!["exec","exec-out"].includes(y.id)),d=new Set(c.map(y=>y.id)),f=new Set((Array.isArray(n.required)?n.required:[]).filter(y=>!d.has(y))),m={...n.properties},p=en(a.data.pinDefaults);for(const y of c)y.required===!0&&f.add(y.id),m[y.id]={...en(m[y.id]),...en(y.schema),...y.type?{"x-abstract-type":y.type}:{},...y.label?{title:y.label}:{},...Object.prototype.hasOwnProperty.call(p,y.id)?{default:structuredClone(p[y.id])}:{}};return{...n,properties:m,required:[...f]}}function Ri(n){return Object.fromEntries(Object.entries((n==null?void 0:n.properties)||{}).flatMap(([r,i])=>Object.prototype.hasOwnProperty.call(en(i),"default")?[[r,structuredClone(en(i).default)]]:[]))}function Kg(n){const r=Array.isArray(n.type)?n.type.find(a=>a!=="null"):n.type;if(r)return r;const i=n["x-abstract-type"];return["tools","assertions"].includes(i)?"array":["json_schema","memory","assertion"].includes(i)?"object":"string"}function Qg(n){const r=(n==null?void 0:n.properties)||{},i=c=>{const d=r[c];return d&&(d.type==="string"||Array.isArray(d.type)&&d.type.includes("string")||!d.type&&d["x-abstract-type"]==="string")},a=Object.keys(r).filter(c=>{var d;return((d=r[c])==null?void 0:d["x-abstract-role"])==="prompt"&&i(c)});return a.length?a.length===1?a[0]:void 0:["prompt","request","task","message","query","input"].find(i)}function Jg(n,r){var c,d,f;if(!n)return[];const i={...Ri(n),...r},a=[];for(const m of Array.isArray(n.required)?n.required:[])i[m]===void 0&&a.push(`${((d=(c=n.properties)==null?void 0:c[m])==null?void 0:d.title)||m} is required.`);for(const[m,p]of Object.entries(i)){const g=(f=n.properties)==null?void 0:f[m];if(!g||p===void 0)continue;const y=g.title||m;Array.isArray(g.enum)&&!g.enum.some(T=>JSON.stringify(T)===JSON.stringify(p))&&a.push(`${y} must be one of the available choices.`);const _=Array.isArray(g.type)?g.type:g.type?[g.type]:[];if(p===null&&(_.includes("null")||!_.length))continue;const w=Array.isArray(p)?"array":p===null?"null":typeof p,k=_.includes(w)?w:w==="number"&&_.includes("integer")?"integer":_[0];(k==="number"||k==="integer")&&(typeof p!="number"||!Number.isFinite(p)||k==="integer"&&!Number.isInteger(p))&&a.push(`${y} must be ${k==="integer"?"a whole number":"a number"}.`),typeof p=="number"&&g.minimum!==void 0&&p<g.minimum&&a.push(`${y} must be at least ${g.minimum}.`),typeof p=="number"&&g.maximum!==void 0&&p>g.maximum&&a.push(`${y} must be at most ${g.maximum}.`),k==="string"&&typeof p!="string"&&a.push(`${y} must be text.`),typeof p=="string"&&g.minLength!==void 0&&p.length<g.minLength&&a.push(`${y} must contain at least ${g.minLength} characters.`),k==="boolean"&&typeof p!="boolean"&&a.push(`${y} must be true or false.`),k==="array"&&!Array.isArray(p)&&a.push(`${y} must be a JSON array.`),k==="object"&&(p===null||typeof p!="object"||Array.isArray(p))&&a.push(`${y} must be a JSON object.`)}return a}function Kf(n){const r=(n==null?void 0:n.properties)||{},i=[];for(const[a,c]of Object.entries(r)){const d=en(c);if(!(a==="provider"||a.endsWith("_provider")||String(d["x-abstract-type"]||"").startsWith("provider")))continue;const f=String(d["x-abstract-type"]||""),m=a.replace("provider","model"),p=Object.keys(r).filter(k=>{var T;return((T=r[k])==null?void 0:T["x-abstract-type"])===f.replace(/^provider/,"model")}),g=m!==a&&r[m]?m:p.length===1?p[0]:"";if(!g)continue;const y=a==="provider"?"":a.startsWith("provider_")?a.slice(9):a.endsWith("_provider")?a.slice(0,-9):f.replace(/^provider_?/,""),_=y&&y!=="text"?`${y}_`:"",w=[`${_}reasoning`,`${_}thinking`,`${_}reasoning_effort`,`reasoning_${y}`,`thinking_${y}`].find(k=>r[k]);i.push({provider:a,model:g,reasoning:w,title:_?_.replace(/_/g," ").trim():"Text model"})}return i}const mc={fetchProviders:async()=>{const n=await yn.discovery_providers(),r=n.providers||n.items;return Array.isArray(r)?r.map(i=>typeof i=="string"?{name:i}:i):[]},fetchModels:async n=>{const r=await yn.discovery_provider_models(n),i=r.models||r.items;return Array.isArray(i)?i.map(a=>typeof a=="string"?a:a.id||a.name).filter(Boolean):[]},fetchModelCapabilities:(n,r="")=>yn.discovery_model_capabilities(n,r)};function Yg(n){for(const r of["output.text","input.text"]){const i=(Array.isArray(n==null?void 0:n.routes)?n.routes:[]).find(a=>a.key===r&&a.source!=="not_configured"&&a.provider&&a.model);if(i)return{provider:i.provider,model:i.model}}}function Xg(n,r){n.startsWith("provider_")?n=`${n.slice(9)}_provider`:r!=null&&r.startsWith("provider_")&&!n.endsWith("_provider")&&(n=`${r.slice(9)}_provider`);const i={image_provider:"text_to_image",image_edit_provider:"image_to_image",image_upscale_provider:"image_upscale",video_provider:"text_to_video",image_to_video_provider:"image_to_video"}[n];if(!i&&!["music_provider","voice_provider"].includes(n))return mc;const a=n==="voice_provider",c=i?`/api/gateway/vision/provider_models?task=${i}`:a?"/api/gateway/audio/speech/models?compact=true":"/api/gateway/audio/music/models?task=text_to_music",d=i?`${c}&providers_only=true`:a?"/api/gateway/voice/voices?providers_only=true&compact=true":"/api/gateway/audio/music/providers?task=text_to_music",f=m=>Array.isArray(m)?m.map(p=>typeof p=="string"?p:p.id||p.name).filter(Boolean):[];return{fetchProviders:async()=>{const m=await Nt(d);if(m.error)throw new Error(m.error);return f(m.providers||m.available_providers||m.items).map(p=>({name:p}))},fetchModels:async m=>{var g,y,_;const p=await Nt(`${c}&provider=${encodeURIComponent(m)}`);if(p.error)throw new Error(p.error);return f(((g=p.models_by_provider)==null?void 0:g[m])||((y=p.tts_models_by_provider)==null?void 0:y[m])||((_=p.music_models_by_provider)==null?void 0:_[m])||p.models||p.items)}}}const Xl={workflows:[],choices:[],policy:null,tools:[],sessions:[],capabilities:{},loading:!1,errors:[],hasMore:!1};function Zg(n){var i;const r=((i=n==null?void 0:n.capabilities)==null?void 0:i.contracts)??(n==null?void 0:n.contracts)??n;return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}function qg(n,r){const[i,a]=x.useState(Xl),[c,d]=x.useState(100),f=x.useRef(0),m=x.useRef(),p=x.useRef({identity:"",values:{}}),g=x.useCallback(async()=>{var S,P;const y=++f.current;(S=m.current)==null||S.abort();const _=new AbortController;if(m.current=_,p.current.identity!==n&&(p.current={identity:n,values:{}}),!n){a(Xl);return}a(C=>({...C,loading:!0,errors:[]}));const w=["bundles?all_versions=true&include_drafts=false","workspace/policy","discovery/tools",`runs?root_only=true&include_ledger_len=false&limit=${c}`,"discovery/capabilities","workflow-catalog?scope=tenant","config/capability-defaults"],k=await Promise.allSettled(w.map(C=>Nt(`/api/gateway/${C}`,{signal:_.signal})));if(f.current!==y)return;const T=C=>k[C].status==="fulfilled"?k[C].value:void 0,N=[];k.forEach((C,j)=>{var L,W;C.status==="rejected"&&(((L=C.reason)==null?void 0:L.status)===401&&r(),!(j===5&&[403,404,501].includes((W=C.reason)==null?void 0:W.status))&&N.push(`${["Workflows","Workspace policy","Tools","Conversations","Capabilities","Shared workflows","Gateway defaults"][j]}: ${En(C.reason)}`))}),a({workflows:of(T(0),T(5)),choices:Rg(of(T(0),T(5))),policy:T(1)?Pg(T(1)):null,tools:Lg(T(2)),sessions:Yl(T(3),p.current.values),capabilities:Zg(T(4)),defaultModel:Yg(T(6)),loading:!1,errors:N,hasMore:!!((P=T(3))!=null&&P.has_more)});const A=Yl(T(3),p.current.values).filter(C=>!C.prompt&&!(C.firstRunId in p.current.values));for(let C=0;C<A.length;C+=4){if(f.current!==y||_.signal.aborted||(await Promise.all(A.slice(C,C+4).map(async j=>{try{const L=await Nt(`/api/gateway/runs/${encodeURIComponent(j.firstRunId)}/input_data`,{signal:_.signal});f.current===y&&!_.signal.aborted&&(p.current.values[j.firstRunId]=L)}catch(L){!_.signal.aborted&&(L==null?void 0:L.status)===401&&r()}})),f.current!==y||_.signal.aborted))return;a(j=>({...j,sessions:Yl(T(3),p.current.values)}))}},[n,c,r]);return x.useEffect(()=>{d(100)},[n]),x.useEffect(()=>(a(Xl),g(),()=>{var y;f.current+=1,(y=m.current)==null||y.abort()}),[g]),{...i,refresh:g,loadMore:()=>d(y=>y+100)}}async function ey(n){if(n.inputSchema)return cf(n.inputSchema);if(!n.bundleId)return;const r=encodeURIComponent(n.bundleId),i=encodeURIComponent(n.flowId),a=n.registryScope==="tenant_catalog"&&n.bundleVersion?`/api/gateway/workflow-catalog/${r}/versions/${encodeURIComponent(n.bundleVersion)}/flows/${i}/input_schema?scope=tenant`:`/api/gateway/bundles/${r}/flows/${i}/input_schema${n.bundleVersion?`?bundle_version=${encodeURIComponent(n.bundleVersion)}`:""}`,c=await Nt(a),d=cf(c);if(!d||c!=null&&c.native_loop_factory||(c==null?void 0:c.version)!==1||!Array.isArray(c==null?void 0:c.inputs)||!(c!=null&&c.input_data_schema)||!Array.isArray(d.required)||!d.required.length)return d;const f=n.bundleVersion||c.bundle_version;if(!f)throw new Error("The Gateway did not identify the workflow version. Refresh workflows and retry.");const m={bundle_id:n.bundleId,bundle_version:f,flow_id:n.flowId},p=_=>{for(const[w,k]of Object.entries(m))if((_==null?void 0:_[w])!==k)throw new Error("The Gateway returned inputs for a different workflow version. Refresh workflows and retry.");if(n.registryScope==="tenant_catalog"&&(_==null?void 0:_.registry_scope)!=="tenant_catalog")throw new Error("The Gateway returned inputs from a different workflow registry. Refresh workflows and retry.")};p(c);const g=n.registryScope==="tenant_catalog"?`/api/gateway/workflow-catalog/${r}/versions/${encodeURIComponent(f)}/flows/${i}?scope=tenant`:`/api/gateway/bundles/${r}/flows/${i}?bundle_version=${encodeURIComponent(f)}`,y=await Nt(g);return p(y),Gg(d,y.flow)}const Zl=n=>`/api/gateway/runs/${encodeURIComponent(n)}`,ty={getRun:(n,r)=>Nt(Zl(n),{signal:r}),getHistory:(n,r)=>Nt(`${Zl(n)}/history_bundle?include_subruns=true&include_session=true&ledger_mode=full`,{signal:r}),getLedger:(n,r,i)=>Nt(`${Zl(n)}/ledger?after=${r}&limit=200`,{signal:i}),streamLedger:(n,r,i,a,c)=>yn.stream_ledger(n,{after:r,on_step:i,signal:a,on_open:c}),submitCommand:(n,r)=>Nt("/api/gateway/commands",{method:"POST",body:JSON.stringify(n),signal:r})};function ny(n,r,i=[],a=null,c){if(!n)return null;const d=n.wait,f=`${n.runId}:${d.wait_key}:${n.stepId||""}`,m=d.details||{};if(m.mode==="approval_required"||m.kind==="tool_approval"){const g=Array.isArray(m.tool_calls)?m.tool_calls:[],y={runId:n.runId,waitKey:String(d.wait_key||""),stepId:n.stepId},_=[...new Set(g.map(w=>w.name||"tool"))];return{id:f,kind:"tool-approval",title:`${g.length||"Requested"} ${g.length===1?"action needs":"actions need"} permission`,toolName:_.join(", ")||"the requested tools",description:"Review the targets below. Allow once approves this batch only.",detail:o.jsxs("div",{className:"code-approval-summary",children:[o.jsx(Lf,{tools:g.map((w,k)=>({id:String(w.call_id||w.id||k),runId:n.runId,name:w.name||"Tool",arguments:w.arguments,status:"waiting"}))}),o.jsxs("details",{children:[o.jsx("summary",{children:"Review full tool arguments (JSON)"}),o.jsx(Us,{value:g.length?g:m})]})]}),approveLabel:"Allow once",denyLabel:"Deny",approveAllLabel:"Allow all enabled tools",approveAllDescription:"Sets permissions: all for this Gateway account, including future turns. Unchecked tools stay unavailable; explicit Ask overrides and Gateway restrictions remain enforced. Questions still need your answer.",onApproveAll:c?async()=>{await r.approveWithPolicyChange(y,()=>{c()})}:void 0,onApprove:async()=>{await r.approve(!0,y)},onDeny:async()=>{await r.approve(!1,y)}}}if(d.reason==="user"||d.reason==="ask_user")return{id:f,kind:"ask-user",title:"A question for you",prompt:String(d.prompt||m.prompt||"How would you like to continue?"),allowFreeText:d.allow_free_text!==!1,choices:(Array.isArray(d.choices)?d.choices:[]).map(g=>typeof g=="object"&&g!==null?{id:String(g.value??g.id??g.label),label:String(g.label??g.text??g.value??g.id),description:g.description}:{id:String(g),label:String(g)}),onSubmit:async g=>{await r.resume(g)}};const p=String(d.wait_key||"");if(d.reason==="event"||p.startsWith("evt:")){const g=Ng(n,i,a),y=g.target,_=(y==null?void 0:y.name)||"";return{id:f,kind:"event-wait",title:y?"Waiting for an event":"Event routing unavailable",eventName:_,prompt:String(d.prompt||`This workflow will continue when “${_||"its trigger"}” arrives.`),description:y?"You can also send the expected event here.":`This event cannot be sent safely. ${g.error}`,initialPayload:"{}",payloadLabel:"Event data (JSON)",sendLabel:"Send event",onSend:async w=>{if(!y)throw new Error(g.error);const k=JSON.parse(w||"{}"),T={name:y.name,scope:y.scope,payload:k};y.scope==="session"?T.session_id=y.scopeId:y.scope==="workflow"?T.workflow_id=y.scopeId:y.scope==="run"&&(T.run_id=y.scopeId),await r.emitEvent(T)}}}return null}function jr(n){return typeof n=="string"?n.trim():""}function ry(n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},a=(Array.isArray(r.skills)?r.skills:[]).flatMap(d=>{const f=d&&typeof d=="object"&&!Array.isArray(d)?d:null,m=jr(f==null?void 0:f.name);if(!f||!m)return[];const p=f.source&&typeof f.source=="object"&&!Array.isArray(f.source)?f.source:void 0;return[{name:m,description:jr(f.description),trustLevel:jr(f.trust_level)||"unverified",blocked:f.blocked===!0,requiresReview:f.requires_review===!0,reasons:Array.isArray(f.reasons)?f.reasons.map(jr).filter(Boolean):[],source:p?{source:jr(p.source),binding:jr(p.binding),ambiguous:p.ambiguous===!0}:void 0}]}),c=Array.isArray(r.warnings)?r.warnings.map(jr).filter(Boolean):[];return{skills:a.sort((d,f)=>d.name.localeCompare(f.name)),warnings:c}}function sy(n){var a;const r=n.trustLevel.replace(/[_-]+/g," "),i=(a=n.source)!=null&&a.source?`Adopted from ${n.source.source}`:"Source has no adoption record";return`Trust: ${r}. ${i}${n.requiresReview?". Review required":""}.`}function iy({value:n,onChange:r,disabled:i}){const[a,c]=x.useState({skills:[],warnings:[]}),[d,f]=x.useState(""),[m,p]=x.useState(!0),[g,y]=x.useState(""),[_,w]=x.useState(0);x.useEffect(()=>{const A=new AbortController;return p(!0),y(""),Nt("/api/gateway/skills",{signal:A.signal}).then(S=>{A.signal.aborted||c(ry(S))}).catch(S=>{A.signal.aborted||y(En(S))}).finally(()=>{A.signal.aborted||p(!1)}),()=>A.abort()},[_]);const k=x.useMemo(()=>new Set(n.map(jr).filter(Boolean)),[n]),T=x.useMemo(()=>{const A=d.trim().toLocaleLowerCase();return A?a.skills.filter(S=>`${S.name}
52
+ ${S.description}
53
+ ${S.trustLevel}`.toLocaleLowerCase().includes(A)):a.skills},[a.skills,d]),N=(A,S)=>{const P=S?[...k,A]:[...k].filter(C=>C!==A);r([...new Set(P)])};return o.jsxs("section",{className:"code-settings-section","aria-labelledby":"code-skills-heading",children:[o.jsx("h3",{id:"code-skills-heading",children:"Skills"}),o.jsx("p",{className:"code-muted",children:"Choose curated guidance for the next turn. The gateway evaluates trust and requirements when the run starts; this browser does not load or execute skill scripts."}),o.jsxs("label",{className:"code-field",children:["Find a skill",o.jsx("input",{type:"search",value:d,onChange:A=>f(A.target.value),disabled:i||m,placeholder:"Search names, descriptions, or trust"})]}),m?o.jsx("p",{className:"code-muted",role:"status",children:"Loading skills from the gateway…"}):null,g?o.jsxs("div",{className:"code-inline-error",role:"alert",children:["Skill selection is unavailable: ",g," ",o.jsx("button",{className:"code-text-button",type:"button",onClick:()=>w(A=>A+1),disabled:i,children:"Retry"})]}):null,a.warnings.length?o.jsxs("details",{className:"code-disabled-tools",children:[o.jsxs("summary",{children:["Gateway reported ",a.warnings.length," skills warning",a.warnings.length===1?"":"s"]}),a.warnings.map((A,S)=>o.jsx("p",{children:A},`${A}:${S}`))]}):null,!m&&!g&&!T.length?o.jsx("p",{className:"code-muted",children:a.skills.length?"No skills match your search.":"This gateway has no skills available."}):null,T.map(A=>{const S=A.reasons.join(" ")||"Blocked by gateway policy.",P=k.has(A.name),C=i||A.blocked;return o.jsxs("label",{className:"code-field",children:[o.jsxs("span",{children:[o.jsx("input",{type:"checkbox",checked:P,disabled:C,onChange:j=>N(A.name,j.target.checked)})," ",o.jsx("strong",{children:A.name})]}),A.description?o.jsx("span",{className:"code-field-help",children:A.description}):null,o.jsx("span",{className:"code-field-help",children:sy(A)}),A.blocked?o.jsxs("span",{className:"code-error-text",children:["Blocked by the gateway: ",S]}):null]},A.name)})]})}function gc(n){if(!["ArrowLeft","ArrowRight","Home","End"].includes(n.key))return;const r=[...n.currentTarget.querySelectorAll('button[role="tab"]')].filter(c=>!c.disabled),i=r.indexOf(n.target);if(i<0||!r.length)return;n.preventDefault();const a=n.key==="Home"?0:n.key==="End"?r.length-1:(i+(n.key==="ArrowRight"?1:-1)+r.length)%r.length;r[a].focus(),r[a].click()}function Qf(n,r,i="default"){const a=n.filter(d=>d.enabled&&!d.servedDisabled&&(r.mode==="all"||r.selected.includes(d.name))),c=d=>{const f=r.approval[d.name];if(f==="ask")return!1;if(f==="approve"||i==="all")return!0;const m=["auto","approve"].includes((d.approval||"").trim().toLowerCase());if(i==="default")return m;const p=m?1:["write_file","edit_file"].includes(d.name)?2:3,g=d.riskRank===void 0||d.riskRank===1?1:d.riskRank===2?2:3;return Math.max(p,g)<=(i==="write"?2:1)};return{enabledTools:a.map(d=>d.name),autoApproveTools:a.filter(c).map(d=>d.name),requireApprovalTools:a.filter(d=>!c(d)).map(d=>d.name)}}function oy(n,r){if(!Array.isArray(r))return n;const i=a=>r.includes(a);return{enabledTools:n.enabledTools.filter(i),autoApproveTools:n.autoApproveTools.filter(i),requireApprovalTools:n.requireApprovalTools.filter(i)}}const Ws={provider:"",model:"",reasoning:"",maxIterations:"",maxTokens:"",system:"",workspaceRoot:"",workspaceMode:"",allowedPaths:"",tools:{mode:"all",selected:[],approval:{}},toolsCustomized:!1,permissions:"default",skills:[]};function ay({open:n,onClose:r,tab:i,onTab:a,value:c,onChange:d,policy:f,tools:m,disabled:p,defaultModel:g,workflowDefault:y}){const _=w=>d({...c,...w});return o.jsx(sc,{open:n,onClose:r,label:"Run settings",title:"Run settings",width:480,topOffset:60,className:"code-settings-drawer",children:o.jsxs("div",{className:"code-settings",children:[o.jsx("p",{className:"code-muted",children:"Settings apply to the next turn. Your gateway enforces the available permissions."}),o.jsx("div",{className:"code-settings-tabs",role:"tablist","aria-label":"Settings sections",onKeyDown:gc,children:["model","workspace","tools","skills"].map(w=>o.jsx("button",{role:"tab",tabIndex:i===w?0:-1,"aria-selected":i===w,onClick:()=>a(w),children:w==="model"?"Model & behavior":w==="workspace"?"Workspace":w==="tools"?"Tools":"Skills"},w))}),p?o.jsx("p",{className:"code-notice",children:"Settings are unavailable while disconnected or while a run is active. Reconnect, or finish or stop the run, then try again."}):null,i==="model"?o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"code-settings-section",children:[o.jsx("h3",{children:"Model"}),o.jsx(dc,{defaultModeLabel:y?"Workflow default":"Gateway default",value:c,onChange:_,disabled:p,effectiveDefault:g,fetchModelCapabilities:mc.fetchModelCapabilities,enableSpeculation:!0,defaultHint:g?`${y?"Workflow":"Gateway"} default: ${g.provider} · ${g.model}.`:void 0,fetchProviders:async()=>{const w=await yn.discovery_providers();return Array.isArray(w.providers)?w.providers:Array.isArray(w.items)?w.items:[]},fetchModels:async w=>{const k=await yn.discovery_provider_models(w);return(Array.isArray(k.models)?k.models:Array.isArray(k.items)?k.items:[]).map(T=>typeof T=="string"?T:T.id||T.name)}})]}),o.jsxs("section",{className:"code-settings-section",children:[o.jsx("h3",{children:"Behavior"}),o.jsxs("div",{className:"code-field-pair",children:[o.jsxs("label",{className:"code-field",children:["Iteration limit",o.jsx("input",{type:"number",min:1,step:1,placeholder:"Workflow default",value:c.maxIterations,disabled:p,onChange:w=>_({maxIterations:w.target.value})})]}),o.jsxs("label",{className:"code-field",children:["Context token limit",o.jsx("input",{type:"number",min:1,step:1,placeholder:"Gateway default",value:c.maxTokens,disabled:p,onChange:w=>_({maxTokens:w.target.value})})]})]}),o.jsxs("label",{className:"code-field",children:["Additional instructions",o.jsx("textarea",{rows:5,value:c.system,placeholder:"Project conventions or guidance for this conversation…",disabled:p,onChange:w=>_({system:w.target.value})})]}),o.jsx("p",{className:"code-field-help",children:"Reasoning and additional instructions depend on the selected workflow and model."})]})]}):i==="workspace"?o.jsxs("section",{className:"code-settings-section",children:[o.jsx("h3",{children:"Workspace access"}),o.jsxs("div",{className:"code-policy",children:[o.jsx("strong",{children:f!=null&&f.clientWorkspaceScopeOverrides?"Client scope requests enabled":"Managed by your gateway"}),o.jsx("p",{children:f!=null&&f.clientWorkspaceScopeOverrides?"You may request a workspace scope. Gateway policy remains authoritative.":"The gateway chooses and restricts the workspace. File browsing and tool execution follow the same policy."})]}),o.jsxs("dl",{className:"code-facts",children:[o.jsx("dt",{children:"Allowed access modes"}),o.jsx("dd",{children:(f==null?void 0:f.allowedAccessModes.join(", "))||"Gateway default"}),o.jsx("dt",{children:"Available mounts"}),o.jsx("dd",{children:f!=null&&f.mounts.length?f.mounts.map(w=>w.label).join(", "):"Default workspace"})]}),f!=null&&f.clientWorkspaceScopeOverrides?o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"code-field",children:["Workspace root",o.jsx("input",{value:c.workspaceRoot,placeholder:"Gateway default",disabled:p,onChange:w=>_({workspaceRoot:w.target.value})})]}),o.jsxs("label",{className:"code-field",children:["Access mode",o.jsxs("select",{value:c.workspaceMode,disabled:p,onChange:w=>_({workspaceMode:w.target.value}),children:[o.jsx("option",{value:"",children:"Gateway default"}),f.allowedAccessModes.map(w=>o.jsx("option",{value:w,children:w.replace(/_/g," ")},w))]})]}),c.workspaceMode==="workspace_or_allowed"?o.jsxs("label",{className:"code-field",children:["Additional allowed paths",o.jsx("textarea",{rows:3,value:c.allowedPaths,disabled:p,placeholder:"One path per line",onChange:w=>_({allowedPaths:w.target.value})})]}):null]}):null]}):i==="tools"?o.jsxs("section",{className:"code-settings-section",children:[o.jsxs("label",{className:"code-field",children:["Permissions",o.jsxs("select",{"aria-label":"Permissions",value:c.permissions,disabled:p,onChange:w=>_({permissions:w.target.value}),children:[o.jsx("option",{value:"default",children:"Workflow / Gateway defaults"}),o.jsx("option",{value:"read",children:"Read"}),o.jsx("option",{value:"write",children:"Write"}),o.jsx("option",{value:"all",children:"All enabled tools"})]})]}),o.jsx("p",{className:"code-field-help",children:"Saved for this Gateway account and future turns. Permissions never enable an unchecked tool. Explicit Ask overrides still ask, even with permissions: all."}),o.jsx(cm,{tools:m.filter(w=>w.enabled).map(w=>({...w,default_approval:Qf(m,c.tools,c.permissions).autoApproveTools.includes(w.name)?"approve":"ask"})),value:c.tools,onChange:w=>_({tools:w,toolsCustomized:!0}),disabled:p,subtitle:"Choose available tools and when they should ask you. Gateway restrictions always apply.",note:"An empty custom selection disables every tool. Approvals follow the permissions level and each tool's override."}),m.some(w=>!w.enabled)?o.jsxs("details",{className:"code-disabled-tools",children:[o.jsxs("summary",{children:[m.filter(w=>!w.enabled).length," tools unavailable under gateway policy"]}),m.filter(w=>!w.enabled).map(w=>o.jsxs("p",{children:[o.jsx("strong",{children:w.name}),o.jsx("br",{}),w.whyDisabled||"Disabled by the gateway"]},w.name))]}):null,o.jsx("button",{className:"code-text-button",disabled:p,onClick:()=>_({toolsCustomized:!1,tools:Ws.tools,permissions:"default"}),children:"Use workflow tool defaults"})]}):o.jsx(iy,{value:c.skills,onChange:w=>_({skills:w}),disabled:p})]})})}const ly=new Set(["abstract.progress","abstractcode.progress"]);function zs(n){return!!n&&typeof n=="object"&&!Array.isArray(n)}function Jr(n){const r=typeof n=="number"?n:Number(n);return Number.isFinite(r)?r:null}function cy(n){if(!zs(n))return null;const r=zs(n.effect)?n.effect:null;if(!r||String(r.type||"")!=="emit_event")return null;const i=zs(r.payload)?r.payload:null,a=String((i==null?void 0:i.name)??(i==null?void 0:i.event_name)??"").trim();if(!ly.has(a))return null;const c=zs(n.result)?n.result:null,d=zs(c==null?void 0:c.payload)?c==null?void 0:c.payload:null,f=zs(i==null?void 0:i.payload)?i==null?void 0:i.payload:null,m=d||f;if(!m||String(m.kind||"")!=="llm")return null;const p=String(m.phase||"").trim();return p!=="prefill"&&p!=="generate"&&p!=="complete"?null:m}function uy(n){let r=null;for(const i of n||[]){const a=cy(i);a&&(r=a)}return!r||r.phase==="complete"||r.final===!0?null:r}function Bs(n){return Math.round(n).toLocaleString()}function Jf(n){if(!n||n.phase!=="prefill")return null;const r=Jr(n.prompt_tokens),i=Jr(n.prefill_processed_tokens);if(r===null||r<=0||i===null||i<0)return null;const a=Math.min(i,r),c=Math.min(99,Math.round(a/r*100));return{processed:a,total:r,percent:c}}function Yf(n){return`${Bs(n.processed)} / ${Bs(n.total)} tokens (${n.percent}%)`}function dy(n){if(!n)return"";if(n.phase==="prefill"){const r=Jf(n);if(r)return`Prefill · ${Yf(r)}`;const i=Jr(n.prompt_tokens);if(i===null||i<=0)return"Prefill";const a=Jr(n.cached_tokens),c=Jr(n.fed_tokens),d=[];a!==null&&a>0&&d.push(`${Bs(a)} cached`),c!==null&&c>0&&d.push(`${Bs(c)} new`);const f=d.length?` (${d.join(", ")})`:"";return`Prefill · ${Bs(i)} tokens${f}`}if(n.phase==="generate"){const r=Jr(n.generated_tokens)??0,i=Math.round(r)===1?"token":"tokens",a=Jr(n.tokens_per_second),c=a!==null&&a>0?` · ${Math.round(a)} tok/s`:"";return`Generating · ${Bs(r)} ${i}${c}`}return""}function fy(n){return dy(uy(n))}const Xf=new Set(["abstract.progress","abstractcode.progress"]),py=new Set(["abstract.status","abstractcode.status"]);function Ae(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function yc(n){const r=Ae(n);return!!(r&&r.$slim)}function at(n){const r=typeof n=="number"?n:Number(n);return Number.isFinite(r)?r:null}function qt(n){return Math.round(n).toLocaleString("en-US")}function Ct(n,r=120){const i=n.replace(/\s+/g," ").trim();return i.length>r?`${i.slice(0,r-1)}…`:i}function Ai(n,r=120){var c,d;if(n==null)return"";if(typeof n=="string")return Ct(n,r);if(typeof n=="number"||typeof n=="boolean")return String(n);if(Array.isArray(n))return Ct(n.length===0?"[]":`${n.length} ${n.length===1?"item":"items"}`,r);const i=Ae(n);if(!i)return"";if(yc(i)){const f=String(((c=i.$slim)==null?void 0:c.field)||""),m=at((d=i.$slim)==null?void 0:d.bytes);return`${f||"payload"} stored${m?` · ${qt(m)} bytes`:""}`}const a=[];for(const[f,m]of Object.entries(i)){const p=typeof m=="string"?Ct(m,60):typeof m=="number"||typeof m=="boolean"?String(m):Array.isArray(m)?`${m.length} items`:m==null?"":"{…}";if(p&&(a.push(`${f.replace(/_/g," ")} ${p}`),a.join(" · ").length>=r))break}return Ct(a.join(" · "),r)}function ia(n){return`${n>=100?String(Math.round(n)):n.toFixed(n<1?2:1).replace(/\.0+$/,"")} s`}function Zf(n,r){const i=Date.parse(String(n||"")),a=Date.parse(String(r||""));if(!Number.isFinite(i)||!Number.isFinite(a))return null;const c=(a-i)/1e3;return c>=0?c:null}function hy(n){const r=String(n||""),i=/T(\d{2}:\d{2}:\d{2})/.exec(r);return i?i[1]:""}function qf(n){const r=String(n||"").trim();if(!r)return"";const i=r.split("/").pop()||r;return i.length>48?`${i.slice(0,47)}…`:i}function Et(n,r=" · "){return n.filter(i=>!!i).join(r)}const uf="visual_react_agent_";function my(n){if(!/^[A-Za-z0-9_-]{8,}$/.test(n))return null;try{const r=n.replace(/-/g,"+").replace(/_/g,"/"),i=atob(r+"=".repeat((4-r.length%4)%4));return!/^[ -~]{3,}$/.test(i)||!/[a-z]/i.test(i)?null:i}catch{return null}}function gy(n){const r=String(n||"").trim();if(!r)return{name:"",node:""};const i=/^([^@]+)@([^:]+)(?::(.+))?$/.exec(r);if(i)return{name:i[1],node:i[3]||""};if(r.startsWith(uf)){const a=r.slice(uf.length),c=/^(.*)_(\d+)_(\d+)_(\d+)_([0-9a-f]{6,12})_(.+)$/.exec(a);if(c){let d=c[1];if(d.includes("__")){const f=d.split("__").filter(Boolean);for(let m=f.length-1;m>=0;m-=1){const p=my(f[m]);if(p&&p.length>3){d=p;break}}}return{name:d,node:c[6]}}return{name:a,node:""}}return{name:r,node:""}}function yy(n){var i;if(!Array.isArray(n)||!n.length)return"";const r=new Map;for(const a of n){const c=String(((i=Ae(a))==null?void 0:i.name)||"").trim()||"tool";r.set(c,(r.get(c)||0)+1)}return[...r.entries()].map(([a,c])=>c>1?`${a} ×${c}`:a).join(", ")}function vy(n){var m;const r=Ae(n);if(!r)return null;const i=Ae(r.effect);if(!i||String(i.type||"")!=="emit_event")return null;const a=Ae(i.payload),c=String((a==null?void 0:a.name)??(a==null?void 0:a.event_name)??"").trim();if(!Xf.has(c))return null;const d=Ae((m=Ae(r.result))==null?void 0:m.payload),f=Ae(a==null?void 0:a.payload);return d||f}function wy(n){if(!n.length)return"";const r=n[n.length-1];let i=null,a=null,c=null,d=null,f=null;for(const y of n)i=at(y.prompt_tokens)??i,a=at(y.cached_tokens)??a,c=at(y.generated_tokens)??c,d=at(y.tokens_per_second)??d,f=at(y.elapsed_s)??f;if(r.final===!0||String(r.phase||"")==="complete")return Et([i!==null?`${qt(i)} tokens in`:null,a!==null&&a>0?`${qt(a)} cached`:null,c!==null?`${qt(c)} out`:null,f!==null?ia(f):null,d!==null&&d>0?`${Math.round(d)} tok/s`:null]);const p=i!==null?`prefill ${qt(i)} tokens${a!==null&&a>0?` (${qt(a)} cached)`:""}`:"prefill";if(String(r.phase||"")==="prefill"){const y=Jf(r);return y?`prefill ${Yf(y)}`:p}const g=Et([`generating ${qt(c??0)} ${Math.round(c??0)===1?"token":"tokens"}`,d!==null&&d>0?`${Math.round(d)} tok/s`:null]);return`${p} → ${g}`}function _y(n){if(!n.length)return"";const r=n[n.length-1],i=at(r.step)??at(r.index),a=at(r.total)??at(r.steps),c=at(r.percent)??at(r.progress),d=at(r.frame),f=at(r.elapsed_s);return Et([typeof r.label=="string"?Ct(r.label,60):null,typeof r.phase=="string"&&!r.label?Ct(r.phase,40):null,i!==null?`step ${qt(i)}${a!==null?`/${qt(a)}`:""}`:null,d!==null?`frame ${qt(d)}`:null,c!==null?`${Math.round(c<=1?c*100:c)}%`:null,f!==null?ia(f):null])}function df(n){return n.length?String(n[n.length-1].kind||"")==="llm"?wy(n):_y(n):""}function xy(n,r,i){var S;const a=String(n.provider||"").trim(),c=qf(n.model||(r==null?void 0:r.model)),d=Et(["llm",a,c])||"llm call";if(!r){const P=Ae(n.params)||{};return{title:d,detail:Et([at(P.temperature)!==null?`temperature ${P.temperature}`:null,P.thinking?`thinking ${P.thinking}`:null,(S=Ae(P.speculation))!=null&&S.mode?`speculation ${Ae(P.speculation).mode}`:null])}}const f=Ae(r.usage)||{},m=Ae(r.metadata)||{},p=Ae(m.prompt_cache)||{},g=Ae(m.performance)||{},y=at(f.prompt_tokens)??at(f.input_tokens),_=at(f.completion_tokens)??at(f.output_tokens),w=at(p.cached_tokens),k=String(p.outcome||"").trim(),T=Zf(i.started_at,i.ended_at),N=at(g.generation_tokens_per_second),A=Array.isArray(r.tool_calls)?r.tool_calls.length:0;return{title:d,detail:Et([y!==null?`${qt(y)} tokens in`:null,w!==null&&w>0?`${qt(w)} cached`:k?`${k} cache`:null,_!==null?`${qt(_)} out`:null,T!==null?ia(T):null,N!==null&&N>0?`${Math.round(N)} tok/s`:null,A?`${A} tool ${A===1?"call":"calls"}`:null])}}function ky(n,r){if(r.length<=60)return Ct(r,60);if(n==="url")try{const i=new URL(r),a=i.pathname.split("/").filter(Boolean).pop()||"";return Ct(`${i.host}${a?` · …/${a}`:""}`,72)}catch{}if(n==="file path"||n==="path"){const i=r.split(/[\\/]/).pop()||r;return Ct(`${i} · ${r.slice(0,24)}…`,60)}return Ct(r,60)}function Sy(n,r){const i=Array.isArray(n.tool_calls)?n.tool_calls:[],a=yy(i),c=Ae(i[0]),d=c?If(c.arguments):{label:"",value:""},f=Array.isArray(r==null?void 0:r.results)?r.results:[],m=f.filter(g=>{var y;return((y=Ae(g))==null?void 0:y.success)===!0}).length,p=f.length-m;return{title:Et(["tools",a||"tool call"]),detail:Et([d.value?`${d.label} ${ky(d.label,d.value)}`:null,f.length?`${m} ok`:null,p>0?`${p} failed`:null])}}function jy(n,r){var g,y;const{name:i,node:a}=gy(n.workflow_id),c=Ae(n.vars),d=c&&!yc(c)?c:null,f=Ae(d==null?void 0:d.context),m=typeof(f==null?void 0:f.task)=="string"?f.task:typeof(d==null?void 0:d.request)=="string"?d.request:"",p=String(((y=Ae((g=Ae(r==null?void 0:r.wait))==null?void 0:g.details))==null?void 0:y.sub_run_id)||"").slice(0,8);return d&&typeof d.state=="string"&&!f?{title:"subflow · status",detail:Et([Ct(d.state,80),p&&`run ${p}`])}:m?{title:"subflow · agent loop",detail:Et([i,Ct(m,90),p&&`run ${p}`])}:{title:Et(["subflow",i||"workflow"]),detail:Et([a,d?Ai(d,80):null,p&&`run ${p}`])}}function by(n,r){const i=n.until,a=Zf(r.started_at,i),c=hy(i);return{title:a!==null?`wait · delay ${ia(a)}`:`wait · until ${c}`,detail:Et([a!==null&&c?`until ${c}`:null,n.resume_to_node?`resumes at ${n.resume_to_node}`:null])}}function ff(n){var m;const r=Ae(n)||{},i=Ae(r.effect),a=String((i==null?void 0:i.type)||"").trim(),c=Ae(i==null?void 0:i.payload)||{},d=Ae(r.result);if(a==="emit_event"){const p=String(c.name??c.event_name??"").trim();if(Xf.has(p))return{kind:"progress",title:"progress",detail:"",isProgress:!0,isStatus:!1,isResume:!1,hidden:!0};if(py.has(p))return{kind:"event",title:"status",detail:Ai(c.payload,80),isProgress:!1,isStatus:!0,isResume:!1,hidden:!0};const g=String(c.scope||"").trim();return{kind:"event",title:`event · ${p||"unnamed"}${g?` (${g})`:""}`,detail:Ai(c.payload??(d==null?void 0:d.payload),110),isProgress:!1,isStatus:!1,isResume:!1,hidden:!1}}if(a==="resume")return{kind:"step",title:"resume",detail:String(c.wait_reason||""),isProgress:!1,isStatus:!1,isResume:!0,hidden:!0};const f={isProgress:!1,isStatus:!1,isResume:!1,hidden:!1};if(a==="llm_call")return{kind:"llm",...xy(c,d,r),...f};if(a==="tool_calls")return{kind:"tools",...Sy(c,d),...f};if(a==="start_subworkflow")return{kind:"subflow",...jy(c,d),...f};if(a==="wait_until")return{kind:"wait",...by(c,r),...f};if(a==="wait_event")return{kind:"wait",title:"wait · event",detail:Et([typeof c.prompt=="string"?Ct(c.prompt,90):null,!c.prompt&&c.wait_key?Ct(String(c.wait_key),70):null]),...f};if(a==="ask_user")return{kind:"ask",title:"ask · your input",detail:Ct(String(c.prompt||((m=Ae(d==null?void 0:d.wait))==null?void 0:m.prompt)||"").split(`
54
+ `)[0],110),...f};if(a==="answer_user")return{kind:"message",title:"message",detail:Ct(String(c.message||""),110),...f};if(!a){if((d==null?void 0:d.completed)===!0){const p=Ae(d.output)||{},g=Ae(p.stop_reason)||{},y=at(p.iterations),_=Et([String(g.code||p.outcome||"").replace(/_/g," ")||null,y!==null?`${qt(y)} ${y===1?"iteration":"iterations"}`:null]),w=[p.answer,p.response,p.result].find(k=>typeof k=="string"&&k.trim());return{kind:"run",title:"run finished",detail:_||(typeof w=="string"?Ct(w,110):Ai(p,110)),...f}}return{kind:"step",title:String(r.node_id||"workflow step"),detail:"",...f}}return{kind:"step",title:a.replace(/_/g," "),detail:Ai(c,110),...f}}function Cy(n,r,i){var d,f;const a=Ae(n)||{},c=String(a.status||"").trim();if(a.error)return{status:"failed",statusLabel:"failed"};if(c==="failed")return{status:"failed",statusLabel:"failed"};if(c==="completed")return{status:"completed",statusLabel:"completed"};if(c==="waiting"){if(i)return{status:"completed",statusLabel:"completed"};const m=Ae((d=Ae(a.result))==null?void 0:d.wait);return String(((f=Ae(m==null?void 0:m.details))==null?void 0:f.mode)||"")==="approval_required"?{status:"waiting",statusLabel:"approval needed"}:r==="subflow"?{status:"waiting",statusLabel:"waiting for subflow"}:r==="ask"?{status:"waiting",statusLabel:"waiting for you"}:r==="wait"?{status:"waiting",statusLabel:String((m==null?void 0:m.reason)||"")==="until"?"waiting":"waiting for event"}:{status:"waiting",statusLabel:"waiting"}}return c==="started"?{status:"started",statusLabel:"running"}:{status:c||"started",statusLabel:c||"running"}}function Ny(n){var c;const r=Ae(n.record)||{},i=String(((c=Ae(r.effect))==null?void 0:c.type)||"(none)"),a=String(r.idempotency_key||r.step_id||n.cursor);return`${n.runId}|${i}|${a}|${r.attempt??1}`}function Ey(n){var p;const r=n.map(g=>Ae(g.record)||{}),i=r[r.length-1]||{},a={};for(const g of r){const y=Ae((p=Ae(g.effect))==null?void 0:p.payload);if(y)for(const[_,w]of Object.entries(y))yc(w)&&_ in a||(a[_]=w)}let c=null,d=null,f=null,m=null;for(const g of r)g.result!==null&&g.result!==void 0&&(c=g.result),g.error!==null&&g.error!==void 0&&(d=g.error),!f&&g.started_at&&(f=g.started_at),g.ended_at&&(m=g.ended_at);return{...i,effect:i.effect?{...i.effect,payload:a}:i.effect,result:c,error:d,started_at:f,ended_at:m}}function $y(n){var i,a;const r=[];for(const c of n){const d=Ae((a=Ae((i=Ae(c.record))==null?void 0:i.result))==null?void 0:a.wait),f=String((d==null?void 0:d.wait_key)||"").trim();f&&r.push(f)}return r}function Ty(n,r){return`${n}|${String(r.step_id||r.node_id||"")}`}function Ry(n,r){const i=new Map;for(const d of r){const f=vy(d.record);if(!f)continue;const m=Ty(d.runId,f),p=i.get(m)||{entries:[],payloads:[]};p.entries.push(d),p.payloads.push(f),i.set(m,p)}if(!i.size)return n.map(d=>({...d}));const a=new Set,c=n.map(d=>{const f=d.stepIds.map(k=>`${d.runId}|${k}`).filter(k=>i.has(k));if(!f.length)return{...d};const m=[],p=[];for(const k of f)a.add(k),m.push(...i.get(k).payloads),p.push(...i.get(k).entries);const g=df(m),y=m[m.length-1],_=y.final===!0||String(y.phase||"")==="complete",w=!(_&&d.status==="completed"&&d.detail);return{...d,progress:w?g:"",progressFinal:_,progressEvents:p.map(k=>Ae(k.record)||{})}});for(const[d,f]of i.entries()){if(a.has(d))continue;const m=f.payloads,p=m[m.length-1],g=String(p.kind||""),y=f.entries[0];c.push({key:`progress:${d}`,runId:y.runId,cursor:f.entries[f.entries.length-1].cursor,kind:"progress",title:Et(g==="llm"?["llm",String(p.provider||""),qf(p.model)]:["progress",g]),detail:"",status:p.final===!0||String(p.phase||"")==="complete"?"completed":"started",statusLabel:p.final===!0||String(p.phase||"")==="complete"?"completed":"running",nodeId:String(p.node_id||""),stepIds:[String(p.step_id||"")],progress:df(m),progressFinal:p.final===!0||String(p.phase||"")==="complete",entries:f.entries,progressEvents:f.entries.map(_=>Ae(_.record)||{}),merged:Ae(f.entries[f.entries.length-1].record)||{}})}return c}function Ay(n){var m,p,g;const r=new Map,i=[],a=[],c=[];for(const y of n||[]){const _=ff(y.record);if(_.isProgress){c.push(y);continue}if(_.isStatus)continue;if(_.isResume){const k=String(((g=(p=Ae((m=Ae(y.record))==null?void 0:m.effect))==null?void 0:p.payload)==null?void 0:g.wait_key)||"").trim();k&&a.push(k);continue}const w=Ny(y);r.has(w)||(r.set(w,[]),i.push(w)),r.get(w).push(y)}const d=new Set(a),f=i.map(y=>{const _=r.get(y),w=Ey(_),k=ff(w),T=$y(_).some(A=>d.has(A)),N=Cy(w,k.kind,T);return{key:y,runId:_[0].runId,cursor:_[_.length-1].cursor,kind:k.kind,title:k.title,detail:k.detail,status:N.status,statusLabel:N.statusLabel,nodeId:String(w.node_id||""),stepIds:[...new Set(_.map(A=>{var S;return String(((S=Ae(A.record))==null?void 0:S.step_id)||"")}).filter(Boolean))],progress:"",progressFinal:!1,entries:_,progressEvents:[],merged:w}});return Ry(f,c)}function My({tab:n,onTab:r,policy:i,runId:a,records:c,enabled:d,onAttach:f,onClose:m}){const p=x.useMemo(()=>Ay(c),[c]);return o.jsxs("aside",{className:"code-inspector","aria-label":"Workspace inspector",children:[o.jsxs("div",{className:"code-inspector-heading",children:[o.jsx("span",{children:"WORKSPACE"}),o.jsx("button",{className:"code-icon-button","aria-label":"Close workspace inspector",onClick:m,children:o.jsx(fe,{name:"x",size:15})})]}),o.jsx("div",{className:"code-inspector-tabs",role:"tablist","aria-label":"Workspace views",onKeyDown:gc,children:["files","activity","artifacts"].map(g=>o.jsxs("button",{id:`inspector-tab-${g}`,role:"tab",tabIndex:n===g?0:-1,"aria-selected":n===g,"aria-controls":`inspector-panel-${g}`,onClick:()=>r(g),children:[g==="files"?"Files":g==="activity"?"Activity":"Artifacts",g==="activity"&&p.length?o.jsx("span",{children:p.length}):null]},g))}),o.jsx("div",{className:"code-inspector-content",id:`inspector-panel-${n}`,role:"tabpanel","aria-labelledby":`inspector-tab-${n}`,children:n==="files"?o.jsx(Iy,{policy:i,enabled:d,runId:a,onAttach:f}):n==="activity"?o.jsx(Ly,{rows:p}):o.jsx(Oy,{runId:a,enabled:d})}),o.jsxs("div",{className:"code-inspector-foot",children:[o.jsx(fe,{name:"server",size:14}),o.jsx("span",{children:"Access enforced by your gateway"})]})]})}function Iy({policy:n,enabled:r,runId:i,onAttach:a}){const[c,d]=x.useState(""),[f,m]=x.useState(""),[p,g]=x.useState([]),[y,_]=x.useState(!1),[w,k]=x.useState(""),[T,N]=x.useState(""),[A,S]=x.useState(0),[P,C]=x.useState("");return x.useEffect(()=>{const j=new AbortController;if(g([]),k(""),N(""),!r||!n)return;_(!0);const L=window.setTimeout(()=>{const W=new URLSearchParams({limit:"100"});c.trim()?W.set("query",c.trim()):f&&W.set("path",f),Nt(`/api/gateway/files/${c.trim()?"search":"list"}?${W}`,{signal:j.signal}).then(V=>{if(V.error)throw new Error(String(V.error));g(Array.isArray(V.items)?V.items:[]),(V.truncated||V.has_more)&&N("Showing the first 100 results. Search to narrow the list.")}).catch(V=>{j.signal.aborted||k(En(V))}).finally(()=>{j.signal.aborted||_(!1)})},c?220:0);return()=>{window.clearTimeout(L),j.abort()}},[r,n,c,f,A,i]),o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"code-pane-intro",children:[o.jsx(fe,{name:"terminal",size:17}),o.jsxs("div",{children:[o.jsx("strong",{children:"Gateway files"}),o.jsx("span",{children:f||"Authorized shared workspace"})]}),o.jsx("button",{className:"code-icon-button","aria-label":"Refresh files",onClick:()=>S(j=>j+1),disabled:!r,children:o.jsx(fe,{name:"refresh",size:14})})]}),o.jsx("input",{className:"code-search","aria-label":"Search workspace files",placeholder:"Search files…",value:c,onChange:j=>d(j.target.value),disabled:!r}),f?o.jsx("button",{className:"code-back",onClick:()=>{m(f.split("/").slice(0,-1).join("/")),d("")},children:"← Parent folder"}):null,r?null:o.jsx("p",{className:"code-pane-empty",children:"Connect to browse your workspace."}),y?o.jsx("p",{className:"code-muted",role:"status",children:"Loading files…"}):null,w?o.jsxs("div",{className:"code-inline-error",role:"alert",children:[w,o.jsx("button",{onClick:()=>S(j=>j+1),children:"Retry"})]}):null,T?o.jsx("p",{className:"code-field-help",role:"status",children:T}):null,o.jsx("ul",{className:"code-file-list",children:p.map(j=>{const L=j.kind==="folder"||j.is_dir||j.type==="directory"||j.type==="dir";return o.jsx("li",{children:o.jsxs("button",{title:L?`Open ${j.path}`:`Attach ${j.path} to the conversation`,disabled:!!P,onClick:async()=>{if(L){m(j.path),d("");return}C(j.path),k("");try{await a(j.path),N(`${j.name||j.path} attached.`)}catch(W){k(En(W))}finally{C("")}},children:[o.jsx(fe,{name:L?"chevronRight":"edit",size:14}),o.jsx("span",{children:j.name||j.path}),P===j.path?o.jsx(fe,{name:"loader",size:13}):o.jsx("span",{className:"code-file-action",children:L?"Open":"+"})]})},j.path)})}),!y&&!w&&r&&!p.length?o.jsxs("div",{className:"code-pane-empty",children:[o.jsx(fe,{name:"terminal",size:28}),o.jsx("p",{children:c?"No matching files.":"No shared files yet."}),o.jsx("small",{children:c?"Try a shorter name or another folder.":"Browse files exposed by your gateway or attach files from your device. Generated output is available in Artifacts."})]}):null]})}const Py={llm:"sparkle",tools:"terminal",subflow:"agent",event:"info",wait:"history",ask:"chat",message:"send",run:"playCircle",progress:"loader",step:"list"};function Ly({rows:n}){return n.length?o.jsx("div",{className:"code-activity",children:n.map(r=>{const i=r.merged,a=i.effect||{};return o.jsxs("details",{className:`code-activity-row code-activity-row--${r.kind}`,children:[o.jsxs("summary",{children:[o.jsx("span",{className:"code-activity-icon","aria-hidden":"true",children:o.jsx(fe,{name:Py[r.kind],size:14})}),o.jsxs("span",{className:"code-activity-text",children:[o.jsx("span",{className:"code-activity-title",children:r.title}),r.detail?o.jsx("span",{className:"code-activity-sub",children:r.detail}):null,r.progress?o.jsx("span",{className:"code-activity-progress",children:r.progress}):null]}),o.jsx("span",{className:`code-step-dot is-${r.status}`}),o.jsx("small",{children:r.statusLabel})]}),o.jsxs("div",{className:"code-activity-detail",children:[o.jsxs("div",{className:"code-field-help",children:[r.nodeId?`${r.nodeId} · `:"","run ",r.runId.slice(0,8)," ","· ",r.entries.length," ",r.entries.length===1?"record":"records",r.progressEvents.length?` · ${r.progressEvents.length} progress`:""]}),o.jsx(Us,{value:{input:a.payload,result:i.result,error:i.error,records:r.entries.map(c=>c.record),...r.progressEvents.length?{progress:r.progressEvents}:{}},collapseAfterDepth:2})]})]},r.key)})}):o.jsxs("div",{className:"code-pane-empty",children:[o.jsx(fe,{name:"playCircle",size:28}),o.jsx("p",{children:"Follow the work as it happens."}),o.jsx("small",{children:"Workflow steps, tool calls, and results will appear here."})]})}function Oy({runId:n,enabled:r}){const[i,a]=x.useState([]),[c,d]=x.useState(""),[f,m]=x.useState(0);return x.useEffect(()=>{if(a([]),d(""),!n||!r)return;const p=new AbortController;return Nt(`/api/gateway/runs/${encodeURIComponent(n)}/artifacts?limit=200`,{signal:p.signal}).then(g=>a(Array.isArray(g.items)?g.items:Array.isArray(g.artifacts)?g.artifacts:[])).catch(g=>{p.signal.aborted||d(En(g))}),()=>p.abort()},[n,r,f]),o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"code-pane-intro",children:[o.jsx(fe,{name:"paperclip",size:17}),o.jsxs("div",{children:[o.jsx("strong",{children:"Run artifacts"}),o.jsx("span",{children:"Files and generated output"})]}),o.jsx("button",{className:"code-icon-button","aria-label":"Refresh artifacts",onClick:()=>m(p=>p+1),children:o.jsx(fe,{name:"refresh",size:14})})]}),c?o.jsx("p",{role:"alert",className:"code-error-text",children:c}):null,i.map(p=>{var _;const g=p.artifact_id||p.id,y=p.filename||((_=p.metadata)==null?void 0:_.filename)||g;return o.jsxs("button",{className:"code-artifact",onClick:()=>{Vg(n,g,y).catch(w=>d(En(w)))},children:[o.jsx(fe,{name:"download",size:16}),o.jsxs("span",{children:[o.jsx("strong",{children:y}),o.jsx("small",{children:p.content_type||"Artifact"})]})]},g)}),!i.length&&!c?o.jsxs("div",{className:"code-pane-empty",children:[o.jsx(fe,{name:"paperclip",size:28}),o.jsx("p",{children:"Everything the workflow creates."}),o.jsx("small",{children:"Generated files and attachments are stored by the gateway and can be downloaded here."})]}):null]})}function zy(n){var p,g;const r=Object.keys(((p=n.schema)==null?void 0:p.properties)||{}),i=((g=n.schema)==null?void 0:g.required)||[],a=[n.promptProperty||"prompt","context","messages","attachments"],c=["provider","model","tools","skills","max_iterations","use_context","use_session_history"],d=Kf(n.schema).map(y=>[y.provider,y.model,y.reasoning].filter(_=>!!_)),f=new Set(r.filter(y=>i.includes(y)&&!a.includes(y)));for(const y of d)y.some(_=>f.has(_))&&y.forEach(_=>f.add(_));const m=new Set(r.filter(y=>!f.has(y)&&!a.includes(y)&&!c.includes(y)));for(const y of d)y.some(_=>m.has(_))&&y.forEach(_=>m.add(_));return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"code-settings-section","aria-label":"Automatic agent configuration",children:[o.jsx("h3",{children:f.size?"Workflow inputs":"Ready to chat"}),o.jsxs("p",{className:"code-field-help",children:[f.size?"This workflow asks for the inputs below before it can run.":"No setup required. Write a message and press Send."," ","Optional values use workflow and Gateway defaults. Use Settings for model, workspace and tool permission overrides."]})]}),f.size?o.jsx(cc,{...n,omit:r.filter(y=>!f.has(y)),rawObject:!1}):null,m.size?o.jsxs("details",{className:"code-advanced-inputs",children:[o.jsxs("summary",{children:["Advanced workflow inputs"," ",o.jsx("span",{className:"code-muted",children:"Optional"})]}),o.jsx("p",{className:"code-field-help",children:"Leave these unset to use the workflow and Gateway defaults. Only change them when you need a specific override."}),o.jsx(cc,{...n,omit:r.filter(y=>!m.has(y)),rawObject:!1})]}):null]})}function Fy(n,r,i){var c;if(!i.length)return r;const a=(c=n==null?void 0:n.properties)==null?void 0:c.attachments;if(!a||a.type&&a.type!=="array")throw new Error("This workflow does not declare an attachments input. Remove the attached files, or choose an agent or workflow that accepts them.");return{...r,attachments:[...Array.isArray(r.attachments)?r.attachments:[],...i]}}function Dy(n){if(!n.trim())return{ok:!0,value:{}};let r;try{r=JSON.parse(n)}catch{return{ok:!1,error:"Enter valid JSON."}}return r===null||typeof r!="object"||Array.isArray(r)?{ok:!1,error:"The workflow input payload must be a JSON object."}:{ok:!0,value:r}}function cc({schema:n,values:r,onChange:i,disabled:a=!1,omit:c=[],rawObject:d=!1,onEditorError:f,defaultModel:m}){const[p,g]=_t.useState("fields"),y=Object.entries((n==null?void 0:n.properties)||{}).filter(([N])=>!c.includes(N)),_=Kf(n),w=new Set(_.flatMap(N=>[N.provider,N.model,N.reasoning].filter(Boolean))),k=N=>{g(N),f==null||f("")},T=y.length?o.jsx("div",{className:"code-input-fields",children:y.map(([N,A])=>{const S={...A,type:Kg(A)},P=_.find(V=>V.provider===N);if(P)return o.jsxs("section",{className:"code-settings-section",children:[o.jsx("h3",{children:P.title}),o.jsx(dc,{value:{provider:String(r[P.provider]||""),model:String(r[P.model]||""),...P.reasoning?{reasoning:String(r[P.reasoning]||"")}:{}},onChange:V=>i({...r,[P.provider]:V.provider,[P.model]:V.model,...P.reasoning?{[P.reasoning]:V.reasoning||""}:{}}),...Xg(P.provider,S["x-abstract-type"]),fetchModelCapabilities:P.reasoning?mc.fetchModelCapabilities:void 0,effectiveDefault:P.provider==="provider"?m:void 0,defaultHint:P.provider==="provider"&&(m!=null&&m.model)?`Gateway default: ${m.provider} · ${m.model}. Workflow defaults take precedence.`:"Empty routing pins inherit the Gateway defaults. Registered workflow defaults are loaded above any Gateway default.",disabled:a})]},N);if(w.has(N))return null;const C=`workflow-input-${N}`,j=String(S.title||N).replace(/_/g," "),L=Array.isArray(n==null?void 0:n.required)&&n.required.includes(N),W=V=>{const Q={...r};V===void 0?delete Q[N]:Q[N]=V,i(Q)};return o.jsxs("div",{className:"code-field",children:[o.jsxs("label",{htmlFor:C,children:[j,L?o.jsx("span",{"aria-label":"required",children:" *"}):null]}),S.enum?o.jsxs("select",{id:C,value:r[N]===void 0?"":JSON.stringify(r[N]),disabled:a,onChange:V=>W(V.target.value?JSON.parse(V.target.value):void 0),children:[o.jsxs("option",{value:"",children:["Choose ",j]}),S.enum.map(V=>o.jsx("option",{value:JSON.stringify(V),children:String(V)},JSON.stringify(V)))]}):S.type==="boolean"?o.jsxs("select",{id:C,value:r[N]===void 0?"":String(r[N]),disabled:a,onChange:V=>W(V.target.value?V.target.value==="true":void 0),children:[o.jsx("option",{value:"",children:"Workflow default"}),o.jsx("option",{value:"true",children:"Yes"}),o.jsx("option",{value:"false",children:"No"})]}):S.type==="number"||S.type==="integer"?o.jsx("input",{id:C,type:"number",value:typeof r[N]=="number"?String(r[N]):"",min:S.minimum,max:S.maximum,step:S.type==="integer"?1:"any",disabled:a,onChange:V=>W(V.target.value===""?void 0:Number(V.target.value))}):S.type==="object"||S.type==="array"?o.jsx(Uy,{id:C,value:r[N],disabled:a,onChange:W},N):o.jsx("textarea",{id:C,rows:2,value:String(r[N]??""),disabled:a,onChange:V=>W(V.target.value)}),S.description?o.jsx("p",{className:"code-field-help",id:`${C}-help`,children:S.description}):null]},N)})}):o.jsx("p",{className:"code-muted",children:"This workflow declares no named top-level fields. Use JSON payload mode to provide registered or additional inputs."});return d?o.jsxs("div",{children:[o.jsxs("div",{className:"code-settings-tabs",role:"tablist","aria-label":"Workflow input editor",onKeyDown:gc,children:[o.jsx("button",{type:"button",role:"tab",tabIndex:p==="fields"?0:-1,"aria-selected":p==="fields",onClick:()=>k("fields"),children:"Fields"}),o.jsx("button",{type:"button",role:"tab",tabIndex:p==="json"?0:-1,"aria-selected":p==="json",onClick:()=>k("json"),children:"JSON payload"})]}),p==="json"?o.jsxs(o.Fragment,{children:[o.jsx(By,{value:r,disabled:a,onChange:i,onError:N=>f==null?void 0:f(N)}),o.jsx("p",{className:"code-field-help",children:"The complete object is sent unchanged. Nested and additional properties are allowed here; the gateway validates it against the registered workflow schema."})]}):T]}):T}function By({value:n,onChange:r,onError:i,disabled:a}){const[c,d]=_t.useState(JSON.stringify(n,null,2)),[f,m]=_t.useState(""),p=_t.useRef(n);return _t.useEffect(()=>{n!==p.current&&(p.current=n,d(JSON.stringify(n,null,2)),m(""),i(""))},[n,i]),o.jsxs("div",{className:"code-field",children:[o.jsx("label",{htmlFor:"workflow-input-payload",children:"Complete input object"}),o.jsx("textarea",{id:"workflow-input-payload",className:"code-mono",rows:12,value:c,disabled:a,"aria-invalid":!!f,onChange:g=>{d(g.target.value);const y=Dy(g.target.value);if(!y.ok){m(y.error),i(y.error);return}p.current=y.value,m(""),i(""),r(y.value)}}),f?o.jsx("span",{role:"alert",className:"code-error-text",children:f}):null]})}function Uy({id:n,value:r,onChange:i,disabled:a}){const[c,d]=_t.useState(r===void 0?"":JSON.stringify(r,null,2)),[f,m]=_t.useState(""),p=_t.useRef(r);return _t.useEffect(()=>{r!==p.current&&(p.current=r,d(r===void 0?"":JSON.stringify(r,null,2)),m(""))},[r]),o.jsxs(o.Fragment,{children:[o.jsx("textarea",{id:n,className:"code-mono",rows:4,value:c,disabled:a,"aria-invalid":!!f,onChange:g=>{d(g.target.value);try{const y=g.target.value.trim()?JSON.parse(g.target.value):void 0;p.current=y,i(y),m("")}catch{p.current=g.target.value,i(g.target.value),m("Enter valid JSON.")}}}),f?o.jsx("span",{role:"alert",className:"code-error-text",children:f}):null]})}const Wy=3,pf=["KB","MB","GB","TB"];function Ii(n){const r=Math.max(0,Number(n)||0);if(r<1024)return`${r} B`;let i=r/1024,a=0;for(;i>=1024&&a<pf.length-1;)i/=1024,a+=1;return`${i<10?Math.round(i*10)/10:Math.round(i)} ${pf[a]}`}function hf(n){return`${Math.round(n).toLocaleString("en-US")} bytes`}function Vy(n,r){if(!r||!(r>0)||n.size<=r)return null;let i=Ii(n.size),a=Ii(r);return i===a&&(i=hf(n.size),a=hf(r)),`${n.name||"This file"} is ${i}; the gateway accepts files up to ${a}.`}function Hy(n){return`Upload failed: ${String(n||"").replace(/^attachments_upload failed:?\s*/i,"").trim()||"the gateway did not say why"}`}function Gy(n,r,i){return n.map(a=>{const c=Vy(a,r);return{id:i(),file:a,name:a.name||"Untitled file",size:a.size,status:c?"refused":"queued",...c?{message:c}:{}}})}async function Ky(n,r,i){let a=0;const c=Array.from({length:Math.max(1,Math.min(Math.floor(r)||1,n.length))},async()=>{for(;a<n.length;){const d=n[a];a+=1,await i(d)}});await Promise.all(c)}function sa(n){return`${n} ${n===1?"file":"files"}`}function mf(n,r){const i=[];return n&&i.push(`${sa(n)} attached`),r&&i.push(`${sa(r)} could not be attached`),i.join(", ")}function Qy(n){const r=n.filter(c=>c.status==="queued"||c.status==="uploading").length;if(r)return`Wait for ${sa(r)} to finish uploading.`;const i=n.filter(c=>c.status==="failed"||c.status==="refused");if(!i.length)return null;const a=i.some(c=>c.status==="failed");return i.length===1?`"${i[0].name}" was not attached. ${a?"Retry or remove":"Remove"} it before sending.`:`${sa(i.length)} were not attached. ${a?"Retry or remove":"Remove"} them before sending.`}function Jy({attachments:n,uploads:r,sizes:i,onRemoveAttachment:a,onRemoveUpload:c,onRetryUpload:d}){return o.jsxs("div",{className:"code-attachments",role:"list","aria-label":"Attached files",children:[n.map((f,m)=>{const p=f.filename||f.path||"Attachment",g=typeof f.size_bytes=="number"?f.size_bytes:i==null?void 0:i.get(f.$artifact),y=typeof g=="number"?Ii(g):"";return o.jsxs("div",{role:"listitem",tabIndex:0,className:"code-attachment is-attached","aria-label":`${p}${y?`, ${y}`:""}, attached`,children:[o.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:o.jsx(fe,{name:"paperclip",size:13})}),o.jsxs("span",{className:"code-attachment__body",children:[o.jsx("span",{className:"code-attachment__name",title:p,children:p}),y?o.jsx("span",{className:"code-attachment__meta",children:y}):null]}),o.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${p}`,title:`Remove ${p}`,onClick:()=>a(m),children:o.jsx(fe,{name:"x",size:12})})]},`${f.$artifact}:${m}`)}),r.map(f=>{const m=f.status==="queued"||f.status==="uploading",p=f.status==="queued"?`Waiting · ${Ii(f.size)}`:f.status==="uploading"?`Uploading · ${Ii(f.size)}`:f.message||"Not attached",g=f.status==="queued"?"waiting to upload":f.status==="uploading"?"uploading":`not attached: ${p}`;return o.jsxs("div",{role:"listitem",tabIndex:0,className:`code-attachment is-${f.status}`,"aria-label":`${f.name}, ${g}`,"aria-busy":m||void 0,children:[o.jsx("span",{className:"code-attachment__icon","aria-hidden":"true",children:m?o.jsx("span",{className:"code-attachment__spinner"}):o.jsx(fe,{name:"warning",size:13})}),o.jsxs("span",{className:"code-attachment__body",children:[o.jsx("span",{className:"code-attachment__name",title:f.name,children:f.name}),o.jsx("span",{className:"code-attachment__meta",children:p})]}),f.status==="failed"?o.jsxs("button",{type:"button",className:"code-attachment__action code-attachment__retry","aria-label":`Retry ${f.name}`,title:"Retry upload",onClick:()=>d(f.id),children:[o.jsx(fe,{name:"refresh",size:12}),o.jsx("span",{children:"Retry"})]}):null,o.jsx("button",{type:"button",className:"code-attachment__action","aria-label":`Remove ${f.name}`,title:`Remove ${f.name}`,onClick:()=>c(f.id),children:o.jsx(fe,{name:"x",size:12})})]},f.id)})]})}function Yy({active:n,paused:r,snapshot:i,onRevokeApproval:a,onCommand:c,onActivity:d,onInteraction:f,permissionsAll:m}){const p=x.useMemo(()=>cg(i),[i]),y=x.useMemo(()=>p.tone==="working"?fy(i.records.map(A=>A.record)):"",[p.tone,i.records])||p.detail,[_,w]=x.useState(Date.now);x.useEffect(()=>{if(!n)return;const A=window.setInterval(()=>w(Date.now()),1e3);return()=>window.clearInterval(A)},[n]);const k=Date.parse(p.startedAt||""),T=Number.isFinite(k)?Math.max(0,Math.floor((_-k)/1e3)):null,N=T===null?"":T<60?`${T}s`:`${Math.floor(T/60)}m ${T%60}s`;return o.jsxs("div",{className:`code-run-strip code-run-strip--${p.tone}`,children:[o.jsxs("div",{className:"code-run-strip__activity",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"code-run-strip__icon","aria-hidden":"true",children:o.jsx(fe,{name:p.tone==="working"?"loader":p.tone==="success"?"check":p.tone==="error"?"error":p.tone==="waiting"?"history":"info",size:15})}),f&&p.tone==="waiting"?o.jsxs("button",{className:"code-run-strip__attention",onClick:f,title:"Go to the pending request",children:[o.jsx("strong",{children:p.label}),o.jsx(fe,{name:"chevronRight",size:12})]}):o.jsx("strong",{children:p.label}),o.jsx("span",{className:"code-run-strip__detail",title:y,children:y})]}),o.jsxs("span",{className:"code-run-strip__metrics","aria-label":"Run activity metrics",children:[n&&N?o.jsx("span",{children:N}):null,p.toolCalls?o.jsxs("span",{children:[p.toolCalls," ",p.toolCalls===1?"tool":"tools"]}):null,p.totalTokens!==void 0?o.jsxs("span",{children:[p.totalTokens.toLocaleString()," tokens"]}):null]}),n?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>c(r?"resume":"pause"),children:r?"Resume":"Pause"}),o.jsx("button",{onClick:()=>c("conclude"),children:"Conclude"})]}):null,o.jsxs("button",{onClick:d,children:["View activity ",o.jsx(fe,{name:"chevronRight",size:12})]}),m?o.jsxs("div",{className:"code-run-strip__consent",children:[o.jsx(fe,{name:"check",size:13}),o.jsx("span",{children:"Permissions: all · enabled tools only"}),o.jsx("button",{onClick:a,children:"Revoke"})]}):null]})}function Xy({runId:n,sessionId:r,capability:i,scope:a,preferences:c,onTranscript:d,onError:f}){var _,w;const m=x.useRef(!0),p=x.useRef(a);p.current=a,x.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const g=()=>{if(!m.current||p.current!==a)throw new Error("Voice session changed.")},y=bm({tts:((_=i.tts)==null?void 0:_.available)===!0&&n?async k=>{g();const T=await Nt(`/api/gateway/runs/${encodeURIComponent(n)}/voice/tts`,{method:"POST",body:JSON.stringify({text:k,request_id:Yr(),...Object.fromEntries(Object.entries(c).filter(([,S])=>S!==""&&S!==void 0))})});g();const N=T==null?void 0:T.audio_artifact;if(!(N!=null&&N.$artifact))throw new Error("The gateway did not return an audio artifact.");const{blob:A}=await yn.get_run_artifact_blob(String(N.run_id||T.child_run_id||n),N.$artifact,{max_bytes:25e6});return g(),A.arrayBuffer()}:void 0,transcribe:((w=i.stt)==null?void 0:w.available)===!0&&n?async(k,T)=>{var j;g();const N=Number(((j=i.stt)==null?void 0:j.max_upload_bytes)||0);if(N>0&&k.size>N)throw new Error("Recording exceeds the gateway's upload limit. Try a shorter recording.");const A=T.includes("mp4")?"m4a":T.includes("ogg")?"ogg":T.includes("wav")?"wav":"webm",S=new File([k],`recording.${A}`,{type:T||"audio/webm"}),P=await yn.attachments_upload(r,S);g();const C=await yn.audio_transcribe(n,{audio_artifact:P,request_id:Yr()});return g(),String(C.text||"")}:void 0,on_transcript:k=>{m.current&&p.current===a&&d(k)},on_error:k=>{m.current&&p.current===a&&f(k)}});return x.useEffect(()=>{var k;return y.stop_tts(),(k=y.cancel_voice_ptt_recording)==null||k.call(y),()=>{var T;y.stop_tts(),(T=y.cancel_voice_ptt_recording)==null||T.call(y)}},[a,y.stop_tts,y.cancel_voice_ptt_recording]),y}function Zy({voice:n,runId:r,capability:i,answer:a,onSettings:c}){var g,y,_,w,k;const d=x.useRef(!1),f=x.useRef(!0);x.useEffect(()=>(f.current=!0,()=>{f.current=!1,d.current=!1}),[]);const m=()=>{d.current=!0,n.start_voice_ptt_recording().then(()=>{(!d.current||!f.current)&&n.stop_voice_ptt_recording()})},p=()=>{d.current=!1,n.stop_voice_ptt_recording()};return x.useEffect(()=>(window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p),window.addEventListener("blur",p),()=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),window.removeEventListener("blur",p)}),[n.stop_voice_ptt_recording]),!((g=i.tts)!=null&&g.available)&&!((y=i.stt)!=null&&y.available)?null:o.jsxs(o.Fragment,{children:[(_=i.stt)!=null&&_.available?o.jsx("button",{className:"code-icon-button","aria-label":n.voice_ptt_recording?"Recording — release to transcribe":"Hold to dictate",title:r?"Hold to dictate (Space or Enter on keyboard)":"Start a conversation to enable dictation",disabled:!n.voice_ptt_supported||n.voice_ptt_busy,"aria-pressed":n.voice_ptt_recording,onPointerDown:T=>{T.button===0&&m()},onPointerUp:p,onPointerCancel:p,onKeyDown:T=>{[" ","Enter"].includes(T.key)&&!T.repeat&&(T.preventDefault(),m())},onKeyUp:T=>{[" ","Enter"].includes(T.key)&&(T.preventDefault(),p())},onBlur:p,children:o.jsx(fe,{name:n.voice_ptt_busy?"loader":"mic",size:15})}):null,(w=i.tts)!=null&&w.available?o.jsx("button",{className:"code-icon-button","aria-label":n.tts_playback.status==="playing"?"Pause spoken reply":n.tts_playback.status==="paused"?"Resume spoken reply":"Read latest reply aloud",disabled:!n.tts_supported||!a||n.tts_playback.status==="loading",onClick:()=>{a&&n.toggle_tts(["playing","paused"].includes(n.tts_playback.status)?n.tts_playback.key:a.id||"latest",a.content)},children:o.jsx(fe,{name:n.tts_playback.status==="playing"?"pause":n.tts_playback.status==="loading"?"loader":"speaker",size:15})}):null,n.tts_playback.status!=="idle"?o.jsx("button",{className:"code-icon-button","aria-label":"Stop spoken reply",onClick:n.stop_tts,children:o.jsx(fe,{name:"x",size:14})}):null,c&&((k=i.tts)!=null&&k.available)?o.jsx("button",{className:"code-icon-button","aria-label":"Voice settings",title:"Voice settings",onClick:c,children:o.jsx(fe,{name:"settings",size:14})}):null,n.voice_ptt_recording||n.voice_ptt_busy?o.jsx("span",{role:"status",children:n.voice_ptt_recording?"Recording…":"Transcribing…"}):null]})}function ql(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Yo(n){return typeof n=="string"?n.trim():""}function qy(n){const r=ql(n),i=ql(r==null?void 0:r.gateway),a=ql(i==null?void 0:i.principal);return JSON.stringify([Yo((r==null?void 0:r.gateway_url)??(r==null?void 0:r.gatewayUrl)),Yo((a==null?void 0:a.tenant_id)??(a==null?void 0:a.tenantId)),Yo((a==null?void 0:a.runtime_id)??(a==null?void 0:a.runtimeId)),Yo((a==null?void 0:a.user_id)??(a==null?void 0:a.userId))||"session"])}function gf(n,r){return!!n.sourceRunId&&n.sessionId===r.sessionId&&n.sessionId===r.snapshotSessionId&&n.sourceRunId===r.runId&&n.sourceRunId===r.snapshotRunId&&n.authEpoch===r.authEpoch}function ev(n){const r=typeof n=="string"?n.trim().toLowerCase():"";return["completed","complete","done"].includes(r)?"advance":["failed","error","cancelled","canceled"].includes(r)?"pause":"wait"}function tv(n,r,i){return n.flatMap(a=>a.id===r.id?[]:a.sessionId!==r.sessionId||a.authEpoch!==r.authEpoch||a.sourceRunId!==r.sourceRunId?[a]:[{...a,sourceRunId:i}])}function yf(){return new DOMException("The conversation changed before the run was attached.","AbortError")}const ec=n=>["completed","failed","cancelled","canceled"].includes(n);function vf(){const n=new URLSearchParams(window.location.hash.replace(/^#/,""));return{sessionId:n.get("session")||Yr(),runId:n.get("run")||""}}function $i(n,r=""){const i=new URLSearchParams({session:n});r&&i.set("run",r),window.history.replaceState(null,"",`#${i}`)}function nv(n){try{const r=JSON.parse(localStorage.getItem(`abstractcode.workspace.v2:${n}`)||"{}");return{...Ws,...r,speculation:Cf(r.speculation),tools:{...Ws.tools,...r.tools}}}catch{return Ws}}function rv(){var Ht,Fi,Di,Bi,Mr,Ir,rr,Pr,Ui,Wi,ls,Gs,cs,sr,Vi;const n=hm({appName:"AbstractCode",variant:"blocking"}),r=n.connected?qy(n.status):"",i=x.useCallback(()=>{n.refresh()},[n.refresh]),a=qg(r,i),[c,d]=vm("abstractcode",{defaults:{theme:"observer-night"}}),[f,m]=x.useState(!1),[p,g]=x.useState(!1),[y,_]=x.useState({});x.useEffect(()=>{try{_(JSON.parse(localStorage.getItem(`abstractcode.voice:${r}`)||"{}"))}catch{_({})}g(!1)},[r]);const w=M=>{if(_(M),r)try{localStorage.setItem(`abstractcode.voice:${r}`,JSON.stringify(M))}catch{}},[k,T]=x.useState(Ws),[N,A]=x.useState(""),S=a.workflows.find(M=>M.id===N)||null,P=pc(S),[C,j]=x.useState(vf),[L,W]=x.useState(""),[V,Q]=x.useState(""),[me,oe]=x.useState(""),[X,le]=x.useState(!1),H=x.useRef(!1),[ae,se]=x.useState([]),[ye,we]=x.useState([]),J=x.useRef(new Set),ne=x.useRef(new Map),[U,E]=x.useState(""),D=x.useRef(null),[z,re]=x.useState(),[ce,ve]=x.useState(!1),[_e,ie]=x.useState(""),[$e,Ue]=x.useState(0),[We,ee]=x.useState({}),[Z,de]=x.useState(""),[je,ke]=x.useState(null),[Ee,Oe]=x.useState(""),[qe,B]=x.useState(!1),[pe,Le]=x.useState(!1),[Ge,zt]=x.useState("model"),[vn,wn]=x.useState(()=>window.innerWidth>1120),[$n,Tn]=x.useState("files"),[Nr,Ut]=x.useState(!1),[Dn,oa]=x.useState(""),Vs=x.useRef(null),[qn,aa]=x.useState("steer"),[_n,cn]=x.useState([]),[Er,tn]=x.useState(!1),[Zr,Rn]=x.useState([]),xn=x.useMemo(()=>Qf(a.tools,k.tools,k.permissions),[a.tools,k.tools,k.permissions]),qr=x.useRef(null),Pi=x.useMemo(()=>{var De,Pe;const M=((De=qr.current)==null?void 0:De.runId)===C.runId?qr.current.input:null;if(C.runId&&!je&&!M)return{enabledTools:[],autoApproveTools:[]};const G=je?je.input_data:M,Ie=oy(xn,(Pe=G==null?void 0:G._runtime)==null?void 0:Pe.allowed_tools);return{...Ie,autoApproveTools:k.toolsCustomized||k.permissions!=="default"?Ie.autoApproveTools:[]}},[xn,je,C.runId,k.toolsCustomized,k.permissions]),{controller:An,snapshot:Fe}=jg({transport:ty,runId:C.runId,enabled:n.connected,onAuthError:i,clientId:"abstractcode-web",authScopeKey:r,toolApprovalPolicy:Pi}),Wt=!!C.runId&&!ec(Fe.status)&&Fe.status!=="idle",$r=((Ht=Fe.run)==null?void 0:Ht.paused)===!0||Fe.status==="paused",Bn=Wt||X,nn=Fe.loading&&Zr.length?Zr:Fe.messages,es=((Di=(Fi=a.capabilities)==null?void 0:Fi.assistant)==null?void 0:Di.voice)||{},un=Xy({scope:`${r}:${C.sessionId}:${C.runId}`,runId:r?C.runId:"",sessionId:C.sessionId,capability:es,preferences:y,onTranscript:M=>W(G=>G?`${G.trimEnd()}
55
+ ${M}`:M),onError:Q}),Li=_g(Fe),$t=x.useMemo(()=>ny(Li,An,Fe.records,Fe.run,async()=>{T(M=>({...M,permissions:"all"}))}),[Li,Fe.records,Fe.run,An]),Tr=!!$t&&qn==="steer",Vt=P?"prompt":Qg(z),ts=P||!!(Vt&&!((Bi=z==null?void 0:z.required)!=null&&Bi.some(M=>M!==Vt))),er=String(((Mr=je==null?void 0:je.workspace)==null?void 0:Mr.workspace_root)||((rr=(Ir=Fe.run)==null?void 0:Ir.vars)==null?void 0:rr.workspace_root)||""),tr=x.useMemo(()=>{var M;return Ig(a.workflows,{inputData:je,runWorkflowId:(M=Fe.run)==null?void 0:M.workflow_id})},[a.workflows,je,(Pr=Fe.run)==null?void 0:Pr.workflow_id]),ns=C.runId&&je&&!a.loading&&Fe.run&&!tr?"This conversation's exact workflow version is unavailable. Restore it in the gateway, or start a new conversation with an available workflow.":"",ft=a.sessions.find(M=>M.sessionId===C.sessionId),Hs=(ft==null?void 0:ft.prompt)||((Ui=nn.find(M=>M.role==="user"))==null?void 0:Ui.content)||"New conversation",rs=x.useRef(""),Rr=x.useRef(r),ut=x.useRef(0);Rr.current!==r&&(ut.current+=1,Rr.current=r);const ss=x.useRef(!1),gt=x.useRef(C);gt.current=C,x.useEffect(()=>{if(H.current=!1,le(!1),we([]),Q(""),oe(""),!r){se([]),W(""),cn([]),tn(!1),Rn([]),T(Ws);return}if(rs.current&&rs.current!==r){const M={sessionId:Yr(),runId:""};j(M),$i(M.sessionId)}rs.current=r,ss.current=!0,T(nv(r))},[r]),x.useEffect(()=>{if(r){if(ss.current){ss.current=!1;return}try{localStorage.setItem(`abstractcode.workspace.v2:${r}`,JSON.stringify(k))}catch{}}},[k,r]),x.useEffect(()=>{if(!a.choices.length){A("");return}!(C.runId&&a.workflows.some(M=>M.id===N))&&!a.choices.some(M=>M.id===N)&&A((a.choices.find(M=>M.isDefault)||a.choices[0]).id)},[a.workflows,a.choices,N,C.runId]),x.useEffect(()=>{let M=!0;if(ee({}),de(""),re(void 0),ie(""),!S){ve(!1);return}return ve(!0),ey(S).then(G=>{M&&(re(G),ee(Ri(G)))}).catch(G=>{M&&ie(En(G))}).finally(()=>{M&&ve(!1)}),()=>{M=!1}},[S==null?void 0:S.id,$e]),x.useEffect(()=>{if(ke(null),Oe(""),!r||!C.runId)return;const M=new AbortController;return Nt(`/api/gateway/runs/${encodeURIComponent(C.runId)}/input_data`,{signal:M.signal}).then(G=>{ke(G)}).catch(G=>{M.signal.aborted||Oe(En(G))}),()=>M.abort()},[C.runId,r]),x.useEffect(()=>{je&&je.flow_id===(S==null?void 0:S.flowId)&&z&&ee({...Ri(z),...Hg(z,je.input_data)})},[je,z,S==null?void 0:S.flowId]),x.useEffect(()=>{!C.runId&&n.connected&&(ft!=null&&ft.latestRunId)&&j(M=>({...M,runId:ft.latestRunId}))},[C.runId,n.connected,ft==null?void 0:ft.latestRunId]),x.useEffect(()=>{$i(C.sessionId,C.runId),H.current=!1,le(!1),we([]),se([]),Rn([]),oe(""),Q(""),cn([]),tn(!1)},[C.sessionId]),x.useEffect(()=>{const M=()=>{const G=vf();H.current=!1,le(!1),we([]),cn([]),tn(!1),W(""),j(G)};return window.addEventListener("hashchange",M),()=>window.removeEventListener("hashchange",M)},[]),x.useEffect(()=>{!C.runId||!ec(Fe.status)||a.refresh()},[C.runId,Fe.status]),x.useEffect(()=>{tr&&A(tr.id)},[C.runId,tr==null?void 0:tr.id]);const Ar=x.useCallback(()=>{const M={sessionId:Yr(),runId:""};j(M),$i(M.sessionId),W(""),cn([]),tn(!1),Ut(!1)},[]);x.useEffect(()=>{const M=G=>{var Ie;if(G.key==="Escape"&&Nr){Ut(!1),(Ie=document.querySelector(".code-mobile-nav"))==null||Ie.focus();return}(G.metaKey||G.ctrlKey)&&(G.key.toLowerCase()==="k"&&(G.preventDefault(),Ut(!0),window.setTimeout(()=>{var De;return(De=Vs.current)==null?void 0:De.focus()},0)),G.key.toLowerCase()==="n"&&G.shiftKey&&(G.preventDefault(),Ar()))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[Ar,Nr]);async function is(M){if(H.current)throw new Error("A turn is already being submitted.");if(!n.connected)throw new Error("Connect to your gateway first.");if(!S)throw new Error("Choose a workflow first.");if(!a.policy)throw new Error("Workspace policy is unavailable. Reconnect or refresh before starting.");if(C.runId&&(!je||Ee))throw new Error(Ee||"Wait for the gateway to restore this conversation's workspace.");if(ns)throw new Error(ns);if(ce||_e)throw new Error(_e||"Wait for workflow inputs to load.");if(Z)throw B(!0),new Error(Z);const G=Qy(ye);if(G)throw new Error(G);if(Wt)throw new Error("The current run is still active.");if(!P&&M.trim()&&!Vt)throw B(!0),new Error("This workflow uses structured inputs. Configure its inputs, then select Run workflow.");const Ie={...Ri(z),...We,...Vt&&M.trim()?{[Vt]:M.trim()}:{}},De=P?Ie:Fy(z,Ie,ae);for(const[kt,lt]of[["Iteration limit",k.maxIterations],["Context token limit",k.maxTokens]])if(lt&&(!Number.isInteger(Number(lt))||Number(lt)<=0))throw new Error(`${kt} must be a positive whole number.`);H.current=!0,le(!0),Q(""),oe("");const Pe=C.sessionId,xt=C.runId,Un=r,Wn=ut.current;let pt="";try{const kt=Fg({workflow:S,inputSchema:z,schemaInputs:De,prompt:M,promptProperty:Vt,model:k,reasoning:k.reasoning||void 0,speculation:k.speculation,systemPromptExtra:k.system||void 0,attachments:ae,limits:{maxIterations:k.maxIterations?Number(k.maxIterations):void 0,maxTokens:k.maxTokens?Number(k.maxTokens):void 0},workspace:a.policy.clientWorkspaceScopeOverrides?{root:k.workspaceRoot||er||void 0,accessMode:k.workspaceMode||void 0,allowedPaths:k.allowedPaths.split(`
56
+ `).filter(Boolean)}:er?{root:er}:void 0,tools:k.toolsCustomized?xn.enabledTools:void 0,toolPolicy:k.toolsCustomized||k.permissions!=="default"?{autoApproveTools:[],requireApprovalTools:xn.enabledTools}:void 0,skills:k.skills.length?k.skills:void 0}),lt=Jg(z,kt);if(lt.length)throw B(!0),new Error(lt.join(" "));const Tt={bundle_id:S.bundleId,bundle_version:S.bundleVersion,registry_scope:S.registryScope,flow_id:S.flowId,session_id:Pe,input_data:kt},Rt=await Nt("/api/gateway/runs/start",{method:"POST",body:JSON.stringify(Tt)});if(!Rt.run_id)throw new Error("The gateway did not return a run identifier.");if(gt.current.sessionId!==Pe||gt.current.runId!==xt||Rr.current!==Un||ut.current!==Wn)throw yf();return pt=String(Rt.run_id),qr.current={runId:pt,input:kt},Rn([...nn,...M.trim()?[{id:`pending:${Rt.run_id}`,role:"user",content:M.trim()}]:[]]),j({sessionId:Pe,runId:Rt.run_id}),$i(Pe,Rt.run_id),W(""),se([]),B(!1),Rt.runner_warning&&oe(String(Rt.runner_warning)),a.refresh(),pt}finally{gt.current.sessionId===Pe&&(gt.current.runId===xt||gt.current.runId===pt)&&Rr.current===Un&&ut.current===Wn&&(H.current=!1,le(!1))}}async function la(M){if(!Wt)return is(M);if(qn==="queue")cn(G=>[...G,{id:Yr(),text:M,sessionId:C.sessionId,sourceRunId:C.runId,authEpoch:ut.current}]),tn(!0),W(""),oe("Queued for the next turn.");else{if($t)throw new Error("Answer the pending workflow request above, or choose Queue next turn.");const G=C.sessionId,Ie=C.runId,De=ut.current;if(await An.sendCommand("inject_guidance",{guidance:M}),gt.current.sessionId!==G||gt.current.runId!==Ie||ut.current!==De)return;W(""),oe("Guidance queued. The workflow will read it at its next supported boundary.")}}async function nt(M){var De,Pe;const G=String(((De=Fe.run)==null?void 0:De.run_id)||"");if(!gf(M,{sessionId:C.sessionId,runId:C.runId,snapshotRunId:G,snapshotSessionId:String(((Pe=Fe.run)==null?void 0:Pe.session_id)||""),authEpoch:ut.current}))throw yf();const Ie=await is(M.text);cn(xt=>tv(xt,M,Ie))}x.useEffect(()=>{var Ie,De;if(!Er||!_n.length||!n.connected||!je||Ee||H.current)return;const M=ev(Fe.status);if(M==="wait")return;if(M==="pause"){tn(!1);const Pe=["failed","error"].includes(Fe.status.toLowerCase());oe(`Queue paused because the run ${Pe?"failed":"was cancelled"}. Review the result, then use Run next to continue explicitly.`);return}const G=_n[0];gf(G,{sessionId:C.sessionId,runId:C.runId,snapshotRunId:String(((Ie=Fe.run)==null?void 0:Ie.run_id)||""),snapshotSessionId:String(((De=Fe.run)==null?void 0:De.session_id)||""),authEpoch:ut.current})&&nt(G).catch(Pe=>{Pe instanceof DOMException&&Pe.name==="AbortError"||(tn(!1),Q(En(Pe)))})},[Er,_n,Fe.status,(Wi=Fe.run)==null?void 0:Wi.run_id,(ls=Fe.run)==null?void 0:ls.session_id,n.connected,je,Ee,C.sessionId,C.runId]);async function Oi(M){const G=C.sessionId,Ie=r,De=ut.current,Pe=()=>gt.current.sessionId!==G||Rr.current!==Ie||ut.current!==De,xt=(pt,kt)=>we(lt=>lt.map(Tt=>Tt.id===pt?{...Tt,...kt}:Tt));let Un=0,Wn=0;await Ky(M,Wy,async pt=>{if(!(Pe()||J.current.has(pt.id))){xt(pt.id,{status:"uploading",message:void 0});try{const kt=await yn.attachments_upload(G,pt.file);if(Pe()||J.current.has(pt.id))return;ne.current.set(kt.$artifact,pt.size),we(lt=>lt.filter(Tt=>Tt.id!==pt.id)),se(lt=>[...lt,kt]),Un+=1}catch(kt){if(Pe()||J.current.has(pt.id))return;xt(pt.id,{status:"failed",message:Hy(En(kt))}),Wn+=1}}}),!Pe()&&(Un||Wn)&&E(mf(Un,Wn))}function os(M){var De;if(!M.length)return;const G=Gy(M,(De=a.policy)==null?void 0:De.maxAttachmentBytes,Yr);we(Pe=>[...Pe,...G]);const Ie=G.filter(Pe=>Pe.status==="refused").length;Ie&&E(mf(0,Ie)),Oi(G.filter(Pe=>Pe.status==="queued"))}function zi(M){const G=ye.find(De=>De.id===M);if(!G||G.status!=="failed")return;const Ie={...G,status:"queued",message:void 0};we(De=>De.map(Pe=>Pe.id===M?Ie:Pe)),Oi([Ie])}function as(M){J.current.add(M),we(G=>G.filter(Ie=>Ie.id!==M))}async function ca(){const M=C.sessionId,G=C.runId,Ie=ut.current;await An.cancel(),gt.current.sessionId===M&&gt.current.runId===G&&ut.current===Ie&&oe("")}const nr=M=>{zt(M),Le(!0)},Mn=M=>{const G=ut.current,Ie=C.sessionId,De=C.runId;Q(""),M().catch(Pe=>{Pe instanceof DOMException&&Pe.name==="AbortError"||ut.current===G&&gt.current.sessionId===Ie&&gt.current.runId===De&&Q(En(Pe))})},rn=a.sessions.filter(M=>`${M.prompt||""} ${M.sessionId}`.toLowerCase().includes(Dn.toLowerCase())),ua=(()=>{var M;try{return new URL(((M=n.status)==null?void 0:M.gateway_url)||"").host}catch{return"Your gateway"}})();return o.jsxs("div",{className:`code-app${Nr?" code-app--nav-open":""}${vn?" code-app--inspector":""}`,children:[o.jsx("a",{className:"code-skip-link",href:"#code-conversation",children:"Skip to conversation"}),o.jsxs("aside",{className:"code-sidebar","aria-label":"Conversations",children:[o.jsxs("div",{className:"code-brand",children:[o.jsxs("span",{className:"code-brand-mark","aria-hidden":"true",children:["a",o.jsx("span",{children:"c"})]}),o.jsxs("div",{children:[o.jsx("strong",{children:"AbstractCode"}),o.jsx("span",{children:"YOUR WORK, IN CONTEXT"})]}),o.jsx("button",{className:"code-mobile-close code-icon-button","aria-label":"Close navigation",onClick:()=>Ut(!1),children:o.jsx(fe,{name:"x",size:18})})]}),o.jsxs("button",{className:"code-new-chat",onClick:Ar,children:[o.jsx(fe,{name:"plus",size:17}),o.jsx("span",{children:"New conversation"}),o.jsx("kbd",{children:"⇧⌘N"})]}),o.jsxs("div",{className:"code-session-search",children:[o.jsx(fe,{name:"history",size:14}),o.jsx("input",{ref:Vs,"aria-label":"Search conversations",placeholder:"Search conversations",value:Dn,onChange:M=>oa(M.target.value)}),o.jsx("kbd",{children:"⌘K"})]}),o.jsxs("div",{className:"code-section-label",children:[o.jsx("span",{children:"CONVERSATIONS"}),o.jsx("button",{className:"code-icon-button","aria-label":"Refresh conversations",disabled:!n.connected||a.loading,onClick:()=>void a.refresh(),children:o.jsx(fe,{name:"refresh",size:13})})]}),o.jsxs("nav",{className:"code-sessions","aria-label":"Conversation history",children:[ft?null:o.jsxs("button",{className:"code-session is-selected",onClick:()=>Ut(!1),children:[o.jsx(fe,{name:"chat",size:15}),o.jsxs("span",{children:[o.jsx("strong",{children:"New conversation"}),o.jsx("small",{children:"Ready when you are"})]})]}),rn.map(M=>o.jsx(sv,{item:M,selected:M.sessionId===C.sessionId,onClick:()=>{H.current=!1,le(!1),we([]),j({sessionId:M.sessionId,runId:M.latestRunId}),$i(M.sessionId,M.latestRunId),Ut(!1),cn([]),tn(!1),W("")}},M.sessionId)),!a.loading&&!rn.length?o.jsx("p",{className:"code-history-empty",children:Dn?"No conversations match your search.":"Your conversations will live here. Pick up where you left off, on any device."}):null,a.loading?o.jsx("p",{className:"code-history-empty",role:"status",children:"Loading conversations…"}):null,a.hasMore?o.jsx("button",{className:"code-load-more",onClick:a.loadMore,children:"Load more conversations"}):null]}),o.jsxs("div",{className:"code-sidebar-bottom",children:[o.jsxs("button",{onClick:()=>nr("workspace"),children:[o.jsx(fe,{name:"terminal",size:17}),o.jsxs("span",{children:[o.jsx("strong",{children:"Workspace"}),o.jsx("small",{children:er.split("/").filter(Boolean).pop()||"Gateway managed"})]}),o.jsx(fe,{name:"chevronRight",size:14})]}),o.jsxs("button",{onClick:()=>nr("model"),children:[o.jsx(fe,{name:"settings",size:17}),o.jsx("span",{children:"Settings"})]}),o.jsxs("div",{className:"code-gateway-foot",children:[o.jsx("span",{className:`code-status-dot ${n.connected?"is-online":""}`}),o.jsx("span",{children:ua}),o.jsx("small",{children:((sr=(cs=(Gs=n.status)==null?void 0:Gs.gateway)==null?void 0:cs.principal)==null?void 0:sr.user_id)||"Signed out"})]})]})]}),Nr?o.jsx("button",{className:"code-nav-scrim","aria-label":"Close conversation navigation",onClick:()=>Ut(!1)}):null,o.jsxs("div",{className:"code-main-shell",children:[o.jsxs("header",{className:"code-topbar",children:[o.jsx("button",{className:"code-mobile-nav code-icon-button","aria-label":"Open conversation navigation",onClick:()=>Ut(!0),children:o.jsx(fe,{name:"list",size:19})}),o.jsxs("div",{className:"code-breadcrumb",children:[o.jsx("span",{children:"Conversations"}),o.jsx("span",{"aria-hidden":"true",children:"/"}),o.jsx("strong",{title:Hs,children:Hs})]}),o.jsx(mm,{appearance:{onOpen:()=>m(!0)},extraActions:o.jsx("button",{className:`af-topbar__btn${vn?" is-active":""}`,"aria-label":"Toggle workspace inspector","aria-pressed":vn,onClick:()=>wn(M=>!M),children:o.jsx(fe,{name:"board",size:17})}),connection:{phase:n.phase,signingOut:n.signingOut,onConnect:n.openModal,onDisconnect:()=>{n.signOut()}}})]}),o.jsxs("div",{className:"code-toolbar",children:[o.jsxs("div",{className:"code-workflow-select",children:[o.jsx(fe,{name:"agent",size:17}),o.jsxs("select",{"aria-label":"Workflow",value:N,disabled:Bn||a.loading||!n.connected,onChange:M=>A(M.target.value),children:[a.choices.length?null:o.jsx("option",{value:"",children:a.loading?"Loading workflows…":"Choose a workflow"}),S&&C.runId&&!a.choices.some(M=>M.id===S.id)?o.jsxs("option",{value:S.id,children:[S.name," · conversation version ",S.bundleVersion]}):null,a.choices.map(M=>o.jsx("option",{value:M.id,children:Ag(M,a.choices)},M.id))]}),o.jsx("span",{className:"code-workflow-kind",children:P?"AGENT":"WORKFLOW"})]}),o.jsx("span",{className:"code-toolbar-divider"}),o.jsxs("button",{className:"code-model-button",onClick:()=>nr("model"),children:[o.jsx(fe,{name:"sparkle",size:14}),o.jsx("span",{children:k.model||(We.provider&&We.model?`Workflow · ${We.model}`:"Gateway default")}),o.jsx(fe,{name:"chevronDown",size:12})]}),o.jsx("div",{className:"code-toolbar-spacer"}),o.jsxs("button",{className:"code-subtle-button",onClick:()=>B(!0),disabled:!S,children:[o.jsx(fe,{name:"settings",size:14}),o.jsx("span",{children:"Inputs"})]}),o.jsxs("button",{className:"code-subtle-button",onClick:()=>nr("tools"),children:[o.jsx(fe,{name:"terminal",size:14}),o.jsx("span",{children:"Tools"})]}),nn.length?o.jsx("button",{className:"code-icon-button","aria-label":"Export conversation",title:"Export conversation",onClick:()=>Am({filename:"conversation.md",text:Rm(nn)}),children:o.jsx(fe,{name:"download",size:15})}):null]}),o.jsxs("div",{className:"code-content",children:[o.jsxs("main",{className:"code-conversation",id:"code-conversation",tabIndex:-1,children:[V||Fe.error||n.signOutError||Ee?o.jsxs("div",{className:"code-alert",role:"alert",children:[o.jsx(fe,{name:"warning",size:16}),o.jsx("span",{children:V||Fe.error||n.signOutError||Ee}),Fe.error||Ee?o.jsx("button",{onClick:()=>{Ee?window.location.reload():Mn(()=>An.load(C.runId))},children:"Reconnect"}):o.jsx("button",{"aria-label":"Dismiss error",onClick:()=>Q(""),children:o.jsx(fe,{name:"x",size:14})})]}):null,a.errors.length?o.jsx("div",{className:"code-discovery-errors",role:"status",children:o.jsxs("details",{children:[o.jsx("summary",{children:"Some gateway information could not be loaded"}),a.errors.map(M=>o.jsx("p",{children:M},M)),o.jsx("button",{onClick:()=>void a.refresh(),children:"Retry discovery"})]})}):null,ns?o.jsxs("div",{className:"code-alert",role:"alert",children:[o.jsx("span",{children:ns}),o.jsx("button",{onClick:Ar,children:"New conversation"})]}):null,_e?o.jsxs("div",{className:"code-alert",role:"alert",children:[o.jsxs("span",{children:["Workflow inputs: ",_e]}),o.jsx("button",{onClick:()=>Ue(M=>M+1),children:"Retry"})]}):null,me?o.jsxs("div",{className:"code-notice",role:"status",children:[me,o.jsx("button",{"aria-label":"Dismiss notice",onClick:()=>oe(""),children:o.jsx(fe,{name:"x",size:13})})]}):null,Wt||ec(Fe.status)?o.jsx(Yy,{active:Wt,paused:$r,snapshot:Fe,permissionsAll:k.permissions==="all",onInteraction:$t&&!$r?()=>{var Ie;const M=document.querySelector(".code-conversation .pc-chat-thread"),G=M==null?void 0:M.querySelector(".pc-workflow-interaction");!M||!G||(M.scrollTop+=G.getBoundingClientRect().top-M.getBoundingClientRect().top,(Ie=G.querySelector("h3"))==null||Ie.focus({preventScroll:!0}))}:void 0,onRevokeApproval:()=>{An.revokeToolApproval(),T(M=>({...M,permissions:"default"}))},onCommand:M=>Mn(()=>An.sendCommand(M,{})),onActivity:()=>{Tn("activity"),wn(!0)}}):null,o.jsx(wg,{messages:($t==null?void 0:$t.kind)==="tool-approval"?nn.filter(M=>{var G,Ie;return!(((G=M.toolActivity)==null?void 0:G.status)==="waiting"&&M.toolActivity.runId===((Ie=Fe.interaction)==null?void 0:Ie.runId))}):nn,messageProps:{...un.tts_supported?{onSpeakToggle:M=>{un.toggle_tts(M.id||M.content,M.content)}}:{},getSpeakState:M=>un.tts_playback.key===(M.id||M.content)?un.tts_playback.status:"idle"},draft:L,onDraftChange:W,onSend:la,busy:Bn,busyLabel:Tr?"Waiting for you":X?"Starting…":$r?"Paused":"Working…",sendWhileBusy:Wt&&!X&&!Tr,sendLabel:Wt?qn==="queue"?"Queue":"Steer":"Send",onCancel:ca,stopState:Fe.stop??null,disabled:!n.connected,interaction:$t,onAttach:()=>{var M;return(M=D.current)==null?void 0:M.click()},onFiles:os,attachments:ae.length||ye.length?o.jsx(Jy,{attachments:ae,uploads:ye,sizes:ne.current,onRemoveAttachment:M=>se(G=>G.filter((Ie,De)=>De!==M)),onRemoveUpload:as,onRetryUpload:zi}):null,placeholder:Wt?qn==="queue"?"Queue the next task after this run…":$t?"Answer the request above, or choose Queue next turn…":"Guide the current workflow…":"Describe what you want to build, fix, or explore…",emptyState:Wt?null:o.jsx(iv,{workflow:S,loading:a.loading||ce,onSuggestion:W,onInputs:()=>B(!0),isAgent:ts,onRun:()=>Mn(()=>is(L)),connected:n.connected}),composerExtras:o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"code-composer-workspace",onClick:()=>nr("workspace"),title:er||"Workspace is managed by the gateway",children:[o.jsx(fe,{name:"terminal",size:14}),o.jsx("span",{children:er.split("/").filter(Boolean).pop()||"Gateway workspace"})]}),n.connected?o.jsx(Zy,{runId:C.runId,voice:un,capability:es,onSettings:()=>g(!0),answer:[...nn].reverse().find(M=>M.role==="assistant")},`${r}:${C.sessionId}:${C.runId}`):null,Wt?o.jsxs("select",{"aria-label":"Message destination",value:qn,onChange:M=>aa(M.target.value),children:[o.jsxs("option",{value:"steer",disabled:!!$t,children:["Guide this run",$t?" (answer above)":""]}),o.jsx("option",{value:"queue",children:"Queue next turn"})]}):null]}),footer:o.jsxs(o.Fragment,{children:[o.jsxs("span",{children:["Enter to send ",o.jsx("span",{"aria-hidden":"true",children:"·"})," Shift + Enter for a new line"]}),o.jsxs("span",{children:[(Vi=a.policy)!=null&&Vi.clientWorkspaceScopeOverrides?"Gateway policy enforced":"Managed workspace",o.jsx("span",{className:"code-small-dot"})]})]})}),_n.length?o.jsxs("div",{className:"code-queue",children:[o.jsxs("div",{children:[o.jsxs("strong",{children:[_n.length," queued"," ",_n.length===1?"turn":"turns"]}),o.jsx("button",{onClick:()=>tn(M=>!M),children:Er?"Pause queue":"Resume queue"})]}),_n.map(M=>o.jsxs("div",{children:[o.jsx("span",{children:M.text}),Wt?null:o.jsx("button",{onClick:()=>Mn(()=>nt(M)),children:"Run next"}),o.jsx("button",{"aria-label":"Remove queued turn",onClick:()=>cn(G=>G.filter(Ie=>Ie.id!==M.id)),children:o.jsx(fe,{name:"x",size:13})})]},M.id))]}):null]}),vn?o.jsx(My,{tab:$n,onTab:Tn,policy:a.policy,runId:C.runId,records:Fe.records,enabled:n.connected,onClose:()=>wn(!1),onAttach:async M=>{const G=C.sessionId,Ie=C.runId,De=ut.current,Pe=await yn.attachments_ingest(G,M);gt.current.sessionId===G&&gt.current.runId===Ie&&ut.current===De&&se(xt=>[...xt,Pe])}}):null]}),o.jsxs("footer",{className:"code-statusbar",children:[o.jsxs("span",{children:[o.jsx("span",{className:`code-status-dot ${n.connected?"is-online":""}`}),n.connected?"Connected":n.phase==="loading"?"Connecting":"Disconnected"]}),o.jsx("span",{children:(S==null?void 0:S.name)||"No workflow selected"}),o.jsx("div",{}),o.jsx("span",{children:C.runId?`Run ${C.runId.slice(0,8)}`:"Ready to start"}),o.jsx("button",{onClick:()=>m(!0),children:c.theme.replace(/-/g," ")})]})]}),o.jsx("div",{className:"pc-sr-only",role:"status","aria-live":"polite",children:U}),o.jsx("input",{ref:D,hidden:!0,type:"file",multiple:!0,onChange:M=>{os(Array.from(M.target.files||[])),M.target.value=""}}),o.jsx(fm,{...n.modalProps}),o.jsx(sc,{open:p,onClose:()=>g(!1),label:"Voice settings",title:"AI voice",width:480,topOffset:60,className:"code-settings-drawer",children:o.jsx("div",{className:"code-settings",children:o.jsx(Cm,{value:y,onChange:M=>{un.stop_tts(),w(M)},fetchCatalog:(M,G)=>Nt(`/api/gateway/voice/voices?compact=true${M?`&provider=${encodeURIComponent(M)}`:""}${G?`&model=${encodeURIComponent(G)}`:""}`)})})}),o.jsx(wm,{open:f,onClose:()=>m(!1),value:c,onChange:d}),o.jsx(ay,{open:pe,onClose:()=>Le(!1),tab:Ge,onTab:zt,value:k,onChange:M=>{const G=[];(k.provider||k.model)&&!M.provider&&!M.model&&G.push("provider","model"),k.toolsCustomized&&!M.toolsCustomized&&G.push("tools"),k.maxIterations&&!M.maxIterations&&G.push("max_iterations"),G.length&&ee(Ie=>{const De={...Ie},Pe=Ri(z);for(const xt of G)delete De[xt],Object.prototype.hasOwnProperty.call(Pe,xt)&&(De[xt]=Pe[xt]);return De}),T(M)},policy:a.policy,tools:a.tools,defaultModel:We.provider&&We.model?{provider:String(We.provider),model:String(We.model)}:a.defaultModel,workflowDefault:!!(We.provider&&We.model),disabled:Bn||!n.connected},r),o.jsx(sc,{open:qe,onClose:()=>B(!1),label:"Workflow inputs",title:(S==null?void 0:S.name)||"Workflow inputs",width:480,topOffset:60,className:"code-settings-drawer",children:o.jsxs("div",{className:"code-settings",children:[o.jsx("p",{className:"code-muted",children:(S==null?void 0:S.description)||"Configure the values this workflow needs to run."}),ce?o.jsx("p",{role:"status",children:"Loading input schema…"}):_e?null:P||Vt?o.jsx(zy,{schema:z,promptProperty:Vt,defaultModel:a.defaultModel,values:We,onChange:ee,disabled:Bn,onEditorError:de},S==null?void 0:S.id):o.jsx(cc,{schema:z,defaultModel:a.defaultModel,values:We,onChange:ee,disabled:Bn,rawObject:!0,onEditorError:de},S==null?void 0:S.id),_e?o.jsx("p",{role:"alert",className:"code-error-text",children:_e}):null,ts?o.jsxs("button",{className:"code-primary-button",onClick:()=>B(!1),children:["Back to chat ",o.jsx(fe,{name:"chat",size:16})]}):o.jsxs("button",{className:"code-primary-button",disabled:Bn||ce||!!_e||!!Z||!n.connected,onClick:()=>Mn(()=>is(L||String(We[Vt||"prompt"]||""))),children:["Run workflow ",o.jsx(fe,{name:"playCircle",size:16})]})]})})]})}function sv({item:n,selected:r,onClick:i}){const a=n.prompt||`Conversation ${n.sessionId.slice(0,8)}`,c=n.updatedAt?new Date(n.updatedAt):null;return o.jsxs("button",{className:`code-session${r?" is-selected":""}`,"aria-current":r?"page":void 0,onClick:i,title:a,children:[o.jsx(fe,{name:"chat",size:15}),o.jsxs("span",{children:[o.jsx("strong",{children:a}),o.jsxs("small",{children:[c&&Number.isFinite(c.getTime())?c.toLocaleDateString(void 0,{month:"short",day:"numeric"}):"Saved conversation"," ",o.jsx("span",{"aria-hidden":"true",children:"·"})," ",n.turnCount," ",n.turnCount===1?"turn":"turns"]})]}),n.state==="running"||n.state==="waiting"?o.jsx("span",{className:`code-status-dot ${n.state==="running"?"is-working":"is-waiting"}`,title:n.state}):null]})}function iv({workflow:n,loading:r,onSuggestion:i,onInputs:a,isAgent:c,onRun:d,connected:f}){return o.jsxs("div",{className:"code-welcome",children:[o.jsxs("div",{className:"code-welcome-symbol","aria-hidden":"true",children:[o.jsx("span",{children:"›"}),o.jsx("span",{children:"_"})]}),o.jsx("p",{className:"code-eyebrow",children:"A LITTLE CONTEXT. A LOT OF POSSIBILITY."}),o.jsx("h1",{children:"What are we building?"}),o.jsxs("p",{className:"code-welcome-description",children:["A focused space to think, code, and get things done.",o.jsx("br",{}),"Your workflows. Your tools. One conversation."]}),n&&!c?o.jsxs("div",{className:"code-workflow-welcome",children:[o.jsx(fe,{name:"playCircle",size:21}),o.jsxs("div",{children:[o.jsx("strong",{children:n.name}),o.jsx("p",{children:n.description||"Run this workflow with its registered inputs."})]}),o.jsx("button",{onClick:a,children:"Configure inputs"}),o.jsx("button",{onClick:d,disabled:r||!f,children:"Run workflow"})]}):o.jsx("div",{className:"code-suggestions",children:[{icon:"terminal",title:"Explore this project",detail:"Find your bearings in the codebase",prompt:"Explore this project and explain its architecture, key entry points, and how to run its tests."},{icon:"edit",title:"Build something new",detail:"Turn an idea into working code",prompt:"I'd like to build a new feature. Help me clarify the requirements and plan the implementation."},{icon:"warning",title:"Track down a bug",detail:"Understand what went wrong",prompt:"Help me investigate a bug. Start by asking what happened and what I expected."},{icon:"check",title:"Review my changes",detail:"Get a second pair of eyes",prompt:"Review the current changes for correctness, edge cases, and maintainability. Explain any findings before making edits."}].map(m=>o.jsxs("button",{onClick:()=>i(m.prompt),disabled:r,children:[o.jsx(fe,{name:m.icon,size:18}),o.jsxs("span",{children:[o.jsx("strong",{children:m.title}),o.jsx("small",{children:m.detail})]}),o.jsx(fe,{name:"chevronRight",size:13})]},m.title))}),o.jsx("p",{className:"code-welcome-hint",children:r?"Discovering your workflows…":n?o.jsxs(o.Fragment,{children:["Using ",o.jsx("strong",{children:n.name})," · Change workflows above"]}):f?"Register a workflow with AbstractGateway to get started.":"Connect your gateway to get started."})]})}class ov extends _t.Component{constructor(){super(...arguments);xr(this,"state",{error:""})}static getDerivedStateFromError(i){return{error:i.message}}render(){return this.state.error?o.jsxs("div",{className:"code-crash",role:"alert",children:[o.jsx("h1",{children:"Something interrupted this view."}),o.jsx("p",{children:this.state.error}),o.jsx("p",{children:"Your runs are stored by the gateway."}),o.jsx("button",{onClick:()=>window.location.reload(),children:"Reload AbstractCode"})]}):this.props.children}}function Xo(){try{const n=window.visualViewport,r=typeof(n==null?void 0:n.height)=="number"&&Number.isFinite(n.height)?n.height:window.innerHeight;document.documentElement.style.setProperty("--vh",`${Math.max(1,r)*.01}px`)}catch{}}const wf="__abstractcode_web_vh_listener_v1";var _f,xf;globalThis[wf]||(globalThis[wf]=!0,Xo(),window.addEventListener("resize",Xo),(_f=window.visualViewport)==null||_f.addEventListener("resize",Xo),(xf=window.visualViewport)==null||xf.addEventListener("scroll",Xo));"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("sw.js").catch(()=>{})});Uh.createRoot(document.getElementById("root")).render(o.jsx(_t.StrictMode,{children:o.jsx(ov,{children:o.jsx(rv,{})})}));