@fieldwangai/agentflow 0.1.37 → 0.1.39

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,218 @@
1
+ var O2=Object.defineProperty;var M2=(e,t,n)=>t in e?O2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rn=(e,t,n)=>M2(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var kd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ta(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v1={exports:{}},km={},k1={exports:{}},At={};/**
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 cf=Symbol.for("react.element"),$2=Symbol.for("react.portal"),D2=Symbol.for("react.fragment"),F2=Symbol.for("react.strict_mode"),z2=Symbol.for("react.profiler"),B2=Symbol.for("react.provider"),H2=Symbol.for("react.context"),V2=Symbol.for("react.forward_ref"),W2=Symbol.for("react.suspense"),U2=Symbol.for("react.memo"),K2=Symbol.for("react.lazy"),f0=Symbol.iterator;function q2(e){return e===null||typeof e!="object"?null:(e=f0&&e[f0]||e["@@iterator"],typeof e=="function"?e:null)}var S1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N1=Object.assign,j1={};function Zc(e,t,n){this.props=e,this.context=t,this.refs=j1,this.updater=n||S1}Zc.prototype.isReactComponent={};Zc.prototype.setState=function(e,t){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,t,"setState")};Zc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function C1(){}C1.prototype=Zc.prototype;function Bw(e,t,n){this.props=e,this.context=t,this.refs=j1,this.updater=n||S1}var Hw=Bw.prototype=new C1;Hw.constructor=Bw;N1(Hw,Zc.prototype);Hw.isPureReactComponent=!0;var p0=Array.isArray,E1=Object.prototype.hasOwnProperty,Vw={current:null},_1={key:!0,ref:!0,__self:!0,__source:!0};function P1(e,t,n){var r,s={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)E1.call(t,r)&&!_1.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:cf,type:e,key:i,ref:a,props:s,_owner:Vw.current}}function Y2(e,t){return{$$typeof:cf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ww(e){return typeof e=="object"&&e!==null&&e.$$typeof===cf}function G2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var h0=/\/+/g;function _g(e,t){return typeof e=="object"&&e!==null&&e.key!=null?G2(""+e.key):t.toString(36)}function Kp(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case cf:case $2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+_g(a,0):r,p0(s)?(n="",e!=null&&(n=e.replace(h0,"$&/")+"/"),Kp(s,t,n,"",function(d){return d})):s!=null&&(Ww(s)&&(s=Y2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(h0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",p0(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+_g(i,l);a+=Kp(i,t,n,c,s)}else if(c=q2(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+_g(i,l++),a+=Kp(i,t,n,c,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function tp(e,t,n){if(e==null)return e;var r=[],s=0;return Kp(e,r,"","",function(i){return t.call(n,i,s++)}),r}function X2(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Ur={current:null},qp={transition:null},J2={ReactCurrentDispatcher:Ur,ReactCurrentBatchConfig:qp,ReactCurrentOwner:Vw};function A1(){throw Error("act(...) is not supported in production builds of React.")}At.Children={map:tp,forEach:function(e,t,n){tp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return tp(e,function(){t++}),t},toArray:function(e){return tp(e,function(t){return t})||[]},only:function(e){if(!Ww(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};At.Component=Zc;At.Fragment=D2;At.Profiler=z2;At.PureComponent=Bw;At.StrictMode=F2;At.Suspense=W2;At.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=J2;At.act=A1;At.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=N1({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Vw.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)E1.call(t,c)&&!_1.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:cf,type:e.type,key:s,ref:i,props:r,_owner:a}};At.createContext=function(e){return e={$$typeof:H2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:B2,_context:e},e.Consumer=e};At.createElement=P1;At.createFactory=function(e){var t=P1.bind(null,e);return t.type=e,t};At.createRef=function(){return{current:null}};At.forwardRef=function(e){return{$$typeof:V2,render:e}};At.isValidElement=Ww;At.lazy=function(e){return{$$typeof:K2,_payload:{_status:-1,_result:e},_init:X2}};At.memo=function(e,t){return{$$typeof:U2,type:e,compare:t===void 0?null:t}};At.startTransition=function(e){var t=qp.transition;qp.transition={};try{e()}finally{qp.transition=t}};At.unstable_act=A1;At.useCallback=function(e,t){return Ur.current.useCallback(e,t)};At.useContext=function(e){return Ur.current.useContext(e)};At.useDebugValue=function(){};At.useDeferredValue=function(e){return Ur.current.useDeferredValue(e)};At.useEffect=function(e,t){return Ur.current.useEffect(e,t)};At.useId=function(){return Ur.current.useId()};At.useImperativeHandle=function(e,t,n){return Ur.current.useImperativeHandle(e,t,n)};At.useInsertionEffect=function(e,t){return Ur.current.useInsertionEffect(e,t)};At.useLayoutEffect=function(e,t){return Ur.current.useLayoutEffect(e,t)};At.useMemo=function(e,t){return Ur.current.useMemo(e,t)};At.useReducer=function(e,t,n){return Ur.current.useReducer(e,t,n)};At.useRef=function(e){return Ur.current.useRef(e)};At.useState=function(e){return Ur.current.useState(e)};At.useSyncExternalStore=function(e,t,n){return Ur.current.useSyncExternalStore(e,t,n)};At.useTransition=function(){return Ur.current.useTransition()};At.version="18.3.1";k1.exports=At;var m=k1.exports;const et=Ta(m);/**
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 Q2=m,Z2=Symbol.for("react.element"),eR=Symbol.for("react.fragment"),tR=Object.prototype.hasOwnProperty,nR=Q2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rR={key:!0,ref:!0,__self:!0,__source:!0};function I1(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)tR.call(t,r)&&!rR.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:Z2,type:e,key:i,ref:a,props:s,_owner:nR.current}}km.Fragment=eR;km.jsx=I1;km.jsxs=I1;v1.exports=km;var o=v1.exports,Gy={},T1={exports:{}},_s={},R1={exports:{}},L1={};/**
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
+ */(function(e){function t(P,T){var E=P.length;P.push(T);e:for(;0<E;){var Y=E-1>>>1,Q=P[Y];if(0<s(Q,T))P[Y]=T,P[E]=Q,E=Y;else break e}}function n(P){return P.length===0?null:P[0]}function r(P){if(P.length===0)return null;var T=P[0],E=P.pop();if(E!==T){P[0]=E;e:for(var Y=0,Q=P.length,U=Q>>>1;Y<U;){var re=2*(Y+1)-1,ue=P[re],ge=re+1,le=P[ge];if(0>s(ue,E))ge<Q&&0>s(le,ue)?(P[Y]=le,P[ge]=E,Y=ge):(P[Y]=ue,P[re]=E,Y=re);else if(ge<Q&&0>s(le,E))P[Y]=le,P[ge]=E,Y=ge;else break e}}return T}function s(P,T){var E=P.sortIndex-T.sortIndex;return E!==0?E:P.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],u=1,f=null,p=3,h=!1,g=!1,v=!1,k=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(P){for(var T=n(d);T!==null;){if(T.callback===null)r(d);else if(T.startTime<=P)r(d),T.sortIndex=T.expirationTime,t(c,T);else break;T=n(d)}}function S(P){if(v=!1,w(P),!g)if(n(c)!==null)g=!0,A(C);else{var T=n(d);T!==null&&B(S,T.startTime-P)}}function C(P,T){g=!1,v&&(v=!1,y(M),M=-1),h=!0;var E=p;try{for(w(T),f=n(c);f!==null&&(!(f.expirationTime>T)||P&&!O());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,p=f.priorityLevel;var Q=Y(f.expirationTime<=T);T=e.unstable_now(),typeof Q=="function"?f.callback=Q:f===n(c)&&r(c),w(T)}else r(c);f=n(c)}if(f!==null)var U=!0;else{var re=n(d);re!==null&&B(S,re.startTime-T),U=!1}return U}finally{f=null,p=E,h=!1}}var N=!1,I=null,M=-1,R=5,F=-1;function O(){return!(e.unstable_now()-F<R)}function L(){if(I!==null){var P=e.unstable_now();F=P;var T=!0;try{T=I(!0,P)}finally{T?W():(N=!1,I=null)}}else N=!1}var W;if(typeof b=="function")W=function(){b(L)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,$=D.port2;D.port1.onmessage=L,W=function(){$.postMessage(null)}}else W=function(){k(L,0)};function A(P){I=P,N||(N=!0,W())}function B(P,T){M=k(function(){P(e.unstable_now())},T)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(P){P.callback=null},e.unstable_continueExecution=function(){g||h||(g=!0,A(C))},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(P){switch(p){case 1:case 2:case 3:var T=3;break;default:T=p}var E=p;p=T;try{return P()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(P,T){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var E=p;p=P;try{return T()}finally{p=E}},e.unstable_scheduleCallback=function(P,T,E){var Y=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Y+E:Y):E=Y,P){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=E+Q,P={id:u++,callback:T,priorityLevel:P,startTime:E,expirationTime:Q,sortIndex:-1},E>Y?(P.sortIndex=E,t(d,P),n(c)===null&&P===n(d)&&(v?(y(M),M=-1):v=!0,B(S,E-Y))):(P.sortIndex=Q,t(c,P),g||h||(g=!0,A(C))),P},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(P){var T=p;return function(){var E=p;p=T;try{return P.apply(this,arguments)}finally{p=E}}}})(L1);R1.exports=L1;var sR=R1.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 iR=m,Cs=sR;function je(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);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 O1=new Set,Sd={};function Cl(e,t){Tc(e,t),Tc(e+"Capture",t)}function Tc(e,t){for(Sd[e]=t,e=0;e<t.length;e++)O1.add(t[e])}var Po=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xy=Object.prototype.hasOwnProperty,oR=/^[: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]*$/,m0={},g0={};function aR(e){return Xy.call(g0,e)?!0:Xy.call(m0,e)?!1:oR.test(e)?g0[e]=!0:(m0[e]=!0,!1)}function lR(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function cR(e,t,n,r){if(t===null||typeof t>"u"||lR(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 Kr(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var Sr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Sr[e]=new Kr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Sr[t]=new Kr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Sr[e]=new Kr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Sr[e]=new Kr(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){Sr[e]=new Kr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Sr[e]=new Kr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Sr[e]=new Kr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Sr[e]=new Kr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Sr[e]=new Kr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Uw=/[\-:]([a-z])/g;function Kw(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(Uw,Kw);Sr[t]=new Kr(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(Uw,Kw);Sr[t]=new Kr(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(Uw,Kw);Sr[t]=new Kr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Sr[e]=new Kr(e,1,!1,e.toLowerCase(),null,!1,!1)});Sr.xlinkHref=new Kr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Sr[e]=new Kr(e,1,!1,e.toLowerCase(),null,!0,!0)});function qw(e,t,n,r){var s=Sr.hasOwnProperty(t)?Sr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(cR(t,n,s,r)&&(n=null),r||s===null?aR(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Mo=iR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,np=Symbol.for("react.element"),rc=Symbol.for("react.portal"),sc=Symbol.for("react.fragment"),Yw=Symbol.for("react.strict_mode"),Jy=Symbol.for("react.profiler"),M1=Symbol.for("react.provider"),$1=Symbol.for("react.context"),Gw=Symbol.for("react.forward_ref"),Qy=Symbol.for("react.suspense"),Zy=Symbol.for("react.suspense_list"),Xw=Symbol.for("react.memo"),ra=Symbol.for("react.lazy"),D1=Symbol.for("react.offscreen"),y0=Symbol.iterator;function Eu(e){return e===null||typeof e!="object"?null:(e=y0&&e[y0]||e["@@iterator"],typeof e=="function"?e:null)}var In=Object.assign,Pg;function Ku(e){if(Pg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Pg=t&&t[1]||""}return`
34
+ `+Pg+e}var Ag=!1;function Ig(e,t){if(!e||Ag)return"";Ag=!0;var n=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(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),a=s.length-1,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[l]){var c=`
37
+ `+s[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{Ag=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ku(e):""}function uR(e){switch(e.tag){case 5:return Ku(e.type);case 16:return Ku("Lazy");case 13:return Ku("Suspense");case 19:return Ku("SuspenseList");case 0:case 2:case 15:return e=Ig(e.type,!1),e;case 11:return e=Ig(e.type.render,!1),e;case 1:return e=Ig(e.type,!0),e;default:return""}}function ex(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 sc:return"Fragment";case rc:return"Portal";case Jy:return"Profiler";case Yw:return"StrictMode";case Qy:return"Suspense";case Zy:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case $1:return(e.displayName||"Context")+".Consumer";case M1:return(e._context.displayName||"Context")+".Provider";case Gw:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xw:return t=e.displayName||null,t!==null?t:ex(e.type)||"Memo";case ra:t=e._payload,e=e._init;try{return ex(e(t))}catch{}}return null}function dR(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 ex(t);case 8:return t===Yw?"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 ja(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function F1(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function fR(e){var t=F1(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rp(e){e._valueTracker||(e._valueTracker=fR(e))}function z1(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=F1(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function gh(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 tx(e,t){var n=t.checked;return In({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function x0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ja(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function B1(e,t){t=t.checked,t!=null&&qw(e,"checked",t,!1)}function nx(e,t){B1(e,t);var n=ja(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?rx(e,t.type,n):t.hasOwnProperty("defaultValue")&&rx(e,t.type,ja(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function w0(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function rx(e,t,n){(t!=="number"||gh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var qu=Array.isArray;function vc(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ja(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function sx(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(je(91));return In({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function b0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(je(92));if(qu(n)){if(1<n.length)throw Error(je(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ja(n)}}function H1(e,t){var n=ja(t.value),r=ja(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function v0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function V1(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 ix(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?V1(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var sp,W1=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(sp=sp||document.createElement("div"),sp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=sp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Nd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var rd={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},pR=["Webkit","ms","Moz","O"];Object.keys(rd).forEach(function(e){pR.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),rd[t]=rd[e]})});function U1(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||rd.hasOwnProperty(e)&&rd[e]?(""+t).trim():t+"px"}function K1(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=U1(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var hR=In({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 ox(e,t){if(t){if(hR[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(je(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(je(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(je(61))}if(t.style!=null&&typeof t.style!="object")throw Error(je(62))}}function ax(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 lx=null;function Jw(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var cx=null,kc=null,Sc=null;function k0(e){if(e=ff(e)){if(typeof cx!="function")throw Error(je(280));var t=e.stateNode;t&&(t=Em(t),cx(e.stateNode,e.type,t))}}function q1(e){kc?Sc?Sc.push(e):Sc=[e]:kc=e}function Y1(){if(kc){var e=kc,t=Sc;if(Sc=kc=null,k0(e),t)for(e=0;e<t.length;e++)k0(t[e])}}function G1(e,t){return e(t)}function X1(){}var Tg=!1;function J1(e,t,n){if(Tg)return e(t,n);Tg=!0;try{return G1(e,t,n)}finally{Tg=!1,(kc!==null||Sc!==null)&&(X1(),Y1())}}function jd(e,t){var n=e.stateNode;if(n===null)return null;var r=Em(n);if(r===null)return null;n=r[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":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(je(231,t,typeof n));return n}var ux=!1;if(Po)try{var _u={};Object.defineProperty(_u,"passive",{get:function(){ux=!0}}),window.addEventListener("test",_u,_u),window.removeEventListener("test",_u,_u)}catch{ux=!1}function mR(e,t,n,r,s,i,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(u){this.onError(u)}}var sd=!1,yh=null,xh=!1,dx=null,gR={onError:function(e){sd=!0,yh=e}};function yR(e,t,n,r,s,i,a,l,c){sd=!1,yh=null,mR.apply(gR,arguments)}function xR(e,t,n,r,s,i,a,l,c){if(yR.apply(this,arguments),sd){if(sd){var d=yh;sd=!1,yh=null}else throw Error(je(198));xh||(xh=!0,dx=d)}}function El(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Q1(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 S0(e){if(El(e)!==e)throw Error(je(188))}function wR(e){var t=e.alternate;if(!t){if(t=El(e),t===null)throw Error(je(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return S0(s),e;if(i===r)return S0(s),t;i=i.sibling}throw Error(je(188))}if(n.return!==r.return)n=s,r=i;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a)throw Error(je(189))}}if(n.alternate!==r)throw Error(je(190))}if(n.tag!==3)throw Error(je(188));return n.stateNode.current===n?e:t}function Z1(e){return e=wR(e),e!==null?eC(e):null}function eC(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=eC(e);if(t!==null)return t;e=e.sibling}return null}var tC=Cs.unstable_scheduleCallback,N0=Cs.unstable_cancelCallback,bR=Cs.unstable_shouldYield,vR=Cs.unstable_requestPaint,zn=Cs.unstable_now,kR=Cs.unstable_getCurrentPriorityLevel,Qw=Cs.unstable_ImmediatePriority,nC=Cs.unstable_UserBlockingPriority,wh=Cs.unstable_NormalPriority,SR=Cs.unstable_LowPriority,rC=Cs.unstable_IdlePriority,Sm=null,Yi=null;function NR(e){if(Yi&&typeof Yi.onCommitFiberRoot=="function")try{Yi.onCommitFiberRoot(Sm,e,void 0,(e.current.flags&128)===128)}catch{}}var yi=Math.clz32?Math.clz32:ER,jR=Math.log,CR=Math.LN2;function ER(e){return e>>>=0,e===0?32:31-(jR(e)/CR|0)|0}var ip=64,op=4194304;function Yu(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 bh(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=Yu(l):(i&=a,i!==0&&(r=Yu(i)))}else a=n&~s,a!==0?r=Yu(a):i!==0&&(r=Yu(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-yi(t),s=1<<n,r|=e[n],t&=~s;return r}function _R(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 PR(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-yi(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=_R(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function fx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function sC(){var e=ip;return ip<<=1,!(ip&4194240)&&(ip=64),e}function Rg(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function uf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yi(t),e[t]=n}function AR(e,t){var n=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 r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-yi(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Zw(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-yi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var Zt=0;function iC(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var oC,eb,aC,lC,cC,px=!1,ap=[],pa=null,ha=null,ma=null,Cd=new Map,Ed=new Map,oa=[],IR="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 j0(e,t){switch(e){case"focusin":case"focusout":pa=null;break;case"dragenter":case"dragleave":ha=null;break;case"mouseover":case"mouseout":ma=null;break;case"pointerover":case"pointerout":Cd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ed.delete(t.pointerId)}}function Pu(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=ff(t),t!==null&&eb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function TR(e,t,n,r,s){switch(t){case"focusin":return pa=Pu(pa,e,t,n,r,s),!0;case"dragenter":return ha=Pu(ha,e,t,n,r,s),!0;case"mouseover":return ma=Pu(ma,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return Cd.set(i,Pu(Cd.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Ed.set(i,Pu(Ed.get(i)||null,e,t,n,r,s)),!0}return!1}function uC(e){var t=il(e.target);if(t!==null){var n=El(t);if(n!==null){if(t=n.tag,t===13){if(t=Q1(n),t!==null){e.blockedOn=t,cC(e.priority,function(){aC(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Yp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=hx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);lx=r,n.target.dispatchEvent(r),lx=null}else return t=ff(n),t!==null&&eb(t),e.blockedOn=n,!1;t.shift()}return!0}function C0(e,t,n){Yp(e)&&n.delete(t)}function RR(){px=!1,pa!==null&&Yp(pa)&&(pa=null),ha!==null&&Yp(ha)&&(ha=null),ma!==null&&Yp(ma)&&(ma=null),Cd.forEach(C0),Ed.forEach(C0)}function Au(e,t){e.blockedOn===t&&(e.blockedOn=null,px||(px=!0,Cs.unstable_scheduleCallback(Cs.unstable_NormalPriority,RR)))}function _d(e){function t(s){return Au(s,e)}if(0<ap.length){Au(ap[0],e);for(var n=1;n<ap.length;n++){var r=ap[n];r.blockedOn===e&&(r.blockedOn=null)}}for(pa!==null&&Au(pa,e),ha!==null&&Au(ha,e),ma!==null&&Au(ma,e),Cd.forEach(t),Ed.forEach(t),n=0;n<oa.length;n++)r=oa[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<oa.length&&(n=oa[0],n.blockedOn===null);)uC(n),n.blockedOn===null&&oa.shift()}var Nc=Mo.ReactCurrentBatchConfig,vh=!0;function LR(e,t,n,r){var s=Zt,i=Nc.transition;Nc.transition=null;try{Zt=1,tb(e,t,n,r)}finally{Zt=s,Nc.transition=i}}function OR(e,t,n,r){var s=Zt,i=Nc.transition;Nc.transition=null;try{Zt=4,tb(e,t,n,r)}finally{Zt=s,Nc.transition=i}}function tb(e,t,n,r){if(vh){var s=hx(e,t,n,r);if(s===null)Vg(e,t,r,kh,n),j0(e,r);else if(TR(s,e,t,n,r))r.stopPropagation();else if(j0(e,r),t&4&&-1<IR.indexOf(e)){for(;s!==null;){var i=ff(s);if(i!==null&&oC(i),i=hx(e,t,n,r),i===null&&Vg(e,t,r,kh,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Vg(e,t,r,null,n)}}var kh=null;function hx(e,t,n,r){if(kh=null,e=Jw(r),e=il(e),e!==null)if(t=El(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Q1(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return kh=e,null}function dC(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(kR()){case Qw:return 1;case nC:return 4;case wh:case SR:return 16;case rC:return 536870912;default:return 16}default:return 16}}var ca=null,nb=null,Gp=null;function fC(){if(Gp)return Gp;var e,t=nb,n=t.length,r,s="value"in ca?ca.value:ca.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===s[i-r];r++);return Gp=s.slice(e,1<r?1-r:void 0)}function Xp(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 lp(){return!0}function E0(){return!1}function Ps(e){function t(n,r,s,i,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?lp:E0,this.isPropagationStopped=E0,this}return In(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=lp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=lp)},persist:function(){},isPersistent:lp}),t}var eu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rb=Ps(eu),df=In({},eu,{view:0,detail:0}),MR=Ps(df),Lg,Og,Iu,Nm=In({},df,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sb,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!==Iu&&(Iu&&e.type==="mousemove"?(Lg=e.screenX-Iu.screenX,Og=e.screenY-Iu.screenY):Og=Lg=0,Iu=e),Lg)},movementY:function(e){return"movementY"in e?e.movementY:Og}}),_0=Ps(Nm),$R=In({},Nm,{dataTransfer:0}),DR=Ps($R),FR=In({},df,{relatedTarget:0}),Mg=Ps(FR),zR=In({},eu,{animationName:0,elapsedTime:0,pseudoElement:0}),BR=Ps(zR),HR=In({},eu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),VR=Ps(HR),WR=In({},eu,{data:0}),P0=Ps(WR),UR={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},KR={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"},qR={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function YR(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=qR[e])?!!t[e]:!1}function sb(){return YR}var GR=In({},df,{key:function(e){if(e.key){var t=UR[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Xp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?KR[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sb,charCode:function(e){return e.type==="keypress"?Xp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Xp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),XR=Ps(GR),JR=In({},Nm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),A0=Ps(JR),QR=In({},df,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sb}),ZR=Ps(QR),eL=In({},eu,{propertyName:0,elapsedTime:0,pseudoElement:0}),tL=Ps(eL),nL=In({},Nm,{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}),rL=Ps(nL),sL=[9,13,27,32],ib=Po&&"CompositionEvent"in window,id=null;Po&&"documentMode"in document&&(id=document.documentMode);var iL=Po&&"TextEvent"in window&&!id,pC=Po&&(!ib||id&&8<id&&11>=id),I0=" ",T0=!1;function hC(e,t){switch(e){case"keyup":return sL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mC(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ic=!1;function oL(e,t){switch(e){case"compositionend":return mC(t);case"keypress":return t.which!==32?null:(T0=!0,I0);case"textInput":return e=t.data,e===I0&&T0?null:e;default:return null}}function aL(e,t){if(ic)return e==="compositionend"||!ib&&hC(e,t)?(e=fC(),Gp=nb=ca=null,ic=!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 pC&&t.locale!=="ko"?null:t.data;default:return null}}var lL={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 R0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!lL[e.type]:t==="textarea"}function gC(e,t,n,r){q1(r),t=Sh(t,"onChange"),0<t.length&&(n=new rb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var od=null,Pd=null;function cL(e){EC(e,0)}function jm(e){var t=lc(e);if(z1(t))return e}function uL(e,t){if(e==="change")return t}var yC=!1;if(Po){var $g;if(Po){var Dg="oninput"in document;if(!Dg){var L0=document.createElement("div");L0.setAttribute("oninput","return;"),Dg=typeof L0.oninput=="function"}$g=Dg}else $g=!1;yC=$g&&(!document.documentMode||9<document.documentMode)}function O0(){od&&(od.detachEvent("onpropertychange",xC),Pd=od=null)}function xC(e){if(e.propertyName==="value"&&jm(Pd)){var t=[];gC(t,Pd,e,Jw(e)),J1(cL,t)}}function dL(e,t,n){e==="focusin"?(O0(),od=t,Pd=n,od.attachEvent("onpropertychange",xC)):e==="focusout"&&O0()}function fL(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return jm(Pd)}function pL(e,t){if(e==="click")return jm(t)}function hL(e,t){if(e==="input"||e==="change")return jm(t)}function mL(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var wi=typeof Object.is=="function"?Object.is:mL;function Ad(e,t){if(wi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Xy.call(t,s)||!wi(e[s],t[s]))return!1}return!0}function M0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function $0(e,t){var n=M0(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=M0(n)}}function wC(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wC(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function bC(){for(var e=window,t=gh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=gh(e.document)}return t}function ob(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 gL(e){var t=bC(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wC(n.ownerDocument.documentElement,n)){if(r!==null&&ob(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=$0(n,i);var a=$0(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var yL=Po&&"documentMode"in document&&11>=document.documentMode,oc=null,mx=null,ad=null,gx=!1;function D0(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;gx||oc==null||oc!==gh(r)||(r=oc,"selectionStart"in r&&ob(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ad&&Ad(ad,r)||(ad=r,r=Sh(mx,"onSelect"),0<r.length&&(t=new rb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=oc)))}function cp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ac={animationend:cp("Animation","AnimationEnd"),animationiteration:cp("Animation","AnimationIteration"),animationstart:cp("Animation","AnimationStart"),transitionend:cp("Transition","TransitionEnd")},Fg={},vC={};Po&&(vC=document.createElement("div").style,"AnimationEvent"in window||(delete ac.animationend.animation,delete ac.animationiteration.animation,delete ac.animationstart.animation),"TransitionEvent"in window||delete ac.transitionend.transition);function Cm(e){if(Fg[e])return Fg[e];if(!ac[e])return e;var t=ac[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in vC)return Fg[e]=t[n];return e}var kC=Cm("animationend"),SC=Cm("animationiteration"),NC=Cm("animationstart"),jC=Cm("transitionend"),CC=new Map,F0="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 Ra(e,t){CC.set(e,t),Cl(t,[e])}for(var zg=0;zg<F0.length;zg++){var Bg=F0[zg],xL=Bg.toLowerCase(),wL=Bg[0].toUpperCase()+Bg.slice(1);Ra(xL,"on"+wL)}Ra(kC,"onAnimationEnd");Ra(SC,"onAnimationIteration");Ra(NC,"onAnimationStart");Ra("dblclick","onDoubleClick");Ra("focusin","onFocus");Ra("focusout","onBlur");Ra(jC,"onTransitionEnd");Tc("onMouseEnter",["mouseout","mouseover"]);Tc("onMouseLeave",["mouseout","mouseover"]);Tc("onPointerEnter",["pointerout","pointerover"]);Tc("onPointerLeave",["pointerout","pointerover"]);Cl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Cl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Cl("onBeforeInput",["compositionend","keypress","textInput","paste"]);Cl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Cl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Cl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gu="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(" "),bL=new Set("cancel close invalid load scroll toggle".split(" ").concat(Gu));function z0(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,xR(r,t,void 0,e),e.currentTarget=null}function EC(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;z0(s,l,d),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;z0(s,l,d),i=c}}}if(xh)throw e=dx,xh=!1,dx=null,e}function wn(e,t){var n=t[vx];n===void 0&&(n=t[vx]=new Set);var r=e+"__bubble";n.has(r)||(_C(t,e,2,!1),n.add(r))}function Hg(e,t,n){var r=0;t&&(r|=4),_C(n,e,r,t)}var up="_reactListening"+Math.random().toString(36).slice(2);function Id(e){if(!e[up]){e[up]=!0,O1.forEach(function(n){n!=="selectionchange"&&(bL.has(n)||Hg(n,!1,e),Hg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[up]||(t[up]=!0,Hg("selectionchange",!1,t))}}function _C(e,t,n,r){switch(dC(t)){case 1:var s=LR;break;case 4:s=OR;break;default:s=tb}n=s.bind(null,t,n,e),s=void 0,!ux||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function Vg(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;a=a.return}for(;l!==null;){if(a=il(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}J1(function(){var d=i,u=Jw(n),f=[];e:{var p=CC.get(e);if(p!==void 0){var h=rb,g=e;switch(e){case"keypress":if(Xp(n)===0)break e;case"keydown":case"keyup":h=XR;break;case"focusin":g="focus",h=Mg;break;case"focusout":g="blur",h=Mg;break;case"beforeblur":case"afterblur":h=Mg;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=_0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=DR;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=ZR;break;case kC:case SC:case NC:h=BR;break;case jC:h=tL;break;case"scroll":h=MR;break;case"wheel":h=rL;break;case"copy":case"cut":case"paste":h=VR;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=A0}var v=(t&4)!==0,k=!v&&e==="scroll",y=v?p!==null?p+"Capture":null:p;v=[];for(var b=d,w;b!==null;){w=b;var S=w.stateNode;if(w.tag===5&&S!==null&&(w=S,y!==null&&(S=jd(b,y),S!=null&&v.push(Td(b,S,w)))),k)break;b=b.return}0<v.length&&(p=new h(p,g,null,n,u),f.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==lx&&(g=n.relatedTarget||n.fromElement)&&(il(g)||g[Ao]))break e;if((h||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=d,g=g?il(g):null,g!==null&&(k=El(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=d),h!==g)){if(v=_0,S="onMouseLeave",y="onMouseEnter",b="mouse",(e==="pointerout"||e==="pointerover")&&(v=A0,S="onPointerLeave",y="onPointerEnter",b="pointer"),k=h==null?p:lc(h),w=g==null?p:lc(g),p=new v(S,b+"leave",h,n,u),p.target=k,p.relatedTarget=w,S=null,il(u)===d&&(v=new v(y,b+"enter",g,n,u),v.target=w,v.relatedTarget=k,S=v),k=S,h&&g)t:{for(v=h,y=g,b=0,w=v;w;w=ql(w))b++;for(w=0,S=y;S;S=ql(S))w++;for(;0<b-w;)v=ql(v),b--;for(;0<w-b;)y=ql(y),w--;for(;b--;){if(v===y||y!==null&&v===y.alternate)break t;v=ql(v),y=ql(y)}v=null}else v=null;h!==null&&B0(f,p,h,v,!1),g!==null&&k!==null&&B0(f,k,g,v,!0)}}e:{if(p=d?lc(d):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var C=uL;else if(R0(p))if(yC)C=hL;else{C=fL;var N=dL}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(C=pL);if(C&&(C=C(e,d))){gC(f,C,n,u);break e}N&&N(e,p,d),e==="focusout"&&(N=p._wrapperState)&&N.controlled&&p.type==="number"&&rx(p,"number",p.value)}switch(N=d?lc(d):window,e){case"focusin":(R0(N)||N.contentEditable==="true")&&(oc=N,mx=d,ad=null);break;case"focusout":ad=mx=oc=null;break;case"mousedown":gx=!0;break;case"contextmenu":case"mouseup":case"dragend":gx=!1,D0(f,n,u);break;case"selectionchange":if(yL)break;case"keydown":case"keyup":D0(f,n,u)}var I;if(ib)e:{switch(e){case"compositionstart":var M="onCompositionStart";break e;case"compositionend":M="onCompositionEnd";break e;case"compositionupdate":M="onCompositionUpdate";break e}M=void 0}else ic?hC(e,n)&&(M="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(M="onCompositionStart");M&&(pC&&n.locale!=="ko"&&(ic||M!=="onCompositionStart"?M==="onCompositionEnd"&&ic&&(I=fC()):(ca=u,nb="value"in ca?ca.value:ca.textContent,ic=!0)),N=Sh(d,M),0<N.length&&(M=new P0(M,e,null,n,u),f.push({event:M,listeners:N}),I?M.data=I:(I=mC(n),I!==null&&(M.data=I)))),(I=iL?oL(e,n):aL(e,n))&&(d=Sh(d,"onBeforeInput"),0<d.length&&(u=new P0("onBeforeInput","beforeinput",null,n,u),f.push({event:u,listeners:d}),u.data=I))}EC(f,t)})}function Td(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Sh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=jd(e,n),i!=null&&r.unshift(Td(e,i,s)),i=jd(e,t),i!=null&&r.push(Td(e,i,s))),e=e.return}return r}function ql(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function B0(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=jd(n,i),c!=null&&a.unshift(Td(n,c,l))):s||(c=jd(n,i),c!=null&&a.push(Td(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var vL=/\r\n?/g,kL=/\u0000|\uFFFD/g;function H0(e){return(typeof e=="string"?e:""+e).replace(vL,`
38
+ `).replace(kL,"")}function dp(e,t,n){if(t=H0(t),H0(e)!==t&&n)throw Error(je(425))}function Nh(){}var yx=null,xx=null;function wx(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 bx=typeof setTimeout=="function"?setTimeout:void 0,SL=typeof clearTimeout=="function"?clearTimeout:void 0,V0=typeof Promise=="function"?Promise:void 0,NL=typeof queueMicrotask=="function"?queueMicrotask:typeof V0<"u"?function(e){return V0.resolve(null).then(e).catch(jL)}:bx;function jL(e){setTimeout(function(){throw e})}function Wg(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),_d(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);_d(t)}function ga(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 W0(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var tu=Math.random().toString(36).slice(2),Wi="__reactFiber$"+tu,Rd="__reactProps$"+tu,Ao="__reactContainer$"+tu,vx="__reactEvents$"+tu,CL="__reactListeners$"+tu,EL="__reactHandles$"+tu;function il(e){var t=e[Wi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ao]||n[Wi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=W0(e);e!==null;){if(n=e[Wi])return n;e=W0(e)}return t}e=n,n=e.parentNode}return null}function ff(e){return e=e[Wi]||e[Ao],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function lc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(je(33))}function Em(e){return e[Rd]||null}var kx=[],cc=-1;function La(e){return{current:e}}function vn(e){0>cc||(e.current=kx[cc],kx[cc]=null,cc--)}function dn(e,t){cc++,kx[cc]=e.current,e.current=t}var Ca={},Or=La(Ca),as=La(!1),ml=Ca;function Rc(e,t){var n=e.type.contextTypes;if(!n)return Ca;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ls(e){return e=e.childContextTypes,e!=null}function jh(){vn(as),vn(Or)}function U0(e,t,n){if(Or.current!==Ca)throw Error(je(168));dn(Or,t),dn(as,n)}function PC(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(je(108,dR(e)||"Unknown",s));return In({},n,r)}function Ch(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ca,ml=Or.current,dn(Or,e),dn(as,as.current),!0}function K0(e,t,n){var r=e.stateNode;if(!r)throw Error(je(169));n?(e=PC(e,t,ml),r.__reactInternalMemoizedMergedChildContext=e,vn(as),vn(Or),dn(Or,e)):vn(as),dn(as,n)}var bo=null,_m=!1,Ug=!1;function AC(e){bo===null?bo=[e]:bo.push(e)}function _L(e){_m=!0,AC(e)}function Oa(){if(!Ug&&bo!==null){Ug=!0;var e=0,t=Zt;try{var n=bo;for(Zt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}bo=null,_m=!1}catch(s){throw bo!==null&&(bo=bo.slice(e+1)),tC(Qw,Oa),s}finally{Zt=t,Ug=!1}}return null}var uc=[],dc=0,Eh=null,_h=0,Ws=[],Us=0,gl=null,So=1,No="";function tl(e,t){uc[dc++]=_h,uc[dc++]=Eh,Eh=e,_h=t}function IC(e,t,n){Ws[Us++]=So,Ws[Us++]=No,Ws[Us++]=gl,gl=e;var r=So;e=No;var s=32-yi(r)-1;r&=~(1<<s),n+=1;var i=32-yi(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,So=1<<32-yi(t)+s|n<<s|r,No=i+e}else So=1<<i|n<<s|r,No=e}function ab(e){e.return!==null&&(tl(e,1),IC(e,1,0))}function lb(e){for(;e===Eh;)Eh=uc[--dc],uc[dc]=null,_h=uc[--dc],uc[dc]=null;for(;e===gl;)gl=Ws[--Us],Ws[Us]=null,No=Ws[--Us],Ws[Us]=null,So=Ws[--Us],Ws[Us]=null}var Ns=null,ks=null,jn=!1,fi=null;function TC(e,t){var n=Ys(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function q0(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Ns=e,ks=ga(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Ns=e,ks=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=gl!==null?{id:So,overflow:No}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ys(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Ns=e,ks=null,!0):!1;default:return!1}}function Sx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Nx(e){if(jn){var t=ks;if(t){var n=t;if(!q0(e,t)){if(Sx(e))throw Error(je(418));t=ga(n.nextSibling);var r=Ns;t&&q0(e,t)?TC(r,n):(e.flags=e.flags&-4097|2,jn=!1,Ns=e)}}else{if(Sx(e))throw Error(je(418));e.flags=e.flags&-4097|2,jn=!1,Ns=e}}}function Y0(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ns=e}function fp(e){if(e!==Ns)return!1;if(!jn)return Y0(e),jn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!wx(e.type,e.memoizedProps)),t&&(t=ks)){if(Sx(e))throw RC(),Error(je(418));for(;t;)TC(e,t),t=ga(t.nextSibling)}if(Y0(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(je(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ks=ga(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ks=null}}else ks=Ns?ga(e.stateNode.nextSibling):null;return!0}function RC(){for(var e=ks;e;)e=ga(e.nextSibling)}function Lc(){ks=Ns=null,jn=!1}function cb(e){fi===null?fi=[e]:fi.push(e)}var PL=Mo.ReactCurrentBatchConfig;function Tu(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(je(309));var r=n.stateNode}if(!r)throw Error(je(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var l=s.refs;a===null?delete l[i]:l[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(je(284));if(!n._owner)throw Error(je(290,e))}return e}function pp(e,t){throw e=Object.prototype.toString.call(t),Error(je(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function G0(e){var t=e._init;return t(e._payload)}function LC(e){function t(y,b){if(e){var w=y.deletions;w===null?(y.deletions=[b],y.flags|=16):w.push(b)}}function n(y,b){if(!e)return null;for(;b!==null;)t(y,b),b=b.sibling;return null}function r(y,b){for(y=new Map;b!==null;)b.key!==null?y.set(b.key,b):y.set(b.index,b),b=b.sibling;return y}function s(y,b){return y=ba(y,b),y.index=0,y.sibling=null,y}function i(y,b,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<b?(y.flags|=2,b):w):(y.flags|=2,b)):(y.flags|=1048576,b)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,b,w,S){return b===null||b.tag!==6?(b=Qg(w,y.mode,S),b.return=y,b):(b=s(b,w),b.return=y,b)}function c(y,b,w,S){var C=w.type;return C===sc?u(y,b,w.props.children,S,w.key):b!==null&&(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===ra&&G0(C)===b.type)?(S=s(b,w.props),S.ref=Tu(y,b,w),S.return=y,S):(S=rh(w.type,w.key,w.props,null,y.mode,S),S.ref=Tu(y,b,w),S.return=y,S)}function d(y,b,w,S){return b===null||b.tag!==4||b.stateNode.containerInfo!==w.containerInfo||b.stateNode.implementation!==w.implementation?(b=Zg(w,y.mode,S),b.return=y,b):(b=s(b,w.children||[]),b.return=y,b)}function u(y,b,w,S,C){return b===null||b.tag!==7?(b=ul(w,y.mode,S,C),b.return=y,b):(b=s(b,w),b.return=y,b)}function f(y,b,w){if(typeof b=="string"&&b!==""||typeof b=="number")return b=Qg(""+b,y.mode,w),b.return=y,b;if(typeof b=="object"&&b!==null){switch(b.$$typeof){case np:return w=rh(b.type,b.key,b.props,null,y.mode,w),w.ref=Tu(y,null,b),w.return=y,w;case rc:return b=Zg(b,y.mode,w),b.return=y,b;case ra:var S=b._init;return f(y,S(b._payload),w)}if(qu(b)||Eu(b))return b=ul(b,y.mode,w,null),b.return=y,b;pp(y,b)}return null}function p(y,b,w,S){var C=b!==null?b.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return C!==null?null:l(y,b,""+w,S);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case np:return w.key===C?c(y,b,w,S):null;case rc:return w.key===C?d(y,b,w,S):null;case ra:return C=w._init,p(y,b,C(w._payload),S)}if(qu(w)||Eu(w))return C!==null?null:u(y,b,w,S,null);pp(y,w)}return null}function h(y,b,w,S,C){if(typeof S=="string"&&S!==""||typeof S=="number")return y=y.get(w)||null,l(b,y,""+S,C);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case np:return y=y.get(S.key===null?w:S.key)||null,c(b,y,S,C);case rc:return y=y.get(S.key===null?w:S.key)||null,d(b,y,S,C);case ra:var N=S._init;return h(y,b,w,N(S._payload),C)}if(qu(S)||Eu(S))return y=y.get(w)||null,u(b,y,S,C,null);pp(b,S)}return null}function g(y,b,w,S){for(var C=null,N=null,I=b,M=b=0,R=null;I!==null&&M<w.length;M++){I.index>M?(R=I,I=null):R=I.sibling;var F=p(y,I,w[M],S);if(F===null){I===null&&(I=R);break}e&&I&&F.alternate===null&&t(y,I),b=i(F,b,M),N===null?C=F:N.sibling=F,N=F,I=R}if(M===w.length)return n(y,I),jn&&tl(y,M),C;if(I===null){for(;M<w.length;M++)I=f(y,w[M],S),I!==null&&(b=i(I,b,M),N===null?C=I:N.sibling=I,N=I);return jn&&tl(y,M),C}for(I=r(y,I);M<w.length;M++)R=h(I,y,M,w[M],S),R!==null&&(e&&R.alternate!==null&&I.delete(R.key===null?M:R.key),b=i(R,b,M),N===null?C=R:N.sibling=R,N=R);return e&&I.forEach(function(O){return t(y,O)}),jn&&tl(y,M),C}function v(y,b,w,S){var C=Eu(w);if(typeof C!="function")throw Error(je(150));if(w=C.call(w),w==null)throw Error(je(151));for(var N=C=null,I=b,M=b=0,R=null,F=w.next();I!==null&&!F.done;M++,F=w.next()){I.index>M?(R=I,I=null):R=I.sibling;var O=p(y,I,F.value,S);if(O===null){I===null&&(I=R);break}e&&I&&O.alternate===null&&t(y,I),b=i(O,b,M),N===null?C=O:N.sibling=O,N=O,I=R}if(F.done)return n(y,I),jn&&tl(y,M),C;if(I===null){for(;!F.done;M++,F=w.next())F=f(y,F.value,S),F!==null&&(b=i(F,b,M),N===null?C=F:N.sibling=F,N=F);return jn&&tl(y,M),C}for(I=r(y,I);!F.done;M++,F=w.next())F=h(I,y,M,F.value,S),F!==null&&(e&&F.alternate!==null&&I.delete(F.key===null?M:F.key),b=i(F,b,M),N===null?C=F:N.sibling=F,N=F);return e&&I.forEach(function(L){return t(y,L)}),jn&&tl(y,M),C}function k(y,b,w,S){if(typeof w=="object"&&w!==null&&w.type===sc&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case np:e:{for(var C=w.key,N=b;N!==null;){if(N.key===C){if(C=w.type,C===sc){if(N.tag===7){n(y,N.sibling),b=s(N,w.props.children),b.return=y,y=b;break e}}else if(N.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===ra&&G0(C)===N.type){n(y,N.sibling),b=s(N,w.props),b.ref=Tu(y,N,w),b.return=y,y=b;break e}n(y,N);break}else t(y,N);N=N.sibling}w.type===sc?(b=ul(w.props.children,y.mode,S,w.key),b.return=y,y=b):(S=rh(w.type,w.key,w.props,null,y.mode,S),S.ref=Tu(y,b,w),S.return=y,y=S)}return a(y);case rc:e:{for(N=w.key;b!==null;){if(b.key===N)if(b.tag===4&&b.stateNode.containerInfo===w.containerInfo&&b.stateNode.implementation===w.implementation){n(y,b.sibling),b=s(b,w.children||[]),b.return=y,y=b;break e}else{n(y,b);break}else t(y,b);b=b.sibling}b=Zg(w,y.mode,S),b.return=y,y=b}return a(y);case ra:return N=w._init,k(y,b,N(w._payload),S)}if(qu(w))return g(y,b,w,S);if(Eu(w))return v(y,b,w,S);pp(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,b!==null&&b.tag===6?(n(y,b.sibling),b=s(b,w),b.return=y,y=b):(n(y,b),b=Qg(w,y.mode,S),b.return=y,y=b),a(y)):n(y,b)}return k}var Oc=LC(!0),OC=LC(!1),Ph=La(null),Ah=null,fc=null,ub=null;function db(){ub=fc=Ah=null}function fb(e){var t=Ph.current;vn(Ph),e._currentValue=t}function jx(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function jc(e,t){Ah=e,ub=fc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ns=!0),e.firstContext=null)}function Xs(e){var t=e._currentValue;if(ub!==e)if(e={context:e,memoizedValue:t,next:null},fc===null){if(Ah===null)throw Error(je(308));fc=e,Ah.dependencies={lanes:0,firstContext:e}}else fc=fc.next=e;return t}var ol=null;function pb(e){ol===null?ol=[e]:ol.push(e)}function MC(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,pb(t)):(n.next=s.next,s.next=n),t.interleaved=n,Io(e,r)}function Io(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var sa=!1;function hb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function $C(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 _o(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ya(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,zt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Io(e,n)}return s=r.interleaved,s===null?(t.next=t,pb(r)):(t.next=s.next,s.next=t),r.interleaved=t,Io(e,n)}function Jp(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zw(e,n)}}function X0(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Ih(e,t,n,r){var s=e.updateQueue;sa=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?i=d:a.next=d,a=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==a&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;a=0,u=d=c=null,l=i;do{var p=l.lane,h=l.eventTime;if((r&p)===p){u!==null&&(u=u.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,v=l;switch(p=t,h=n,v.tag){case 1:if(g=v.payload,typeof g=="function"){f=g.call(h,f,p);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=v.payload,p=typeof g=="function"?g.call(h,f,p):g,p==null)break e;f=In({},f,p);break e;case 2:sa=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=h,c=f):u=u.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(u===null&&(c=f),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=u,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);xl|=a,e.lanes=a,e.memoizedState=f}}function J0(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(je(191,s));s.call(r)}}}var pf={},Gi=La(pf),Ld=La(pf),Od=La(pf);function al(e){if(e===pf)throw Error(je(174));return e}function mb(e,t){switch(dn(Od,t),dn(Ld,e),dn(Gi,pf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ix(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ix(t,e)}vn(Gi),dn(Gi,t)}function Mc(){vn(Gi),vn(Ld),vn(Od)}function DC(e){al(Od.current);var t=al(Gi.current),n=ix(t,e.type);t!==n&&(dn(Ld,e),dn(Gi,n))}function gb(e){Ld.current===e&&(vn(Gi),vn(Ld))}var Pn=La(0);function Th(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)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 Kg=[];function yb(){for(var e=0;e<Kg.length;e++)Kg[e]._workInProgressVersionPrimary=null;Kg.length=0}var Qp=Mo.ReactCurrentDispatcher,qg=Mo.ReactCurrentBatchConfig,yl=0,An=null,Qn=null,cr=null,Rh=!1,ld=!1,Md=0,AL=0;function Ir(){throw Error(je(321))}function xb(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!wi(e[n],t[n]))return!1;return!0}function wb(e,t,n,r,s,i){if(yl=i,An=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Qp.current=e===null||e.memoizedState===null?LL:OL,e=n(r,s),ld){i=0;do{if(ld=!1,Md=0,25<=i)throw Error(je(301));i+=1,cr=Qn=null,t.updateQueue=null,Qp.current=ML,e=n(r,s)}while(ld)}if(Qp.current=Lh,t=Qn!==null&&Qn.next!==null,yl=0,cr=Qn=An=null,Rh=!1,t)throw Error(je(300));return e}function bb(){var e=Md!==0;return Md=0,e}function zi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cr===null?An.memoizedState=cr=e:cr=cr.next=e,cr}function Js(){if(Qn===null){var e=An.alternate;e=e!==null?e.memoizedState:null}else e=Qn.next;var t=cr===null?An.memoizedState:cr.next;if(t!==null)cr=t,Qn=e;else{if(e===null)throw Error(je(310));Qn=e,e={memoizedState:Qn.memoizedState,baseState:Qn.baseState,baseQueue:Qn.baseQueue,queue:Qn.queue,next:null},cr===null?An.memoizedState=cr=e:cr=cr.next=e}return cr}function $d(e,t){return typeof t=="function"?t(e):t}function Yg(e){var t=Js(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=Qn,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=a=null,c=null,d=i;do{var u=d.lane;if((yl&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var f={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,An.lanes|=u,xl|=u}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,wi(r,t.memoizedState)||(ns=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,An.lanes|=i,xl|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Gg(e){var t=Js(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do i=e(i,a.action),a=a.next;while(a!==s);wi(i,t.memoizedState)||(ns=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function FC(){}function zC(e,t){var n=An,r=Js(),s=t(),i=!wi(r.memoizedState,s);if(i&&(r.memoizedState=s,ns=!0),r=r.queue,vb(VC.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||cr!==null&&cr.memoizedState.tag&1){if(n.flags|=2048,Dd(9,HC.bind(null,n,r,s,t),void 0,null),dr===null)throw Error(je(349));yl&30||BC(n,t,s)}return s}function BC(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=An.updateQueue,t===null?(t={lastEffect:null,stores:null},An.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function HC(e,t,n,r){t.value=n,t.getSnapshot=r,WC(t)&&UC(e)}function VC(e,t,n){return n(function(){WC(t)&&UC(e)})}function WC(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!wi(e,n)}catch{return!0}}function UC(e){var t=Io(e,1);t!==null&&xi(t,e,1,-1)}function Q0(e){var t=zi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:$d,lastRenderedState:e},t.queue=e,e=e.dispatch=RL.bind(null,An,e),[t.memoizedState,e]}function Dd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=An.updateQueue,t===null?(t={lastEffect:null,stores:null},An.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function KC(){return Js().memoizedState}function Zp(e,t,n,r){var s=zi();An.flags|=e,s.memoizedState=Dd(1|t,n,void 0,r===void 0?null:r)}function Pm(e,t,n,r){var s=Js();r=r===void 0?null:r;var i=void 0;if(Qn!==null){var a=Qn.memoizedState;if(i=a.destroy,r!==null&&xb(r,a.deps)){s.memoizedState=Dd(t,n,i,r);return}}An.flags|=e,s.memoizedState=Dd(1|t,n,i,r)}function Z0(e,t){return Zp(8390656,8,e,t)}function vb(e,t){return Pm(2048,8,e,t)}function qC(e,t){return Pm(4,2,e,t)}function YC(e,t){return Pm(4,4,e,t)}function GC(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 XC(e,t,n){return n=n!=null?n.concat([e]):null,Pm(4,4,GC.bind(null,t,e),n)}function kb(){}function JC(e,t){var n=Js();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xb(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function QC(e,t){var n=Js();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xb(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function ZC(e,t,n){return yl&21?(wi(n,t)||(n=sC(),An.lanes|=n,xl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ns=!0),e.memoizedState=n)}function IL(e,t){var n=Zt;Zt=n!==0&&4>n?n:4,e(!0);var r=qg.transition;qg.transition={};try{e(!1),t()}finally{Zt=n,qg.transition=r}}function eE(){return Js().memoizedState}function TL(e,t,n){var r=wa(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},tE(e))nE(t,n);else if(n=MC(e,t,n,r),n!==null){var s=Wr();xi(n,e,r,s),rE(n,t,r)}}function RL(e,t,n){var r=wa(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(tE(e))nE(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,l=i(a,n);if(s.hasEagerState=!0,s.eagerState=l,wi(l,a)){var c=t.interleaved;c===null?(s.next=s,pb(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=MC(e,t,s,r),n!==null&&(s=Wr(),xi(n,e,r,s),rE(n,t,r))}}function tE(e){var t=e.alternate;return e===An||t!==null&&t===An}function nE(e,t){ld=Rh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function rE(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zw(e,n)}}var Lh={readContext:Xs,useCallback:Ir,useContext:Ir,useEffect:Ir,useImperativeHandle:Ir,useInsertionEffect:Ir,useLayoutEffect:Ir,useMemo:Ir,useReducer:Ir,useRef:Ir,useState:Ir,useDebugValue:Ir,useDeferredValue:Ir,useTransition:Ir,useMutableSource:Ir,useSyncExternalStore:Ir,useId:Ir,unstable_isNewReconciler:!1},LL={readContext:Xs,useCallback:function(e,t){return zi().memoizedState=[e,t===void 0?null:t],e},useContext:Xs,useEffect:Z0,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Zp(4194308,4,GC.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zp(4194308,4,e,t)},useInsertionEffect:function(e,t){return Zp(4,2,e,t)},useMemo:function(e,t){var n=zi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=zi();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=TL.bind(null,An,e),[r.memoizedState,e]},useRef:function(e){var t=zi();return e={current:e},t.memoizedState=e},useState:Q0,useDebugValue:kb,useDeferredValue:function(e){return zi().memoizedState=e},useTransition:function(){var e=Q0(!1),t=e[0];return e=IL.bind(null,e[1]),zi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=An,s=zi();if(jn){if(n===void 0)throw Error(je(407));n=n()}else{if(n=t(),dr===null)throw Error(je(349));yl&30||BC(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Z0(VC.bind(null,r,i,e),[e]),r.flags|=2048,Dd(9,HC.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=zi(),t=dr.identifierPrefix;if(jn){var n=No,r=So;n=(r&~(1<<32-yi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Md++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=AL++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},OL={readContext:Xs,useCallback:JC,useContext:Xs,useEffect:vb,useImperativeHandle:XC,useInsertionEffect:qC,useLayoutEffect:YC,useMemo:QC,useReducer:Yg,useRef:KC,useState:function(){return Yg($d)},useDebugValue:kb,useDeferredValue:function(e){var t=Js();return ZC(t,Qn.memoizedState,e)},useTransition:function(){var e=Yg($d)[0],t=Js().memoizedState;return[e,t]},useMutableSource:FC,useSyncExternalStore:zC,useId:eE,unstable_isNewReconciler:!1},ML={readContext:Xs,useCallback:JC,useContext:Xs,useEffect:vb,useImperativeHandle:XC,useInsertionEffect:qC,useLayoutEffect:YC,useMemo:QC,useReducer:Gg,useRef:KC,useState:function(){return Gg($d)},useDebugValue:kb,useDeferredValue:function(e){var t=Js();return Qn===null?t.memoizedState=e:ZC(t,Qn.memoizedState,e)},useTransition:function(){var e=Gg($d)[0],t=Js().memoizedState;return[e,t]},useMutableSource:FC,useSyncExternalStore:zC,useId:eE,unstable_isNewReconciler:!1};function ci(e,t){if(e&&e.defaultProps){t=In({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Cx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:In({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Am={isMounted:function(e){return(e=e._reactInternals)?El(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Wr(),s=wa(e),i=_o(r,s);i.payload=t,n!=null&&(i.callback=n),t=ya(e,i,s),t!==null&&(xi(t,e,s,r),Jp(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Wr(),s=wa(e),i=_o(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ya(e,i,s),t!==null&&(xi(t,e,s,r),Jp(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wr(),r=wa(e),s=_o(n,r);s.tag=2,t!=null&&(s.callback=t),t=ya(e,s,r),t!==null&&(xi(t,e,r,n),Jp(t,e,r))}};function ek(e,t,n,r,s,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!Ad(n,r)||!Ad(s,i):!0}function sE(e,t,n){var r=!1,s=Ca,i=t.contextType;return typeof i=="object"&&i!==null?i=Xs(i):(s=ls(t)?ml:Or.current,r=t.contextTypes,i=(r=r!=null)?Rc(e,s):Ca),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Am,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function tk(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Am.enqueueReplaceState(t,t.state,null)}function Ex(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},hb(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=Xs(i):(i=ls(t)?ml:Or.current,s.context=Rc(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Cx(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Am.enqueueReplaceState(s,s.state,null),Ih(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function $c(e,t){try{var n="",r=t;do n+=uR(r),r=r.return;while(r);var s=n}catch(i){s=`
39
+ Error generating stack: `+i.message+`
40
+ `+i.stack}return{value:e,source:t,stack:s,digest:null}}function Xg(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function _x(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var $L=typeof WeakMap=="function"?WeakMap:Map;function iE(e,t,n){n=_o(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Mh||(Mh=!0,Dx=r),_x(e,t)},n}function oE(e,t,n){n=_o(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){_x(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){_x(e,t),typeof r!="function"&&(xa===null?xa=new Set([this]):xa.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function nk(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new $L;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=JL.bind(null,e,t,n),t.then(e,e))}function rk(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 sk(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=_o(-1,1),t.tag=2,ya(n,t,1))),n.lanes|=1),e)}var DL=Mo.ReactCurrentOwner,ns=!1;function Hr(e,t,n,r){t.child=e===null?OC(t,null,n,r):Oc(t,e.child,n,r)}function ik(e,t,n,r,s){n=n.render;var i=t.ref;return jc(t,s),r=wb(e,t,n,r,i,s),n=bb(),e!==null&&!ns?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,To(e,t,s)):(jn&&n&&ab(t),t.flags|=1,Hr(e,t,r,s),t.child)}function ok(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!Ab(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,aE(e,t,i,r,s)):(e=rh(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:Ad,n(a,r)&&e.ref===t.ref)return To(e,t,s)}return t.flags|=1,e=ba(i,r),e.ref=t.ref,e.return=t,t.child=e}function aE(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(Ad(i,r)&&e.ref===t.ref)if(ns=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ns=!0);else return t.lanes=e.lanes,To(e,t,s)}return Px(e,t,n,r,s)}function lE(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},dn(hc,xs),xs|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,dn(hc,xs),xs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,dn(hc,xs),xs|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,dn(hc,xs),xs|=r;return Hr(e,t,s,n),t.child}function cE(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Px(e,t,n,r,s){var i=ls(n)?ml:Or.current;return i=Rc(t,i),jc(t,s),n=wb(e,t,n,r,i,s),r=bb(),e!==null&&!ns?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,To(e,t,s)):(jn&&r&&ab(t),t.flags|=1,Hr(e,t,n,s),t.child)}function ak(e,t,n,r,s){if(ls(n)){var i=!0;Ch(t)}else i=!1;if(jc(t,s),t.stateNode===null)eh(e,t),sE(t,n,r),Ex(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Xs(d):(d=ls(n)?ml:Or.current,d=Rc(t,d));var u=n.getDerivedStateFromProps,f=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&tk(t,a,r,d),sa=!1;var p=t.memoizedState;a.state=p,Ih(t,r,a,s),c=t.memoizedState,l!==r||p!==c||as.current||sa?(typeof u=="function"&&(Cx(t,n,u,r),c=t.memoizedState),(l=sa||ek(t,n,l,r,p,c,d))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,$C(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:ci(t.type,l),a.props=d,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Xs(c):(c=ls(n)?ml:Or.current,c=Rc(t,c));var h=n.getDerivedStateFromProps;(u=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&tk(t,a,r,c),sa=!1,p=t.memoizedState,a.state=p,Ih(t,r,a,s);var g=t.memoizedState;l!==f||p!==g||as.current||sa?(typeof h=="function"&&(Cx(t,n,h,r),g=t.memoizedState),(d=sa||ek(t,n,d,r,p,g,c)||!1)?(u||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),a.props=r,a.state=g,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return Ax(e,t,n,r,i,s)}function Ax(e,t,n,r,s,i){cE(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&K0(t,n,!1),To(e,t,i);r=t.stateNode,DL.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Oc(t,e.child,null,i),t.child=Oc(t,null,l,i)):Hr(e,t,l,i),t.memoizedState=r.state,s&&K0(t,n,!0),t.child}function uE(e){var t=e.stateNode;t.pendingContext?U0(e,t.pendingContext,t.pendingContext!==t.context):t.context&&U0(e,t.context,!1),mb(e,t.containerInfo)}function lk(e,t,n,r,s){return Lc(),cb(s),t.flags|=256,Hr(e,t,n,r),t.child}var Ix={dehydrated:null,treeContext:null,retryLane:0};function Tx(e){return{baseLanes:e,cachePool:null,transitions:null}}function dE(e,t,n){var r=t.pendingProps,s=Pn.current,i=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),dn(Pn,s&1),e===null)return Nx(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Rm(a,r,0,null),e=ul(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Tx(n),t.memoizedState=Ix,e):Sb(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return FL(e,t,a,r,l,s,n);if(i){i=r.fallback,a=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=ba(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=ba(l,i):(i=ul(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?Tx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=Ix,r}return i=e.child,e=i.sibling,r=ba(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Sb(e,t){return t=Rm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function hp(e,t,n,r){return r!==null&&cb(r),Oc(t,e.child,null,n),e=Sb(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function FL(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=Xg(Error(je(422))),hp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Rm({mode:"visible",children:r.children},s,0,null),i=ul(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Oc(t,e.child,null,a),t.child.memoizedState=Tx(a),t.memoizedState=Ix,i);if(!(t.mode&1))return hp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(je(419)),r=Xg(i,r,void 0),hp(e,t,a,r)}if(l=(a&e.childLanes)!==0,ns||l){if(r=dr,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,Io(e,s),xi(r,e,s,-1))}return Pb(),r=Xg(Error(je(421))),hp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=QL.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ks=ga(s.nextSibling),Ns=t,jn=!0,fi=null,e!==null&&(Ws[Us++]=So,Ws[Us++]=No,Ws[Us++]=gl,So=e.id,No=e.overflow,gl=t),t=Sb(t,r.children),t.flags|=4096,t)}function ck(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),jx(e.return,t,n)}function Jg(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function fE(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(Hr(e,t,r.children,n),r=Pn.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ck(e,n,t);else if(e.tag===19)ck(e,n,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}r&=1}if(dn(Pn,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Th(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Jg(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Th(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Jg(t,!0,n,null,i);break;case"together":Jg(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function eh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function To(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),xl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(je(153));if(t.child!==null){for(e=t.child,n=ba(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ba(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function zL(e,t,n){switch(t.tag){case 3:uE(t),Lc();break;case 5:DC(t);break;case 1:ls(t.type)&&Ch(t);break;case 4:mb(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;dn(Ph,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(dn(Pn,Pn.current&1),t.flags|=128,null):n&t.child.childLanes?dE(e,t,n):(dn(Pn,Pn.current&1),e=To(e,t,n),e!==null?e.sibling:null);dn(Pn,Pn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return fE(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),dn(Pn,Pn.current),r)break;return null;case 22:case 23:return t.lanes=0,lE(e,t,n)}return To(e,t,n)}var pE,Rx,hE,mE;pE=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Rx=function(){};hE=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,al(Gi.current);var i=null;switch(n){case"input":s=tx(e,s),r=tx(e,r),i=[];break;case"select":s=In({},s,{value:void 0}),r=In({},r,{value:void 0}),i=[];break;case"textarea":s=sx(e,s),r=sx(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Nh)}ox(n,r);var a;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Sd.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Sd.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&wn("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};mE=function(e,t,n,r){n!==r&&(t.flags|=4)};function Ru(e,t){if(!jn)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Tr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function BL(e,t,n){var r=t.pendingProps;switch(lb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tr(t),null;case 1:return ls(t.type)&&jh(),Tr(t),null;case 3:return r=t.stateNode,Mc(),vn(as),vn(Or),yb(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(fp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,fi!==null&&(Bx(fi),fi=null))),Rx(e,t),Tr(t),null;case 5:gb(t);var s=al(Od.current);if(n=t.type,e!==null&&t.stateNode!=null)hE(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(je(166));return Tr(t),null}if(e=al(Gi.current),fp(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Wi]=t,r[Rd]=i,e=(t.mode&1)!==0,n){case"dialog":wn("cancel",r),wn("close",r);break;case"iframe":case"object":case"embed":wn("load",r);break;case"video":case"audio":for(s=0;s<Gu.length;s++)wn(Gu[s],r);break;case"source":wn("error",r);break;case"img":case"image":case"link":wn("error",r),wn("load",r);break;case"details":wn("toggle",r);break;case"input":x0(r,i),wn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},wn("invalid",r);break;case"textarea":b0(r,i),wn("invalid",r)}ox(n,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&dp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&dp(r.textContent,l,e),s=["children",""+l]):Sd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&wn("scroll",r)}switch(n){case"input":rp(r),w0(r,i,!0);break;case"textarea":rp(r),v0(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Nh)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=V1(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Wi]=t,e[Rd]=r,pE(e,t,!1,!1),t.stateNode=e;e:{switch(a=ax(n,r),n){case"dialog":wn("cancel",e),wn("close",e),s=r;break;case"iframe":case"object":case"embed":wn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Gu.length;s++)wn(Gu[s],e);s=r;break;case"source":wn("error",e),s=r;break;case"img":case"image":case"link":wn("error",e),wn("load",e),s=r;break;case"details":wn("toggle",e),s=r;break;case"input":x0(e,r),s=tx(e,r),wn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=In({},r,{value:void 0}),wn("invalid",e);break;case"textarea":b0(e,r),s=sx(e,r),wn("invalid",e);break;default:s=r}ox(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?K1(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&W1(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Nd(e,c):typeof c=="number"&&Nd(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Sd.hasOwnProperty(i)?c!=null&&i==="onScroll"&&wn("scroll",e):c!=null&&qw(e,i,c,a))}switch(n){case"input":rp(e),w0(e,r,!1);break;case"textarea":rp(e),v0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ja(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?vc(e,!!r.multiple,i,!1):r.defaultValue!=null&&vc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Nh)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Tr(t),null;case 6:if(e&&t.stateNode!=null)mE(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(je(166));if(n=al(Od.current),al(Gi.current),fp(t)){if(r=t.stateNode,n=t.memoizedProps,r[Wi]=t,(i=r.nodeValue!==n)&&(e=Ns,e!==null))switch(e.tag){case 3:dp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&dp(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Wi]=t,t.stateNode=r}return Tr(t),null;case 13:if(vn(Pn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(jn&&ks!==null&&t.mode&1&&!(t.flags&128))RC(),Lc(),t.flags|=98560,i=!1;else if(i=fp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(je(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(je(317));i[Wi]=t}else Lc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Tr(t),i=!1}else fi!==null&&(Bx(fi),fi=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Pn.current&1?er===0&&(er=3):Pb())),t.updateQueue!==null&&(t.flags|=4),Tr(t),null);case 4:return Mc(),Rx(e,t),e===null&&Id(t.stateNode.containerInfo),Tr(t),null;case 10:return fb(t.type._context),Tr(t),null;case 17:return ls(t.type)&&jh(),Tr(t),null;case 19:if(vn(Pn),i=t.memoizedState,i===null)return Tr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Ru(i,!1);else{if(er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Th(e),a!==null){for(t.flags|=128,Ru(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return dn(Pn,Pn.current&1|2),t.child}e=e.sibling}i.tail!==null&&zn()>Dc&&(t.flags|=128,r=!0,Ru(i,!1),t.lanes=4194304)}else{if(!r)if(e=Th(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Ru(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!jn)return Tr(t),null}else 2*zn()-i.renderingStartTime>Dc&&n!==1073741824&&(t.flags|=128,r=!0,Ru(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=zn(),t.sibling=null,n=Pn.current,dn(Pn,r?n&1|2:n&1),t):(Tr(t),null);case 22:case 23:return _b(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?xs&1073741824&&(Tr(t),t.subtreeFlags&6&&(t.flags|=8192)):Tr(t),null;case 24:return null;case 25:return null}throw Error(je(156,t.tag))}function HL(e,t){switch(lb(t),t.tag){case 1:return ls(t.type)&&jh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Mc(),vn(as),vn(Or),yb(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return gb(t),null;case 13:if(vn(Pn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(je(340));Lc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return vn(Pn),null;case 4:return Mc(),null;case 10:return fb(t.type._context),null;case 22:case 23:return _b(),null;case 24:return null;default:return null}}var mp=!1,Rr=!1,VL=typeof WeakSet=="function"?WeakSet:Set,He=null;function pc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ln(e,t,r)}else n.current=null}function Lx(e,t,n){try{n()}catch(r){Ln(e,t,r)}}var uk=!1;function WL(e,t){if(yx=vh,e=bC(),ob(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,u=0,f=e,p=null;t:for(;;){for(var h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==i||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)p=f,f=h;for(;;){if(f===e)break t;if(p===n&&++d===s&&(l=a),p===i&&++u===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(xx={focusedElem:e,selectionRange:n},vh=!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 g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var v=g.memoizedProps,k=g.memoizedState,y=t.stateNode,b=y.getSnapshotBeforeUpdate(t.elementType===t.type?v:ci(t.type,v),k);y.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(je(163))}}catch(S){Ln(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,He=e;break}He=t.return}return g=uk,uk=!1,g}function cd(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Lx(t,n,i)}s=s.next}while(s!==r)}}function Im(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ox(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function gE(e){var t=e.alternate;t!==null&&(e.alternate=null,gE(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Wi],delete t[Rd],delete t[vx],delete t[CL],delete t[EL])),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 yE(e){return e.tag===5||e.tag===3||e.tag===4}function dk(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||yE(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 Mx(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Nh));else if(r!==4&&(e=e.child,e!==null))for(Mx(e,t,n),e=e.sibling;e!==null;)Mx(e,t,n),e=e.sibling}function $x(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for($x(e,t,n),e=e.sibling;e!==null;)$x(e,t,n),e=e.sibling}var br=null,ui=!1;function Xo(e,t,n){for(n=n.child;n!==null;)xE(e,t,n),n=n.sibling}function xE(e,t,n){if(Yi&&typeof Yi.onCommitFiberUnmount=="function")try{Yi.onCommitFiberUnmount(Sm,n)}catch{}switch(n.tag){case 5:Rr||pc(n,t);case 6:var r=br,s=ui;br=null,Xo(e,t,n),br=r,ui=s,br!==null&&(ui?(e=br,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):br.removeChild(n.stateNode));break;case 18:br!==null&&(ui?(e=br,n=n.stateNode,e.nodeType===8?Wg(e.parentNode,n):e.nodeType===1&&Wg(e,n),_d(e)):Wg(br,n.stateNode));break;case 4:r=br,s=ui,br=n.stateNode.containerInfo,ui=!0,Xo(e,t,n),br=r,ui=s;break;case 0:case 11:case 14:case 15:if(!Rr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Lx(n,t,a),s=s.next}while(s!==r)}Xo(e,t,n);break;case 1:if(!Rr&&(pc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Ln(n,t,l)}Xo(e,t,n);break;case 21:Xo(e,t,n);break;case 22:n.mode&1?(Rr=(r=Rr)||n.memoizedState!==null,Xo(e,t,n),Rr=r):Xo(e,t,n);break;default:Xo(e,t,n)}}function fk(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new VL),t.forEach(function(r){var s=ZL.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ai(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:br=l.stateNode,ui=!1;break e;case 3:br=l.stateNode.containerInfo,ui=!0;break e;case 4:br=l.stateNode.containerInfo,ui=!0;break e}l=l.return}if(br===null)throw Error(je(160));xE(i,a,s),br=null,ui=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Ln(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)wE(t,e),t=t.sibling}function wE(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(ai(t,e),$i(e),r&4){try{cd(3,e,e.return),Im(3,e)}catch(v){Ln(e,e.return,v)}try{cd(5,e,e.return)}catch(v){Ln(e,e.return,v)}}break;case 1:ai(t,e),$i(e),r&512&&n!==null&&pc(n,n.return);break;case 5:if(ai(t,e),$i(e),r&512&&n!==null&&pc(n,n.return),e.flags&32){var s=e.stateNode;try{Nd(s,"")}catch(v){Ln(e,e.return,v)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&B1(s,i),ax(l,a);var d=ax(l,i);for(a=0;a<c.length;a+=2){var u=c[a],f=c[a+1];u==="style"?K1(s,f):u==="dangerouslySetInnerHTML"?W1(s,f):u==="children"?Nd(s,f):qw(s,u,f,d)}switch(l){case"input":nx(s,i);break;case"textarea":H1(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?vc(s,!!i.multiple,h,!1):p!==!!i.multiple&&(i.defaultValue!=null?vc(s,!!i.multiple,i.defaultValue,!0):vc(s,!!i.multiple,i.multiple?[]:"",!1))}s[Rd]=i}catch(v){Ln(e,e.return,v)}}break;case 6:if(ai(t,e),$i(e),r&4){if(e.stateNode===null)throw Error(je(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(v){Ln(e,e.return,v)}}break;case 3:if(ai(t,e),$i(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{_d(t.containerInfo)}catch(v){Ln(e,e.return,v)}break;case 4:ai(t,e),$i(e);break;case 13:ai(t,e),$i(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Cb=zn())),r&4&&fk(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(Rr=(d=Rr)||u,ai(t,e),Rr=d):ai(t,e),$i(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(He=e,u=e.child;u!==null;){for(f=He=u;He!==null;){switch(p=He,h=p.child,p.tag){case 0:case 11:case 14:case 15:cd(4,p,p.return);break;case 1:pc(p,p.return);var g=p.stateNode;if(typeof g.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(v){Ln(r,n,v)}}break;case 5:pc(p,p.return);break;case 22:if(p.memoizedState!==null){hk(f);continue}}h!==null?(h.return=p,He=h):hk(f)}u=u.sibling}e:for(u=null,f=e;;){if(f.tag===5){if(u===null){u=f;try{s=f.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=U1("display",a))}catch(v){Ln(e,e.return,v)}}}else if(f.tag===6){if(u===null)try{f.stateNode.nodeValue=d?"":f.memoizedProps}catch(v){Ln(e,e.return,v)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;u===f&&(u=null),f=f.return}u===f&&(u=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:ai(t,e),$i(e),r&4&&fk(e);break;case 21:break;default:ai(t,e),$i(e)}}function $i(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(yE(n)){var r=n;break e}n=n.return}throw Error(je(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Nd(s,""),r.flags&=-33);var i=dk(e);$x(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=dk(e);Mx(e,l,a);break;default:throw Error(je(161))}}catch(c){Ln(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function UL(e,t,n){He=e,bE(e)}function bE(e,t,n){for(var r=(e.mode&1)!==0;He!==null;){var s=He,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||mp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Rr;l=mp;var d=Rr;if(mp=a,(Rr=c)&&!d)for(He=s;He!==null;)a=He,c=a.child,a.tag===22&&a.memoizedState!==null?mk(s):c!==null?(c.return=a,He=c):mk(s);for(;i!==null;)He=i,bE(i),i=i.sibling;He=s,mp=l,Rr=d}pk(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,He=i):pk(e)}}function pk(e){for(;He!==null;){var t=He;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Rr||Im(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Rr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:ci(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&J0(t,i,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}J0(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var f=u.dehydrated;f!==null&&_d(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(je(163))}Rr||t.flags&512&&Ox(t)}catch(p){Ln(t,t.return,p)}}if(t===e){He=null;break}if(n=t.sibling,n!==null){n.return=t.return,He=n;break}He=t.return}}function hk(e){for(;He!==null;){var t=He;if(t===e){He=null;break}var n=t.sibling;if(n!==null){n.return=t.return,He=n;break}He=t.return}}function mk(e){for(;He!==null;){var t=He;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Im(4,t)}catch(c){Ln(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Ln(t,s,c)}}var i=t.return;try{Ox(t)}catch(c){Ln(t,i,c)}break;case 5:var a=t.return;try{Ox(t)}catch(c){Ln(t,a,c)}}}catch(c){Ln(t,t.return,c)}if(t===e){He=null;break}var l=t.sibling;if(l!==null){l.return=t.return,He=l;break}He=t.return}}var KL=Math.ceil,Oh=Mo.ReactCurrentDispatcher,Nb=Mo.ReactCurrentOwner,Gs=Mo.ReactCurrentBatchConfig,zt=0,dr=null,Kn=null,vr=0,xs=0,hc=La(0),er=0,Fd=null,xl=0,Tm=0,jb=0,ud=null,es=null,Cb=0,Dc=1/0,wo=null,Mh=!1,Dx=null,xa=null,gp=!1,ua=null,$h=0,dd=0,Fx=null,th=-1,nh=0;function Wr(){return zt&6?zn():th!==-1?th:th=zn()}function wa(e){return e.mode&1?zt&2&&vr!==0?vr&-vr:PL.transition!==null?(nh===0&&(nh=sC()),nh):(e=Zt,e!==0||(e=window.event,e=e===void 0?16:dC(e.type)),e):1}function xi(e,t,n,r){if(50<dd)throw dd=0,Fx=null,Error(je(185));uf(e,n,r),(!(zt&2)||e!==dr)&&(e===dr&&(!(zt&2)&&(Tm|=n),er===4&&aa(e,vr)),cs(e,r),n===1&&zt===0&&!(t.mode&1)&&(Dc=zn()+500,_m&&Oa()))}function cs(e,t){var n=e.callbackNode;PR(e,t);var r=bh(e,e===dr?vr:0);if(r===0)n!==null&&N0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&N0(n),t===1)e.tag===0?_L(gk.bind(null,e)):AC(gk.bind(null,e)),NL(function(){!(zt&6)&&Oa()}),n=null;else{switch(iC(r)){case 1:n=Qw;break;case 4:n=nC;break;case 16:n=wh;break;case 536870912:n=rC;break;default:n=wh}n=_E(n,vE.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function vE(e,t){if(th=-1,nh=0,zt&6)throw Error(je(327));var n=e.callbackNode;if(Cc()&&e.callbackNode!==n)return null;var r=bh(e,e===dr?vr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Dh(e,r);else{t=r;var s=zt;zt|=2;var i=SE();(dr!==e||vr!==t)&&(wo=null,Dc=zn()+500,cl(e,t));do try{GL();break}catch(l){kE(e,l)}while(!0);db(),Oh.current=i,zt=s,Kn!==null?t=0:(dr=null,vr=0,t=er)}if(t!==0){if(t===2&&(s=fx(e),s!==0&&(r=s,t=zx(e,s))),t===1)throw n=Fd,cl(e,0),aa(e,r),cs(e,zn()),n;if(t===6)aa(e,r);else{if(s=e.current.alternate,!(r&30)&&!qL(s)&&(t=Dh(e,r),t===2&&(i=fx(e),i!==0&&(r=i,t=zx(e,i))),t===1))throw n=Fd,cl(e,0),aa(e,r),cs(e,zn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(je(345));case 2:nl(e,es,wo);break;case 3:if(aa(e,r),(r&130023424)===r&&(t=Cb+500-zn(),10<t)){if(bh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Wr(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=bx(nl.bind(null,e,es,wo),t);break}nl(e,es,wo);break;case 4:if(aa(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-yi(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=zn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*KL(r/1960))-r,10<r){e.timeoutHandle=bx(nl.bind(null,e,es,wo),r);break}nl(e,es,wo);break;case 5:nl(e,es,wo);break;default:throw Error(je(329))}}}return cs(e,zn()),e.callbackNode===n?vE.bind(null,e):null}function zx(e,t){var n=ud;return e.current.memoizedState.isDehydrated&&(cl(e,t).flags|=256),e=Dh(e,t),e!==2&&(t=es,es=n,t!==null&&Bx(t)),e}function Bx(e){es===null?es=e:es.push.apply(es,e)}function qL(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!wi(i(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;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 aa(e,t){for(t&=~jb,t&=~Tm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-yi(t),r=1<<n;e[n]=-1,t&=~r}}function gk(e){if(zt&6)throw Error(je(327));Cc();var t=bh(e,0);if(!(t&1))return cs(e,zn()),null;var n=Dh(e,t);if(e.tag!==0&&n===2){var r=fx(e);r!==0&&(t=r,n=zx(e,r))}if(n===1)throw n=Fd,cl(e,0),aa(e,t),cs(e,zn()),n;if(n===6)throw Error(je(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,nl(e,es,wo),cs(e,zn()),null}function Eb(e,t){var n=zt;zt|=1;try{return e(t)}finally{zt=n,zt===0&&(Dc=zn()+500,_m&&Oa())}}function wl(e){ua!==null&&ua.tag===0&&!(zt&6)&&Cc();var t=zt;zt|=1;var n=Gs.transition,r=Zt;try{if(Gs.transition=null,Zt=1,e)return e()}finally{Zt=r,Gs.transition=n,zt=t,!(zt&6)&&Oa()}}function _b(){xs=hc.current,vn(hc)}function cl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,SL(n)),Kn!==null)for(n=Kn.return;n!==null;){var r=n;switch(lb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&jh();break;case 3:Mc(),vn(as),vn(Or),yb();break;case 5:gb(r);break;case 4:Mc();break;case 13:vn(Pn);break;case 19:vn(Pn);break;case 10:fb(r.type._context);break;case 22:case 23:_b()}n=n.return}if(dr=e,Kn=e=ba(e.current,null),vr=xs=t,er=0,Fd=null,jb=Tm=xl=0,es=ud=null,ol!==null){for(t=0;t<ol.length;t++)if(n=ol[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}n.pending=r}ol=null}return e}function kE(e,t){do{var n=Kn;try{if(db(),Qp.current=Lh,Rh){for(var r=An.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Rh=!1}if(yl=0,cr=Qn=An=null,ld=!1,Md=0,Nb.current=null,n===null||n.return===null){er=1,Fd=t,Kn=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=vr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=l,f=u.tag;if(!(u.mode&1)&&(f===0||f===11||f===15)){var p=u.alternate;p?(u.updateQueue=p.updateQueue,u.memoizedState=p.memoizedState,u.lanes=p.lanes):(u.updateQueue=null,u.memoizedState=null)}var h=rk(a);if(h!==null){h.flags&=-257,sk(h,a,l,i,t),h.mode&1&&nk(i,d,t),t=h,c=d;var g=t.updateQueue;if(g===null){var v=new Set;v.add(c),t.updateQueue=v}else g.add(c);break e}else{if(!(t&1)){nk(i,d,t),Pb();break e}c=Error(je(426))}}else if(jn&&l.mode&1){var k=rk(a);if(k!==null){!(k.flags&65536)&&(k.flags|=256),sk(k,a,l,i,t),cb($c(c,l));break e}}i=c=$c(c,l),er!==4&&(er=2),ud===null?ud=[i]:ud.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=iE(i,c,t);X0(i,y);break e;case 1:l=c;var b=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof b.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(xa===null||!xa.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var S=oE(i,l,t);X0(i,S);break e}}i=i.return}while(i!==null)}jE(n)}catch(C){t=C,Kn===n&&n!==null&&(Kn=n=n.return);continue}break}while(!0)}function SE(){var e=Oh.current;return Oh.current=Lh,e===null?Lh:e}function Pb(){(er===0||er===3||er===2)&&(er=4),dr===null||!(xl&268435455)&&!(Tm&268435455)||aa(dr,vr)}function Dh(e,t){var n=zt;zt|=2;var r=SE();(dr!==e||vr!==t)&&(wo=null,cl(e,t));do try{YL();break}catch(s){kE(e,s)}while(!0);if(db(),zt=n,Oh.current=r,Kn!==null)throw Error(je(261));return dr=null,vr=0,er}function YL(){for(;Kn!==null;)NE(Kn)}function GL(){for(;Kn!==null&&!bR();)NE(Kn)}function NE(e){var t=EE(e.alternate,e,xs);e.memoizedProps=e.pendingProps,t===null?jE(e):Kn=t,Nb.current=null}function jE(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=HL(n,t),n!==null){n.flags&=32767,Kn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{er=6,Kn=null;return}}else if(n=BL(n,t,xs),n!==null){Kn=n;return}if(t=t.sibling,t!==null){Kn=t;return}Kn=t=e}while(t!==null);er===0&&(er=5)}function nl(e,t,n){var r=Zt,s=Gs.transition;try{Gs.transition=null,Zt=1,XL(e,t,n,r)}finally{Gs.transition=s,Zt=r}return null}function XL(e,t,n,r){do Cc();while(ua!==null);if(zt&6)throw Error(je(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(je(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(AR(e,i),e===dr&&(Kn=dr=null,vr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||gp||(gp=!0,_E(wh,function(){return Cc(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Gs.transition,Gs.transition=null;var a=Zt;Zt=1;var l=zt;zt|=4,Nb.current=null,WL(e,n),wE(n,e),gL(xx),vh=!!yx,xx=yx=null,e.current=n,UL(n),vR(),zt=l,Zt=a,Gs.transition=i}else e.current=n;if(gp&&(gp=!1,ua=e,$h=s),i=e.pendingLanes,i===0&&(xa=null),NR(n.stateNode),cs(e,zn()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Mh)throw Mh=!1,e=Dx,Dx=null,e;return $h&1&&e.tag!==0&&Cc(),i=e.pendingLanes,i&1?e===Fx?dd++:(dd=0,Fx=e):dd=0,Oa(),null}function Cc(){if(ua!==null){var e=iC($h),t=Gs.transition,n=Zt;try{if(Gs.transition=null,Zt=16>e?16:e,ua===null)var r=!1;else{if(e=ua,ua=null,$h=0,zt&6)throw Error(je(331));var s=zt;for(zt|=4,He=e.current;He!==null;){var i=He,a=i.child;if(He.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(He=d;He!==null;){var u=He;switch(u.tag){case 0:case 11:case 15:cd(8,u,i)}var f=u.child;if(f!==null)f.return=u,He=f;else for(;He!==null;){u=He;var p=u.sibling,h=u.return;if(gE(u),u===d){He=null;break}if(p!==null){p.return=h,He=p;break}He=h}}}var g=i.alternate;if(g!==null){var v=g.child;if(v!==null){g.child=null;do{var k=v.sibling;v.sibling=null,v=k}while(v!==null)}}He=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,He=a;else e:for(;He!==null;){if(i=He,i.flags&2048)switch(i.tag){case 0:case 11:case 15:cd(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,He=y;break e}He=i.return}}var b=e.current;for(He=b;He!==null;){a=He;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,He=w;else e:for(a=b;He!==null;){if(l=He,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Im(9,l)}}catch(C){Ln(l,l.return,C)}if(l===a){He=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,He=S;break e}He=l.return}}if(zt=s,Oa(),Yi&&typeof Yi.onPostCommitFiberRoot=="function")try{Yi.onPostCommitFiberRoot(Sm,e)}catch{}r=!0}return r}finally{Zt=n,Gs.transition=t}}return!1}function yk(e,t,n){t=$c(n,t),t=iE(e,t,1),e=ya(e,t,1),t=Wr(),e!==null&&(uf(e,1,t),cs(e,t))}function Ln(e,t,n){if(e.tag===3)yk(e,e,n);else for(;t!==null;){if(t.tag===3){yk(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(xa===null||!xa.has(r))){e=$c(n,e),e=oE(t,e,1),t=ya(t,e,1),e=Wr(),t!==null&&(uf(t,1,e),cs(t,e));break}}t=t.return}}function JL(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Wr(),e.pingedLanes|=e.suspendedLanes&n,dr===e&&(vr&n)===n&&(er===4||er===3&&(vr&130023424)===vr&&500>zn()-Cb?cl(e,0):jb|=n),cs(e,t)}function CE(e,t){t===0&&(e.mode&1?(t=op,op<<=1,!(op&130023424)&&(op=4194304)):t=1);var n=Wr();e=Io(e,t),e!==null&&(uf(e,t,n),cs(e,n))}function QL(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),CE(e,n)}function ZL(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(je(314))}r!==null&&r.delete(t),CE(e,n)}var EE;EE=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||as.current)ns=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ns=!1,zL(e,t,n);ns=!!(e.flags&131072)}else ns=!1,jn&&t.flags&1048576&&IC(t,_h,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;eh(e,t),e=t.pendingProps;var s=Rc(t,Or.current);jc(t,n),s=wb(null,t,r,e,s,n);var i=bb();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ls(r)?(i=!0,Ch(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,hb(t),s.updater=Am,t.stateNode=s,s._reactInternals=t,Ex(t,r,e,n),t=Ax(null,t,r,!0,i,n)):(t.tag=0,jn&&i&&ab(t),Hr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(eh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=tO(r),e=ci(r,e),s){case 0:t=Px(null,t,r,e,n);break e;case 1:t=ak(null,t,r,e,n);break e;case 11:t=ik(null,t,r,e,n);break e;case 14:t=ok(null,t,r,ci(r.type,e),n);break e}throw Error(je(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ci(r,s),Px(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ci(r,s),ak(e,t,r,s,n);case 3:e:{if(uE(t),e===null)throw Error(je(387));r=t.pendingProps,i=t.memoizedState,s=i.element,$C(e,t),Ih(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=$c(Error(je(423)),t),t=lk(e,t,r,n,s);break e}else if(r!==s){s=$c(Error(je(424)),t),t=lk(e,t,r,n,s);break e}else for(ks=ga(t.stateNode.containerInfo.firstChild),Ns=t,jn=!0,fi=null,n=OC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Lc(),r===s){t=To(e,t,n);break e}Hr(e,t,r,n)}t=t.child}return t;case 5:return DC(t),e===null&&Nx(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,wx(r,s)?a=null:i!==null&&wx(r,i)&&(t.flags|=32),cE(e,t),Hr(e,t,a,n),t.child;case 6:return e===null&&Nx(t),null;case 13:return dE(e,t,n);case 4:return mb(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Oc(t,null,r,n):Hr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ci(r,s),ik(e,t,r,s,n);case 7:return Hr(e,t,t.pendingProps,n),t.child;case 8:return Hr(e,t,t.pendingProps.children,n),t.child;case 12:return Hr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,dn(Ph,r._currentValue),r._currentValue=a,i!==null)if(wi(i.value,a)){if(i.children===s.children&&!as.current){t=To(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=_o(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),jx(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(je(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),jx(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Hr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,jc(t,n),s=Xs(s),r=r(s),t.flags|=1,Hr(e,t,r,n),t.child;case 14:return r=t.type,s=ci(r,t.pendingProps),s=ci(r.type,s),ok(e,t,r,s,n);case 15:return aE(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ci(r,s),eh(e,t),t.tag=1,ls(r)?(e=!0,Ch(t)):e=!1,jc(t,n),sE(t,r,s),Ex(t,r,s,n),Ax(null,t,r,!0,e,n);case 19:return fE(e,t,n);case 22:return lE(e,t,n)}throw Error(je(156,t.tag))};function _E(e,t){return tC(e,t)}function eO(e,t,n,r){this.tag=e,this.key=n,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=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(e,t,n,r){return new eO(e,t,n,r)}function Ab(e){return e=e.prototype,!(!e||!e.isReactComponent)}function tO(e){if(typeof e=="function")return Ab(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Gw)return 11;if(e===Xw)return 14}return 2}function ba(e,t){var n=e.alternate;return n===null?(n=Ys(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function rh(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Ab(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case sc:return ul(n.children,s,i,t);case Yw:a=8,s|=8;break;case Jy:return e=Ys(12,n,t,s|2),e.elementType=Jy,e.lanes=i,e;case Qy:return e=Ys(13,n,t,s),e.elementType=Qy,e.lanes=i,e;case Zy:return e=Ys(19,n,t,s),e.elementType=Zy,e.lanes=i,e;case D1:return Rm(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case M1:a=10;break e;case $1:a=9;break e;case Gw:a=11;break e;case Xw:a=14;break e;case ra:a=16,r=null;break e}throw Error(je(130,e==null?e:typeof e,""))}return t=Ys(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function ul(e,t,n,r){return e=Ys(7,e,r,t),e.lanes=n,e}function Rm(e,t,n,r){return e=Ys(22,e,r,t),e.elementType=D1,e.lanes=n,e.stateNode={isHidden:!1},e}function Qg(e,t,n){return e=Ys(6,e,null,t),e.lanes=n,e}function Zg(e,t,n){return t=Ys(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function nO(e,t,n,r,s){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=Rg(0),this.expirationTimes=Rg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rg(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ib(e,t,n,r,s,i,a,l,c){return e=new nO(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ys(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hb(i),e}function rO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:rc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function PE(e){if(!e)return Ca;e=e._reactInternals;e:{if(El(e)!==e||e.tag!==1)throw Error(je(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ls(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(je(171))}if(e.tag===1){var n=e.type;if(ls(n))return PC(e,n,t)}return t}function AE(e,t,n,r,s,i,a,l,c){return e=Ib(n,r,!0,e,s,i,a,l,c),e.context=PE(null),n=e.current,r=Wr(),s=wa(n),i=_o(r,s),i.callback=t??null,ya(n,i,s),e.current.lanes=s,uf(e,s,r),cs(e,r),e}function Lm(e,t,n,r){var s=t.current,i=Wr(),a=wa(s);return n=PE(n),t.context===null?t.context=n:t.pendingContext=n,t=_o(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ya(s,t,a),e!==null&&(xi(e,s,a,i),Jp(e,s,a)),a}function Fh(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 xk(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Tb(e,t){xk(e,t),(e=e.alternate)&&xk(e,t)}function sO(){return null}var IE=typeof reportError=="function"?reportError:function(e){console.error(e)};function Rb(e){this._internalRoot=e}Om.prototype.render=Rb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(je(409));Lm(e,t,null,null)};Om.prototype.unmount=Rb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wl(function(){Lm(null,e,null,null)}),t[Ao]=null}};function Om(e){this._internalRoot=e}Om.prototype.unstable_scheduleHydration=function(e){if(e){var t=lC();e={blockedOn:null,target:e,priority:t};for(var n=0;n<oa.length&&t!==0&&t<oa[n].priority;n++);oa.splice(n,0,e),n===0&&uC(e)}};function Lb(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Mm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function wk(){}function iO(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=Fh(a);i.call(d)}}var a=AE(t,r,e,0,null,!1,!1,"",wk);return e._reactRootContainer=a,e[Ao]=a.current,Id(e.nodeType===8?e.parentNode:e),wl(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Fh(c);l.call(d)}}var c=Ib(e,0,!1,null,null,!1,!1,"",wk);return e._reactRootContainer=c,e[Ao]=c.current,Id(e.nodeType===8?e.parentNode:e),wl(function(){Lm(t,c,n,r)}),c}function $m(e,t,n,r,s){var i=n._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var c=Fh(a);l.call(c)}}Lm(t,a,e,s)}else a=iO(n,t,e,s,r);return Fh(a)}oC=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Yu(t.pendingLanes);n!==0&&(Zw(t,n|1),cs(t,zn()),!(zt&6)&&(Dc=zn()+500,Oa()))}break;case 13:wl(function(){var r=Io(e,1);if(r!==null){var s=Wr();xi(r,e,1,s)}}),Tb(e,1)}};eb=function(e){if(e.tag===13){var t=Io(e,134217728);if(t!==null){var n=Wr();xi(t,e,134217728,n)}Tb(e,134217728)}};aC=function(e){if(e.tag===13){var t=wa(e),n=Io(e,t);if(n!==null){var r=Wr();xi(n,e,t,r)}Tb(e,t)}};lC=function(){return Zt};cC=function(e,t){var n=Zt;try{return Zt=e,t()}finally{Zt=n}};cx=function(e,t,n){switch(t){case"input":if(nx(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=Em(r);if(!s)throw Error(je(90));z1(r),nx(r,s)}}}break;case"textarea":H1(e,n);break;case"select":t=n.value,t!=null&&vc(e,!!n.multiple,t,!1)}};G1=Eb;X1=wl;var oO={usingClientEntryPoint:!1,Events:[ff,lc,Em,q1,Y1,Eb]},Lu={findFiberByHostInstance:il,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},aO={bundleType:Lu.bundleType,version:Lu.version,rendererPackageName:Lu.rendererPackageName,rendererConfig:Lu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Mo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Z1(e),e===null?null:e.stateNode},findFiberByHostInstance:Lu.findFiberByHostInstance||sO,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 yp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yp.isDisabled&&yp.supportsFiber)try{Sm=yp.inject(aO),Yi=yp}catch{}}_s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oO;_s.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Lb(t))throw Error(je(200));return rO(e,t,null,n)};_s.createRoot=function(e,t){if(!Lb(e))throw Error(je(299));var n=!1,r="",s=IE;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Ib(e,1,!1,null,null,n,!1,r,s),e[Ao]=t.current,Id(e.nodeType===8?e.parentNode:e),new Rb(t)};_s.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(je(188)):(e=Object.keys(e).join(","),Error(je(268,e)));return e=Z1(t),e=e===null?null:e.stateNode,e};_s.flushSync=function(e){return wl(e)};_s.hydrate=function(e,t,n){if(!Mm(t))throw Error(je(200));return $m(null,e,t,!0,n)};_s.hydrateRoot=function(e,t,n){if(!Lb(e))throw Error(je(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=IE;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=AE(t,null,e,1,n??null,s,!1,i,a),e[Ao]=t.current,Id(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Om(t)};_s.render=function(e,t,n){if(!Mm(t))throw Error(je(200));return $m(null,e,t,!1,n)};_s.unmountComponentAtNode=function(e){if(!Mm(e))throw Error(je(40));return e._reactRootContainer?(wl(function(){$m(null,null,e,!1,function(){e._reactRootContainer=null,e[Ao]=null})}),!0):!1};_s.unstable_batchedUpdates=Eb;_s.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Mm(n))throw Error(je(200));if(e==null||e._reactInternals===void 0)throw Error(je(38));return $m(e,t,n,!1,r)};_s.version="18.3.1-next-f1338f8080-20240426";function TE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(TE)}catch(e){console.error(e)}}TE(),T1.exports=_s;var ts=T1.exports,bk=ts;Gy.createRoot=bk.createRoot,Gy.hydrateRoot=bk.hydrateRoot;const RE=m.createContext(null);function Hx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function lO(){const e=Hx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function cO({children:e}){const[t,n]=m.useState(lO);m.useEffect(()=>{const i=()=>n(Hx(window.location.pathname));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const r=m.useCallback(i=>{const a=i.startsWith("/")?i:`/${i}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Hx(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(RE.Provider,{value:s,children:e})}function Ma(){const e=m.useContext(RE);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function uO(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const vk={};function Vx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&vk[t[0]]||(typeof t[0]=="string"&&(vk[t[0]]=new Date),uO(...t))}const LE=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function kk(e,t,n){e.loadNamespaces(t,LE(e,n))}function Sk(e,t,n,r){typeof n=="string"&&(n=[n]),n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,LE(e,r))}function dO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],s=t.options?t.options.fallbackLng:!1,i=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=t.services.backendConnector.state[`${l}|${c}`];return d===-1||d===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(i,e)))}function fO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Vx("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,e))return!1}}):dO(e,t,n)}const pO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,hO={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},mO=e=>hO[e],gO=e=>e.replace(pO,mO);let Wx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:gO};function yO(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Wx={...Wx,...e}}function xO(){return Wx}let OE;function wO(e){OE=e}function bO(){return OE}const vO={type:"3rdParty",init(e){yO(e.options.react),wO(e)}},kO=m.createContext();class SO{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const NO=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function pn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(kO)||{},i=n||r||bO();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new SO),!i){Vx("You will need to pass in an i18next instance by using initReactI18next");const w=(C,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(C)?C[C.length-1]:C,S=[w,{},!1];return S.t=w,S.i18n={},S.ready=!1,S}i.options.react&&i.options.react.wait!==void 0&&Vx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...xO(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let d=e||s||i.options&&i.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(d);const u=(i.isInitialized||i.initializedStoreOnce)&&d.every(w=>fO(w,i,a));function f(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],c)}const[p,h]=m.useState(f);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const v=NO(g),k=m.useRef(!0);m.useEffect(()=>{const{bindI18n:w,bindI18nStore:S}=a;k.current=!0,!u&&!l&&(t.lng?Sk(i,t.lng,d,()=>{k.current&&h(f)}):kk(i,d,()=>{k.current&&h(f)})),u&&v&&v!==g&&k.current&&h(f);function C(){k.current&&h(f)}return w&&i&&i.on(w,C),S&&i&&i.store.on(S,C),()=>{k.current=!1,w&&i&&w.split(" ").forEach(N=>i.off(N,C)),S&&i&&S.split(" ").forEach(N=>i.store.off(N,C))}},[i,g]);const y=m.useRef(!0);m.useEffect(()=>{k.current&&!y.current&&h(f),y.current=!1},[i,c]);const b=[p,i,u];if(b.t=p,b.i18n=i,b.ready=u,u||!u&&!l)return b;throw new Promise(w=>{t.lng?Sk(i,t.lng,d,()=>w()):kk(i,d,()=>w())})}const ME="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20fill='none'%20role='img'%20aria-label='AgentFlow'%3e%3ctitle%3eAgentFlow%3c/title%3e%3crect%20width='32'%20height='32'%20rx='9'%20fill='%23131313'/%3e%3crect%20x='4.5'%20y='11'%20width='10.5'%20height='10'%20rx='3'%20fill='%232a2a2a'%20stroke='%237c4dff'%20stroke-width='1.2'/%3e%3cpath%20d='M15.25%2014.25C17.8%2012.2%2019.2%209.8%2022.25%209.25'%20stroke='%23cdbdff'%20stroke-width='1.65'%20stroke-linecap='round'%20/%3e%3cpath%20d='M15.25%2017.75C17.8%2019.8%2019.2%2022.2%2022.25%2022.75'%20stroke='%237c4dff'%20stroke-width='1.65'%20stroke-linecap='round'%20opacity='0.92'%20/%3e%3crect%20x='21.75'%20y='6'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%23e8deff'%20stroke-width='0.95'%20opacity='0.95'/%3e%3crect%20x='21.75'%20y='19'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%239ecaff'%20stroke-width='0.95'%20opacity='0.9'/%3e%3c/svg%3e",jO=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],CO=[{href:"https://agentflow-hub.com",icon:"hub",labelKey:"common:links.hub"},{href:"https://docs.agentflow-hub.com",icon:"menu_book",labelKey:"common:links.docs"},{href:"https://github.com/pproject-github/agentflow",icon:"code",labelKey:"common:links.github"}];function EO(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function _O({authUser:e,onLogout:t}){const{path:n,navigate:r}=Ma(),{t:s}=pn(),[i,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),o.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[o.jsxs("div",{className:"af-brand",children:[o.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:o.jsx("img",{src:ME,alt:"",width:"36",height:"36",decoding:"async"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),o.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),o.jsx("nav",{className:"af-nav",children:jO.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(EO(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[o.jsx("span",{className:"material-symbols-outlined",children:l.icon}),o.jsx("span",{children:s(l.labelKey)})]},l.to))}),o.jsxs("div",{className:"af-sidebar-footer",children:[o.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[o.jsx("span",{className:"material-symbols-outlined",children:"person"}),o.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),o.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:o.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!i&&CO.map(l=>{const c=s(l.labelKey);return o.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:o.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const $E="agentflow.pipelineRecent",PO=50,AO=15;function IO(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function DE(){if(typeof localStorage>"u")return[];const e=localStorage.getItem($E);return e?IO(e).filter(t=>t&&typeof t.flowId=="string"&&(t.flowSource==="user"||t.flowSource==="builtin"||t.flowSource==="admin"||t.flowSource==="workspace")&&t.kind==="opened"&&typeof t.at=="number"):[]}function xp(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=DE(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,PO);try{localStorage.setItem($E,JSON.stringify(i))}catch{}}function TO(e,t){const n=e.filter(r=>r.id===t);return n.length===0||n.some(r=>(r.source??"user")==="user")?"user":n.some(r=>r.source==="workspace")?"workspace":n.some(r=>r.source==="admin")?"admin":n.some(r=>r.source==="builtin")?"builtin":n[0].source??"user"}function Ux(e,t){const n=Date.now(),r=Math.max(0,n-e),s=Math.floor(r/1e3);if(s<60)return t("flow:time.justNow");const i=Math.floor(s/60);if(i<60)return t("flow:time.minutesAgo",{n:i});const a=Math.floor(i/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,d=new Date(c);if(d.setDate(d.getDate()-1),l.toDateString()===d.toDateString())return t("flow:time.yesterday");const u=Math.floor(a/24);return u<7?t("flow:time.daysAgo",{n:u}):`${l.getMonth()+1}/${l.getDate()}`}function RO(e,t){if(e==null||!Number.isFinite(e)||e<=0)return"--";if(e<1e3)return t("flow:time.milliseconds",{n:Math.max(1,Math.round(e))});const n=e/1e3;return t("flow:time.seconds",{n:n>=10?Math.round(n):n.toFixed(1)})}function LO(e,t,n){const r=[];for(const s of e)!s||typeof s.flowId!="string"||typeof s.at!="number"||r.push({flowId:s.flowId,flowSource:TO(n,s.flowId),kind:"executed",at:s.at});for(const s of t)r.push({flowId:s.flowId,flowSource:s.flowSource,kind:"opened",at:s.at});return r.sort((s,i)=>i.at-s.at),r.slice(0,AO)}var ws=Uint8Array,mc=Uint16Array,OO=Int32Array,FE=new ws([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),zE=new ws([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),MO=new ws([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),BE=function(e,t){for(var n=new mc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new OO(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},HE=BE(FE,2),VE=HE.b,$O=HE.r;VE[28]=258,$O[258]=28;var DO=BE(zE,0),FO=DO.b,Kx=new mc(32768);for(var bn=0;bn<32768;++bn){var Jo=(bn&43690)>>1|(bn&21845)<<1;Jo=(Jo&52428)>>2|(Jo&13107)<<2,Jo=(Jo&61680)>>4|(Jo&3855)<<4,Kx[bn]=((Jo&65280)>>8|(Jo&255)<<8)>>1}var fd=function(e,t,n){for(var r=e.length,s=0,i=new mc(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new mc(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new mc(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],u=t-e[s],f=a[e[s]-1]++<<u,p=f|(1<<u)-1;f<=p;++f)l[Kx[f]>>c]=d}else for(l=new mc(r),s=0;s<r;++s)e[s]&&(l[s]=Kx[a[e[s]-1]++]>>15-e[s]);return l},hf=new ws(288);for(var bn=0;bn<144;++bn)hf[bn]=8;for(var bn=144;bn<256;++bn)hf[bn]=9;for(var bn=256;bn<280;++bn)hf[bn]=7;for(var bn=280;bn<288;++bn)hf[bn]=8;var WE=new ws(32);for(var bn=0;bn<32;++bn)WE[bn]=5;var zO=fd(hf,9,1),BO=fd(WE,5,1),ey=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},li=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ty=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},HO=function(e){return(e+7)/8|0},Ob=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new ws(e.subarray(t,n))},VO=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Vs=function(e,t,n){var r=new Error(t||VO[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Vs),!n)throw r;return r},WO=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new ws(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new ws(s*3));var d=function(Ne){var Pe=n.length;if(Ne>Pe){var Ie=new ws(Math.max(Pe*2,Ne));Ie.set(n),n=Ie}},u=t.f||0,f=t.p||0,p=t.b||0,h=t.l,g=t.d,v=t.m,k=t.n,y=s*8;do{if(!h){u=li(e,f,1);var b=li(e,f+1,3);if(f+=3,b)if(b==1)h=zO,g=BO,v=9,k=5;else if(b==2){var N=li(e,f,31)+257,I=li(e,f+10,15)+4,M=N+li(e,f+5,31)+1;f+=14;for(var R=new ws(M),F=new ws(19),O=0;O<I;++O)F[MO[O]]=li(e,f+O*3,7);f+=I*3;for(var L=ey(F),W=(1<<L)-1,D=fd(F,L,1),O=0;O<M;){var $=D[li(e,f,W)];f+=$&15;var w=$>>4;if(w<16)R[O++]=w;else{var A=0,B=0;for(w==16?(B=3+li(e,f,3),f+=2,A=R[O-1]):w==17?(B=3+li(e,f,7),f+=3):w==18&&(B=11+li(e,f,127),f+=7);B--;)R[O++]=A}}var P=R.subarray(0,N),T=R.subarray(N);v=ey(P),k=ey(T),h=fd(P,v,1),g=fd(T,k,1)}else Vs(1);else{var w=HO(f)+4,S=e[w-4]|e[w-3]<<8,C=w+S;if(C>s){c&&Vs(0);break}l&&d(p+S),n.set(e.subarray(w,C),p),t.b=p+=S,t.p=f=C*8,t.f=u;continue}if(f>y){c&&Vs(0);break}}l&&d(p+131072);for(var E=(1<<v)-1,Y=(1<<k)-1,Q=f;;Q=f){var A=h[ty(e,f)&E],U=A>>4;if(f+=A&15,f>y){c&&Vs(0);break}if(A||Vs(2),U<256)n[p++]=U;else if(U==256){Q=f,h=null;break}else{var re=U-254;if(U>264){var O=U-257,ue=FE[O];re=li(e,f,(1<<ue)-1)+VE[O],f+=ue}var ge=g[ty(e,f)&Y],le=ge>>4;ge||Vs(3),f+=ge&15;var T=FO[le];if(le>3){var ue=zE[le];T+=ty(e,f)&(1<<ue)-1,f+=ue}if(f>y){c&&Vs(0);break}l&&d(p+131072);var ce=p+re;if(p<T){var de=i-T,Ae=Math.min(T,ce);for(de+p<0&&Vs(3);p<Ae;++p)n[p]=r[de+p]}for(;p<ce;++p)n[p]=n[p-T]}}t.l=h,t.p=Q,t.b=p,t.f=u,h&&(u=1,t.m=v,t.d=g,t.n=k)}while(!u);return p!=n.length&&a?Ob(n,0,p):n.subarray(0,p)},UO=new ws(0),Ui=function(e,t){return e[t]|e[t+1]<<8},pi=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ny=function(e,t){return pi(e,t)+pi(e,t+4)*4294967296};function KO(e,t){return WO(e,{i:2},t&&t.out,t&&t.dictionary)}var qx=typeof TextDecoder<"u"&&new TextDecoder,qO=0;try{qx.decode(UO,{stream:!0}),qO=1}catch{}var YO=function(e){for(var t="",n=0;;){var r=e[n++],s=(r>127)+(r>223)+(r>239);if(n+s>e.length)return{s:t,r:Ob(e,n-1)};s?s==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):s&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function GO(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else{if(qx)return qx.decode(e);var s=YO(e),i=s.s,n=s.r;return n.length&&Vs(8),i}}var XO=function(e,t){return t+30+Ui(e,t+26)+Ui(e,t+28)},JO=function(e,t,n){var r=Ui(e,t+28),s=GO(e.subarray(t+46,t+46+r),!(Ui(e,t+8)&2048)),i=t+46+r,a=pi(e,t+20),l=n&&a==4294967295?QO(e,i):[a,pi(e,t+24),pi(e,t+42)],c=l[0],d=l[1],u=l[2];return[Ui(e,t+10),c,d,s,i+Ui(e,t+30)+Ui(e,t+32),u]},QO=function(e,t){for(;Ui(e,t)!=1;t+=4+Ui(e,t+2));return[ny(e,t+12),ny(e,t+4),ny(e,t+20)]};function ZO(e,t){for(var n={},r=e.length-22;pi(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Vs(13);var s=Ui(e,r+8);if(!s)return{};var i=pi(e,r+16),a=i==4294967295||s==65535;if(a){var l=pi(e,r-12);a=pi(e,l)==101075792,a&&(s=pi(e,l+32),i=pi(e,l+48))}for(var c=0;c<s;++c){var d=JO(e,i,a),u=d[0],f=d[1],p=d[2],h=d[3],g=d[4],v=d[5],k=XO(e,v);i=g,u?u==8?n[h]=KO(e.subarray(k,k+f),{out:new ws(p)}):Vs(14,"unknown compression type "+u):n[h]=Ob(e,k,k+f)}return n}const eM=8*1024*1024,tM=500;function nM(e){if(e==null||typeof e!="string")return null;let t=e.replace(/\\/g,"/").replace(/^\uFEFF/,"");for(;t.startsWith("/");)t=t.slice(1);if(!t||t.includes("\0")||/^[a-zA-Z]:/.test(t))return null;const n=t.split("/").filter(r=>r.length>0);for(const r of n)if(r==="."||r==="..")return null;return n.join("/")}function rM(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function sM(e){const t=e.toLowerCase();if(t==="flow.yaml"||t==="flow.yml")return"";const n="/flow.yaml",r="/flow.yml";let s=null;if(t.endsWith(n))s=e.slice(0,-n.length);else if(t.endsWith(r))s=e.slice(0,-r.length);else return null;return s.includes("/")?null:s}const iM=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function oM(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=ZO(t),r=new Map;let s=0,i=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const u=nM(c);if(!u||rM(u))continue;const f=(d==null?void 0:d.length)??0;if(s+=f,s>eM||(i+=1,i>tM))return null;r.set(u,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=sM(c);d!==null&&a.add(d)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return iM.test(l)?l:null}catch{return null}}const ry=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function aM({file:e,onClose:t,onImported:n}){const{t:r}=pn(),s=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[d,u]=m.useState("user"),[f,p]=m.useState(!1),[h,g]=m.useState(""),[v,k]=m.useState(null),y=v??e;m.useEffect(()=>{const C=requestAnimationFrame(()=>{var N;return(N=i.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(C)},[]),m.useEffect(()=>{let C=!1;return(async()=>{const N=y.name||"",I=N.toLowerCase();let M="";if(I.endsWith(".zip")){if(M=await oM(y)||"",!M){const R=N.replace(/\.zip$/i,"");ry.test(R)&&(M=R)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const R=N.replace(/\.ya?ml$/i,"");ry.test(R)&&(M=R)}C||c(M)})(),()=>{C=!0}},[y]);const b=l.trim(),w=b.length>0&&ry.test(b);async function S(C){if(C.preventDefault(),!(!w||f)){p(!0),g("");try{const N=new FormData;N.set("flowId",b),N.set("targetSpace",d),N.set("file",y,y.name);const I=await fetch("/api/flows/import",{method:"POST",body:N}),M=await I.json().catch(()=>({}));if(!I.ok){g(typeof M.error=="string"?M.error:r("project:importModal.importFailed"));return}n({id:M.flowId,source:M.flowSource??"user"})}catch(N){g(String((N==null?void 0:N.message)||N))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&t()},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:S,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),o.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:C=>{var I;const N=(I=C.target.files)==null?void 0:I[0];N&&k(N),C.target.value=""}}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:C=>c(C.target.value),"aria-invalid":b.length>0&&!w}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),o.jsx("div",{className:"af-import-repick",children:o.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var C;return(C=a.current)==null?void 0:C.click()},children:r("project:importModal.changeFile")})}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const lM=/^[a-zA-Z][a-zA-Z0-9_-]*$/,Nk="af:newPipelineGuide";function cM({open:e,onClose:t,onCreated:n}){const{t:r}=pn(),s=m.useId(),i=m.useRef(null),[a,l]=m.useState(""),[c,d]=m.useState(""),[u,f]=m.useState("user"),[p,h]=m.useState(!1),[g,v]=m.useState(""),[k,y]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),d(""),f("user"),v(""),h(!1),localStorage.getItem(Nk)==="true"&&y(!0);const I=requestAnimationFrame(()=>{var M;return(M=i.current)==null?void 0:M.focus()});return()=>cancelAnimationFrame(I)},[e]);const b=()=>{localStorage.removeItem(Nk),y(!1)};if(!e)return null;const w=a.trim(),S=w.length>0&&lM.test(w);async function C(N){if(N.preventDefault(),!(!S||p)){h(!0),v(""),b();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:w,description:c.trim(),targetSpace:u})}),M=await I.json().catch(()=>({}));if(!I.ok){v(typeof M.error=="string"?M.error:r("project:newPipelineModal.createFailed"));return}n({id:M.flowId,source:M.flowSource??"user"})}catch(I){v(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&(b(),t())},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{b(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),k?o.jsx("div",{className:"af-new-pipeline-guide",children:o.jsxs("div",{className:"af-new-pipeline-guide-content",children:[o.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),o.jsxs("div",{className:"af-new-pipeline-guide-text",children:[o.jsx("p",{children:o.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),o.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),o.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:C,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:N=>l(N.target.value),"aria-invalid":w.length>0&&!S}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(k?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(k?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:N=>d(N.target.value)}),k?o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?o.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{b(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!S||p,children:r(p?"project:newPipelineModal.creating":k?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const UE="agentflow.pipelineViewPreference";function KE(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function qE(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(UE)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function uM(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(UE,JSON.stringify(e))}catch{}}function zh(e){return e==="pipeline"?"pipeline":"workspace"}function dM(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function YE(e,t,n,r=!1){if(!e)return;const s=qE();s[KE(e,t,r)]={view:zh(n),at:Date.now()},uM(s)}function fM(e,t="workspace"){if(!(e!=null&&e.id))return zh(t);const r=qE()[KE(e.id,e.source??"user",!!e.archived)],s=zh((r==null?void 0:r.view)||t);return s==="pipeline"&&!dM(e)?"workspace":s}function Mb(e,t="workspace"){if(!(e!=null&&e.id))return t==="pipeline"?"/flow":"/workspace";const n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&n.set(t==="pipeline"?"flowArchived":"archived","1"),`/${zh(t)==="pipeline"?"flow":"workspace"}?${n.toString()}`}function wp(e,t="workspace"){return Mb(e,fM(e,t))}function pM(e,t){const n=String(e||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),r=String(t||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=Number.isFinite(n[i])?n[i]:0,l=Number.isFinite(r[i])?r[i]:0;if(a!==l)return a>l?1:-1}return 0}function Yx(e){return String((e==null?void 0:e.version)||"").trim()}function hM(e){const t=Yx(e),n=[(e==null?void 0:e.agent)||"codex",(e==null?void 0:e.kind)||"skill"];return t&&n.push(`v${t}`),n.join(" · ")}function mM({onChanged:e}){const[t,n]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=m.useState([]),[i,a]=m.useState(""),[l,c]=m.useState("keyword"),[d,u]=m.useState([]),[f,p]=m.useState({}),[h,g]=m.useState(""),[v,k]=m.useState(""),[y,b]=m.useState(""),w=m.useCallback(async()=>{k("");try{const[R,F]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),O=await R.json().catch(()=>({}));R.ok&&n({available:!!O.available,version:typeof O.version=="string"?O.version:"",loggedIn:!!O.loggedIn,user:typeof O.user=="string"?O.user:"",error:typeof O.error=="string"?O.error:""});const L=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+F.status);s(Array.isArray(L.skills)?L.skills:[]),p({})}catch(R){k(String(R.message||R))}},[]);m.useEffect(()=>{w()},[w]);const S=m.useCallback(async()=>{const R=i.trim();if(R){g("search"),k(""),b("");try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(R)}&mode=${encodeURIComponent(l)}`),O=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+F.status);u(Array.isArray(O.items)?O.items:[])}catch(F){k(String(F.message||F))}finally{g("")}}},[i,l]),C=m.useCallback(async(R,F=!1)=>{const O=R&&typeof R=="object"?R:null,L=String(O?O.slug||O.name||O.collection||O.skillId||O.id:R||"").trim();if(L){g(`install:${L}`),k(""),b("");try{const W=O?{slug:O.slug||"",skillId:O.skillId||"",collection:O.collection||"",collectionName:O.collection&&O.name||"",target:"global",agent:"codex",force:F}:{slug:L,target:"global",agent:"codex",force:F},D=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+D.status);b(F?`已更新 ${L}`:`已安装 ${L}`),await w(),typeof e=="function"&&await e()}catch(W){k(String(W.message||W))}finally{g("")}}},[w,e]),N=m.useCallback(async()=>{if(r.length!==0){g("check-updates"),k(""),b("");try{const R=await Promise.all(r.map(async L=>{const W=String(L.name||"").trim();if(!W)return null;try{const D=await fetch(`/api/skillhub/search?q=${encodeURIComponent(W)}&mode=keyword`),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+D.status);const A=Array.isArray($.items)?$.items:[],B=A.find(Y=>Y.slug===W||Y.name===W||Y.id===W)||A[0],P=Yx(L),T=String((B==null?void 0:B.version)||"").trim();let E="unknown";return B?P&&T?E=pM(P,T)<0?"update":"current":T&&(E="remote-only"):E="missing",[W,{state:E,latestVersion:T,installedVersion:P,summary:(B==null?void 0:B.summary)||""}]}catch(D){return[W,{state:"error",error:String(D.message||D),installedVersion:Yx(L)}]}})),F={};for(const L of R)L&&(F[L[0]]=L[1]);p(F);const O=Object.values(F).filter(L=>L.state==="update").length;b(O>0?`发现 ${O} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[r]),I=m.useCallback(async R=>{const F=String(R||"").trim();if(F){g(`uninstall:${F}`),k(""),b("");try{const O=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:F,target:"global",agent:"codex"})}),L=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+O.status);b(`已卸载 ${F}`),await w(),typeof e=="function"&&await e()}catch(O){k(String(O.message||O))}finally{g("")}}},[w,e]),M=m.useCallback(async()=>{g("update-cli"),k(""),b("");try{const R=await fetch("/api/skillhub/update",{method:"POST"}),F=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof F.error=="string"?F.error:"HTTP "+R.status);b("SkillHub CLI 已更新"),await w()}catch(R){k(String(R.message||R))}finally{g("")}},[w]);return o.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"搜索、安装、更新和卸载 Codex 全局 skills。"})]}),o.jsxs("div",{className:"af-set-skillhub-head-actions",children:[o.jsxs("div",{className:"af-set-skillhub-status",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),o.jsx("span",{children:t.loggedIn?`已登录 ${t.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(t.available?" af-set-badge--ok":" af-set-badge--err"),children:t.available?`v${t.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:w,disabled:!!h,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!h||r.length===0,children:h==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:M,disabled:!!h,children:h==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),o.jsxs("div",{className:"af-set-skillhub-search",children:[o.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:l,onChange:R=>{c(R.target.value),u([])},children:[o.jsx("option",{value:"keyword",children:"关键词"}),o.jsx("option",{value:"skillId",children:"Skill ID"}),o.jsx("option",{value:"collectionId",children:"Collection ID"})]}),o.jsx("input",{className:"af-set-input af-set-input--sm",value:i,onChange:R=>a(R.target.value),onKeyDown:R=>{R.key==="Enter"&&S()},placeholder:l==="collectionId"?"输入 collection id,例如 1":l==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>S(),disabled:!i.trim()||h==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),h==="search"?"搜索中…":"搜索"]})]}),v?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:v}):null,y?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:y}):null,o.jsxs("div",{className:"af-set-skillhub-grid",children:[o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"已安装"}),o.jsx("span",{children:r.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:r.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 Codex 全局 skills"}):r.map(R=>{const F=f[R.name],O=!F||F.state==="update"||F.state==="remote-only"||F.state==="unknown"||F.state==="error",L=h===`install:${R.name}`?"更新中…":(F==null?void 0:F.state)==="current"?"已最新":(F==null?void 0:F.state)==="update"&&F.latestVersion?`更新到 v${F.latestVersion}`:(F==null?void 0:F.state)==="remote-only"&&F.latestVersion?`安装 v${F.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:R.displayName||R.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:hM(R)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:F?F.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",F.installedVersion?`v${F.installedVersion} -> `:"","v",F.latestVersion]}):F.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",F.latestVersion||F.installedVersion]}):F.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",F.latestVersion,",本地版本未知"]}):F.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):F.state==="error"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>C(R.name,!0),disabled:!!h||!O,children:L}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>I(R.name),disabled:!!h,children:"卸载"})]})]},`${R.agent}:${R.path}:${R.name}`)})})]}),o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"搜索结果"}),o.jsx("span",{children:d.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(R=>{const F=R.slug||R.name,O=R.kind==="collection"||R.collection,L=!O&&r.some(W=>W.name===F||W.name===R.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:R.name||F}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[O?`collection:${R.collection}`:F,R.skillId?` · id:${R.skillId}`:"",R.version?` · ${R.version}`:""]}),R.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:R.summary}):null]}),o.jsx("button",{type:"button",className:L?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>C(R,L),disabled:!!h,children:L?"更新":O?"安装合集":"安装"})]},R.id||F)})})]})]})]})}function va(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function gM(e){return{version:1,collections:va({collections:e})}}function Ea(e,t){const n=new Set((Array.isArray(t)?t:[]).map(r=>r.key).filter(Boolean));return(Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).filter(r=>n.has(r))}function GE(e,t){const n=new Set(Array.isArray(e)?e:[]);for(const r of Array.isArray(t)?t:[])r&&n.add(r);return Array.from(n)}function XE(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function JE(e,t,n){const r=Ea(e,n);if(r.length===0)return"empty";const s=r.filter(i=>t.has(i)).length;return s===0?"none":s===r.length?"all":"partial"}function yM(e,t,n){const r=String(e||"").trim().toLowerCase(),s=va({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return Ea(s,t)}function QE(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=va({collections:r}),l=yM(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const d=localStorage.getItem(e);if(d!==null){const u=JSON.parse(d);if(Array.isArray(u)){const f=new Set(s),p=u.map(String).filter(y=>f.has(y));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),g=new Set(l),v=l.length>0&&l.every(y=>h.has(y)),k=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const b=Ea(y,n);return b.length>0&&b.every(w=>h.has(w))});return l.length>0&&k&&!v?c:p}}}catch{}return c}function Ou(e){return e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function xM(e){return e==="executed"?"material-symbols-outlined af-act-icon af-act-icon--executed":"material-symbols-outlined af-act-icon af-act-icon--opened"}function Gx(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function ZE(e){const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${e.id}`:t==="admin"?`admin builtin / ${e.ownerUserId||"-"} / ${e.id}`:t==="workspace"?e.archived?`.workspace/agentflow/pipelines/_archived / ${e.id}`:`.workspace/agentflow/pipelines / ${e.id}`:e.archived?`~/agentflow/pipelines/_archived / ${e.id}`:`~/agentflow/pipelines / ${e.id}`}const wM="project:defaultCardDesc";function e_(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(wM)}function bM(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fn({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return o.jsx("span",{className:t,children:s});const i=new RegExp(`(${bM(r)})`,"gi"),a=s.split(i);return o.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?o.jsx("mark",{className:"af-search-hit",children:l},c):o.jsx("span",{children:l},c))})}function vM(e,t,n){const r=[String(e.id),e_(e,n),ZE(e),Gx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
+ `).toLowerCase()}function kM(e,t,n){return t?vM(e,t,n).includes(t):!0}function SM(e,t){const n=e.trim().toLowerCase();if(!n)return!0;const r=String(t.flowId).toLowerCase(),s=String(t.flowSource??"user").toLowerCase();return r.includes(n)||s.includes(n)}function sy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
+ `).toLowerCase().includes(n):!0}function jk(e,t){return e==="flow"?t("project:resourceSource.flow"):e==="marketplace"?t("project:resourceSource.marketplace"):e==="project"?t("project:resourceSource.global"):e||t("project:resourceSource.global")}function Ck(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const NM=["all","agent","control","provide","marketplace"],jM=["all","agent","control","provide"],t_="agentflow.projects.activityPanelOpen",Xx="agentflow.projects.activitySelected";function CM(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(t_);return e!=="0"}function Ek(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function EM(){return typeof localStorage>"u"?"":localStorage.getItem(Xx)||""}function bp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Nn(e){return(e==null?void 0:e.key)||`${(e==null?void 0:e.id)||(e==null?void 0:e.name)||""}:${(e==null?void 0:e.source)||""}:${(e==null?void 0:e.packageId)||""}`}function Qo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function n_(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.instances;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):t&&typeof t=="object"?Object.entries(t).map(([r,s])=>({...s&&typeof s=="object"?s:{},instanceId:(s==null?void 0:s.instanceId)||r})):[]}function r_(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.edges;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):[]}function Jx(e,t){return String((e==null?void 0:e.instanceId)||(e==null?void 0:e.id)||(e==null?void 0:e.nodeId)||`node_${t+1}`)}function _k(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Jx(e,t))}function _M(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function Pk(e,t){return String(t==="source"?(e==null?void 0:e.source)||(e==null?void 0:e.from)||(e==null?void 0:e.sourceId)||(e==null?void 0:e.fromNode)||(e==null?void 0:e.fromInstanceId)||"":(e==null?void 0:e.target)||(e==null?void 0:e.to)||(e==null?void 0:e.targetId)||(e==null?void 0:e.toNode)||(e==null?void 0:e.toInstanceId)||"")}function PM(e){const t=(e==null?void 0:e.sourceHandle)||(e==null?void 0:e.fromHandle)||(e==null?void 0:e.output)||(e==null?void 0:e.outputName),n=(e==null?void 0:e.targetHandle)||(e==null?void 0:e.toHandle)||(e==null?void 0:e.input)||(e==null?void 0:e.inputName);return t&&n?`${t} -> ${n}`:String(t||n||"")}function iy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function AM(e){const t=Number(e==null?void 0:e.x),n=Number(e==null?void 0:e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}function IM(e,t){const n=e.map(u=>u.id),r=new Set(n),s=new Map(n.map(u=>[u,0])),i=new Map(n.map(u=>[u,[]]));t.forEach(u=>{var f;!r.has(u.sourceId)||!r.has(u.targetId)||(s.set(u.targetId,(s.get(u.targetId)||0)+1),(f=i.get(u.sourceId))==null||f.push(u.targetId))});const a=new Map,l=n.filter(u=>(s.get(u)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(u=>a.set(u,0));for(let u=0;u<l.length;u+=1){const f=l[u],p=(a.get(f)||0)+1;for(const h of i.get(f)||[])(!a.has(h)||p>a.get(h))&&(a.set(h,p),l.push(h))}n.forEach((u,f)=>{a.has(u)||a.set(u,f%3)});const c=new Map,d=new Map;return n.forEach(u=>{const f=a.get(u)||0,p=c.get(f)||0;c.set(f,p+1),d.set(u,{x:f*190,y:p*86})}),d}function TM(e){var v,k,y,b;const t=n_(e),n=r_(e),r=new Map(t.map((w,S)=>[Jx(w,S),_k(w,S)])),s=t.map((w,S)=>({id:Jx(w,S),title:_k(w,S),meta:_M(w)})),i=n.map((w,S)=>{const C=Pk(w,"source"),N=Pk(w,"target");return{key:(w==null?void 0:w.id)||`${C}-${N}-${S}`,sourceId:C,targetId:N,source:r.get(C)||C||"?",target:r.get(N)||N||"?",label:PM(w)}}),a=(k=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&k.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(b=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&b.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=IM(s,i),d=s.map(w=>{const S=AM(a[w.id])||c.get(w.id)||{x:0,y:0},C=l[w.id]&&typeof l[w.id]=="object"?l[w.id]:{},N=Number(C.width),I=Number(C.height),M=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),R=Math.max(48,Math.min(76,Number.isFinite(I)?I*.46:54));return{...w,x:S.x,y:S.y,width:M,height:R}}),u=new Map(d.map(w=>[w.id,w])),f=i.map(w=>{const S=u.get(w.sourceId),C=u.get(w.targetId);if(!S||!C)return null;const N=S.x+S.width,I=S.y+S.height/2,M=C.x,R=C.y+C.height/2,F=Math.max(48,Math.abs(M-N)*.45);return{...w,path:`M ${N} ${I} C ${N+F} ${I}, ${M-F} ${R}, ${M} ${R}`,labelX:(N+M)/2,labelY:(I+R)/2}}).filter(Boolean),p=d.reduce((w,S)=>({minX:Math.min(w.minX,S.x),minY:Math.min(w.minY,S.y),maxX:Math.max(w.maxX,S.x+S.width),maxY:Math.max(w.maxY,S.y+S.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,g=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:i,diagram:{nodes:d,edges:f,viewBox:g}}}function Yl({resourceKind:e="",authUser:t=null}){var Vt,gr,Rs,ms,Yr,Ls;const{t:n}=pn(),{navigate:r,path:s}=Ma(),[i,a]=m.useState(e||"all"),[l,c]=m.useState([]),[d,u]=m.useState([]),[f,p]=m.useState([]),[h,g]=m.useState([]),[v,k]=m.useState([]),[y,b]=m.useState(""),[w,S]=m.useState(!1),[C,N]=m.useState([]),[I,M]=m.useState(""),[R,F]=m.useState(""),[O,L]=m.useState(!1),[W,D]=m.useState(!1),[$,A]=m.useState(!1),[B,P]=m.useState(null),[T,E]=m.useState(!1),[Y,Q]=m.useState(""),[U,re]=m.useState(CM),[ue,ge]=m.useState(EM),[le,ce]=m.useState("all"),[de,Ae]=m.useState(""),[Ne,Pe]=m.useState("overview"),[Ie,qe]=m.useState({}),[ct,Ge]=m.useState(""),[xt,Fe]=m.useState({}),[ee,De]=m.useState(""),[tt,Nt]=m.useState(""),[en,fr]=m.useState({}),[jr,ae]=m.useState(""),[ve,Xe]=m.useState(""),[ot,nt]=m.useState(""),[hn,Mn]=m.useState(""),[Tn,tr]=m.useState(""),[pr,Bt]=m.useState(!1),[nr,ye]=m.useState(""),[ze,$t]=m.useState({hiddenBuiltins:[],promoted:[]}),kt=m.useRef(0),Ut=m.useRef(0),qr=m.useCallback(async()=>{var he,Se;const V=++Ut.current;M("");try{const Te=await fetch("/api/flows");if(V!==Ut.current)return;if(!Te.ok)throw new Error("HTTP "+Te.status);const $e=await Te.json();if(V!==Ut.current)return;c(Array.isArray($e)?$e:[])}catch(Te){if(V!==Ut.current)return;c([]),M(String(Te.message||Te))}try{const Te=await fetch("/api/pipeline-recent-runs");if(V!==Ut.current)return;if(Te.ok){const $e=await Te.json();if(V!==Ut.current)return;N(Array.isArray($e.runs)?$e.runs:[])}else N([])}catch{if(V!==Ut.current)return;N([])}if(t!=null&&t.isAdmin)try{const Te=await fetch("/api/admin/builtin-flows");if(V!==Ut.current)return;const $e=await Te.json().catch(()=>({}));Te.ok&&$t({hiddenBuiltins:Array.isArray((he=$e==null?void 0:$e.config)==null?void 0:he.hiddenBuiltins)?$e.config.hiddenBuiltins:[],promoted:Array.isArray((Se=$e==null?void 0:$e.config)==null?void 0:Se.promoted)?$e.config.promoted:[]})}catch{if(V!==Ut.current)return;$t({hiddenBuiltins:[],promoted:[]})}else $t({hiddenBuiltins:[],promoted:[]});L(!0)},[t==null?void 0:t.isAdmin]),$n=m.useCallback(async(V,he)=>{if(!(t!=null&&t.isAdmin)||!(V!=null&&V.id))return;const Se=`${he}:${V.source}:${V.id}`;ye(Se),M("");try{const Te=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:he,flowId:V.id,ownerUserId:V.ownerUserId||t.userId})}),$e=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error($e.error||"更新内置配置失败");await qr()}catch(Te){M(String(Te.message||Te))}finally{ye("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,qr]),Gn=m.useCallback(async()=>{F(""),D(!1);try{const[V,he,Se,Te]=await Promise.all([fetch("/api/nodes"),fetch("/api/skills"),fetch("/api/skill-collections"),fetch("/api/marketplace/flow-snippets")]),$e=await V.json().catch(()=>({})),Dt=await he.json().catch(()=>({})),wt=await Se.json().catch(()=>({})),Ft=await Te.json().catch(()=>({}));if(!V.ok)throw new Error($e.error||"Nodes HTTP "+V.status);if(!he.ok)throw new Error(Dt.error||"Skills HTTP "+he.status);if(!Se.ok)throw new Error(wt.error||"Collections HTTP "+Se.status);if(!Te.ok)throw new Error(Ft.error||"Flow snippets HTTP "+Te.status);u(Array.isArray($e.nodes)?$e.nodes:Array.isArray($e)?$e:[]),p(Array.isArray(Dt.skills)?Dt.skills:[]),k(va(wt)),g(Array.isArray(Ft.snippets)?Ft.snippets:[])}catch(V){u([]),p([]),g([]),k([]),F(String(V.message||V))}finally{D(!0)}},[]);m.useEffect(()=>{L(!1),qr(),Gn()},[qr,Gn]),m.useEffect(()=>{try{localStorage.setItem(t_,U?"1":"0")}catch{}},[U]),m.useEffect(()=>{try{ue?localStorage.setItem(Xx,ue):localStorage.removeItem(Xx)}catch{}},[ue]),m.useEffect(()=>{let V=!1;return fetch("/api/ui-context").then(he=>he.json()).then(he=>{V||Bt(!!he.hideCommunityLinks)}).catch(()=>{}),()=>{V=!0}},[]);const rr=m.useCallback(async V=>{const he=va({collections:V});S(!0),F("");try{const Se=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(gM(he))}),Te=await Se.json().catch(()=>({}));if(!Se.ok)throw new Error(Te.error||"Collections HTTP "+Se.status);k(va(Te))}catch(Se){F(String(Se.message||Se))}finally{S(!1)}},[]),Fo=m.useCallback(()=>{const V=y.trim();if(!V)return;const he=V.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Se=new Set(v.map(wt=>wt.id));let Te=he,$e=2;for(;Se.has(Te);)Te=`${he}-${$e++}`;const Dt=Date.now();rr([...v,{id:Te,name:V,skillKeys:[],createdAt:Dt,updatedAt:Dt}]),b(""),ce(`collection:${Te}`)},[y,rr,v]),so=m.useCallback(V=>{const he=v.find(Te=>Te.id===V);if(he!=null&&he.builtin)return;const Se=v.filter(Te=>Te.id!==V);le===`collection:${V}`&&ce("all"),rr(Se)},[le,rr,v]),zo=m.useCallback((V,he,Se)=>{const Te=String(he||"").trim();if(!Te)return;const $e=Date.now(),Dt=v.map(wt=>{if(wt.id!==V)return wt;const Ft=new Set(wt.skillKeys||[]);return Se?Ft.add(Te):Ft.delete(Te),{...wt,skillKeys:Array.from(Ft),updatedAt:$e}});rr(Dt)},[rr,v]),Qs=m.useCallback(async V=>{const he=V==null?void 0:V.packageId,Se=V==null?void 0:V.version;if(!he||!Se||!window.confirm(n("project:deleteMyNodeConfirm",{id:he,version:Se})))return;const Te=Nn(V);Xe(Te),nt(""),F("");try{const $e=new URLSearchParams({id:he,version:Se}),Dt=await fetch(`/api/marketplace/node?${$e.toString()}`,{method:"DELETE"}),wt=await Dt.json().catch(()=>({}));if(!Dt.ok||(wt==null?void 0:wt.ok)===!1){const Ft=Array.isArray(wt==null?void 0:wt.usage)&&wt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:wt.usage.length})}`:"";throw new Error(((wt==null?void 0:wt.error)||"Delete failed")+Ft)}nt(n("project:deleteMyNodeSuccess",{id:he,version:Se})),Fe(Ft=>{const Dr={...Ft};return delete Dr[Te],Dr}),fr(Ft=>{const Dr={};for(const[_r,ao]of Object.entries(Ft))_r.startsWith(`${Te}:`)||(Dr[_r]=ao);return Dr}),Ae(""),await Gn()}catch($e){nt(String($e.message||$e))}finally{Xe("")}},[Gn,n]),Zs=m.useCallback(async V=>{const he=V==null?void 0:V.id,Se=(V==null?void 0:V.version)||"1.0.0";if(!he||!Se||!window.confirm(n("project:deleteMyFlowConfirm",{id:he,version:Se})))return;const Te=Qo(V);Mn(Te),tr(""),F("");try{const $e=new URLSearchParams({id:he,version:Se}),Dt=await fetch(`/api/marketplace/flow-snippet?${$e.toString()}`,{method:"DELETE"}),wt=await Dt.json().catch(()=>({}));if(!Dt.ok||(wt==null?void 0:wt.ok)===!1)throw new Error((wt==null?void 0:wt.error)||"Delete failed");tr(n("project:deleteMyFlowSuccess",{id:he,version:Se})),Ae(""),await Gn()}catch($e){tr(String($e.message||$e))}finally{Mn("")}},[Gn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){a(e),ce("all"),Ae(""),Pe("overview");return}a(V=>V==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const V=new URLSearchParams(window.location.search);let he=!1;if(V.get("tab")==="nodes"){r("/nodes");return}if(V.get("tab")==="my-nodes"){r("/my-nodes");return}if(V.get("tab")==="my-flows"){r("/my-flows");return}if(V.get("tab")==="skills"){r("/skills");return}if(V.get("tab")==="archived"&&(a("archived"),V.delete("tab"),he=!0),V.get("new")==="1"&&(A(!0),V.delete("new"),he=!0),he){const Se=V.toString();window.history.replaceState({},"",Se?`/projects?${Se}`:"/projects")}},[s,r]);const Ni=m.useMemo(()=>LO(C,DE(),l),[C,l,s]),Cr=m.useMemo(()=>Ni.filter(V=>SM(Y,V)),[Ni,Y]),hr=Y.trim().toLowerCase(),io=m.useMemo(()=>i==="archived"?l.filter(V=>V.archived):l.filter(V=>!V.archived),[l,i]),ji=m.useMemo(()=>io.filter(V=>kM(V,hr,n)),[io,hr,n]),oo=m.useMemo(()=>new Set((ze.promoted||[]).map(V=>String((V==null?void 0:V.id)||"").trim()).filter(Boolean)),[ze.promoted]),As=m.useMemo(()=>(ze.hiddenBuiltins||[]).map(V=>String(V||"").trim()).filter(Boolean),[ze.hiddenBuiltins]),_e=i==="nodes"||i==="my-nodes",Xt=i==="my-nodes",Bn=i==="my-flows",rt=m.useMemo(()=>d.filter(V=>Xt&&V.source!=="marketplace"?!1:(le==="all"||(le==="marketplace"?V.source==="marketplace":V.type===le))&&sy(Y,[V.id,V.label,V.displayName,V.description,V.type,V.source,V.packageId,V.version])),[d,Xt,Y,le]),hs=m.useMemo(()=>{const V=new Map;for(const he of v)V.set(he.id,new Set(he.skillKeys||[]));return V},[v]),Er=m.useMemo(()=>[{id:"all",label:"全部"},...v.map(V=>({id:`collection:${V.id}`,label:V.name,count:V.skillKeys.length,collection:V})),{id:"ungrouped",label:"未分组"}],[v]),mn=m.useMemo(()=>f.filter(V=>{var Te;const he=Nn(V);let Se=le==="all";if(le.startsWith("collection:")){const $e=le.slice(11);Se=!!((Te=hs.get($e))!=null&&Te.has(he))}else le==="ungrouped"&&(Se=!Array.from(hs.values()).some($e=>$e.has(he)));return Se&&sy(Y,[V.name,V.id,V.description,V.sourceLabel,V.source,V.path])}),[f,Y,le,hs]),mr=m.useMemo(()=>h.filter(V=>sy(Y,[V.id,V.name,V.displayName,V.description,V.version,V.packageDir,Array.isArray(V.tags)?V.tags.join(" "):""])),[h,Y]),Jt=_e||Bn||i==="skills",at=m.useMemo(()=>rt.find(V=>Nn(V)===de)||rt[0]||null,[rt,de]),Ht=m.useMemo(()=>mn.find(V=>Nn(V)===de)||mn[0]||null,[mn,de]),Kt=m.useMemo(()=>mr.find(V=>Qo(V)===de)||mr[0]||null,[mr,de]),Xn=Ht?Ie[Nn(Ht)]:null,Me=at?xt[Nn(at)]:null,Dn=at&&tt?en[`${Nn(at)}:${tt}`]:null,Is=n(_e?"project:searchNodes":Bn?"project:searchFlows":i==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(i!=="skills"||!Ht)return;const V=Nn(Ht);if(Ie[V])return;let he=!1;return Ge(V),fetch(`/api/skills/detail?key=${encodeURIComponent(V)}`).then(Se=>Se.json().then(Te=>({ok:Se.ok,json:Te}))).then(({ok:Se,json:Te})=>{he||Se&&Te.skill&&qe($e=>({...$e,[V]:Te.skill}))}).catch(()=>{}).finally(()=>{he||Ge("")}),()=>{he=!0}},[i,Ht,Ie]),m.useEffect(()=>{if(!_e||!at)return;const V=Nn(at);if(xt[V])return;let he=!1;return De(V),fetch(`/api/nodes/detail?id=${encodeURIComponent(at.id)}`).then(Se=>Se.json().then(Te=>({ok:Se.ok,json:Te}))).then(({ok:Se,json:Te})=>{he||Se&&Fe($e=>({...$e,[V]:Te}))}).catch(()=>{}).finally(()=>{he||De("")}),()=>{he=!0}},[_e,at,xt]),m.useEffect(()=>{if(!_e)return;const V=Array.isArray(Me==null?void 0:Me.files)?Me.files:[];Nt(he=>{var Se;return he&&V.some(Te=>Te.path===he)?he:((Se=V[0])==null?void 0:Se.path)||""})},[_e,Me]),m.useEffect(()=>{if(!_e||!at||!tt)return;const V=`${Nn(at)}:${tt}`;if(en[V])return;let he=!1;return ae(V),fetch(`/api/nodes/file?id=${encodeURIComponent(at.id)}&path=${encodeURIComponent(tt)}`).then(Se=>Se.json().then(Te=>({ok:Se.ok,json:Te}))).then(({ok:Se,json:Te})=>{he||Se&&fr($e=>({...$e,[V]:Te}))}).catch(()=>{}).finally(()=>{he||ae("")}),()=>{he=!0}},[_e,at,tt,en]),m.useEffect(()=>{nt("")},[de,i]);const Ci=V=>{r(wp(V,"workspace"))},ei=V=>{ge(Ek(V)),r(wp({id:V.flowId,source:V.flowSource,archived:!!V.archived},"workspace"))},Bo=m.useCallback(V=>{var he,Se;V.preventDefault(),V.stopPropagation(),(Se=(he=V.dataTransfer)==null?void 0:he.types)!=null&&Se.includes("Files")&&(kt.current+=1,E(!0))},[]),Ts=m.useCallback(V=>{V.preventDefault(),V.stopPropagation(),kt.current-=1,kt.current<=0&&(kt.current=0,E(!1))},[]),Ei=m.useCallback(V=>{V.preventDefault(),V.stopPropagation()},[]),ti=m.useCallback(V=>{var Te,$e;V.preventDefault(),V.stopPropagation(),kt.current=0,E(!1);const he=($e=(Te=V.dataTransfer)==null?void 0:Te.files)==null?void 0:$e[0];if(!he)return;const Se=he.name.toLowerCase();!Se.endsWith(".yaml")&&!Se.endsWith(".yml")&&!Se.endsWith(".zip")||P(he)},[]);return o.jsxs("div",{className:"af-projects"+(T?" af-projects--drop-target":""),onDragEnter:Bo,onDragLeave:Ts,onDragOver:Ei,onDrop:ti,children:[o.jsxs("header",{className:"af-projects-top",children:[e?o.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):o.jsxs("div",{className:"af-projects-tabs",children:[o.jsx("button",{type:"button",className:i==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>a("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:i==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>a("archived"),children:n("project:archived")})]}),o.jsxs("div",{className:"af-projects-top-right",children:[o.jsxs("div",{className:"af-search-wrap",children:[o.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),o.jsx("input",{className:"af-search"+(Y.trim()?" af-search--has-clear":""),type:"search",placeholder:Is,"aria-label":Is,autoComplete:"off",value:Y,onChange:V=>Q(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(Q(""),V.currentTarget.blur())}}),Y.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Q(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Jt?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>Gn(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(U?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":U,"aria-controls":"af-recent-activity-panel",onClick:()=>re(V=>!V),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>A(!0),children:n("project:createNew")})]})]})]}),o.jsxs("div",{className:"af-projects-body",children:[o.jsxs("section",{className:"af-projects-main",children:[o.jsxs("header",{className:"af-projects-section-head",children:[o.jsx("h2",{className:"af-projects-h2",children:n(i==="my-nodes"?"project:myNodes":i==="my-flows"?"project:myFlows":i==="nodes"?"project:globalNodes":i==="skills"?"project:globalSkills":i==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:hr?n("project:filterResult",{count:i==="nodes"||i==="my-nodes"?rt.length:i==="my-flows"?mr.length:i==="skills"?mn.length:ji.length}):i==="my-nodes"?n("project:myNodesHint",{count:rt.length}):i==="my-flows"?n("project:myFlowsHint",{count:mr.length}):i==="nodes"?n("project:nodesHint",{count:d.length}):i==="skills"?n("project:skillsHint",{count:f.length}):n(i==="archived"?"project:archivedHint":"project:activeHint")}),I?o.jsx("p",{className:"af-err af-projects-api-hint",children:I}):null,R&&Jt?o.jsx("p",{className:"af-err af-projects-api-hint",children:R}):null]}),Jt?o.jsxs("div",{className:"af-resource-toolbar",children:[i==="skills"?o.jsx(mM,{onChanged:Gn}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:Bn?"schema":_e?Xt?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(Bn?"project:myFlowsPurposeTitle":Xt?"project:myNodesPurposeTitle":_e?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(Bn?"project:myFlowsPurposeDesc":Xt?"project:myNodesPurposeDesc":_e?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Bn?null:o.jsx("div",{className:"af-resource-filter-row",children:(_e?(Xt?jM:NM).map(V=>({id:V,label:n(`project:resourceFilter.${V}`)})):Er).map(V=>V.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(le===V.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ce(V.id),Ae("")},children:[V.label,o.jsx("em",{children:V.count}),V.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),V.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:w,"aria-label":`删除 ${V.collection.name}`,onClick:()=>so(V.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},V.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(le===V.id?" af-resource-filter--active":""),onClick:()=>{ce(V.id),Ae("")},children:V.label},V.id))}),i==="skills"?o.jsx("div",{className:"af-skill-collections-manager",children:o.jsxs("div",{className:"af-skill-collections-create",children:[o.jsx("input",{className:"af-set-input af-set-input--sm",value:y,onChange:V=>b(V.target.value),onKeyDown:V=>{V.key==="Enter"&&Fo()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!y.trim()||w,onClick:()=>Fo(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,_e?o.jsx("div",{className:"af-resource-grid",children:rt.length>0?rt.map(V=>o.jsxs("button",{type:"button",className:"af-resource-card"+(at&&Nn(V)===Nn(at)?" af-resource-card--active":""),onClick:()=>Ae(Nn(V)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Ou(V.type==="control"?"secondary":V.type==="provide"?"primary":"muted"),children:o.jsx(Fn,{query:Y,children:V.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(Fn,{query:Y,children:jk(V.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(Fn,{query:Y,children:V.label||V.displayName||V.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(Fn,{query:Y,children:V.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(Fn,{query:Y,children:V.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(V.inputs||{}).length,outputs:Object.keys(V.outputs||{}).length})})]}),V.packageId?o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),o.jsx("span",{className:"af-path-text",children:o.jsx(Fn,{query:Y,children:`${V.packageId}${V.version?` / ${V.version}`:""}`})})]}):null]},`${V.id}:${V.source||""}:${V.packageId||""}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:hr?n("project:noNodeMatch",{query:Y.trim()}):n(Xt?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Bn?o.jsx("div",{className:"af-resource-grid",children:mr.length>0?mr.map(V=>{const he=n_(V),Se=r_(V),Te=Number.isFinite(Number(V.nodeCount))?Number(V.nodeCount):he.length,$e=Number.isFinite(Number(V.edgeCount))?Number(V.edgeCount):Se.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(Kt&&Qo(V)===Qo(Kt)?" af-resource-card--active":""),onClick:()=>Ae(Qo(V)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Ou("primary"),children:o.jsx(Fn,{query:Y,children:V.version?`v${V.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(Fn,{query:Y,children:V.displayName||V.name||V.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(Fn,{query:Y,children:V.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Te,edges:$e})}),o.jsx("span",{children:o.jsx(Fn,{query:Y,children:V.id})})]}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),o.jsx("span",{className:"af-path-text",children:o.jsx(Fn,{query:Y,children:Ck(V)})})]})]},Qo(V))}):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:hr?n("project:noFlowSnippetMatch",{query:Y.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i==="skills"?o.jsx("div",{className:"af-resource-grid",children:mn.length>0?mn.map(V=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Ht&&Nn(V)===Nn(Ht)?" af-resource-card--active":""),onClick:()=>Ae(Nn(V)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Ou(V.source==="builtin"?"muted":"primary"),children:o.jsx(Fn,{query:Y,children:V.sourceLabel||V.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(Fn,{query:Y,children:V.name||V.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(Fn,{query:Y,children:V.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),o.jsx("span",{className:"af-path-text",children:o.jsx(Fn,{query:Y,children:V.path||V.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[v.filter(he=>he.skillKeys.includes(Nn(V))).slice(0,3).map(he=>o.jsx("span",{children:he.name},he.id)),v.filter(he=>he.skillKeys.includes(Nn(V))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},V.key||`${V.source}:${V.name}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:hr?n("project:noSkillMatch",{query:Y.trim()}):n("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):o.jsxs(o.Fragment,{children:[t!=null&&t.isAdmin&&i==="all"&&As.length>0?o.jsxs("div",{className:"af-project-admin-panel",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已隐藏内置"}),o.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),o.jsx("div",{className:"af-project-admin-hidden-list",children:As.map(V=>{const he=nr===`show-builtin:builtin:${V}`;return o.jsxs("button",{type:"button",disabled:he,onClick:()=>$n({id:V,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:V}),o.jsx("em",{children:he?"恢复中":"恢复"})]},V)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[ji.length>0?ji.map(V=>{const he=(t==null?void 0:t.isAdmin)&&V.source==="user"&&!V.archived&&!oo.has(V.id),Se=(t==null?void 0:t.isAdmin)&&V.source==="admin",Te=(t==null?void 0:t.isAdmin)&&V.source==="builtin",$e=nr.endsWith(`:${V.source}:${V.id}`);return o.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>Ci(V),onKeyDown:Dt=>{(Dt.key==="Enter"||Dt.key===" ")&&(Dt.preventDefault(),Ci(V))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:Ou(Gx(V.source,n).tone),children:o.jsx(Fn,{query:Y,children:Gx(V.source,n).label})}),V.archived?o.jsx("span",{className:Ou("muted"),children:o.jsx(Fn,{query:Y,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(Fn,{query:Y,children:V.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(Fn,{query:Y,children:e_(V,n)})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),o.jsx("span",{className:"af-path-text",children:o.jsx(Fn,{query:Y,children:ZE(V)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Dt=>Dt.stopPropagation(),onKeyDown:Dt=>Dt.stopPropagation(),children:[he?o.jsx("button",{type:"button",disabled:$e,onClick:()=>$n(V,"promote"),children:"设为内置"}):null,Se?o.jsx("button",{type:"button",disabled:$e,onClick:()=>$n(V,"unpromote"),children:"取消内置"}):null,Te?o.jsx("button",{type:"button",disabled:$e,onClick:()=>$n(V,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${V.id}:${V.source??"user"}:${V.archived?"a":""}`)}):O?io.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:i==="archived"?n("project:noArchived"):l.length>0?n("project:noActive"):n(I?"project:loadFailed":"project:noPipelines")}),!I&&l.length===0&&i==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:Y.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>A(!0),children:[o.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),o.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),pr?null:o.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[o.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),o.jsxs("span",{className:"af-hub-card__eyebrow",children:[o.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),o.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),o.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),Jt?o.jsx("aside",{className:"af-resource-detail","aria-label":n(_e?"project:nodeDetail":Bn?"project:flowDetail":"project:skillDetail"),children:_e&&at?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h3",{children:at.label||at.displayName||at.id}),o.jsx("p",{children:at.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(V=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Ne===V?" af-resource-detail-tab--active":""),onClick:()=>Pe(V),children:n(`project:nodeDetailTabs.${V}`)},V))}),ee===Nn(at)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):Ne==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:at.description||((Vt=Me==null?void 0:Me.node)==null?void 0:Vt.description)||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailType")}),o.jsx("dd",{children:at.type||((gr=Me==null?void 0:Me.node)==null?void 0:gr.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:jk(at.source,n)})]}),at.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:at.packageId})]}):null,at.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:at.version})]}):null,at.packageDir||Me!=null&&Me.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:at.packageDir||(Me==null?void 0:Me.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Me==null?void 0:Me.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),Xt&&at.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myNodeManagement")}),o.jsx("p",{children:n("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:ve===Nn(at),onClick:()=>Qs(at),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),ve===Nn(at)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),ot?o.jsx("p",{className:"af-resource-action-message",children:ot}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:nodesMeaning")})]})]}):Ne==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeInputs")}),bp(((Rs=Me==null?void 0:Me.node)==null?void 0:Rs.inputs)||at.inputs).length>0?bp(((ms=Me==null?void 0:Me.node)==null?void 0:ms.inputs)||at.inputs).map(V=>o.jsxs("code",{children:[V.name||V.key,V.type?`: ${V.type}`:""]},V.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),bp(((Yr=Me==null?void 0:Me.node)==null?void 0:Yr.outputs)||at.outputs).length>0?bp(((Ls=Me==null?void 0:Me.node)==null?void 0:Ls.outputs)||at.outputs).map(V=>o.jsxs("code",{children:[V.name||V.key,V.type?`: ${V.type}`:""]},V.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):Ne==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),Me!=null&&Me.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Me.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Me!=null&&Me.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:Me.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):Ne==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Me==null?void 0:Me.files)&&Me.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Me.files.map(V=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(tt===V.path?" af-node-file-item--active":""),onClick:()=>Nt(V.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:V.path})]},V.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[jr===`${Nn(at)}:${tt}`?n("project:loadingResources"):Dn!=null&&Dn.binary?n("project:binaryFile"):(Dn==null?void 0:Dn.content)||n("project:selectNodeFile"),Dn!=null&&Dn.truncated?`
43
+
44
+ ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(Me==null?void 0:Me.usage)&&Me.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Me.usage.map(V=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:V.flowId}),o.jsxs("span",{children:[V.flowSource,V.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:V.instances.map(he=>he.label||he.instanceId).join(", ")})]},`${V.flowSource}:${V.flowId}:${V.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):Bn&&Kt?(()=>{const V=TM(Kt);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"schema"}),o.jsxs("div",{children:[o.jsx("h3",{children:Kt.displayName||Kt.name||Kt.id}),o.jsx("p",{children:Kt.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Kt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:Kt.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Ck(Kt)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Kt.nodeCount))?Number(Kt.nodeCount):V.nodes.length,edges:Number.isFinite(Number(Kt.edgeCount))?Number(Kt.edgeCount):V.edges.length})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myFlowManagement")}),o.jsx("p",{children:n("project:deleteMyFlowHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:hn===Qo(Kt),onClick:()=>Zs(Kt),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),hn===Qo(Kt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),Tn?o.jsx("p",{className:"af-resource-action-message",children:Tn}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),V.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:V.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:o.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),o.jsx("g",{className:"af-flow-snippet-map__edges",children:V.diagram.edges.map(he=>o.jsxs("g",{children:[o.jsx("path",{d:he.path}),he.label?o.jsx("text",{x:he.labelX,y:he.labelY-5,textAnchor:"middle",children:iy(he.label,18)}):null]},he.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:V.diagram.nodes.map((he,Se)=>o.jsxs("g",{transform:`translate(${he.x} ${he.y})`,children:[o.jsx("rect",{width:he.width,height:he.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:he.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:he.height/2+4,textAnchor:"middle",children:Se+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:he.height/2-3,children:iy(he.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:he.height/2+16,children:iy(he.meta||he.id,20)})]},he.id))})]})}):o.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),o.jsxs("details",{className:"af-flow-snippet-json",children:[o.jsx("summary",{children:n("project:flowSnippetJson")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Kt.snippet||{},null,2)})]})]})]})})():i==="skills"&&Ht?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:Ht.name||Ht.id}),o.jsx("p",{children:Ht.sourceLabel||Ht.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Ht.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:Ht.sourceLabel||Ht.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Ht.path||Ht.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),v.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:v.map(V=>{const he=Nn(Ht),Se=V.skillKeys.includes(he);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Se,disabled:w,onChange:Te=>zo(V.id,he,Te.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:V.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[V.skillKeys.length," skills"]})]})]},V.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:ct===Nn(Ht)?n("project:loadingResources"):(Xn==null?void 0:Xn.body)||(Xn==null?void 0:Xn.content)||n("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(U?"":" af-activity--hidden"),"aria-hidden":!U,"aria-label":n("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:Cr.length===0?o.jsx("p",{className:"af-activity-empty",children:Ni.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Cr.map(V=>{const he=ue===Ek(V);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(he?" af-activity-row--active":""),"aria-current":he?"page":void 0,onClick:()=>ei(V),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(Fn,{query:Y,children:V.flowId})}),o.jsx("span",{className:"af-activity-time",children:Ux(V.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:xM(V.kind),children:V.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[V.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",Ux(V.at,n)]})]})]},`${V.kind}-${V.flowId}-${V.flowSource}-${V.at}`)})})]})]}),o.jsx(cM,{open:$,onClose:()=>A(!1),onCreated:async V=>{A(!1),await qr();const he=V.source??"user";r(wp({id:V.id,source:he},"workspace"))}}),B?o.jsx(aM,{file:B,onClose:()=>P(null),onImported:async V=>{P(null),await qr();const he=V.source??"user";r(wp({id:V.id,source:he},"workspace"))}},`${B.name}-${B.size}-${B.lastModified}`):null]})}function Yn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Yn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var RM={value:()=>{}};function Dm(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new sh(n)}function sh(e){this._=e}function LM(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}sh.prototype=Dm.prototype={constructor:sh,on:function(e,t){var n=this._,r=LM(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=OM(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(s=(e=r[i]).type)n[s]=Ak(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Ak(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new sh(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function OM(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function Ak(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=RM,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Qx="http://www.w3.org/1999/xhtml";const Ik={svg:"http://www.w3.org/2000/svg",xhtml:Qx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ik.hasOwnProperty(t)?{space:Ik[t],local:e}:e}function MM(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Qx&&t.documentElement.namespaceURI===Qx?t.createElement(e):t.createElementNS(n,e)}}function $M(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function s_(e){var t=Fm(e);return(t.local?$M:MM)(t)}function DM(){}function $b(e){return e==null?DM:function(){return this.querySelector(e)}}function FM(e){typeof e!="function"&&(e=$b(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=new Array(a),c,d,u=0;u<a;++u)(c=i[u])&&(d=e.call(c,c.__data__,u,i))&&("__data__"in c&&(d.__data__=c.__data__),l[u]=d);return new Es(r,this._parents)}function zM(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function BM(){return[]}function i_(e){return e==null?BM:function(){return this.querySelectorAll(e)}}function HM(e){return function(){return zM(e.apply(this,arguments))}}function VM(e){typeof e=="function"?e=HM(e):e=i_(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var a=t[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&(r.push(e.call(c,c.__data__,d,a)),s.push(c));return new Es(r,s)}function o_(e){return function(){return this.matches(e)}}function a_(e){return function(t){return t.matches(e)}}var WM=Array.prototype.find;function UM(e){return function(){return WM.call(this.children,e)}}function KM(){return this.firstElementChild}function qM(e){return this.select(e==null?KM:UM(typeof e=="function"?e:a_(e)))}var YM=Array.prototype.filter;function GM(){return Array.from(this.children)}function XM(e){return function(){return YM.call(this.children,e)}}function JM(e){return this.selectAll(e==null?GM:XM(typeof e=="function"?e:a_(e)))}function QM(e){typeof e!="function"&&(e=o_(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new Es(r,this._parents)}function l_(e){return new Array(e.length)}function ZM(){return new Es(this._enter||this._groups.map(l_),this._parents)}function Bh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bh.prototype={constructor:Bh,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function e$(e){return function(){return e}}function t$(e,t,n,r,s,i){for(var a=0,l,c=t.length,d=i.length;a<d;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Bh(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function n$(e,t,n,r,s,i,a){var l,c,d=new Map,u=t.length,f=i.length,p=new Array(u),h;for(l=0;l<u;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",d.has(h)?s[l]=c:d.set(h,c));for(l=0;l<f;++l)h=a.call(e,i[l],l,i)+"",(c=d.get(h))?(r[l]=c,c.__data__=i[l],d.delete(h)):n[l]=new Bh(e,i[l]);for(l=0;l<u;++l)(c=t[l])&&d.get(p[l])===c&&(s[l]=c)}function r$(e){return e.__data__}function s$(e,t){if(!arguments.length)return Array.from(this,r$);var n=t?n$:t$,r=this._parents,s=this._groups;typeof e!="function"&&(e=e$(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),d=0;d<i;++d){var u=r[d],f=s[d],p=f.length,h=i$(e.call(u,u&&u.__data__,d,r)),g=h.length,v=l[d]=new Array(g),k=a[d]=new Array(g),y=c[d]=new Array(p);n(u,f,v,k,y,h,t);for(var b=0,w=0,S,C;b<g;++b)if(S=v[b]){for(b>=w&&(w=b+1);!(C=k[w])&&++w<g;);S._next=C||null}}return a=new Es(a,r),a._enter=l,a._exit=c,a}function i$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function o$(){return new Es(this._exit||this._groups.map(l_),this._parents)}function a$(e,t,n){var r=this.enter(),s=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),r&&s?r.merge(s).order():s}function l$(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,a=Math.min(s,i),l=new Array(s),c=0;c<a;++c)for(var d=n[c],u=r[c],f=d.length,p=l[c]=new Array(f),h,g=0;g<f;++g)(h=d[g]||u[g])&&(p[g]=h);for(;c<s;++c)l[c]=n[c];return new Es(l,this._parents)}function c$(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],a;--s>=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function u$(e){e||(e=d$);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,c=s[i]=new Array(l),d,u=0;u<l;++u)(d=a[u])&&(c[u]=d);c.sort(t)}return new Es(s,this._parents).order()}function d$(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function f$(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function p$(){return Array.from(this)}function h$(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var a=r[s];if(a)return a}return null}function m$(){let e=0;for(const t of this)++e;return e}function g$(){return!this.node()}function y$(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,a=s.length,l;i<a;++i)(l=s[i])&&e.call(l,l.__data__,i,s);return this}function x$(e){return function(){this.removeAttribute(e)}}function w$(e){return function(){this.removeAttributeNS(e.space,e.local)}}function b$(e,t){return function(){this.setAttribute(e,t)}}function v$(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function k$(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function S$(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function N$(e,t){var n=Fm(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?w$:x$:typeof t=="function"?n.local?S$:k$:n.local?v$:b$)(n,t))}function c_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function j$(e){return function(){this.style.removeProperty(e)}}function C$(e,t,n){return function(){this.style.setProperty(e,t,n)}}function E$(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function _$(e,t,n){return arguments.length>1?this.each((t==null?j$:typeof t=="function"?E$:C$)(e,t,n??"")):Fc(this.node(),e)}function Fc(e,t){return e.style.getPropertyValue(t)||c_(e).getComputedStyle(e,null).getPropertyValue(t)}function P$(e){return function(){delete this[e]}}function A$(e,t){return function(){this[e]=t}}function I$(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function T$(e,t){return arguments.length>1?this.each((t==null?P$:typeof t=="function"?I$:A$)(e,t)):this.node()[e]}function u_(e){return e.trim().split(/^|\s+/)}function Db(e){return e.classList||new d_(e)}function d_(e){this._node=e,this._names=u_(e.getAttribute("class")||"")}d_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function f_(e,t){for(var n=Db(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function p_(e,t){for(var n=Db(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function R$(e){return function(){f_(this,e)}}function L$(e){return function(){p_(this,e)}}function O$(e,t){return function(){(t.apply(this,arguments)?f_:p_)(this,e)}}function M$(e,t){var n=u_(e+"");if(arguments.length<2){for(var r=Db(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?O$:t?R$:L$)(n,t))}function $$(){this.textContent=""}function D$(e){return function(){this.textContent=e}}function F$(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function z$(e){return arguments.length?this.each(e==null?$$:(typeof e=="function"?F$:D$)(e)):this.node().textContent}function B$(){this.innerHTML=""}function H$(e){return function(){this.innerHTML=e}}function V$(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function W$(e){return arguments.length?this.each(e==null?B$:(typeof e=="function"?V$:H$)(e)):this.node().innerHTML}function U$(){this.nextSibling&&this.parentNode.appendChild(this)}function K$(){return this.each(U$)}function q$(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Y$(){return this.each(q$)}function G$(e){var t=typeof e=="function"?e:s_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function X$(){return null}function J$(e,t){var n=typeof e=="function"?e:s_(e),r=t==null?X$:typeof t=="function"?t:$b(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Q$(){var e=this.parentNode;e&&e.removeChild(this)}function Z$(){return this.each(Q$)}function eD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nD(e){return this.select(e?tD:eD)}function rD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sD(e){return function(t){e.call(this,t,this.__data__)}}function iD(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function oD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function aD(e,t,n){return function(){var r=this.__on,s,i=sD(t);if(r){for(var a=0,l=r.length;a<l;++a)if((s=r[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function lD(e,t,n){var r=iD(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,u;c<d;++c)for(s=0,u=l[c];s<i;++s)if((a=r[s]).type===u.type&&a.name===u.name)return u.value}return}for(l=t?aD:oD,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function h_(e,t,n){var r=c_(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function cD(e,t){return function(){return h_(this,e,t)}}function uD(e,t){return function(){return h_(this,e,t.apply(this,arguments))}}function dD(e,t){return this.each((typeof t=="function"?uD:cD)(e,t))}function*fD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,a;s<i;++s)(a=r[s])&&(yield a)}var m_=[null];function Es(e,t){this._groups=e,this._parents=t}function mf(){return new Es([[document.documentElement]],m_)}function pD(){return this}Es.prototype=mf.prototype={constructor:Es,select:FM,selectAll:VM,selectChild:qM,selectChildren:JM,filter:QM,data:s$,enter:ZM,exit:o$,join:a$,merge:l$,selection:pD,order:c$,sort:u$,call:f$,nodes:p$,node:h$,size:m$,empty:g$,each:y$,attr:N$,style:_$,property:T$,classed:M$,text:z$,html:W$,raise:K$,lower:Y$,append:G$,insert:J$,remove:Z$,clone:nD,datum:rD,on:lD,dispatch:dD,[Symbol.iterator]:fD};function bs(e){return typeof e=="string"?new Es([[document.querySelector(e)]],[document.documentElement]):new Es([[e]],m_)}function hD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function di(e,t){if(e=hD(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const mD={passive:!1},zd={capture:!0,passive:!1};function oy(e){e.stopImmediatePropagation()}function Ec(e){e.preventDefault(),e.stopImmediatePropagation()}function g_(e){var t=e.document.documentElement,n=bs(e).on("dragstart.drag",Ec,zd);"onselectstart"in t?n.on("selectstart.drag",Ec,zd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function y_(e,t){var n=e.document.documentElement,r=bs(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ec,zd),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const vp=e=>()=>e;function Zx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Zx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gD(e){return!e.ctrlKey&&!e.button}function yD(){return this.parentNode}function xD(e,t){return t??{x:e.x,y:e.y}}function wD(){return navigator.maxTouchPoints||"ontouchstart"in this}function x_(){var e=gD,t=yD,n=xD,r=wD,s={},i=Dm("start","drag","end"),a=0,l,c,d,u,f=0;function p(S){S.on("mousedown.drag",h).filter(r).on("touchstart.drag",k).on("touchmove.drag",y,mD).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(S,C){if(!(u||!e.call(this,S,C))){var N=w(this,t.call(this,S,C),S,C,"mouse");N&&(bs(S.view).on("mousemove.drag",g,zd).on("mouseup.drag",v,zd),g_(S.view),oy(S),d=!1,l=S.clientX,c=S.clientY,N("start",S))}}function g(S){if(Ec(S),!d){var C=S.clientX-l,N=S.clientY-c;d=C*C+N*N>f}s.mouse("drag",S)}function v(S){bs(S.view).on("mousemove.drag mouseup.drag",null),y_(S.view,d),Ec(S),s.mouse("end",S)}function k(S,C){if(e.call(this,S,C)){var N=S.changedTouches,I=t.call(this,S,C),M=N.length,R,F;for(R=0;R<M;++R)(F=w(this,I,S,C,N[R].identifier,N[R]))&&(oy(S),F("start",S,N[R]))}}function y(S){var C=S.changedTouches,N=C.length,I,M;for(I=0;I<N;++I)(M=s[C[I].identifier])&&(Ec(S),M("drag",S,C[I]))}function b(S){var C=S.changedTouches,N=C.length,I,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),I=0;I<N;++I)(M=s[C[I].identifier])&&(oy(S),M("end",S,C[I]))}function w(S,C,N,I,M,R){var F=i.copy(),O=di(R||N,C),L,W,D;if((D=n.call(S,new Zx("beforestart",{sourceEvent:N,target:p,identifier:M,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:F}),I))!=null)return L=D.x-O[0]||0,W=D.y-O[1]||0,function $(A,B,P){var T=O,E;switch(A){case"start":s[M]=$,E=a++;break;case"end":delete s[M],--a;case"drag":O=di(P||B,C),E=a;break}F.call(A,S,new Zx(A,{sourceEvent:B,subject:D,target:p,identifier:M,active:E,x:O[0]+L,y:O[1]+W,dx:O[0]-T[0],dy:O[1]-T[1],dispatch:F}),I)}}return p.filter=function(S){return arguments.length?(e=typeof S=="function"?S:vp(!!S),p):e},p.container=function(S){return arguments.length?(t=typeof S=="function"?S:vp(S),p):t},p.subject=function(S){return arguments.length?(n=typeof S=="function"?S:vp(S),p):n},p.touchable=function(S){return arguments.length?(r=typeof S=="function"?S:vp(!!S),p):r},p.on=function(){var S=i.on.apply(i,arguments);return S===i?p:S},p.clickDistance=function(S){return arguments.length?(f=(S=+S)*S,p):Math.sqrt(f)},p}function Fb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function w_(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function gf(){}var Bd=.7,Hh=1/Bd,_c="\\s*([+-]?\\d+)\\s*",Hd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bD=/^#([0-9a-f]{3,8})$/,vD=new RegExp(`^rgb\\(${_c},${_c},${_c}\\)$`),kD=new RegExp(`^rgb\\(${Xi},${Xi},${Xi}\\)$`),SD=new RegExp(`^rgba\\(${_c},${_c},${_c},${Hd}\\)$`),ND=new RegExp(`^rgba\\(${Xi},${Xi},${Xi},${Hd}\\)$`),jD=new RegExp(`^hsl\\(${Hd},${Xi},${Xi}\\)$`),CD=new RegExp(`^hsla\\(${Hd},${Xi},${Xi},${Hd}\\)$`),Tk={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Fb(gf,bl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Rk,formatHex:Rk,formatHex8:ED,formatHsl:_D,formatRgb:Lk,toString:Lk});function Rk(){return this.rgb().formatHex()}function ED(){return this.rgb().formatHex8()}function _D(){return b_(this).formatHsl()}function Lk(){return this.rgb().formatRgb()}function bl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=bD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ok(t):n===3?new rs(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kp(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=vD.exec(e))?new rs(t[1],t[2],t[3],1):(t=kD.exec(e))?new rs(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=SD.exec(e))?kp(t[1],t[2],t[3],t[4]):(t=ND.exec(e))?kp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jD.exec(e))?Dk(t[1],t[2]/100,t[3]/100,1):(t=CD.exec(e))?Dk(t[1],t[2]/100,t[3]/100,t[4]):Tk.hasOwnProperty(e)?Ok(Tk[e]):e==="transparent"?new rs(NaN,NaN,NaN,0):null}function Ok(e){return new rs(e>>16&255,e>>8&255,e&255,1)}function kp(e,t,n,r){return r<=0&&(e=t=n=NaN),new rs(e,t,n,r)}function PD(e){return e instanceof gf||(e=bl(e)),e?(e=e.rgb(),new rs(e.r,e.g,e.b,e.opacity)):new rs}function ew(e,t,n,r){return arguments.length===1?PD(e):new rs(e,t,n,r??1)}function rs(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Fb(rs,ew,w_(gf,{brighter(e){return e=e==null?Hh:Math.pow(Hh,e),new rs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Bd:Math.pow(Bd,e),new rs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rs(dl(this.r),dl(this.g),dl(this.b),Vh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Mk,formatHex:Mk,formatHex8:AD,formatRgb:$k,toString:$k}));function Mk(){return`#${ll(this.r)}${ll(this.g)}${ll(this.b)}`}function AD(){return`#${ll(this.r)}${ll(this.g)}${ll(this.b)}${ll((isNaN(this.opacity)?1:this.opacity)*255)}`}function $k(){const e=Vh(this.opacity);return`${e===1?"rgb(":"rgba("}${dl(this.r)}, ${dl(this.g)}, ${dl(this.b)}${e===1?")":`, ${e})`}`}function Vh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function dl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ll(e){return e=dl(e),(e<16?"0":"")+e.toString(16)}function Dk(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new hi(e,t,n,r)}function b_(e){if(e instanceof hi)return new hi(e.h,e.s,e.l,e.opacity);if(e instanceof gf||(e=bl(e)),!e)return new hi;if(e instanceof hi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-s,c=(i+s)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?i+s:2-i-s,a*=60):l=c>0&&c<1?0:a,new hi(a,l,c,e.opacity)}function ID(e,t,n,r){return arguments.length===1?b_(e):new hi(e,t,n,r??1)}function hi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Fb(hi,ID,w_(gf,{brighter(e){return e=e==null?Hh:Math.pow(Hh,e),new hi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Bd:Math.pow(Bd,e),new hi(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new rs(ay(e>=240?e-240:e+120,s,r),ay(e,s,r),ay(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new hi(Fk(this.h),Sp(this.s),Sp(this.l),Vh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Vh(this.opacity);return`${e===1?"hsl(":"hsla("}${Fk(this.h)}, ${Sp(this.s)*100}%, ${Sp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fk(e){return e=(e||0)%360,e<0?e+360:e}function Sp(e){return Math.max(0,Math.min(1,e||0))}function ay(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const zb=e=>()=>e;function TD(e,t){return function(n){return e+n*t}}function RD(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function LD(e){return(e=+e)==1?v_:function(t,n){return n-t?RD(t,n,e):zb(isNaN(t)?n:t)}}function v_(e,t){var n=t-e;return n?TD(e,n):zb(isNaN(e)?t:e)}const Wh=function e(t){var n=LD(t);function r(s,i){var a=n((s=ew(s)).r,(i=ew(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),d=v_(s.opacity,i.opacity);return function(u){return s.r=a(u),s.g=l(u),s.b=c(u),s.opacity=d(u),s+""}}return r.gamma=e,r}(1);function OD(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function MD(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function $D(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)s[a]=pd(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=s[a](l);return i}}function DD(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Hi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function FD(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=pd(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var tw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ly=new RegExp(tw.source,"g");function zD(e){return function(){return e}}function BD(e){return function(t){return e(t)+""}}function k_(e,t){var n=tw.lastIndex=ly.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=tw.exec(e))&&(s=ly.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:Hi(r,s)})),n=ly.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?BD(c[0].x):zD(t):(t=c.length,function(d){for(var u=0,f;u<t;++u)l[(f=c[u]).i]=f.x(d);return l.join("")})}function pd(e,t){var n=typeof t,r;return t==null||n==="boolean"?zb(t):(n==="number"?Hi:n==="string"?(r=bl(t))?(t=r,Wh):k_:t instanceof bl?Wh:t instanceof Date?DD:MD(t)?OD:Array.isArray(t)?$D:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?FD:Hi)(e,t)}var zk=180/Math.PI,nw={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function S_(e,t,n,r,s,i){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*zk,skewX:Math.atan(c)*zk,scaleX:a,scaleY:l}}var Np;function HD(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?nw:S_(t.a,t.b,t.c,t.d,t.e,t.f)}function VD(e){return e==null||(Np||(Np=document.createElementNS("http://www.w3.org/2000/svg","g")),Np.setAttribute("transform",e),!(e=Np.transform.baseVal.consolidate()))?nw:(e=e.matrix,S_(e.a,e.b,e.c,e.d,e.e,e.f))}function N_(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function i(d,u,f,p,h,g){if(d!==f||u!==p){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:Hi(d,f)},{i:v-2,x:Hi(u,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Hi(d,u)})):u&&f.push(s(f)+"rotate("+u+r)}function l(d,u,f,p){d!==u?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Hi(d,u)}):u&&f.push(s(f)+"skewX("+u+r)}function c(d,u,f,p,h,g){if(d!==f||u!==p){var v=h.push(s(h)+"scale(",null,",",null,")");g.push({i:v-4,x:Hi(d,f)},{i:v-2,x:Hi(u,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),i(d.translateX,d.translateY,u.translateX,u.translateY,f,p),a(d.rotate,u.rotate,f,p),l(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(h){for(var g=-1,v=p.length,k;++g<v;)f[(k=p[g]).i]=k.x(h);return f.join("")}}}var WD=N_(HD,"px, ","px)","deg)"),UD=N_(VD,", ",")",")"),KD=1e-12;function Bk(e){return((e=Math.exp(e))+1/e)/2}function qD(e){return((e=Math.exp(e))-1/e)/2}function YD(e){return((e=Math.exp(2*e))-1)/(e+1)}const ih=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],d=i[2],u=a[0],f=a[1],p=a[2],h=u-l,g=f-c,v=h*h+g*g,k,y;if(v<KD)y=Math.log(p/d)/t,k=function(I){return[l+I*h,c+I*g,d*Math.exp(t*I*y)]};else{var b=Math.sqrt(v),w=(p*p-d*d+r*v)/(2*d*n*b),S=(p*p-d*d-r*v)/(2*p*n*b),C=Math.log(Math.sqrt(w*w+1)-w),N=Math.log(Math.sqrt(S*S+1)-S);y=(N-C)/t,k=function(I){var M=I*y,R=Bk(C),F=d/(n*b)*(R*YD(t*M+C)-qD(C));return[l+F*h,c+F*g,d*R/Bk(t*M+C)]}}return k.duration=y*1e3*t/Math.SQRT2,k}return s.rho=function(i){var a=Math.max(.001,+i),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var zc=0,Xu=0,Mu=0,j_=1e3,Uh,Ju,Kh=0,vl=0,zm=0,Vd=typeof performance=="object"&&performance.now?performance:Date,C_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Bb(){return vl||(C_(GD),vl=Vd.now()+zm)}function GD(){vl=0}function qh(){this._call=this._time=this._next=null}qh.prototype=E_.prototype={constructor:qh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Bb():+n)+(t==null?0:+t),!this._next&&Ju!==this&&(Ju?Ju._next=this:Uh=this,Ju=this),this._call=e,this._time=n,rw()},stop:function(){this._call&&(this._call=null,this._time=1/0,rw())}};function E_(e,t,n){var r=new qh;return r.restart(e,t,n),r}function XD(){Bb(),++zc;for(var e=Uh,t;e;)(t=vl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--zc}function Hk(){vl=(Kh=Vd.now())+zm,zc=Xu=0;try{XD()}finally{zc=0,QD(),vl=0}}function JD(){var e=Vd.now(),t=e-Kh;t>j_&&(zm-=t,Kh=e)}function QD(){for(var e,t=Uh,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Uh=n);Ju=e,rw(r)}function rw(e){if(!zc){Xu&&(Xu=clearTimeout(Xu));var t=e-vl;t>24?(e<1/0&&(Xu=setTimeout(Hk,e-Vd.now()-zm)),Mu&&(Mu=clearInterval(Mu))):(Mu||(Kh=Vd.now(),Mu=setInterval(JD,j_)),zc=1,C_(Hk))}}function Vk(e,t,n){var r=new qh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var ZD=Dm("start","end","cancel","interrupt"),eF=[],__=0,Wk=1,sw=2,oh=3,Uk=4,iw=5,ah=6;function Bm(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;tF(e,n,{name:t,index:r,group:s,on:ZD,tween:eF,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:__})}function Hb(e,t){var n=ki(e,t);if(n.state>__)throw new Error("too late; already scheduled");return n}function no(e,t){var n=ki(e,t);if(n.state>oh)throw new Error("too late; already running");return n}function ki(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function tF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=E_(i,0,n.time);function i(d){n.state=Wk,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var u,f,p,h;if(n.state!==Wk)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===oh)return Vk(a);h.state===Uk?(h.state=ah,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=ah,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(Vk(function(){n.state===oh&&(n.state=Uk,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=sw,n.on.call("start",e,e.__data__,n.index,n.group),n.state===sw){for(n.state=oh,s=new Array(p=n.tween.length),u=0,f=-1;u<p;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=iw,1),f=-1,p=s.length;++f<p;)s[f].call(e,u);n.state===iw&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=ah,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function lh(e,t){var n=e.__transition,r,s,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}s=r.state>sw&&r.state<iw,r.state=ah,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function nF(e){return this.each(function(){lh(this,e)})}function rF(e,t){var n,r;return function(){var s=no(this,e),i=s.tween;if(i!==n){r=n=i;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}s.tween=r}}function sF(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=no(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}i.tween=s}}function iF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ki(this.node(),n).tween,s=0,i=r.length,a;s<i;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?rF:sF)(n,e,t))}function Vb(e,t,n){var r=e._id;return e.each(function(){var s=no(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ki(s,r).value[t]}}function P_(e,t){var n;return(typeof t=="number"?Hi:t instanceof bl?Wh:(n=bl(t))?(t=n,Wh):k_)(e,t)}function oF(e){return function(){this.removeAttribute(e)}}function aF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttribute(e);return a===s?null:a===r?i:i=t(r=a,n)}}function cF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?i:i=t(r=a,n)}}function uF(e,t,n){var r,s,i;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l)))}}function dF(e,t,n){var r,s,i;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l)))}}function fF(e,t){var n=Fm(e),r=n==="transform"?UD:P_;return this.attrTween(e,typeof t=="function"?(n.local?dF:uF)(n,r,Vb(this,"attr."+e,t)):t==null?(n.local?aF:oF)(n):(n.local?cF:lF)(n,r,t))}function pF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function hF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function mF(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hF(e,i)),n}return s._value=t,s}function gF(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&pF(e,i)),n}return s._value=t,s}function yF(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Fm(e);return this.tween(n,(r.local?mF:gF)(r,t))}function xF(e,t){return function(){Hb(this,e).delay=+t.apply(this,arguments)}}function wF(e,t){return t=+t,function(){Hb(this,e).delay=t}}function bF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xF:wF)(t,e)):ki(this.node(),t).delay}function vF(e,t){return function(){no(this,e).duration=+t.apply(this,arguments)}}function kF(e,t){return t=+t,function(){no(this,e).duration=t}}function SF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vF:kF)(t,e)):ki(this.node(),t).duration}function NF(e,t){if(typeof t!="function")throw new Error;return function(){no(this,e).ease=t}}function jF(e){var t=this._id;return arguments.length?this.each(NF(t,e)):ki(this.node(),t).ease}function CF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;no(this,e).ease=n}}function EF(e){if(typeof e!="function")throw new Error;return this.each(CF(this._id,e))}function _F(e){typeof e!="function"&&(e=o_(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new Ro(r,this._parents,this._name,this._id)}function PF(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),a=new Array(r),l=0;l<i;++l)for(var c=t[l],d=n[l],u=c.length,f=a[l]=new Array(u),p,h=0;h<u;++h)(p=c[h]||d[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new Ro(a,this._parents,this._name,this._id)}function AF(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function IF(e,t,n){var r,s,i=AF(t)?Hb:no;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function TF(e,t){var n=this._id;return arguments.length<2?ki(this.node(),n).on.on(e):this.each(IF(n,e,t))}function RF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function LF(){return this.on("end.remove",RF(this._id))}function OF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$b(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,d=i[a]=new Array(c),u,f,p=0;p<c;++p)(u=l[p])&&(f=e.call(u,u.__data__,p,l))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,Bm(d[p],t,n,p,d,ki(u,n)));return new Ro(i,this._parents,t,n)}function MF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=i_(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),h,g=ki(u,n),v=0,k=p.length;v<k;++v)(h=p[v])&&Bm(h,t,n,v,p,g);i.push(p),a.push(u)}return new Ro(i,a,t,n)}var $F=mf.prototype.constructor;function DF(){return new $F(this._groups,this._parents)}function FF(e,t){var n,r,s;return function(){var i=Fc(this,e),a=(this.style.removeProperty(e),Fc(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function A_(e){return function(){this.style.removeProperty(e)}}function zF(e,t,n){var r,s=n+"",i;return function(){var a=Fc(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function BF(e,t,n){var r,s,i;return function(){var a=Fc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Fc(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function HF(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=no(this,e),d=c.on,u=c.value[i]==null?l||(l=A_(t)):void 0;(d!==n||s!==u)&&(r=(n=d).copy()).on(a,s=u),c.on=r}}function VF(e,t,n){var r=(e+="")=="transform"?WD:P_;return t==null?this.styleTween(e,FF(e,r)).on("end.style."+e,A_(e)):typeof t=="function"?this.styleTween(e,BF(e,r,Vb(this,"style."+e,t))).each(HF(this._id,e)):this.styleTween(e,zF(e,r,t),n).on("end.style."+e,null)}function WF(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function UF(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&WF(e,a,n)),r}return i._value=t,i}function KF(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,UF(e,t,n??""))}function qF(e){return function(){this.textContent=e}}function YF(e){return function(){var t=e(this);this.textContent=t??""}}function GF(e){return this.tween("text",typeof e=="function"?YF(Vb(this,"text",e)):qF(e==null?"":e+""))}function XF(e){return function(t){this.textContent=e.call(this,t)}}function JF(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&XF(s)),t}return r._value=e,r}function QF(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,JF(e))}function ZF(){for(var e=this._name,t=this._id,n=I_(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)if(c=a[d]){var u=ki(c,t);Bm(c,e,n,d,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ro(r,this._parents,e,n)}function e3(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,a){var l={value:a},c={value:function(){--s===0&&i()}};n.each(function(){var d=no(this,r),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&i()})}var t3=0;function Ro(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function I_(){return++t3}var yo=mf.prototype;Ro.prototype={constructor:Ro,select:OF,selectAll:MF,selectChild:yo.selectChild,selectChildren:yo.selectChildren,filter:_F,merge:PF,selection:DF,transition:ZF,call:yo.call,nodes:yo.nodes,node:yo.node,size:yo.size,empty:yo.empty,each:yo.each,on:TF,attr:fF,attrTween:yF,style:VF,styleTween:KF,text:GF,textTween:QF,remove:LF,tween:iF,delay:bF,duration:SF,ease:jF,easeVarying:EF,end:e3,[Symbol.iterator]:yo[Symbol.iterator]};function n3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var r3={time:null,delay:0,duration:250,ease:n3};function s3(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function i3(e){var t,n;e instanceof Ro?(t=e._id,e=e._name):(t=I_(),(n=r3).time=Bb(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&Bm(c,e,t,d,a,n||s3(c,t));return new Ro(r,this._parents,e,t)}mf.prototype.interrupt=nF;mf.prototype.transition=i3;const jp=e=>()=>e;function o3(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function jo(e,t,n){this.k=e,this.x=t,this.y=n}jo.prototype={constructor:jo,scale:function(e){return e===1?this:new jo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new jo(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Hm=new jo(1,0,0);T_.prototype=jo.prototype;function T_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Hm;return e.__zoom}function cy(e){e.stopImmediatePropagation()}function $u(e){e.preventDefault(),e.stopImmediatePropagation()}function a3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function l3(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Kk(){return this.__zoom||Hm}function c3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function u3(){return navigator.maxTouchPoints||"ontouchstart"in this}function d3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function R_(){var e=a3,t=l3,n=d3,r=c3,s=u3,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=ih,d=Dm("start","zoom","end"),u,f,p,h=500,g=150,v=0,k=10;function y(D){D.property("__zoom",Kk).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(D,$,A,B){var P=D.selection?D.selection():D;P.property("__zoom",Kk),D!==P?C(D,$,A,B):P.interrupt().each(function(){N(this,arguments).event(B).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},y.scaleBy=function(D,$,A,B){y.scaleTo(D,function(){var P=this.__zoom.k,T=typeof $=="function"?$.apply(this,arguments):$;return P*T},A,B)},y.scaleTo=function(D,$,A,B){y.transform(D,function(){var P=t.apply(this,arguments),T=this.__zoom,E=A==null?S(P):typeof A=="function"?A.apply(this,arguments):A,Y=T.invert(E),Q=typeof $=="function"?$.apply(this,arguments):$;return n(w(b(T,Q),E,Y),P,a)},A,B)},y.translateBy=function(D,$,A,B){y.transform(D,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof A=="function"?A.apply(this,arguments):A),t.apply(this,arguments),a)},null,B)},y.translateTo=function(D,$,A,B,P){y.transform(D,function(){var T=t.apply(this,arguments),E=this.__zoom,Y=B==null?S(T):typeof B=="function"?B.apply(this,arguments):B;return n(Hm.translate(Y[0],Y[1]).scale(E.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof A=="function"?-A.apply(this,arguments):-A),T,a)},B,P)};function b(D,$){return $=Math.max(i[0],Math.min(i[1],$)),$===D.k?D:new jo($,D.x,D.y)}function w(D,$,A){var B=$[0]-A[0]*D.k,P=$[1]-A[1]*D.k;return B===D.x&&P===D.y?D:new jo(D.k,B,P)}function S(D){return[(+D[0][0]+ +D[1][0])/2,(+D[0][1]+ +D[1][1])/2]}function C(D,$,A,B){D.on("start.zoom",function(){N(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(B).end()}).tween("zoom",function(){var P=this,T=arguments,E=N(P,T).event(B),Y=t.apply(P,T),Q=A==null?S(Y):typeof A=="function"?A.apply(P,T):A,U=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),re=P.__zoom,ue=typeof $=="function"?$.apply(P,T):$,ge=c(re.invert(Q).concat(U/re.k),ue.invert(Q).concat(U/ue.k));return function(le){if(le===1)le=ue;else{var ce=ge(le),de=U/ce[2];le=new jo(de,Q[0]-ce[0]*de,Q[1]-ce[1]*de)}E.zoom(null,le)}})}function N(D,$,A){return!A&&D.__zooming||new I(D,$)}function I(D,$){this.that=D,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(D,$),this.taps=0}I.prototype={event:function(D){return D&&(this.sourceEvent=D),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(D,$){return this.mouse&&D!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&D!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&D!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(D){var $=bs(this.that).datum();d.call(D,this.that,new o3(D,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),$)}};function M(D,...$){if(!e.apply(this,arguments))return;var A=N(this,$).event(D),B=this.__zoom,P=Math.max(i[0],Math.min(i[1],B.k*Math.pow(2,r.apply(this,arguments)))),T=di(D);if(A.wheel)(A.mouse[0][0]!==T[0]||A.mouse[0][1]!==T[1])&&(A.mouse[1]=B.invert(A.mouse[0]=T)),clearTimeout(A.wheel);else{if(B.k===P)return;A.mouse=[T,B.invert(T)],lh(this),A.start()}$u(D),A.wheel=setTimeout(E,g),A.zoom("mouse",n(w(b(B,P),A.mouse[0],A.mouse[1]),A.extent,a));function E(){A.wheel=null,A.end()}}function R(D,...$){if(p||!e.apply(this,arguments))return;var A=D.currentTarget,B=N(this,$,!0).event(D),P=bs(D.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",U,!0),T=di(D,A),E=D.clientX,Y=D.clientY;g_(D.view),cy(D),B.mouse=[T,this.__zoom.invert(T)],lh(this),B.start();function Q(re){if($u(re),!B.moved){var ue=re.clientX-E,ge=re.clientY-Y;B.moved=ue*ue+ge*ge>v}B.event(re).zoom("mouse",n(w(B.that.__zoom,B.mouse[0]=di(re,A),B.mouse[1]),B.extent,a))}function U(re){P.on("mousemove.zoom mouseup.zoom",null),y_(re.view,B.moved),$u(re),B.event(re).end()}}function F(D,...$){if(e.apply(this,arguments)){var A=this.__zoom,B=di(D.changedTouches?D.changedTouches[0]:D,this),P=A.invert(B),T=A.k*(D.shiftKey?.5:2),E=n(w(b(A,T),B,P),t.apply(this,$),a);$u(D),l>0?bs(this).transition().duration(l).call(C,E,B,D):bs(this).call(y.transform,E,B,D)}}function O(D,...$){if(e.apply(this,arguments)){var A=D.touches,B=A.length,P=N(this,$,D.changedTouches.length===B).event(D),T,E,Y,Q;for(cy(D),E=0;E<B;++E)Y=A[E],Q=di(Y,this),Q=[Q,this.__zoom.invert(Q),Y.identifier],P.touch0?!P.touch1&&P.touch0[2]!==Q[2]&&(P.touch1=Q,P.taps=0):(P.touch0=Q,T=!0,P.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(P.taps<2&&(f=Q[0],u=setTimeout(function(){u=null},h)),lh(this),P.start())}}function L(D,...$){if(this.__zooming){var A=N(this,$).event(D),B=D.changedTouches,P=B.length,T,E,Y,Q;for($u(D),T=0;T<P;++T)E=B[T],Y=di(E,this),A.touch0&&A.touch0[2]===E.identifier?A.touch0[0]=Y:A.touch1&&A.touch1[2]===E.identifier&&(A.touch1[0]=Y);if(E=A.that.__zoom,A.touch1){var U=A.touch0[0],re=A.touch0[1],ue=A.touch1[0],ge=A.touch1[1],le=(le=ue[0]-U[0])*le+(le=ue[1]-U[1])*le,ce=(ce=ge[0]-re[0])*ce+(ce=ge[1]-re[1])*ce;E=b(E,Math.sqrt(le/ce)),Y=[(U[0]+ue[0])/2,(U[1]+ue[1])/2],Q=[(re[0]+ge[0])/2,(re[1]+ge[1])/2]}else if(A.touch0)Y=A.touch0[0],Q=A.touch0[1];else return;A.zoom("touch",n(w(E,Y,Q),A.extent,a))}}function W(D,...$){if(this.__zooming){var A=N(this,$).event(D),B=D.changedTouches,P=B.length,T,E;for(cy(D),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),T=0;T<P;++T)E=B[T],A.touch0&&A.touch0[2]===E.identifier?delete A.touch0:A.touch1&&A.touch1[2]===E.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(E=di(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<k)){var Y=bs(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return y.wheelDelta=function(D){return arguments.length?(r=typeof D=="function"?D:jp(+D),y):r},y.filter=function(D){return arguments.length?(e=typeof D=="function"?D:jp(!!D),y):e},y.touchable=function(D){return arguments.length?(s=typeof D=="function"?D:jp(!!D),y):s},y.extent=function(D){return arguments.length?(t=typeof D=="function"?D:jp([[+D[0][0],+D[0][1]],[+D[1][0],+D[1][1]]]),y):t},y.scaleExtent=function(D){return arguments.length?(i[0]=+D[0],i[1]=+D[1],y):[i[0],i[1]]},y.translateExtent=function(D){return arguments.length?(a[0][0]=+D[0][0],a[1][0]=+D[1][0],a[0][1]=+D[0][1],a[1][1]=+D[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(D){return arguments.length?(n=D,y):n},y.duration=function(D){return arguments.length?(l=+D,y):l},y.interpolate=function(D){return arguments.length?(c=D,y):c},y.on=function(){var D=d.on.apply(d,arguments);return D===d?y:D},y.clickDistance=function(D){return arguments.length?(v=(D=+D)*D,y):Math.sqrt(v)},y.tapDistance=function(D){return arguments.length?(k=+D,y):k},y}const eo={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Wd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],L_=["Enter"," ","Escape"],O_={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Bc;(function(e){e.Strict="strict",e.Loose="loose"})(Bc||(Bc={}));var fl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(fl||(fl={}));var Ud;(function(e){e.Partial="partial",e.Full="full"})(Ud||(Ud={}));const M_={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var la;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(la||(la={}));var us;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(us||(us={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));const qk={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};function $_(e){return e===null?null:e?"valid":"invalid"}const D_=e=>"id"in e&&"source"in e&&"target"in e,f3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Wb=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),yf=(e,t=[0,0])=>{const{width:n,height:r}=$o(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},p3=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Wb(s)?s:t.nodeLookup.get(s.id));const l=a?Yh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Vm(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Wm(n)},xf=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Vm(n,Yh(s)),r=!0)}),r?Wm(n):{x:0,y:0,width:0,height:0}},Ub=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...bf(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:u,selectable:f=!0,hidden:p=!1}=d;if(a&&!f||p)continue;const h=u.width??d.width??d.initialWidth??null,g=u.height??d.height??d.initialHeight??null,v=Kd(l,Vc(d)),k=(h??0)*(g??0),y=i&&v>0;(!d.internals.handleBounds||y||v>=k||d.dragging)&&c.push(d)}return c},h3=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function m3(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function g3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=m3(e,a),c=xf(l),d=Kb(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function F_({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},u=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",eo.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(f=[[c,d],[c+h,d+g]])}else l&&Wc(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+d],[a.extent[1][0]+c,a.extent[1][1]+d]]);const p=Wc(f)?kl(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",eo.error015())),{position:{x:p.x-c+(a.measured.width??0)*u[0],y:p.y-d+(a.measured.height??0)*u[1]},positionAbsolute:p}}async function y3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const h=i.has(p.id),g=!h&&p.parentId&&a.find(v=>v.id===p.parentId);(h||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),u=h3(a,c);for(const p of c)l.has(p.id)&&!u.find(g=>g.id===p.id)&&u.push(p);if(!s)return{edges:u,nodes:a};const f=await s({nodes:a,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:a}:{edges:[],nodes:[]}:f}const Hc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),kl=(e={x:0,y:0},t,n)=>({x:Hc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Hc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function z_(e,t,n){const{width:r,height:s}=$o(n),{x:i,y:a}=n.internals.positionAbsolute;return kl(e,[[i,a],[i+r,a+s]],t)}const Yk=(e,t,n)=>e<t?Hc(Math.abs(e-t),1,t)/t:e>n?-Hc(Math.abs(e-n),1,t)/t:0,B_=(e,t,n=15,r=40)=>{const s=Yk(e.x,r,t.width-r)*n,i=Yk(e.y,r,t.height-r)*n;return[s,i]},Vm=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),ow=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Wm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Vc=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Wb(e)?e.internals.positionAbsolute:yf(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Yh=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Wb(e)?e.internals.positionAbsolute:yf(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},H_=(e,t)=>Wm(Vm(ow(e),ow(t))),Kd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Gk=e=>mi(e.width)&&mi(e.height)&&mi(e.x)&&mi(e.y),mi=e=>!isNaN(e)&&isFinite(e),x3=(e,t)=>{},wf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),bf=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?wf(l,a):l},Gh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Gl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function w3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Gl(e,n),s=Gl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Gl(e.top??e.y??0,n),s=Gl(e.bottom??e.y??0,n),i=Gl(e.left??e.x??0,t),a=Gl(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function b3(e,t,n,r,s,i){const{x:a,y:l}=Gh(e,[t,n,r]),{x:c,y:d}=Gh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=s-c,f=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(u),bottom:Math.floor(f)}}const Kb=(e,t,n,r,s,i)=>{const a=w3(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),u=Hc(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*u,g=n/2-p*u,v=b3(e,h,g,u,t,n),k={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:h-k.left+k.right,y:g-k.top+k.bottom,zoom:u}},qd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Wc(e){return e!=null&&e!=="parent"}function $o(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function V_(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function W_(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const l=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function Xk(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function v3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function k3(e){return{...O_,...e||{}}}function hd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=gi(e),l=bf({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?wf(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const qb=e=>({width:e.offsetWidth,height:e.offsetHeight}),U_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},S3=["INPUT","SELECT","TEXTAREA"];function K_(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:S3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const q_=e=>"clientX"in e,gi=(e,t)=>{var i,a;const n=q_(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Jk=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...qb(a)}})};function Y_({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,d=t*.125+i*.375+l*.375+r*.125,u=Math.abs(c-e),f=Math.abs(d-t);return[c,d,u,f]}function Cp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Qk({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Ue.Left:return[t-Cp(t-r,i),n];case Ue.Right:return[t+Cp(r-t,i),n];case Ue.Top:return[t,n-Cp(n-s,i)];case Ue.Bottom:return[t,n+Cp(s-n,i)]}}function G_({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:i=Ue.Top,curvature:a=.25}){const[l,c]=Qk({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,u]=Qk({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,g]=Y_({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${e},${t} C${l},${c} ${d},${u} ${r},${s}`,f,p,h,g]}function X_({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,s,a]}function N3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const a=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function j3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Vm(Yh(e),Yh(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Kd(a,Wm(i))>0}const C3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,E3=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Yd=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||C3;let s;return D_(e)?s={...e}:s={...e,id:r(e)},E3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function J_({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=X_({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const Zk={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},_3=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},eS=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function P3({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:s,offset:i,stepPosition:a}){const l=Zk[t],c=Zk[r],d={x:e.x+l.x*i,y:e.y+l.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=_3({source:d,sourcePosition:t,target:u}),p=f.x!==0?"x":"y",h=f[p];let g=[],v,k;const y={x:0,y:0},b={x:0,y:0},[,,w,S]=X_({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??d.x+(u.x-d.x)*a,k=s.y??(d.y+u.y)/2):(v=s.x??(d.x+u.x)/2,k=s.y??d.y+(u.y-d.y)*a);const M=[{x:v,y:d.y},{x:v,y:u.y}],R=[{x:d.x,y:k},{x:u.x,y:k}];l[p]===h?g=p==="x"?M:R:g=p==="x"?R:M}else{const M=[{x:d.x,y:u.y}],R=[{x:u.x,y:d.y}];if(p==="x"?g=l.x===h?R:M:g=l.y===h?M:R,t===r){const D=Math.abs(e[p]-n[p]);if(D<=i){const $=Math.min(i-1,i-D);l[p]===h?y[p]=(d[p]>e[p]?-1:1)*$:b[p]=(u[p]>n[p]?-1:1)*$}}if(t!==r){const D=p==="x"?"y":"x",$=l[p]===c[D],A=d[D]>u[D],B=d[D]<u[D];(l[p]===1&&(!$&&A||$&&B)||l[p]!==1&&(!$&&B||$&&A))&&(g=p==="x"?M:R)}const F={x:d.x+y.x,y:d.y+y.y},O={x:u.x+b.x,y:u.y+b.y},L=Math.max(Math.abs(F.x-g[0].x),Math.abs(O.x-g[0].x)),W=Math.max(Math.abs(F.y-g[0].y),Math.abs(O.y-g[0].y));L>=W?(v=(F.x+O.x)/2,k=g[0].y):(v=g[0].x,k=(F.y+O.y)/2)}const C={x:d.x+y.x,y:d.y+y.y},N={x:u.x+b.x,y:u.y+b.y};return[[e,...C.x!==g[0].x||C.y!==g[0].y?[C]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],v,k,w,S]}function A3(e,t,n,r){const s=Math.min(eS(e,t)/2,eS(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*u}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${a+s*c}Q ${i},${a} ${i+s*l},${a}`}function aw({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:i=Ue.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:u=.5}){const[f,p,h,g,v]=P3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:d,stepPosition:u});let k=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)k+=A3(f[y-1],f[y],f[y+1],a);return k+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[k,p,h,g,v]}function tS(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function I3(e){var f;const{sourceNode:t,targetNode:n}=e;if(!tS(t)||!tS(n))return null;const r=t.internals.handleBounds||nS(t.handles),s=n.internals.handleBounds||nS(n.handles),i=rS((r==null?void 0:r.source)??[],e.sourceHandle),a=rS(e.connectionMode===Bc.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!a)return(f=e.onError)==null||f.call(e,"008",eo.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Ue.Bottom,c=(a==null?void 0:a.position)||Ue.Top,d=Sl(t,i,l),u=Sl(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:l,targetPosition:c}}function nS(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Sl(e,t,n=Ue.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??$o(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Ue.Top:return{x:s+a/2,y:i};case Ue.Right:return{x:s+a,y:i+l/2};case Ue.Bottom:return{x:s+a/2,y:i+l};case Ue.Left:return{x:s,y:i+l/2}}}function rS(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function lw(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function T3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=lw(c,t);i.has(d)||(a.push({id:d,color:c.color||n,...c}),i.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const Q_=1e3,R3=10,Yb={nodeOrigin:[0,0],nodeExtent:Wd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},L3={...Yb,checkEquality:!0};function Gb(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function O3(e,t,n){const r=Gb(Yb,n);for(const s of e.values())if(s.parentId)Jb(s,e,t,r);else{const i=yf(s,r.nodeOrigin),a=Wc(s.extent)?s.extent:r.nodeExtent,l=kl(i,a,$o(s));s.internals.positionAbsolute=l}}function M3(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Xb(e){return e==="manual"}function cw(e,t,n,r={}){var u,f;const s=Gb(L3,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Xb(s.zIndexMode)?Q_:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const g=yf(p,s.nodeOrigin),v=Wc(p.extent)?p.extent:s.nodeExtent,k=kl(g,v,$o(p));h={...s.defaults,...p,measured:{width:(u=p.measured)==null?void 0:u.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:k,handleBounds:M3(p,h),z:Z_(p,l,s.zIndexMode),userNode:p}},t.set(p.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),p.parentId&&Jb(h,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function $3(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Jb(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Gb(Yb,r),d=e.parentId,u=t.get(d);if(!u){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}$3(e,n),s&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++s.i,u.internals.z=u.internals.z+s.i*R3),s&&u.internals.rootParentIndex!==void 0&&(s.i=u.internals.rootParentIndex);const f=i&&!Xb(c)?Q_:0,{x:p,y:h,z:g}=D3(e,u,a,l,f,c),{positionAbsolute:v}=e.internals,k=p!==v.x||h!==v.y;(k||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:p,y:h}:v,z:g}})}function Z_(e,t,n){const r=mi(e.zIndex)?e.zIndex:0;return Xb(n)?r:r+(e.selected?t:0)}function D3(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=$o(e),d=yf(e,n),u=Wc(e.extent)?kl(d,e.extent,c):d;let f=kl({x:a+u.x,y:l+u.y},r,c);e.extent==="parent"&&(f=z_(f,c,t));const p=Z_(e,s,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Qb(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const d=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??Vc(c),u=H_(d,l.rect);i.set(l.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},d)=>{var w;const u=c.internals.positionAbsolute,f=$o(c),p=c.origin??r,h=l.x<u.x?Math.round(Math.abs(u.x-l.x)):0,g=l.y<u.y?Math.round(Math.abs(u.y-l.y)):0,v=Math.max(f.width,Math.round(l.width)),k=Math.max(f.height,Math.round(l.height)),y=(v-f.width)*p[0],b=(k-f.height)*p[1];(h>0||g>0||y||b)&&(s.push({id:d,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+b}}),(w=n.get(d))==null||w.forEach(S=>{e.some(C=>C.id===S.id)||s.push({id:S.id,type:"position",position:{x:S.position.x+h,y:S.position.y+g}})})),(f.width<l.width||f.height<l.height||h||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?p[0]*h-y:0),height:k+(g?p[1]*g-b:0)}})}),s}function F3(e,t,n,r,s,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],u=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(u.transform),p=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=qb(h.nodeElement),k=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(k||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),w=Wc(g.extent)?g.extent:i;let{positionAbsolute:S}=g.internals;g.parentId&&g.extent==="parent"?S=z_(S,v,t.get(g.parentId)):w&&(S=kl(S,w,v));const C={...g,measured:v,internals:{...g.internals,positionAbsolute:S,handleBounds:{source:Jk("source",h.nodeElement,b,f,g.id),target:Jk("target",h.nodeElement,b,f,g.id)}}};t.set(g.id,C),g.parentId&&Jb(C,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,k&&(d.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:Vc(C,s)}))}}if(p.length>0){const h=Qb(p,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function z3({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function sS(e,t,n,r,s,i){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),i){a=`${s}-${e}-${i}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function eP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${i}-${l}`,u=`${i}-${l}--${s}-${a}`;sS("source",c,u,e,s,a),sS("target",c,d,e,i,l),t.set(r.id,r)}}function tP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:tP(n,t):!1}function iS(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function B3(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!tP(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&s.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function uy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[d,u]of t){const f=(a=n.get(d))==null?void 0:a.internals.userNode;f&&s.push({...f,position:u.position,dragging:r})}if(!e)return[s[0],s];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function H3({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=wf(i,t);return{x:a.x-i.x,y:a.y-i.y}}function V3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,c=!1,d={x:0,y:0},u=null,f=!1,p=null,h=!1,g=!1,v=null;function k({noDragClassName:b,handleSelector:w,domNode:S,isSelectable:C,nodeId:N,nodeClickDistance:I=0}){p=bs(S);function M({x:L,y:W}){const{nodeLookup:D,nodeExtent:$,snapGrid:A,snapToGrid:B,nodeOrigin:P,onNodeDrag:T,onSelectionDrag:E,onError:Y,updateNodePositions:Q}=t();i={x:L,y:W};let U=!1;const re=l.size>1,ue=re&&$?ow(xf(l)):null,ge=re&&B?H3({dragItems:l,snapGrid:A,x:L,y:W}):null;for(const[le,ce]of l){if(!D.has(le))continue;let de={x:L-ce.distance.x,y:W-ce.distance.y};B&&(de=ge?{x:Math.round(de.x+ge.x),y:Math.round(de.y+ge.y)}:wf(de,A));let Ae=null;if(re&&$&&!ce.extent&&ue){const{positionAbsolute:Ie}=ce.internals,qe=Ie.x-ue.x+$[0][0],ct=Ie.x+ce.measured.width-ue.x2+$[1][0],Ge=Ie.y-ue.y+$[0][1],xt=Ie.y+ce.measured.height-ue.y2+$[1][1];Ae=[[qe,Ge],[ct,xt]]}const{position:Ne,positionAbsolute:Pe}=F_({nodeId:le,nextPosition:de,nodeLookup:D,nodeExtent:Ae||$,nodeOrigin:P,onError:Y});U=U||ce.position.x!==Ne.x||ce.position.y!==Ne.y,ce.position=Ne,ce.internals.positionAbsolute=Pe}if(g=g||U,!!U&&(Q(l,!0),v&&(r||T||!N&&E))){const[le,ce]=uy({nodeId:N,dragItems:l,nodeLookup:D});r==null||r(v,l,le,ce),T==null||T(v,le,ce),N||E==null||E(v,ce)}}async function R(){if(!u)return;const{transform:L,panBy:W,autoPanSpeed:D,autoPanOnNodeDrag:$}=t();if(!$){c=!1,cancelAnimationFrame(a);return}const[A,B]=B_(d,u,D);(A!==0||B!==0)&&(i.x=(i.x??0)-A/L[2],i.y=(i.y??0)-B/L[2],await W({x:A,y:B})&&M(i)),a=requestAnimationFrame(R)}function F(L){var re;const{nodeLookup:W,multiSelectionActive:D,nodesDraggable:$,transform:A,snapGrid:B,snapToGrid:P,selectNodesOnDrag:T,onNodeDragStart:E,onSelectionDragStart:Y,unselectNodesAndEdges:Q}=t();f=!0,(!T||!C)&&!D&&N&&((re=W.get(N))!=null&&re.selected||Q()),C&&T&&N&&(e==null||e(N));const U=hd(L.sourceEvent,{transform:A,snapGrid:B,snapToGrid:P,containerBounds:u});if(i=U,l=B3(W,$,U,N),l.size>0&&(n||E||!N&&Y)){const[ue,ge]=uy({nodeId:N,dragItems:l,nodeLookup:W});n==null||n(L.sourceEvent,l,ue,ge),E==null||E(L.sourceEvent,ue,ge),N||Y==null||Y(L.sourceEvent,ge)}}const O=x_().clickDistance(I).on("start",L=>{const{domNode:W,nodeDragThreshold:D,transform:$,snapGrid:A,snapToGrid:B}=t();u=(W==null?void 0:W.getBoundingClientRect())||null,h=!1,g=!1,v=L.sourceEvent,D===0&&F(L),i=hd(L.sourceEvent,{transform:$,snapGrid:A,snapToGrid:B,containerBounds:u}),d=gi(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:W,transform:D,snapGrid:$,snapToGrid:A,nodeDragThreshold:B,nodeLookup:P}=t(),T=hd(L.sourceEvent,{transform:D,snapGrid:$,snapToGrid:A,containerBounds:u});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||N&&!P.has(N))&&(h=!0),!h){if(!c&&W&&f&&(c=!0,R()),!f){const E=gi(L.sourceEvent,u),Y=E.x-d.x,Q=E.y-d.y;Math.sqrt(Y*Y+Q*Q)>B&&F(L)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&l&&f&&(d=gi(L.sourceEvent,u),M(T))}}).on("end",L=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:W,updateNodePositions:D,onNodeDragStop:$,onSelectionDragStop:A}=t();if(g&&(D(l,!1),g=!1),s||$||!N&&A){const[B,P]=uy({nodeId:N,dragItems:l,nodeLookup:W,dragging:!1});s==null||s(L.sourceEvent,l,B,P),$==null||$(L.sourceEvent,B,P),N||A==null||A(L.sourceEvent,P)}}}).filter(L=>{const W=L.target;return!L.button&&(!b||!iS(W,`.${b}`,S))&&(!w||iS(W,w,S))});p.call(O)}function y(){p==null||p.on(".drag",null)}return{update:k,destroy:y}}function W3(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Kd(s,Vc(i))>0&&r.push(i);return r}const U3=250;function K3(e,t,n,r){var l,c;let s=[],i=1/0;const a=W3(e,n,t+U3);for(const d of a){const u=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((c=d.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:h}=Sl(d,f,f.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(s=[{...f,x:p,y:h}],i=g):g===i&&s.push({...f,x:p,y:h}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(u=>u.type===d)??s[0]}return s[0]}function nP(e,t,n,r,s,i=!1){var d,u,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((u=a.internals.handleBounds)==null?void 0:u.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...Sl(a,c,c.position,!0)}:c}function rP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function q3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const sP=()=>!0;function Y3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:u,flowId:f,panBy:p,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:k,isValidConnection:y=sP,onReconnectEnd:b,updateConnection:w,getTransform:S,getFromHandle:C,autoPanSpeed:N,dragThreshold:I=1,handleDomNode:M}){const R=U_(e.target);let F=0,O;const{x:L,y:W}=gi(e),D=rP(i,M),$=l==null?void 0:l.getBoundingClientRect();let A=!1;if(!$||!D)return;const B=nP(s,D,r,c,t);if(!B)return;let P=gi(e,$),T=!1,E=null,Y=!1,Q=null;function U(){if(!u||!$)return;const[Ne,Pe]=B_(P,$,N);p({x:Ne,y:Pe}),F=requestAnimationFrame(U)}const re={...B,nodeId:s,type:D,position:B.position},ue=c.get(s);let le={inProgress:!0,isValid:null,from:Sl(ue,re,Ue.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ue,to:P,toHandle:null,toPosition:qk[re.position],toNode:null,pointer:P};function ce(){A=!0,w(le),g==null||g(e,{nodeId:s,handleId:r,handleType:D})}I===0&&ce();function de(Ne){if(!A){const{x:xt,y:Fe}=gi(Ne),ee=xt-L,De=Fe-W;if(!(ee*ee+De*De>I*I))return;ce()}if(!C()||!re){Ae(Ne);return}const Pe=S();P=gi(Ne,$),O=K3(bf(P,Pe,!1,[1,1]),n,c,re),T||(U(),T=!0);const Ie=iP(Ne,{handle:O,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:R,lib:d,flowId:f,nodeLookup:c});Q=Ie.handleDomNode,E=Ie.connection,Y=q3(!!O,Ie.isValid);const qe=c.get(s),ct=qe?Sl(qe,re,Ue.Left,!0):le.from,Ge={...le,from:ct,isValid:Y,to:Ie.toHandle&&Y?Gh({x:Ie.toHandle.x,y:Ie.toHandle.y},Pe):P,toHandle:Ie.toHandle,toPosition:Y&&Ie.toHandle?Ie.toHandle.position:qk[re.position],toNode:Ie.toHandle?c.get(Ie.toHandle.nodeId):null,pointer:P};w(Ge),le=Ge}function Ae(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(A){(O||Q)&&E&&Y&&(v==null||v(E));const{inProgress:Pe,...Ie}=le,qe={...Ie,toPosition:le.toHandle?le.toPosition:null};k==null||k(Ne,qe),i&&(b==null||b(Ne,qe))}h(),cancelAnimationFrame(F),T=!1,Y=!1,E=null,Q=null,R.removeEventListener("mousemove",de),R.removeEventListener("mouseup",Ae),R.removeEventListener("touchmove",de),R.removeEventListener("touchend",Ae)}}R.addEventListener("mousemove",de),R.addEventListener("mouseup",Ae),R.addEventListener("touchmove",de),R.addEventListener("touchend",Ae)}function iP(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:d=sP,nodeLookup:u}){const f=i==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=gi(e),v=a.elementFromPoint(h,g),k=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:p,y={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const b=rP(void 0,k),w=k.getAttribute("data-nodeid"),S=k.getAttribute("data-handleid"),C=k.classList.contains("connectable"),N=k.classList.contains("connectableend");if(!w||!b)return y;const I={source:f?w:r,sourceHandle:f?S:s,target:f?r:w,targetHandle:f?s:S};y.connection=I;const R=C&&N&&(n===Bc.Strict?f&&b==="source"||!f&&b==="target":w!==r||S!==s);y.isValid=R&&d(I),y.toHandle=nP(w,b,S,u,n,!0)}return y}const uw={onPointerDown:Y3,isValid:iP};function G3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=bs(e);function i({translateExtent:l,width:c,height:d,zoomStep:u=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const g=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const S=n(),C=w.sourceEvent.ctrlKey&&qd()?10:1,N=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*u,I=S[2]*Math.pow(2,N*C);t.scaleTo(I)};let v=[0,0];const k=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(v=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},y=w=>{const S=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const C=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],N=[C[0]-v[0],C[1]-v[1]];v=C;const I=r()*Math.max(S[2],Math.log(S[2]))*(h?-1:1),M={x:S[0]-N[0]*I,y:S[1]-N[1]*I},R=[[0,0],[c,d]];t.setViewportConstrained({x:M.x,y:M.y,zoom:S[2]},R,l)},b=R_().on("start",k).on("zoom",f?y:null).on("zoom.wheel",p?g:null);s.call(b,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:di}}const Um=e=>({x:e.x,y:e.y,zoom:e.k}),dy=({x:e,y:t,zoom:n})=>Hm.translate(e,t).scale(n),gc=(e,t)=>e.target.closest(`.${t}`),oP=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),X3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,fy=(e,t=0,n=X3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},aP=e=>{const t=e.ctrlKey&&qd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function J3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return u=>{if(gc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&a){const k=di(u),y=aP(u),b=f*Math.pow(2,y);r.scaleTo(n,b,k,u);return}const p=u.deltaMode===1?20:1;let h=s===fl.Vertical?0:u.deltaX*p,g=s===fl.Horizontal?0:u.deltaY*p;!qd()&&u.shiftKey&&s!==fl.Vertical&&(h=u.deltaY*p,g=0),r.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const v=Um(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(u,v),e.panScrollTimeout=setTimeout(()=>{d==null||d(u,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(u,v))}}function Q3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=gc(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function Z3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Um(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function ez({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&oP(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((l=i.sourceEvent)!=null&&l.internal)&&(s==null||s(i.sourceEvent,Um(i.transform)))}}function tz({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&oP(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Um(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function nz({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:u}){return f=>{var k;const p=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(gc(f,`${d}-flow__node`)||gc(f,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||u&&!g||gc(f,l)&&g||gc(f,c)&&(!g||s&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((k=f.touches)==null?void 0:k.length)>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&g||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&v}}function rz({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),f=R_().scaleExtent([t,n]).translateExtent(r),p=bs(e).call(f);b({x:s.x,y:s.y,zoom:Hc(s.zoom,t,n)},[[0,0],[u.width,u.height]],r);const h=p.on("wheel.zoom"),g=p.on("dblclick.zoom");f.wheelDelta(aP);function v(O,L){return p?new Promise(W=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?pd:ih).transform(fy(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>W(!0)),O)}):Promise.resolve(!1)}function k({noWheelClassName:O,noPanClassName:L,onPaneContextMenu:W,userSelectionActive:D,panOnScroll:$,panOnDrag:A,panOnScrollMode:B,panOnScrollSpeed:P,preventScrolling:T,zoomOnPinch:E,zoomOnScroll:Y,zoomOnDoubleClick:Q,zoomActivationKeyPressed:U,lib:re,onTransformChange:ue,connectionInProgress:ge,paneClickDistance:le,selectionOnDrag:ce}){D&&!d.isZoomingOrPanning&&y();const de=$&&!U&&!D;f.clickDistance(ce?1/0:!mi(le)||le<0?0:le);const Ae=de?J3({zoomPanValues:d,noWheelClassName:O,d3Selection:p,d3Zoom:f,panOnScrollMode:B,panOnScrollSpeed:P,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):Q3({noWheelClassName:O,preventScrolling:T,d3ZoomHandler:h});if(p.on("wheel.zoom",Ae,{passive:!1}),!D){const Pe=Z3({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});f.on("start",Pe);const Ie=ez({zoomPanValues:d,panOnDrag:A,onPaneContextMenu:!!W,onPanZoom:i,onTransformChange:ue});f.on("zoom",Ie);const qe=tz({zoomPanValues:d,panOnDrag:A,panOnScroll:$,onPaneContextMenu:W,onPanZoomEnd:l,onDraggingChange:c});f.on("end",qe)}const Ne=nz({zoomActivationKeyPressed:U,panOnDrag:A,zoomOnScroll:Y,panOnScroll:$,zoomOnDoubleClick:Q,zoomOnPinch:E,userSelectionActive:D,noPanClassName:L,noWheelClassName:O,lib:re,connectionInProgress:ge});f.filter(Ne),Q?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function b(O,L,W){const D=dy(O),$=f==null?void 0:f.constrain()(D,L,W);return $&&await v($),new Promise(A=>A($))}async function w(O,L){const W=dy(O);return await v(W,L),new Promise(D=>D(W))}function S(O){if(p){const L=dy(O),W=p.property("__zoom");(W.k!==O.zoom||W.x!==O.x||W.y!==O.y)&&(f==null||f.transform(p,L,null,{sync:!0}))}}function C(){const O=p?T_(p.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function N(O,L){return p?new Promise(W=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?pd:ih).scaleTo(fy(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>W(!0)),O)}):Promise.resolve(!1)}function I(O,L){return p?new Promise(W=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?pd:ih).scaleBy(fy(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>W(!0)),O)}):Promise.resolve(!1)}function M(O){f==null||f.scaleExtent(O)}function R(O){f==null||f.translateExtent(O)}function F(O){const L=!mi(O)||O<0?0:O;f==null||f.clickDistance(L)}return{update:k,destroy:y,setViewport:w,setViewportConstrained:b,getViewport:C,scaleTo:N,scaleBy:I,setScaleExtent:M,setTranslateExtent:R,syncViewport:S,setClickDistance:F}}var Uc;(function(e){e.Line="line",e.Handle="handle"})(Uc||(Uc={}));function sz({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&i&&(c[1]=c[1]*-1),c}function oS(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Zo(e,t){return Math.max(0,t-e)}function ea(e,t){return Math.max(0,e-t)}function Ep(e,t,n){return Math.max(0,t-e,e-n)}function aS(e,t){return e?!t:t}function iz(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:u,isVertical:f}=t,p=u&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:k,minHeight:y,maxHeight:b}=r,{x:w,y:S,width:C,height:N,aspectRatio:I}=e;let M=Math.floor(u?h-e.pointerX:0),R=Math.floor(f?g-e.pointerY:0);const F=C+(c?-M:M),O=N+(d?-R:R),L=-i[0]*C,W=-i[1]*N;let D=Ep(F,v,k),$=Ep(O,y,b);if(a){let P=0,T=0;c&&M<0?P=Zo(w+M+L,a[0][0]):!c&&M>0&&(P=ea(w+F+L,a[1][0])),d&&R<0?T=Zo(S+R+W,a[0][1]):!d&&R>0&&(T=ea(S+O+W,a[1][1])),D=Math.max(D,P),$=Math.max($,T)}if(l){let P=0,T=0;c&&M>0?P=ea(w+M,l[0][0]):!c&&M<0&&(P=Zo(w+F,l[1][0])),d&&R>0?T=ea(S+R,l[0][1]):!d&&R<0&&(T=Zo(S+O,l[1][1])),D=Math.max(D,P),$=Math.max($,T)}if(s){if(u){const P=Ep(F/I,y,b)*I;if(D=Math.max(D,P),a){let T=0;!c&&!d||c&&!d&&p?T=ea(S+W+F/I,a[1][1])*I:T=Zo(S+W+(c?M:-M)/I,a[0][1])*I,D=Math.max(D,T)}if(l){let T=0;!c&&!d||c&&!d&&p?T=Zo(S+F/I,l[1][1])*I:T=ea(S+(c?M:-M)/I,l[0][1])*I,D=Math.max(D,T)}}if(f){const P=Ep(O*I,v,k)/I;if($=Math.max($,P),a){let T=0;!c&&!d||d&&!c&&p?T=ea(w+O*I+L,a[1][0])/I:T=Zo(w+(d?R:-R)*I+L,a[0][0])/I,$=Math.max($,T)}if(l){let T=0;!c&&!d||d&&!c&&p?T=Zo(w+O*I,l[1][0])/I:T=ea(w+(d?R:-R)*I,l[0][0])/I,$=Math.max($,T)}}}R=R+(R<0?$:-$),M=M+(M<0?D:-D),s&&(p?F>O*I?R=(aS(c,d)?-M:M)/I:M=(aS(c,d)?-R:R)*I:u?(R=M/I,d=c):(M=R*I,c=d));const A=c?w+M:w,B=d?S+R:S;return{width:C+(c?-M:M),height:N+(d?-R:R),x:i[0]*M*(c?-1:1)+A,y:i[1]*R*(d?-1:1)+B}}const lP={width:0,height:0,x:0,y:0},oz={...lP,pointerX:0,pointerY:0,aspectRatio:1};function az(e){return[[0,0],[e.measured.width,e.measured.height]]}function lz(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,c=n[1]*a;return[[r-l,s-c],[r+i-l,s+a-c]]}function cz({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=bs(e);let a={controlDirection:oS("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:u,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:k}){let y={...lP},b={...oz};a={boundaries:u,resizeDirection:p,keepAspectRatio:f,controlDirection:oS(d)};let w,S=null,C=[],N,I,M,R=!1;const F=x_().on("start",O=>{const{nodeLookup:L,transform:W,snapGrid:D,snapToGrid:$,nodeOrigin:A,paneDomNode:B}=n();if(w=L.get(t),!w)return;S=(B==null?void 0:B.getBoundingClientRect())??null;const{xSnapped:P,ySnapped:T}=hd(O.sourceEvent,{transform:W,snapGrid:D,snapToGrid:$,containerBounds:S});y={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},b={...y,pointerX:P,pointerY:T,aspectRatio:y.width/y.height},N=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(N=L.get(w.parentId),I=N&&w.extent==="parent"?az(N):void 0),C=[],M=void 0;for(const[E,Y]of L)if(Y.parentId===t&&(C.push({id:E,position:{...Y.position},extent:Y.extent}),Y.extent==="parent"||Y.expandParent)){const Q=lz(Y,w,Y.origin??A);M?M=[[Math.min(Q[0][0],M[0][0]),Math.min(Q[0][1],M[0][1])],[Math.max(Q[1][0],M[1][0]),Math.max(Q[1][1],M[1][1])]]:M=Q}h==null||h(O,{...y})}).on("drag",O=>{const{transform:L,snapGrid:W,snapToGrid:D,nodeOrigin:$}=n(),A=hd(O.sourceEvent,{transform:L,snapGrid:W,snapToGrid:D,containerBounds:S}),B=[];if(!w)return;const{x:P,y:T,width:E,height:Y}=y,Q={},U=w.origin??$,{width:re,height:ue,x:ge,y:le}=iz(b,a.controlDirection,A,a.boundaries,a.keepAspectRatio,U,I,M),ce=re!==E,de=ue!==Y,Ae=ge!==P&&ce,Ne=le!==T&&de;if(!Ae&&!Ne&&!ce&&!de)return;if((Ae||Ne||U[0]===1||U[1]===1)&&(Q.x=Ae?ge:y.x,Q.y=Ne?le:y.y,y.x=Q.x,y.y=Q.y,C.length>0)){const ct=ge-P,Ge=le-T;for(const xt of C)xt.position={x:xt.position.x-ct+U[0]*(re-E),y:xt.position.y-Ge+U[1]*(ue-Y)},B.push(xt)}if((ce||de)&&(Q.width=ce&&(!a.resizeDirection||a.resizeDirection==="horizontal")?re:y.width,Q.height=de&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:y.height,y.width=Q.width,y.height=Q.height),N&&w.expandParent){const ct=U[0]*(Q.width??0);Q.x&&Q.x<ct&&(y.x=ct,b.x=b.x-(Q.x-ct));const Ge=U[1]*(Q.height??0);Q.y&&Q.y<Ge&&(y.y=Ge,b.y=b.y-(Q.y-Ge))}const Pe=sz({width:y.width,prevWidth:E,height:y.height,prevHeight:Y,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Ie={...y,direction:Pe};(k==null?void 0:k(O,Ie))!==!1&&(R=!0,g==null||g(O,Ie),r(Q,B))}).on("end",O=>{R&&(v==null||v(O,{...y}),s==null||s({...y}),R=!1)});i.call(F)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var cP={exports:{}},uP={},dP={exports:{}},fP={};/**
45
+ * @license React
46
+ * use-sync-external-store-shim.production.js
47
+ *
48
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
49
+ *
50
+ * This source code is licensed under the MIT license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */var Kc=m;function uz(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var dz=typeof Object.is=="function"?Object.is:uz,fz=Kc.useState,pz=Kc.useEffect,hz=Kc.useLayoutEffect,mz=Kc.useDebugValue;function gz(e,t){var n=t(),r=fz({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return hz(function(){s.value=n,s.getSnapshot=t,py(s)&&i({inst:s})},[e,n,t]),pz(function(){return py(s)&&i({inst:s}),e(function(){py(s)&&i({inst:s})})},[e]),mz(n),n}function py(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!dz(e,n)}catch{return!0}}function yz(e,t){return t()}var xz=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?yz:gz;fP.useSyncExternalStore=Kc.useSyncExternalStore!==void 0?Kc.useSyncExternalStore:xz;dP.exports=fP;var pP=dP.exports;/**
53
+ * @license React
54
+ * use-sync-external-store-shim/with-selector.production.js
55
+ *
56
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
57
+ *
58
+ * This source code is licensed under the MIT license found in the
59
+ * LICENSE file in the root directory of this source tree.
60
+ */var Km=m,wz=pP;function bz(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var vz=typeof Object.is=="function"?Object.is:bz,kz=wz.useSyncExternalStore,Sz=Km.useRef,Nz=Km.useEffect,jz=Km.useMemo,Cz=Km.useDebugValue;uP.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=Sz(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=jz(function(){function c(h){if(!d){if(d=!0,u=h,h=r(h),s!==void 0&&a.hasValue){var g=a.value;if(s(g,h))return f=g}return f=h}if(g=f,vz(u,h))return g;var v=r(h);return s!==void 0&&s(g,v)?(u=h,g):(u=h,f=v)}var d=!1,u,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=kz(e,i[0],i[1]);return Nz(function(){a.hasValue=!0,a.value=l},[l]),Cz(l),l};cP.exports=uP;var Ez=cP.exports;const _z=Ta(Ez),Pz={},lS=e=>{let t;const n=new Set,r=(u,f)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Pz?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},Az=e=>e?lS(e):lS,{useDebugValue:Iz}=et,{useSyncExternalStoreWithSelector:Tz}=_z,Rz=e=>e;function hP(e,t=Rz,n){const r=Tz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Iz(r),r}const cS=(e,t)=>{const n=Az(e),r=(s,i=t)=>hP(n,s,i);return Object.assign(r,n),r},Lz=(e,t)=>e?cS(e,t):cS;function Cn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const qm=m.createContext(null),Oz=qm.Provider,mP=eo.error001();function Mt(e,t){const n=m.useContext(qm);if(n===null)throw new Error(mP);return hP(n,e,t)}function kn(){const e=m.useContext(qm);if(e===null)throw new Error(mP);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const uS={display:"none"},Mz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},gP="react-flow__node-desc",yP="react-flow__edge-desc",$z="react-flow__aria-live",Dz=e=>e.ariaLiveMessage,Fz=e=>e.ariaLabelConfig;function zz({rfId:e}){const t=Mt(Dz);return o.jsx("div",{id:`${$z}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mz,children:t})}function Bz({rfId:e,disableKeyboardA11y:t}){const n=Mt(Fz);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${gP}-${e}`,style:uS,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${yP}-${e}`,style:uS,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(zz,{rfId:e})]})}const qc=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:Yn(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});qc.displayName="Panel";function Hz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(qc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Vz=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},_p=e=>e.id;function Wz(e,t){return Cn(e.selectedNodes.map(_p),t.selectedNodes.map(_p))&&Cn(e.selectedEdges.map(_p),t.selectedEdges.map(_p))}function Uz({onSelectionChange:e}){const t=kn(),{selectedNodes:n,selectedEdges:r}=Mt(Vz,Wz);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const Kz=e=>!!e.onSelectionChangeHandlers;function qz({onSelectionChange:e}){const t=Mt(Kz);return e||t?o.jsx(Uz,{onSelectionChange:e}):null}const dw=typeof window<"u"?m.useLayoutEffect:m.useEffect,xP=[0,0],Yz={x:0,y:0,zoom:1},Gz=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],dS=[...Gz,"rfId"],Xz=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),fS={translateExtent:Wd,nodeOrigin:xP,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Jz(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Mt(Xz,Cn),d=kn();dw(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=fS,l()}),[]);const u=m.useRef(fS);return dw(()=>{for(const f of dS){const p=e[f],h=u.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?i(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:k3(p)}):f==="fitView"?d.setState({fitViewQueued:p}):f==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[f]:p})))}u.current=e},dS.map(f=>e[f])),null}function pS(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Qz(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=pS(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=pS())!=null&&r.matches?"dark":"light"}const hS=typeof document<"u"?document:null;function Gd(e=null,t={target:hS,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),i=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
+ `).replace(`
62
+
63
+ `,`
64
+ +`).split(`
65
+ `)),u=d.reduce((f,p)=>f.concat(...p),[]);return[d,u]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??hS,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var k,y;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&K_(h))return!1;const v=gS(h.code,l);if(i.current.add(h[v]),mS(a,i.current,!1)){const b=((y=(k=h.composedPath)==null?void 0:k.call(h))==null?void 0:y[0])||h.target,w=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(s.current||!w)&&h.preventDefault(),r(!0)}},f=h=>{const g=gS(h.code,l);mS(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function mS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function gS(e,t){return t.includes(e)?"code":"key"}const Zz=()=>{const e=kn();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),c=Kb(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},u=n.snapGrid??s,f=n.snapToGrid??i;return bf(d,r,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=Gh(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function wP(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const c of a)e5(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function e5(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Zb(e,t){return wP(e,t)}function bP(e,t){return wP(e,t)}function rl(e,t){return{id:e,type:"select",selected:t}}function yc(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(rl(i.id,a)))}return r}function yS({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function xS(e){return{id:e.id,type:"remove"}}const wS=e=>f3(e),t5=e=>D_(e);function vP(e){return m.forwardRef(e)}function bS(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>n5(()=>n(s=>s+BigInt(1))));return dw(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function n5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const kP=m.createContext(null);function r5({children:e}){const t=kn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:u,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let v=c;for(const y of l)v=typeof y=="function"?y(v):y;let k=yS({items:v,lookup:p});for(const y of g.values())k=y(k);u&&d(v),k.length>0?f==null||f(k):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:b,setNodes:w}=t.getState();y&&w(b)})},[]),r=bS(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;u?d(h):f&&f(yS({items:h,lookup:p}))},[]),i=bS(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(kP.Provider,{value:a,children:e})}function s5(){const e=m.useContext(kP);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const i5=e=>!!e.panZoom;function _l(){const e=Zz(),t=kn(),n=s5(),r=Mt(i5),s=m.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var y,b;const{nodeLookup:p,nodeOrigin:h}=t.getState(),g=wS(f)?f:p.get(f.id),v=g.parentId?W_(g.position,g.measured,g.parentId,p,h):g.position,k={...g,position:v,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Vc(k)},d=(f,p,h={replace:!1})=>{a(g=>g.map(v=>{if(v.id===f){const k=typeof p=="function"?p(v):p;return h.replace&&wS(k)?k:{...v,...k}}return v}))},u=(f,p,h={replace:!1})=>{l(g=>g.map(v=>{if(v.id===f){const k=typeof p=="function"?p(v):p;return h.replace&&t5(k)?k:{...v,...k}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var p;return(p=i(f))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(p=>({...p}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const p=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:h}=t.getState(),[g,v,k]=h;return{nodes:f.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:v,zoom:k}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:g,onNodesDelete:v,onEdgesDelete:k,triggerNodeChanges:y,triggerEdgeChanges:b,onDelete:w,onBeforeDelete:S}=t.getState(),{nodes:C,edges:N}=await y3({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:g,onBeforeDelete:S}),I=N.length>0,M=C.length>0;if(I){const R=N.map(xS);k==null||k(N),b(R)}if(M){const R=C.map(xS);v==null||v(C),y(R)}return(M||I)&&(w==null||w({nodes:C,edges:N})),{deletedNodes:C,deletedEdges:N}},getIntersectingNodes:(f,p=!0,h)=>{const g=Gk(f),v=g?f:c(f),k=h!==void 0;return v?(h||t.getState().nodes).filter(y=>{const b=t.getState().nodeLookup.get(y.id);if(b&&!g&&(y.id===f.id||!b.internals.positionAbsolute))return!1;const w=Vc(k?y:b),S=Kd(w,v);return p&&S>0||S>=w.width*w.height||S>=v.width*v.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const v=Gk(f)?f:c(f);if(!v)return!1;const k=Kd(v,p);return h&&k>0||k>=p.width*p.height||k>=v.width*v.height},updateNode:d,updateNodeData:(f,p,h={replace:!1})=>{d(f,g=>{const v=typeof p=="function"?p(g):p;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},updateEdge:u,updateEdgeData:(f,p,h={replace:!1})=>{u(f,g=>{const v=typeof p=="function"?p(g):p;return h.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return p3(f,{nodeLookup:p,nodeOrigin:h})},getHandleConnections:({type:f,id:p,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${f}${p?`-${p}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:g.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??v3();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(h=>[...h]),p.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const vS=e=>e.selected,o5=typeof window<"u"?window:void 0;function a5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=kn(),{deleteElements:r}=_l(),s=Gd(e,{actInsideInputWithModifier:!1}),i=Gd(t,{target:o5});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(vS),edges:a.filter(vS)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function l5(e){const t=kn();m.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=qb(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",eo.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Ym={position:"absolute",width:"100%",height:"100%",top:0,left:0},c5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function u5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=fl.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:u,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:g,noWheelClassName:v,noPanClassName:k,onViewportChange:y,isControlledViewport:b,paneClickDistance:w,selectionOnDrag:S}){const C=kn(),N=m.useRef(null),{userSelectionActive:I,lib:M,connectionInProgress:R}=Mt(c5,Cn),F=Gd(p),O=m.useRef();l5(N);const L=m.useCallback(W=>{y==null||y({x:W[0],y:W[1],zoom:W[2]}),b||C.setState({transform:W})},[y,b]);return m.useEffect(()=>{if(N.current){O.current=rz({domNode:N.current,minZoom:u,maxZoom:f,translateExtent:d,viewport:c,onDraggingChange:A=>C.setState(B=>B.paneDragging===A?B:{paneDragging:A}),onPanZoomStart:(A,B)=>{const{onViewportChangeStart:P,onMoveStart:T}=C.getState();T==null||T(A,B),P==null||P(B)},onPanZoom:(A,B)=>{const{onViewportChange:P,onMove:T}=C.getState();T==null||T(A,B),P==null||P(B)},onPanZoomEnd:(A,B)=>{const{onViewportChangeEnd:P,onMoveEnd:T}=C.getState();T==null||T(A,B),P==null||P(B)}});const{x:W,y:D,zoom:$}=O.current.getViewport();return C.setState({panZoom:O.current,transform:[W,D,$],domNode:N.current.closest(".react-flow")}),()=>{var A;(A=O.current)==null||A.destroy()}}},[]),m.useEffect(()=>{var W;(W=O.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:h,noPanClassName:k,userSelectionActive:I,noWheelClassName:v,lib:M,onTransformChange:L,connectionInProgress:R,selectionOnDrag:S,paneClickDistance:w})},[e,t,n,r,s,i,a,l,F,h,k,I,v,M,L,R,S,w]),o.jsx("div",{className:"react-flow__renderer",ref:N,style:Ym,children:g})}const d5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function f5(){const{userSelectionActive:e,userSelectionRect:t}=Mt(d5,Cn);return e&&t?o.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const hy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},p5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function h5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ud.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:g}){const v=kn(),{userSelectionActive:k,elementsSelectable:y,dragging:b,connectionInProgress:w}=Mt(p5,Cn),S=y&&(e||k),C=m.useRef(null),N=m.useRef(),I=m.useRef(new Set),M=m.useRef(new Set),R=m.useRef(!1),F=P=>{if(R.current||w){R.current=!1;return}c==null||c(P),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},O=P=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){P.preventDefault();return}d==null||d(P)},L=u?P=>u(P):void 0,W=P=>{R.current&&(P.stopPropagation(),R.current=!1)},D=P=>{var ue,ge;const{domNode:T}=v.getState();if(N.current=T==null?void 0:T.getBoundingClientRect(),!N.current)return;const E=P.target===C.current;if(!E&&!!P.target.closest(".nokey")||!e||!(i&&E||t)||P.button!==0||!P.isPrimary)return;(ge=(ue=P.target)==null?void 0:ue.setPointerCapture)==null||ge.call(ue,P.pointerId),R.current=!1;const{x:U,y:re}=gi(P.nativeEvent,N.current);v.setState({userSelectionRect:{width:0,height:0,startX:U,startY:re,x:U,y:re}}),E||(P.stopPropagation(),P.preventDefault())},$=P=>{const{userSelectionRect:T,transform:E,nodeLookup:Y,edgeLookup:Q,connectionLookup:U,triggerNodeChanges:re,triggerEdgeChanges:ue,defaultEdgeOptions:ge,resetSelectedElements:le}=v.getState();if(!N.current||!T)return;const{x:ce,y:de}=gi(P.nativeEvent,N.current),{startX:Ae,startY:Ne}=T;if(!R.current){const Ge=t?0:s;if(Math.hypot(ce-Ae,de-Ne)<=Ge)return;le(),a==null||a(P)}R.current=!0;const Pe={startX:Ae,startY:Ne,x:ce<Ae?ce:Ae,y:de<Ne?de:Ne,width:Math.abs(ce-Ae),height:Math.abs(de-Ne)},Ie=I.current,qe=M.current;I.current=new Set(Ub(Y,Pe,E,n===Ud.Partial,!0).map(Ge=>Ge.id)),M.current=new Set;const ct=(ge==null?void 0:ge.selectable)??!0;for(const Ge of I.current){const xt=U.get(Ge);if(xt)for(const{edgeId:Fe}of xt.values()){const ee=Q.get(Fe);ee&&(ee.selectable??ct)&&M.current.add(Fe)}}if(!Xk(Ie,I.current)){const Ge=yc(Y,I.current,!0);re(Ge)}if(!Xk(qe,M.current)){const Ge=yc(Q,M.current);ue(Ge)}v.setState({userSelectionRect:Pe,userSelectionActive:!0,nodesSelectionActive:!1})},A=P=>{var T,E;P.button===0&&((E=(T=P.target)==null?void 0:T.releasePointerCapture)==null||E.call(T,P.pointerId),!k&&P.target===C.current&&v.getState().userSelectionRect&&(F==null||F(P)),v.setState({userSelectionActive:!1,userSelectionRect:null}),R.current&&(l==null||l(P),v.setState({nodesSelectionActive:I.current.size>0})))},B=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:Yn(["react-flow__pane",{draggable:B,dragging:b,selection:e}]),onClick:S?void 0:hy(F,C),onContextMenu:hy(O,C),onWheel:hy(L,C),onPointerEnter:S?void 0:f,onPointerMove:S?$:p,onPointerUp:S?A:void 0,onPointerDownCapture:S?D:void 0,onClickCapture:S?W:void 0,onPointerLeave:h,ref:C,style:Ym,children:[g,o.jsx(f5,{})]})}function fw({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",eo.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([e])}function SP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=kn(),[c,d]=m.useState(!1),u=m.useRef();return m.useEffect(()=>{u.current=V3({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{fw({id:f,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=u.current)==null||f.destroy()}},[n,r,t,i,e,s,a]),c}const m5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function NP(){const e=kn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:u}=e.getState(),f=new Map,p=m5(a),h=s?i[0]:5,g=s?i[1]:5,v=n.direction.x*h*n.factor,k=n.direction.y*g*n.factor;for(const[,y]of d){if(!p(y))continue;let b={x:y.internals.positionAbsolute.x+v,y:y.internals.positionAbsolute.y+k};s&&(b=wf(b,i));const{position:w,positionAbsolute:S}=F_({nodeId:y.id,nextPosition:b,nodeLookup:d,nodeExtent:r,nodeOrigin:u,onError:l});y.position=w,y.internals.positionAbsolute=S,f.set(y.id,y)}c(f)},[])}const ev=m.createContext(null),g5=ev.Provider;ev.Consumer;const jP=()=>m.useContext(ev),y5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),x5=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:u,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Bc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:u&&d}};function w5({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:u,onTouchStart:f,...p},h){var $,A;const g=a||null,v=e==="target",k=kn(),y=jP(),{connectOnClick:b,noPanClassName:w,rfId:S}=Mt(y5,Cn),{connectingFrom:C,connectingTo:N,clickConnecting:I,isPossibleEndHandle:M,connectionInProcess:R,clickConnectionInProcess:F,valid:O}=Mt(x5(y,g,e),Cn);y||(A=($=k.getState()).onError)==null||A.call($,"010",eo.error010());const L=B=>{const{defaultEdgeOptions:P,onConnect:T,hasDefaultEdges:E}=k.getState(),Y={...P,...B};if(E){const{edges:Q,setEdges:U}=k.getState();U(Yd(Y,Q))}T==null||T(Y),l==null||l(Y)},W=B=>{if(!y)return;const P=q_(B.nativeEvent);if(s&&(P&&B.button===0||!P)){const T=k.getState();uw.onPointerDown(B.nativeEvent,{handleDomNode:B.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:v,handleId:g,nodeId:y,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...E)=>{var Y,Q;return(Q=(Y=k.getState()).onConnectEnd)==null?void 0:Q.call(Y,...E)},updateConnection:T.updateConnection,onConnect:L,isValidConnection:n||((...E)=>{var Y,Q;return((Q=(Y=k.getState()).isValidConnection)==null?void 0:Q.call(Y,...E))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}P?u==null||u(B):f==null||f(B)},D=B=>{const{onClickConnectStart:P,onClickConnectEnd:T,connectionClickStartHandle:E,connectionMode:Y,isValidConnection:Q,lib:U,rfId:re,nodeLookup:ue,connection:ge}=k.getState();if(!y||!E&&!s)return;if(!E){P==null||P(B.nativeEvent,{nodeId:y,handleId:g,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const le=U_(B.target),ce=n||Q,{connection:de,isValid:Ae}=uw.isValid(B.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:Y,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:ce,flowId:re,doc:le,lib:U,nodeLookup:ue});Ae&&de&&L(de);const Ne=structuredClone(ge);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,T==null||T(B,Ne),k.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${S}-${y}-${g}-${e}`,className:Yn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,d,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:i,clickconnecting:I,connectingfrom:C,connectingto:N,valid:O,connectionindicator:r&&(!R||M)&&(R||F?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:b?D:void 0,ref:h,...p,children:c})}const fs=m.memo(vP(w5));function b5({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(fs,{type:"source",position:n,isConnectable:t})]})}function v5({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:r=Ue.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(fs,{type:"source",position:r,isConnectable:t})]})}function k5(){return null}function S5({data:e,isConnectable:t,targetPosition:n=Ue.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(fs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Xh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},kS={input:b5,default:v5,output:S5,group:k5};function N5(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const j5=e=>{const{width:t,height:n,x:r,y:s}=xf(e.nodeLookup,{filter:i=>!!i.selected});return{width:mi(t)?t:null,height:mi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function C5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=kn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Mt(j5,Cn),c=NP(),d=m.useRef(null);m.useEffect(()=>{var h;n||(h=d.current)==null||h.focus({preventScroll:!0})},[n]);const u=!l&&s!==null&&i!==null;if(SP({nodeRef:d,disabled:!u}),!u)return null;const f=e?h=>{const g=r.getState().nodes.filter(v=>v.selected);e(h,g)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(Xh,h.key)&&(h.preventDefault(),c({direction:Xh[h.key],factor:h.shiftKey?4:1}))};return o.jsx("div",{className:Yn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const SS=typeof window<"u"?window:void 0,E5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function CP({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:u,selectionMode:f,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:k,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:w,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:M,defaultViewport:R,translateExtent:F,minZoom:O,maxZoom:L,preventScrolling:W,onSelectionContextMenu:D,noWheelClassName:$,noPanClassName:A,disableKeyboardA11y:B,onViewportChange:P,isControlledViewport:T}){const{nodesSelectionActive:E,userSelectionActive:Y}=Mt(E5,Cn),Q=Gd(d,{target:SS}),U=Gd(v,{target:SS}),re=U||M,ue=U||S,ge=u&&re!==!0,le=Q||Y||ge;return a5({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(u5,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:w,panOnScroll:ue,panOnScrollSpeed:C,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:!Q&&re,defaultViewport:R,translateExtent:F,minZoom:O,maxZoom:L,zoomActivationKeyCode:k,preventScrolling:W,noWheelClassName:$,noPanClassName:A,onViewportChange:P,isControlledViewport:T,paneClickDistance:l,selectionOnDrag:ge,children:o.jsxs(h5,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:re,isSelecting:!!le,selectionMode:f,selectionKeyPressed:Q,paneClickDistance:l,selectionOnDrag:ge,children:[e,E&&o.jsx(C5,{onSelectionContextMenu:D,noPanClassName:A,disableKeyboardA11y:B})]})})}CP.displayName="FlowRenderer";const _5=m.memo(CP),P5=e=>t=>e?Ub(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function A5(e){return Mt(m.useCallback(P5(e),[e]),Cn)}const I5=e=>e.updateNodeInternals;function T5(){const e=Mt(I5),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function R5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=kn(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),d=m.useRef(t),u=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!u||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[u,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const f=d.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function L5({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:u,resizeObserver:f,noDragClassName:p,noPanClassName:h,disableKeyboardA11y:g,rfId:v,nodeTypes:k,nodeClickDistance:y,onError:b}){const{node:w,internals:S,isParent:C}=Mt(ce=>{const de=ce.nodeLookup.get(e),Ae=ce.parentLookup.has(e);return{node:de,internals:de.internals,isParent:Ae}},Cn);let N=w.type||"default",I=(k==null?void 0:k[N])||kS[N];I===void 0&&(b==null||b("003",eo.error003(N)),N="default",I=(k==null?void 0:k.default)||kS.default);const M=!!(w.draggable||l&&typeof w.draggable>"u"),R=!!(w.selectable||c&&typeof w.selectable>"u"),F=!!(w.connectable||d&&typeof w.connectable>"u"),O=!!(w.focusable||u&&typeof w.focusable>"u"),L=kn(),W=V_(w),D=R5({node:w,nodeType:N,hasDimensions:W,resizeObserver:f}),$=SP({nodeRef:D,disabled:w.hidden||!M,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:y}),A=NP();if(w.hidden)return null;const B=$o(w),P=N5(w),T=R||M||t||n||r||s,E=n?ce=>n(ce,{...S.userNode}):void 0,Y=r?ce=>r(ce,{...S.userNode}):void 0,Q=s?ce=>s(ce,{...S.userNode}):void 0,U=i?ce=>i(ce,{...S.userNode}):void 0,re=a?ce=>a(ce,{...S.userNode}):void 0,ue=ce=>{const{selectNodesOnDrag:de,nodeDragThreshold:Ae}=L.getState();R&&(!de||!M||Ae>0)&&fw({id:e,store:L,nodeRef:D}),t&&t(ce,{...S.userNode})},ge=ce=>{if(!(K_(ce.nativeEvent)||g)){if(L_.includes(ce.key)&&R){const de=ce.key==="Escape";fw({id:e,store:L,unselect:de,nodeRef:D})}else if(M&&w.selected&&Object.prototype.hasOwnProperty.call(Xh,ce.key)){ce.preventDefault();const{ariaLabelConfig:de}=L.getState();L.setState({ariaLiveMessage:de["node.a11yDescription.ariaLiveMessage"]({direction:ce.key.replace("Arrow","").toLowerCase(),x:~~S.positionAbsolute.x,y:~~S.positionAbsolute.y})}),A({direction:Xh[ce.key],factor:ce.shiftKey?4:1})}}},le=()=>{var qe;if(g||!((qe=D.current)!=null&&qe.matches(":focus-visible")))return;const{transform:ce,width:de,height:Ae,autoPanOnNodeFocus:Ne,setCenter:Pe}=L.getState();if(!Ne)return;Ub(new Map([[e,w]]),{x:0,y:0,width:de,height:Ae},ce,!0).length>0||Pe(w.position.x+B.width/2,w.position.y+B.height/2,{zoom:ce[2]})};return o.jsx("div",{className:Yn(["react-flow__node",`react-flow__node-${N}`,{[h]:M},w.className,{selected:w.selected,selectable:R,parent:C,draggable:M,dragging:$}]),ref:D,style:{zIndex:S.z,transform:`translate(${S.positionAbsolute.x}px,${S.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:W?"visible":"hidden",...w.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Y,onMouseLeave:Q,onContextMenu:U,onClick:ue,onDoubleClick:re,onKeyDown:O?ge:void 0,tabIndex:O?0:void 0,onFocus:O?le:void 0,role:w.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${gP}-${v}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(g5,{value:e,children:o.jsx(I,{id:e,data:w.data,type:N,positionAbsoluteX:S.positionAbsolute.x,positionAbsoluteY:S.positionAbsolute.y,selected:w.selected??!1,selectable:R,draggable:M,deletable:w.deletable??!0,isConnectable:F,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:$,dragHandle:w.dragHandle,zIndex:S.z,parentId:w.parentId,...B})})})}var O5=m.memo(L5);const M5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function EP(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Mt(M5,Cn),a=A5(e.onlyRenderVisibleElements),l=T5();return o.jsx("div",{className:"react-flow__nodes",style:Ym,children:a.map(c=>o.jsx(O5,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}EP.displayName="NodeRenderer";const $5=m.memo(EP);function D5(e){return Mt(m.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&j3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Cn)}const F5=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},z5=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},NS={[us.Arrow]:F5,[us.ArrowClosed]:z5};function B5(e){const t=kn();return m.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(NS,e)?NS[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",eo.error009(e)),null)},[e])}const H5=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=B5(t);return c?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(c,{color:n,strokeWidth:a})}):null},_P=({defaultColor:e,rfId:t})=>{const n=Mt(i=>i.edges),r=Mt(i=>i.defaultEdgeOptions),s=m.useMemo(()=>T3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(H5,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};_P.displayName="MarkerDefinitions";var V5=m.memo(_P);function PP({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...u}){const[f,p]=m.useState({x:1,y:0,width:0,height:0}),h=Yn(["react-flow__edge-textwrapper",d]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const v=g.current.getBBox();p({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...u,children:[s&&o.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}PP.displayName="EdgeText";const W5=m.memo(PP);function Gm({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...u}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...u,d:e,fill:"none",className:Yn(["react-flow__edge-path",u.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&mi(t)&&mi(n)?o.jsx(W5,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function jS({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ue.Left||e===Ue.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function AP({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:i=Ue.Top}){const[a,l]=jS({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=jS({pos:i,x1:r,y1:s,x2:e,y2:t}),[u,f,p,h]=Y_({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${s}`,u,f,p,h]}function IP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:k,interactionWidth:y})=>{const[b,w,S]=AP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),C=e.isInternal?void 0:t;return o.jsx(Gm,{id:C,path:b,labelX:w,labelY:S,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:k,interactionWidth:y})})}const U5=IP({isInternal:!1}),TP=IP({isInternal:!0});U5.displayName="SimpleBezierEdge";TP.displayName="SimpleBezierEdgeInternal";function RP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,sourcePosition:h=Ue.Bottom,targetPosition:g=Ue.Top,markerEnd:v,markerStart:k,pathOptions:y,interactionWidth:b})=>{const[w,S,C]=aw({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),N=e.isInternal?void 0:t;return o.jsx(Gm,{id:N,path:w,labelX:S,labelY:C,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:k,interactionWidth:b})})}const LP=RP({isInternal:!1}),OP=RP({isInternal:!0});LP.displayName="SmoothStepEdge";OP.displayName="SmoothStepEdgeInternal";function MP(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(LP,{...n,id:r,pathOptions:m.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const K5=MP({isInternal:!1}),$P=MP({isInternal:!0});K5.displayName="StepEdge";$P.displayName="StepEdgeInternal";function DP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:v})=>{const[k,y,b]=J_({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(Gm,{id:w,path:k,labelX:y,labelY:b,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:v})})}const q5=DP({isInternal:!1}),FP=DP({isInternal:!0});q5.displayName="StraightEdge";FP.displayName="StraightEdgeInternal";function zP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:k,pathOptions:y,interactionWidth:b})=>{const[w,S,C]=G_({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),N=e.isInternal?void 0:t;return o.jsx(Gm,{id:N,path:w,labelX:S,labelY:C,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:k,interactionWidth:b})})}const Y5=zP({isInternal:!1}),BP=zP({isInternal:!0});Y5.displayName="BezierEdge";BP.displayName="BezierEdgeInternal";const CS={default:BP,straight:FP,step:$P,smoothstep:OP,simplebezier:TP},ES={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},G5=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,X5=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,_S="react-flow__edgeupdater";function PS({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:Yn([_S,`${_S}-${l}`]),cx:G5(t,r,e),cy:X5(n,r,e),r,stroke:"transparent",fill:"transparent"})}function J5({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:u,onReconnectEnd:f,setReconnecting:p,setUpdateHover:h}){const g=kn(),v=(S,C)=>{if(S.button!==0)return;const{autoPanOnConnect:N,domNode:I,connectionMode:M,connectionRadius:R,lib:F,onConnectStart:O,cancelConnection:L,nodeLookup:W,rfId:D,panBy:$,updateConnection:A}=g.getState(),B=C.type==="target",P=(Y,Q)=>{p(!1),f==null||f(Y,n,C.type,Q)},T=Y=>d==null?void 0:d(n,Y),E=(Y,Q)=>{p(!0),u==null||u(S,n,C.type),O==null||O(Y,Q)};uw.onPointerDown(S.nativeEvent,{autoPanOnConnect:N,connectionMode:M,connectionRadius:R,domNode:I,handleId:C.id,nodeId:C.nodeId,nodeLookup:W,isTarget:B,edgeUpdaterType:C.type,lib:F,flowId:D,cancelConnection:L,panBy:$,isValidConnection:(...Y)=>{var Q,U;return((U=(Q=g.getState()).isValidConnection)==null?void 0:U.call(Q,...Y))??!0},onConnect:T,onConnectStart:E,onConnectEnd:(...Y)=>{var Q,U;return(U=(Q=g.getState()).onConnectEnd)==null?void 0:U.call(Q,...Y)},onReconnectEnd:P,updateConnection:A,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:S.currentTarget})},k=S=>v(S,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=S=>v(S,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),w=()=>h(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(PS,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:b,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(PS,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:w,type:"target"})]})}function Q5({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,rfId:g,edgeTypes:v,noPanClassName:k,onError:y,disableKeyboardA11y:b}){let w=Mt(Pe=>Pe.edgeLookup.get(e));const S=Mt(Pe=>Pe.defaultEdgeOptions);w=S?{...S,...w}:w;let C=w.type||"default",N=(v==null?void 0:v[C])||CS[C];N===void 0&&(y==null||y("011",eo.error011(C)),C="default",N=(v==null?void 0:v.default)||CS.default);const I=!!(w.focusable||t&&typeof w.focusable>"u"),M=typeof f<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),R=!!(w.selectable||r&&typeof w.selectable>"u"),F=m.useRef(null),[O,L]=m.useState(!1),[W,D]=m.useState(!1),$=kn(),{zIndex:A,sourceX:B,sourceY:P,targetX:T,targetY:E,sourcePosition:Y,targetPosition:Q}=Mt(m.useCallback(Pe=>{const Ie=Pe.nodeLookup.get(w.source),qe=Pe.nodeLookup.get(w.target);if(!Ie||!qe)return{zIndex:w.zIndex,...ES};const ct=I3({id:e,sourceNode:Ie,targetNode:qe,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:Pe.connectionMode,onError:y});return{zIndex:N3({selected:w.selected,zIndex:w.zIndex,sourceNode:Ie,targetNode:qe,elevateOnSelect:Pe.elevateEdgesOnSelect,zIndexMode:Pe.zIndexMode}),...ct||ES}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),Cn),U=m.useMemo(()=>w.markerStart?`url('#${lw(w.markerStart,g)}')`:void 0,[w.markerStart,g]),re=m.useMemo(()=>w.markerEnd?`url('#${lw(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||B===null||P===null||T===null||E===null)return null;const ue=Pe=>{var Ge;const{addSelectedEdges:Ie,unselectNodesAndEdges:qe,multiSelectionActive:ct}=$.getState();R&&($.setState({nodesSelectionActive:!1}),w.selected&&ct?(qe({nodes:[],edges:[w]}),(Ge=F.current)==null||Ge.blur()):Ie([e])),s&&s(Pe,w)},ge=i?Pe=>{i(Pe,{...w})}:void 0,le=a?Pe=>{a(Pe,{...w})}:void 0,ce=l?Pe=>{l(Pe,{...w})}:void 0,de=c?Pe=>{c(Pe,{...w})}:void 0,Ae=d?Pe=>{d(Pe,{...w})}:void 0,Ne=Pe=>{var Ie;if(!b&&L_.includes(Pe.key)&&R){const{unselectNodesAndEdges:qe,addSelectedEdges:ct}=$.getState();Pe.key==="Escape"?((Ie=F.current)==null||Ie.blur(),qe({edges:[w]})):ct([e])}};return o.jsx("svg",{style:{zIndex:A},children:o.jsxs("g",{className:Yn(["react-flow__edge",`react-flow__edge-${C}`,w.className,k,{selected:w.selected,animated:w.animated,inactive:!R&&!s,updating:O,selectable:R}]),onClick:ue,onDoubleClick:ge,onContextMenu:le,onMouseEnter:ce,onMouseMove:de,onMouseLeave:Ae,onKeyDown:I?Ne:void 0,tabIndex:I?0:void 0,role:w.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":I?`${yP}-${g}`:void 0,ref:F,...w.domAttributes,children:[!W&&o.jsx(N,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:R,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:B,sourceY:P,targetX:T,targetY:E,sourcePosition:Y,targetPosition:Q,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:U,markerEnd:re,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),M&&o.jsx(J5,{edge:w,isReconnectable:M,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:B,sourceY:P,targetX:T,targetY:E,sourcePosition:Y,targetPosition:Q,setUpdateHover:L,setReconnecting:D})]})})}var Z5=m.memo(Q5);const eB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function HP({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:k,edgesReconnectable:y,elementsSelectable:b,onError:w}=Mt(eB,Cn),S=D5(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(V5,{defaultColor:e,rfId:n}),S.map(C=>o.jsx(Z5,{id:C,edgesFocusable:k,edgesReconnectable:y,elementsSelectable:b,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:u,reconnectRadius:f,onDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:r,disableKeyboardA11y:v},C))]})}HP.displayName="EdgeRenderer";const tB=m.memo(HP),nB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function rB({children:e}){const t=Mt(nB);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function sB(e){const t=_l(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const iB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function oB(e){const t=Mt(iB),n=kn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function aB(e){return e.connection.inProgress?{...e.connection,to:bf(e.connection.to,e.transform)}:{...e.connection}}function lB(e){return aB}function cB(e){const t=lB();return Mt(t,Cn)}const uB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function dB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Mt(uB,Cn);return!(i&&s&&c)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:Yn(["react-flow__connection",$_(l)]),children:o.jsx(VP,{style:t,type:n,CustomComponent:r,isValid:l})})})}const VP=({style:e,type:t=la.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:u,toHandle:f,toPosition:p,pointer:h}=cB();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:p,connectionStatus:$_(r),toNode:u,toHandle:f,pointer:h});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case la.Bezier:[g]=G_(v);break;case la.SimpleBezier:[g]=AP(v);break;case la.Step:[g]=aw({...v,borderRadius:0});break;case la.SmoothStep:[g]=aw(v);break;default:[g]=J_(v)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};VP.displayName="ConnectionLine";const fB={};function AS(e=fB){m.useRef(e),kn(),m.useEffect(()=>{},[e])}function pB(){kn(),m.useRef(!1),m.useEffect(()=>{},[])}function WP({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:k,connectionLineContainerStyle:y,selectionKeyCode:b,selectionOnDrag:w,selectionMode:S,multiSelectionKeyCode:C,panActivationKeyCode:N,zoomActivationKeyCode:I,deleteKeyCode:M,onlyRenderVisibleElements:R,elementsSelectable:F,defaultViewport:O,translateExtent:L,minZoom:W,maxZoom:D,preventScrolling:$,defaultMarkerColor:A,zoomOnScroll:B,zoomOnPinch:P,panOnScroll:T,panOnScrollSpeed:E,panOnScrollMode:Y,zoomOnDoubleClick:Q,panOnDrag:U,onPaneClick:re,onPaneMouseEnter:ue,onPaneMouseMove:ge,onPaneMouseLeave:le,onPaneScroll:ce,onPaneContextMenu:de,paneClickDistance:Ae,nodeClickDistance:Ne,onEdgeContextMenu:Pe,onEdgeMouseEnter:Ie,onEdgeMouseMove:qe,onEdgeMouseLeave:ct,reconnectRadius:Ge,onReconnect:xt,onReconnectStart:Fe,onReconnectEnd:ee,noDragClassName:De,noWheelClassName:tt,noPanClassName:Nt,disableKeyboardA11y:en,nodeExtent:fr,rfId:jr,viewport:ae,onViewportChange:ve}){return AS(e),AS(t),pB(),sB(n),oB(ae),o.jsx(_5,{onPaneClick:re,onPaneMouseEnter:ue,onPaneMouseMove:ge,onPaneMouseLeave:le,onPaneContextMenu:de,onPaneScroll:ce,paneClickDistance:Ae,deleteKeyCode:M,selectionKeyCode:b,selectionOnDrag:w,selectionMode:S,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:C,panActivationKeyCode:N,zoomActivationKeyCode:I,elementsSelectable:F,zoomOnScroll:B,zoomOnPinch:P,zoomOnDoubleClick:Q,panOnScroll:T,panOnScrollSpeed:E,panOnScrollMode:Y,panOnDrag:U,defaultViewport:O,translateExtent:L,minZoom:W,maxZoom:D,onSelectionContextMenu:f,preventScrolling:$,noDragClassName:De,noWheelClassName:tt,noPanClassName:Nt,disableKeyboardA11y:en,onViewportChange:ve,isControlledViewport:!!ae,children:o.jsxs(rB,{children:[o.jsx(tB,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:xt,onReconnectStart:Fe,onReconnectEnd:ee,onlyRenderVisibleElements:R,onEdgeContextMenu:Pe,onEdgeMouseEnter:Ie,onEdgeMouseMove:qe,onEdgeMouseLeave:ct,reconnectRadius:Ge,defaultMarkerColor:A,noPanClassName:Nt,disableKeyboardA11y:en,rfId:jr}),o.jsx(dB,{style:v,type:g,component:k,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx($5,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:Ne,onlyRenderVisibleElements:R,noPanClassName:Nt,noDragClassName:De,disableKeyboardA11y:en,nodeExtent:fr,rfId:jr}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}WP.displayName="GraphView";const hB=m.memo(WP),IS=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:f,zIndexMode:p="basic"}={})=>{const h=new Map,g=new Map,v=new Map,k=new Map,y=r??t??[],b=n??e??[],w=u??[0,0],S=f??Wd;eP(v,k,y);const{nodesInitialized:C}=cw(b,h,g,{nodeOrigin:w,nodeExtent:S,zIndexMode:p});let N=[0,0,1];if(a&&s&&i){const I=xf(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:M,y:R,zoom:F}=Kb(I,s,i,c,d,(l==null?void 0:l.padding)??.1);N=[M,R,F]}return{rfId:"1",width:s??0,height:i??0,transform:N,nodes:b,nodesInitialized:C,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:k,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Wd,nodeExtent:S,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Bc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...M_},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:x3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:O_,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},mB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p})=>Lz((h,g)=>{async function v(){const{nodeLookup:k,panZoom:y,fitViewOptions:b,fitViewResolver:w,width:S,height:C,minZoom:N,maxZoom:I}=g();y&&(await g3({nodes:k,width:S,height:C,panZoom:y,minZoom:N,maxZoom:I},b),w==null||w.resolve(!0),h({fitViewResolver:null}))}return{...IS({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:k=>{const{nodeLookup:y,parentLookup:b,nodeOrigin:w,elevateNodesOnSelect:S,fitViewQueued:C,zIndexMode:N,nodesSelectionActive:I}=g(),{nodesInitialized:M,hasSelectedNodes:R}=cw(k,y,b,{nodeOrigin:w,nodeExtent:f,elevateNodesOnSelect:S,checkEquality:!0,zIndexMode:N}),F=I&&R;C&&M?(v(),h({nodes:k,nodesInitialized:M,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):h({nodes:k,nodesInitialized:M,nodesSelectionActive:F})},setEdges:k=>{const{connectionLookup:y,edgeLookup:b}=g();eP(y,b,k),h({edges:k})},setDefaultNodesAndEdges:(k,y)=>{if(k){const{setNodes:b}=g();b(k),h({hasDefaultNodes:!0})}if(y){const{setEdges:b}=g();b(y),h({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:y,nodeLookup:b,parentLookup:w,domNode:S,nodeOrigin:C,nodeExtent:N,debug:I,fitViewQueued:M,zIndexMode:R}=g(),{changes:F,updatedInternals:O}=F3(k,b,w,S,C,N,R);O&&(O3(b,w,{nodeOrigin:C,nodeExtent:N,zIndexMode:R}),M?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(F==null?void 0:F.length)>0&&(I&&console.log("React Flow: trigger node changes",F),y==null||y(F)))},updateNodePositions:(k,y=!1)=>{const b=[];let w=[];const{nodeLookup:S,triggerNodeChanges:C,connection:N,updateConnection:I,onNodesChangeMiddlewareMap:M}=g();for(const[R,F]of k){const O=S.get(R),L=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(F!=null&&F.position)),W={id:R,type:"position",position:L?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:y};if(O&&N.inProgress&&N.fromNode.id===O.id){const D=Sl(O,N.fromHandle,Ue.Left,!0);I({...N,from:D})}L&&O.parentId&&b.push({id:R,parentId:O.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),w.push(W)}if(b.length>0){const{parentLookup:R,nodeOrigin:F}=g(),O=Qb(b,S,R,F);w.push(...O)}for(const R of M.values())w=R(w);C(w)},triggerNodeChanges:k=>{const{onNodesChange:y,setNodes:b,nodes:w,hasDefaultNodes:S,debug:C}=g();if(k!=null&&k.length){if(S){const N=Zb(k,w);b(N)}C&&console.log("React Flow: trigger node changes",k),y==null||y(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:y,setEdges:b,edges:w,hasDefaultEdges:S,debug:C}=g();if(k!=null&&k.length){if(S){const N=bP(k,w);b(N)}C&&console.log("React Flow: trigger edge changes",k),y==null||y(k)}},addSelectedNodes:k=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:C}=g();if(y){const N=k.map(I=>rl(I,!0));S(N);return}S(yc(w,new Set([...k]),!0)),C(yc(b))},addSelectedEdges:k=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:C}=g();if(y){const N=k.map(I=>rl(I,!0));C(N);return}C(yc(b,new Set([...k]))),S(yc(w,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:y}={})=>{const{edges:b,nodes:w,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:N}=g(),I=k||w,M=y||b,R=[];for(const O of I){if(!O.selected)continue;const L=S.get(O.id);L&&(L.selected=!1),R.push(rl(O.id,!1))}const F=[];for(const O of M)O.selected&&F.push(rl(O.id,!1));C(R),N(F)},setMinZoom:k=>{const{panZoom:y,maxZoom:b}=g();y==null||y.setScaleExtent([k,b]),h({minZoom:k})},setMaxZoom:k=>{const{panZoom:y,minZoom:b}=g();y==null||y.setScaleExtent([b,k]),h({maxZoom:k})},setTranslateExtent:k=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(k),h({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:y,triggerNodeChanges:b,triggerEdgeChanges:w,elementsSelectable:S}=g();if(!S)return;const C=y.reduce((I,M)=>M.selected?[...I,rl(M.id,!1)]:I,[]),N=k.reduce((I,M)=>M.selected?[...I,rl(M.id,!1)]:I,[]);b(C),w(N)},setNodeExtent:k=>{const{nodes:y,nodeLookup:b,parentLookup:w,nodeOrigin:S,elevateNodesOnSelect:C,nodeExtent:N,zIndexMode:I}=g();k[0][0]===N[0][0]&&k[0][1]===N[0][1]&&k[1][0]===N[1][0]&&k[1][1]===N[1][1]||(cw(y,b,w,{nodeOrigin:S,nodeExtent:k,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:I}),h({nodeExtent:k}))},panBy:k=>{const{transform:y,width:b,height:w,panZoom:S,translateExtent:C}=g();return z3({delta:k,panZoom:S,transform:y,translateExtent:C,width:b,height:w})},setCenter:async(k,y,b)=>{const{width:w,height:S,maxZoom:C,panZoom:N}=g();if(!N)return Promise.resolve(!1);const I=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:C;return await N.setViewport({x:w/2-k*I,y:S/2-y*I,zoom:I},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...M_}})},updateConnection:k=>{h({connection:k})},reset:()=>h({...IS()})}},Object.is);function tv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p,children:h}){const[g]=m.useState(()=>mB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:u,nodeExtent:f,zIndexMode:p}));return o.jsx(Oz,{value:g,children:o.jsx(r5,{children:h})})}function gB({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:h}){return m.useContext(qm)?o.jsx(o.Fragment,{children:e}):o.jsx(tv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:e})}const yB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function xB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:u,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:k,onClickConnectEnd:y,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:S,onNodeContextMenu:C,onNodeDoubleClick:N,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onNodesDelete:F,onEdgesDelete:O,onDelete:L,onSelectionChange:W,onSelectionDragStart:D,onSelectionDrag:$,onSelectionDragStop:A,onSelectionContextMenu:B,onSelectionStart:P,onSelectionEnd:T,onBeforeDelete:E,connectionMode:Y,connectionLineType:Q=la.Bezier,connectionLineStyle:U,connectionLineComponent:re,connectionLineContainerStyle:ue,deleteKeyCode:ge="Backspace",selectionKeyCode:le="Shift",selectionOnDrag:ce=!1,selectionMode:de=Ud.Full,panActivationKeyCode:Ae="Space",multiSelectionKeyCode:Ne=qd()?"Meta":"Control",zoomActivationKeyCode:Pe=qd()?"Meta":"Control",snapToGrid:Ie,snapGrid:qe,onlyRenderVisibleElements:ct=!1,selectNodesOnDrag:Ge,nodesDraggable:xt,autoPanOnNodeFocus:Fe,nodesConnectable:ee,nodesFocusable:De,nodeOrigin:tt=xP,edgesFocusable:Nt,edgesReconnectable:en,elementsSelectable:fr=!0,defaultViewport:jr=Yz,minZoom:ae=.5,maxZoom:ve=2,translateExtent:Xe=Wd,preventScrolling:ot=!0,nodeExtent:nt,defaultMarkerColor:hn="#b1b1b7",zoomOnScroll:Mn=!0,zoomOnPinch:Tn=!0,panOnScroll:tr=!1,panOnScrollSpeed:pr=.5,panOnScrollMode:Bt=fl.Free,zoomOnDoubleClick:nr=!0,panOnDrag:ye=!0,onPaneClick:ze,onPaneMouseEnter:$t,onPaneMouseMove:kt,onPaneMouseLeave:Ut,onPaneScroll:qr,onPaneContextMenu:$n,paneClickDistance:Gn=1,nodeClickDistance:rr=0,children:Fo,onReconnect:so,onReconnectStart:zo,onReconnectEnd:Qs,onEdgeContextMenu:Zs,onEdgeDoubleClick:Ni,onEdgeMouseEnter:Cr,onEdgeMouseMove:hr,onEdgeMouseLeave:io,reconnectRadius:ji=10,onNodesChange:oo,onEdgesChange:As,noDragClassName:_e="nodrag",noWheelClassName:Xt="nowheel",noPanClassName:Bn="nopan",fitView:rt,fitViewOptions:hs,connectOnClick:Er,attributionPosition:mn,proOptions:mr,defaultEdgeOptions:Jt,elevateNodesOnSelect:at=!0,elevateEdgesOnSelect:Ht=!1,disableKeyboardA11y:Kt=!1,autoPanOnConnect:Xn,autoPanOnNodeDrag:Me,autoPanSpeed:Dn,connectionRadius:Is,isValidConnection:Ci,onError:ei,style:Bo,id:Ts,nodeDragThreshold:Ei,connectionDragThreshold:ti,viewport:Vt,onViewportChange:gr,width:Rs,height:ms,colorMode:Yr="light",debug:Ls,onScroll:V,ariaLabelConfig:he,zIndexMode:Se="basic",...Te},$e){const Dt=Ts||"1",wt=Qz(Yr),Ft=m.useCallback(Dr=>{Dr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),V==null||V(Dr)},[V]);return o.jsx("div",{"data-testid":"rf__wrapper",...Te,onScroll:Ft,style:{...Bo,...yB},ref:$e,className:Yn(["react-flow",s,wt]),id:Ts,role:"application",children:o.jsxs(gB,{nodes:e,edges:t,width:Rs,height:ms,fitView:rt,fitViewOptions:hs,minZoom:ae,maxZoom:ve,nodeOrigin:tt,nodeExtent:nt,zIndexMode:Se,children:[o.jsx(Jz,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:v,onClickConnectStart:k,onClickConnectEnd:y,nodesDraggable:xt,autoPanOnNodeFocus:Fe,nodesConnectable:ee,nodesFocusable:De,edgesFocusable:Nt,edgesReconnectable:en,elementsSelectable:fr,elevateNodesOnSelect:at,elevateEdgesOnSelect:Ht,minZoom:ae,maxZoom:ve,nodeExtent:nt,onNodesChange:oo,onEdgesChange:As,snapToGrid:Ie,snapGrid:qe,connectionMode:Y,translateExtent:Xe,connectOnClick:Er,defaultEdgeOptions:Jt,fitView:rt,fitViewOptions:hs,onNodesDelete:F,onEdgesDelete:O,onDelete:L,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onSelectionDrag:$,onSelectionDragStart:D,onSelectionDragStop:A,onMove:u,onMoveStart:f,onMoveEnd:p,noPanClassName:Bn,nodeOrigin:tt,rfId:Dt,autoPanOnConnect:Xn,autoPanOnNodeDrag:Me,autoPanSpeed:Dn,onError:ei,connectionRadius:Is,isValidConnection:Ci,selectNodesOnDrag:Ge,nodeDragThreshold:Ei,connectionDragThreshold:ti,onBeforeDelete:E,debug:Ls,ariaLabelConfig:he,zIndexMode:Se}),o.jsx(hB,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:w,onNodeMouseLeave:S,onNodeContextMenu:C,onNodeDoubleClick:N,nodeTypes:i,edgeTypes:a,connectionLineType:Q,connectionLineStyle:U,connectionLineComponent:re,connectionLineContainerStyle:ue,selectionKeyCode:le,selectionOnDrag:ce,selectionMode:de,deleteKeyCode:ge,multiSelectionKeyCode:Ne,panActivationKeyCode:Ae,zoomActivationKeyCode:Pe,onlyRenderVisibleElements:ct,defaultViewport:jr,translateExtent:Xe,minZoom:ae,maxZoom:ve,preventScrolling:ot,zoomOnScroll:Mn,zoomOnPinch:Tn,zoomOnDoubleClick:nr,panOnScroll:tr,panOnScrollSpeed:pr,panOnScrollMode:Bt,panOnDrag:ye,onPaneClick:ze,onPaneMouseEnter:$t,onPaneMouseMove:kt,onPaneMouseLeave:Ut,onPaneScroll:qr,onPaneContextMenu:$n,paneClickDistance:Gn,nodeClickDistance:rr,onSelectionContextMenu:B,onSelectionStart:P,onSelectionEnd:T,onReconnect:so,onReconnectStart:zo,onReconnectEnd:Qs,onEdgeContextMenu:Zs,onEdgeDoubleClick:Ni,onEdgeMouseEnter:Cr,onEdgeMouseMove:hr,onEdgeMouseLeave:io,reconnectRadius:ji,defaultMarkerColor:hn,noDragClassName:_e,noWheelClassName:Xt,noPanClassName:Bn,rfId:Dt,disableKeyboardA11y:Kt,nodeExtent:nt,viewport:Vt,onViewportChange:gr}),o.jsx(qz,{onSelectionChange:W}),Fo,o.jsx(Hz,{proOptions:mr,position:mn}),o.jsx(Bz,{rfId:Dt,disableKeyboardA11y:Kt})]})})}var UP=vP(xB);function KP(){const e=kn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function qP(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Zb(s,i)),[]);return[t,n,r]}function YP(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>bP(s,i)),[]);return[t,n,r]}function wB({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Yn(["react-flow__background-pattern",n,r])})}function bB({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:Yn(["react-flow__background-pattern","dots",t])})}var ka;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ka||(ka={}));const vB={[ka.Dots]:1,[ka.Lines]:1,[ka.Cross]:6},kB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function GP({id:e,variant:t=ka.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:u}){const f=m.useRef(null),{transform:p,patternId:h}=Mt(kB,Cn),g=r||vB[t],v=t===ka.Dots,k=t===ka.Cross,y=Array.isArray(n)?n:[n,n],b=[y[0]*p[2]||1,y[1]*p[2]||1],w=g*p[2],S=Array.isArray(i)?i:[i,i],C=k?[w,w]:b,N=[S[0]*p[2]||1+C[0]/2,S[1]*p[2]||1+C[1]/2],I=`${h}${e||""}`;return o.jsxs("svg",{className:Yn(["react-flow__background",d]),style:{...c,...Ym,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[o.jsx("pattern",{id:I,x:p[0]%b[0],y:p[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?o.jsx(bB,{radius:w/2,className:u}):o.jsx(wB,{dimensions:C,lineWidth:s,variant:t,className:u})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}GP.displayName="Background";const XP=m.memo(GP);function SB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function NB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function jB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function CB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function EB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Pp({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:Yn(["react-flow__controls-button",t]),...n,children:e})}const _B=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function JP({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:u,position:f="bottom-left",orientation:p="vertical","aria-label":h}){const g=kn(),{isInteractive:v,minZoomReached:k,maxZoomReached:y,ariaLabelConfig:b}=Mt(_B,Cn),{zoomIn:w,zoomOut:S,fitView:C}=_l(),N=()=>{w(),i==null||i()},I=()=>{S(),a==null||a()},M=()=>{C(s),l==null||l()},R=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},F=p==="horizontal"?"horizontal":"vertical";return o.jsxs(qc,{className:Yn(["react-flow__controls",F,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(Pp,{onClick:N,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(SB,{})}),o.jsx(Pp,{onClick:I,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:k,children:o.jsx(NB,{})})]}),n&&o.jsx(Pp,{className:"react-flow__controls-fitview",onClick:M,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:o.jsx(jB,{})}),r&&o.jsx(Pp,{className:"react-flow__controls-interactive",onClick:R,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?o.jsx(EB,{}):o.jsx(CB,{})}),u]})}JP.displayName="Controls";const PB=m.memo(JP);function AB({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:u,shapeRendering:f,selected:p,onClick:h}){const{background:g,backgroundColor:v}=i||{},k=a||g||v;return o.jsx("rect",{className:Yn(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:u,ry:u,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?y=>h(y,e):void 0})}const IB=m.memo(AB),TB=e=>e.nodes.map(t=>t.id),my=e=>e instanceof Function?e:()=>e;function RB({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=IB,onClick:a}){const l=Mt(TB,Cn),c=my(t),d=my(e),u=my(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(OB,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:f},p))})}function LB({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:u,y:f,width:p,height:h}=Mt(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const k=v.internals.userNode,{x:y,y:b}=v.internals.positionAbsolute,{width:w,height:S}=$o(k);return{node:k,x:y,y:b,width:w,height:S}},Cn);return!d||d.hidden||!V_(d)?null:o.jsx(l,{x:u,y:f,width:p,height:h,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:c,id:d.id})}const OB=m.memo(LB);var MB=m.memo(RB);const $B=200,DB=150,FB=e=>!e.hidden,zB=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?H_(xf(e.nodeLookup,{filter:FB}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},BB="react-flow__minimap-desc";function QP({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:u,maskStrokeWidth:f,position:p="bottom-right",onClick:h,onNodeClick:g,pannable:v=!1,zoomable:k=!1,ariaLabel:y,inversePan:b,zoomStep:w=1,offsetScale:S=5}){const C=kn(),N=m.useRef(null),{boundingRect:I,viewBB:M,rfId:R,panZoom:F,translateExtent:O,flowWidth:L,flowHeight:W,ariaLabelConfig:D}=Mt(zB,Cn),$=(e==null?void 0:e.width)??$B,A=(e==null?void 0:e.height)??DB,B=I.width/$,P=I.height/A,T=Math.max(B,P),E=T*$,Y=T*A,Q=S*T,U=I.x-(E-I.width)/2-Q,re=I.y-(Y-I.height)/2-Q,ue=E+Q*2,ge=Y+Q*2,le=`${BB}-${R}`,ce=m.useRef(0),de=m.useRef();ce.current=T,m.useEffect(()=>{if(N.current&&F)return de.current=G3({domNode:N.current,panZoom:F,getTransform:()=>C.getState().transform,getViewScale:()=>ce.current}),()=>{var Ie;(Ie=de.current)==null||Ie.destroy()}},[F]),m.useEffect(()=>{var Ie;(Ie=de.current)==null||Ie.update({translateExtent:O,width:L,height:W,inversePan:b,pannable:v,zoomStep:w,zoomable:k})},[v,k,b,w,O,L,W]);const Ae=h?Ie=>{var Ge;const[qe,ct]=((Ge=de.current)==null?void 0:Ge.pointer(Ie))||[0,0];h(Ie,{x:qe,y:ct})}:void 0,Ne=g?m.useCallback((Ie,qe)=>{const ct=C.getState().nodeLookup.get(qe).internals.userNode;g(Ie,ct)},[]):void 0,Pe=y??D["minimap.ariaLabel"];return o.jsx(qc,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*T:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Yn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:$,height:A,viewBox:`${U} ${re} ${ue} ${ge}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":le,ref:N,onClick:Ae,children:[Pe&&o.jsx("title",{id:le,children:Pe}),o.jsx(MB,{onClick:Ne,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${U-Q},${re-Q}h${ue+Q*2}v${ge+Q*2}h${-ue-Q*2}z
66
+ M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}QP.displayName="MiniMap";const HB=m.memo(QP),VB=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,WB={[Uc.Line]:"right",[Uc.Handle]:"bottom-right"};function UB({nodeId:e,position:t,variant:n=Uc.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:h=!0,shouldResize:g,onResizeStart:v,onResize:k,onResizeEnd:y}){const b=jP(),w=typeof e=="string"?e:b,S=kn(),C=m.useRef(null),N=n===Uc.Handle,I=Mt(m.useCallback(VB(N&&h),[N,h]),Cn),M=m.useRef(null),R=t??WB[n];m.useEffect(()=>{if(!(!C.current||!w))return M.current||(M.current=cz({domNode:C.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:O,transform:L,snapGrid:W,snapToGrid:D,nodeOrigin:$,domNode:A}=S.getState();return{nodeLookup:O,transform:L,snapGrid:W,snapToGrid:D,nodeOrigin:$,paneDomNode:A}},onChange:(O,L)=>{const{triggerNodeChanges:W,nodeLookup:D,parentLookup:$,nodeOrigin:A}=S.getState(),B=[],P={x:O.x,y:O.y},T=D.get(w);if(T&&T.expandParent&&T.parentId){const E=T.origin??A,Y=O.width??T.measured.width??0,Q=O.height??T.measured.height??0,U={id:T.id,parentId:T.parentId,rect:{width:Y,height:Q,...W_({x:O.x??T.position.x,y:O.y??T.position.y},{width:Y,height:Q},T.parentId,D,E)}},re=Qb([U],D,$,A);B.push(...re),P.x=O.x?Math.max(E[0]*Y,O.x):void 0,P.y=O.y?Math.max(E[1]*Q,O.y):void 0}if(P.x!==void 0&&P.y!==void 0){const E={id:w,type:"position",position:{...P}};B.push(E)}if(O.width!==void 0&&O.height!==void 0){const Y={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};B.push(Y)}for(const E of L){const Y={...E,type:"position"};B.push(Y)}W(B)},onEnd:({width:O,height:L})=>{const W={id:w,type:"dimensions",resizing:!1,dimensions:{width:O,height:L}};S.getState().triggerNodeChanges([W])}})),M.current.update({controlPosition:R,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:u},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:k,onResizeEnd:y,shouldResize:g}),()=>{var O;(O=M.current)==null||O.destroy()}},[R,l,c,d,u,f,v,k,y,g]);const F=R.split("-");return o.jsx("div",{className:Yn(["react-flow__resize-control","nodrag",...F,n,r]),ref:C,style:{...s,scale:I,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:i})}const KB=m.memo(UB);function qB(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const YB=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GB=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XB={};function TS(e,t){return(XB.jsx?GB:YB).test(e)}const JB=/[ \t\n\f\r]/g;function QB(e){return typeof e=="object"?e.type==="text"?RS(e.value):!1:RS(e)}function RS(e){return e.replace(JB,"")===""}let vf=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};vf.prototype.normal={};vf.prototype.property={};vf.prototype.space=void 0;function ZP(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new vf(n,r,t)}function pw(e){return e.toLowerCase()}class ps{constructor(t,n){this.attribute=n,this.property=t}}ps.prototype.attribute="";ps.prototype.booleanish=!1;ps.prototype.boolean=!1;ps.prototype.commaOrSpaceSeparated=!1;ps.prototype.commaSeparated=!1;ps.prototype.defined=!1;ps.prototype.mustUseProperty=!1;ps.prototype.number=!1;ps.prototype.overloadedBoolean=!1;ps.prototype.property="";ps.prototype.spaceSeparated=!1;ps.prototype.space=void 0;let ZB=0;const bt=Pl(),Un=Pl(),hw=Pl(),Ee=Pl(),un=Pl(),Pc=Pl(),ys=Pl();function Pl(){return 2**++ZB}const mw=Object.freeze(Object.defineProperty({__proto__:null,boolean:bt,booleanish:Un,commaOrSpaceSeparated:ys,commaSeparated:Pc,number:Ee,overloadedBoolean:hw,spaceSeparated:un},Symbol.toStringTag,{value:"Module"})),gy=Object.keys(mw);class nv extends ps{constructor(t,n,r,s){let i=-1;if(super(t,n),LS(this,"space",s),typeof r=="number")for(;++i<gy.length;){const a=gy[i];LS(this,gy[i],(r&mw[a])===mw[a])}}}nv.prototype.defined=!0;function LS(e,t,n){n&&(e[t]=n)}function nu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new nv(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[pw(r)]=r,n[pw(i.attribute)]=r}return new vf(t,n,e.space)}const eA=nu({properties:{ariaActiveDescendant:null,ariaAtomic:Un,ariaAutoComplete:null,ariaBusy:Un,ariaChecked:Un,ariaColCount:Ee,ariaColIndex:Ee,ariaColSpan:Ee,ariaControls:un,ariaCurrent:null,ariaDescribedBy:un,ariaDetails:null,ariaDisabled:Un,ariaDropEffect:un,ariaErrorMessage:null,ariaExpanded:Un,ariaFlowTo:un,ariaGrabbed:Un,ariaHasPopup:null,ariaHidden:Un,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:un,ariaLevel:Ee,ariaLive:null,ariaModal:Un,ariaMultiLine:Un,ariaMultiSelectable:Un,ariaOrientation:null,ariaOwns:un,ariaPlaceholder:null,ariaPosInSet:Ee,ariaPressed:Un,ariaReadOnly:Un,ariaRelevant:null,ariaRequired:Un,ariaRoleDescription:un,ariaRowCount:Ee,ariaRowIndex:Ee,ariaRowSpan:Ee,ariaSelected:Un,ariaSetSize:Ee,ariaSort:null,ariaValueMax:Ee,ariaValueMin:Ee,ariaValueNow:Ee,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tA(e,t){return t in e?e[t]:t}function nA(e,t){return tA(e,t.toLowerCase())}const e4=nu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Pc,acceptCharset:un,accessKey:un,action:null,allow:null,allowFullScreen:bt,allowPaymentRequest:bt,allowUserMedia:bt,alt:null,as:null,async:bt,autoCapitalize:null,autoComplete:un,autoFocus:bt,autoPlay:bt,blocking:un,capture:null,charSet:null,checked:bt,cite:null,className:un,cols:Ee,colSpan:null,content:null,contentEditable:Un,controls:bt,controlsList:un,coords:Ee|Pc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:bt,defer:bt,dir:null,dirName:null,disabled:bt,download:hw,draggable:Un,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:bt,formTarget:null,headers:un,height:Ee,hidden:hw,high:Ee,href:null,hrefLang:null,htmlFor:un,httpEquiv:un,id:null,imageSizes:null,imageSrcSet:null,inert:bt,inputMode:null,integrity:null,is:null,isMap:bt,itemId:null,itemProp:un,itemRef:un,itemScope:bt,itemType:un,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:bt,low:Ee,manifest:null,max:null,maxLength:Ee,media:null,method:null,min:null,minLength:Ee,multiple:bt,muted:bt,name:null,nonce:null,noModule:bt,noValidate:bt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:bt,optimum:Ee,pattern:null,ping:un,placeholder:null,playsInline:bt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:bt,referrerPolicy:null,rel:un,required:bt,reversed:bt,rows:Ee,rowSpan:Ee,sandbox:un,scope:null,scoped:bt,seamless:bt,selected:bt,shadowRootClonable:bt,shadowRootDelegatesFocus:bt,shadowRootMode:null,shape:null,size:Ee,sizes:null,slot:null,span:Ee,spellCheck:Un,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ee,step:null,style:null,tabIndex:Ee,target:null,title:null,translate:null,type:null,typeMustMatch:bt,useMap:null,value:Un,width:Ee,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:un,axis:null,background:null,bgColor:null,border:Ee,borderColor:null,bottomMargin:Ee,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:bt,declare:bt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ee,leftMargin:Ee,link:null,longDesc:null,lowSrc:null,marginHeight:Ee,marginWidth:Ee,noResize:bt,noHref:bt,noShade:bt,noWrap:bt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ee,rules:null,scheme:null,scrolling:Un,standby:null,summary:null,text:null,topMargin:Ee,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ee,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:bt,disableRemotePlayback:bt,prefix:null,property:null,results:Ee,security:null,unselectable:null},space:"html",transform:nA}),t4=nu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ys,accentHeight:Ee,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ee,amplitude:Ee,arabicForm:null,ascent:Ee,attributeName:null,attributeType:null,azimuth:Ee,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ee,by:null,calcMode:null,capHeight:Ee,className:un,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ee,diffuseConstant:Ee,direction:null,display:null,dur:null,divisor:Ee,dominantBaseline:null,download:bt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ee,enableBackground:null,end:null,event:null,exponent:Ee,externalResourcesRequired:null,fill:null,fillOpacity:Ee,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Pc,g2:Pc,glyphName:Pc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ee,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ee,horizOriginX:Ee,horizOriginY:Ee,id:null,ideographic:Ee,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ee,k:Ee,k1:Ee,k2:Ee,k3:Ee,k4:Ee,kernelMatrix:ys,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ee,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ee,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ee,overlineThickness:Ee,paintOrder:null,panose1:null,path:null,pathLength:Ee,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:un,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ee,pointsAtY:Ee,pointsAtZ:Ee,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ys,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ys,rev:ys,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ys,requiredFeatures:ys,requiredFonts:ys,requiredFormats:ys,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ee,specularExponent:Ee,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ee,strikethroughThickness:Ee,string:null,stroke:null,strokeDashArray:ys,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ee,strokeOpacity:Ee,strokeWidth:null,style:null,surfaceScale:Ee,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ys,tabIndex:Ee,tableValues:null,target:null,targetX:Ee,targetY:Ee,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ys,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ee,underlineThickness:Ee,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ee,values:null,vAlphabetic:Ee,vMathematical:Ee,vectorEffect:null,vHanging:Ee,vIdeographic:Ee,version:null,vertAdvY:Ee,vertOriginX:Ee,vertOriginY:Ee,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ee,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tA}),rA=nu({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),sA=nu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:nA}),iA=nu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),n4={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},r4=/[A-Z]/g,OS=/-[a-z]/g,s4=/^data[-\w.:]+$/i;function i4(e,t){const n=pw(t);let r=t,s=ps;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&s4.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(OS,a4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!OS.test(i)){let a=i.replace(r4,o4);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=nv}return new s(r,t)}function o4(e){return"-"+e.toLowerCase()}function a4(e){return e.charAt(1).toUpperCase()}const l4=ZP([eA,e4,rA,sA,iA],"html"),rv=ZP([eA,t4,rA,sA,iA],"svg");function c4(e){return e.join(" ").trim()}var sv={},MS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,u4=/\n/g,d4=/^\s*/,f4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,p4=/^:\s*/,h4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,m4=/^[;\s]*/,g4=/^\s+|\s+$/g,y4=`
67
+ `,$S="/",DS="*",sl="",x4="comment",w4="declaration";function b4(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var v=g.match(u4);v&&(n+=v.length);var k=g.lastIndexOf(y4);r=~k?g.length-k:r+g.length}function i(){var g={line:n,column:r};return function(v){return v.position=new a(g),d(),v}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var v=new Error(t.source+":"+n+":"+r+": "+g);if(v.reason=g,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function c(g){var v=g.exec(e);if(v){var k=v[0];return s(k),e=e.slice(k.length),v}}function d(){c(d4)}function u(g){var v;for(g=g||[];v=f();)v!==!1&&g.push(v);return g}function f(){var g=i();if(!($S!=e.charAt(0)||DS!=e.charAt(1))){for(var v=2;sl!=e.charAt(v)&&(DS!=e.charAt(v)||$S!=e.charAt(v+1));)++v;if(v+=2,sl===e.charAt(v-1))return l("End of comment missing");var k=e.slice(2,v-2);return r+=2,s(k),e=e.slice(v),r+=2,g({type:x4,comment:k})}}function p(){var g=i(),v=c(f4);if(v){if(f(),!c(p4))return l("property missing ':'");var k=c(h4),y=g({type:w4,property:FS(v[0].replace(MS,sl)),value:k?FS(k[0].replace(MS,sl)):sl});return c(m4),y}}function h(){var g=[];u(g);for(var v;v=p();)v!==!1&&(g.push(v),u(g));return g}return d(),h()}function FS(e){return e?e.replace(g4,sl):sl}var v4=b4,k4=kd&&kd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sv,"__esModule",{value:!0});sv.default=N4;const S4=k4(v4);function N4(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,S4.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var Xm={};Object.defineProperty(Xm,"__esModule",{value:!0});Xm.camelCase=void 0;var j4=/^--[a-zA-Z0-9_-]+$/,C4=/-([a-z])/g,E4=/^[^-]+$/,_4=/^-(webkit|moz|ms|o|khtml)-/,P4=/^-(ms)-/,A4=function(e){return!e||E4.test(e)||j4.test(e)},I4=function(e,t){return t.toUpperCase()},zS=function(e,t){return"".concat(t,"-")},T4=function(e,t){return t===void 0&&(t={}),A4(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(P4,zS):e=e.replace(_4,zS),e.replace(C4,I4))};Xm.camelCase=T4;var R4=kd&&kd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},L4=R4(sv),O4=Xm;function gw(e,t){var n={};return!e||typeof e!="string"||(0,L4.default)(e,function(r,s){r&&s&&(n[(0,O4.camelCase)(r,t)]=s)}),n}gw.default=gw;var M4=gw;const $4=Ta(M4),oA=aA("end"),iv=aA("start");function aA(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function D4(e){const t=iv(e),n=oA(e);if(t&&n)return{start:t,end:n}}function md(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?BS(e.position):"start"in e||"end"in e?BS(e):"line"in e||"column"in e?yw(e):""}function yw(e){return HS(e&&e.line)+":"+HS(e&&e.column)}function BS(e){return yw(e&&e.start)+"-"+yw(e&&e.end)}function HS(e){return e&&typeof e=="number"?e:1}class Mr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=md(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Mr.prototype.file="";Mr.prototype.name="";Mr.prototype.reason="";Mr.prototype.message="";Mr.prototype.stack="";Mr.prototype.column=void 0;Mr.prototype.line=void 0;Mr.prototype.ancestors=void 0;Mr.prototype.cause=void 0;Mr.prototype.fatal=void 0;Mr.prototype.place=void 0;Mr.prototype.ruleId=void 0;Mr.prototype.source=void 0;const ov={}.hasOwnProperty,F4=new Map,z4=/[A-Z]/g,B4=new Set(["table","tbody","thead","tfoot","tr"]),H4=new Set(["td","th"]),lA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function V4(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=J4(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=X4(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?rv:l4,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=cA(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function cA(e,t,n){if(t.type==="element")return W4(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return U4(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return q4(e,t,n);if(t.type==="mdxjsEsm")return K4(e,t);if(t.type==="root")return Y4(e,t,n);if(t.type==="text")return G4(e,t)}function W4(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=rv,e.schema=s),e.ancestors.push(t);const i=dA(e,t.tagName,!1),a=Q4(e,t);let l=lv(e,t);return B4.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!QB(c):!0})),uA(e,a,i,t),av(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function U4(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Xd(e,t.position)}function K4(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xd(e,t.position)}function q4(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=rv,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:dA(e,t.name,!0),a=Z4(e,t),l=lv(e,t);return uA(e,a,i,t),av(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function Y4(e,t,n){const r={};return av(r,lv(e,t)),e.create(t,e.Fragment,r,n)}function G4(e,t){return t.value}function uA(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function av(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function X4(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function J4(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=iv(r);return t(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Q4(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&ov.call(t.properties,s)){const i=eH(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&H4.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Z4(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Xd(e,t.position);else{const s=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else Xd(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function lv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:F4;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=cA(e,i,a);l!==void 0&&n.push(l)}return n}function eH(e,t,n){const r=i4(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?qB(n):c4(n)),r.property==="style"){let s=typeof n=="object"?n:tH(e,String(n));return e.stylePropertyNameCase==="css"&&(s=nH(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?n4[r.property]||r.property:r.attribute,n]}}function tH(e,t){try{return $4(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Mr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=lA+"#cannot-parse-style-attribute",s}}function dA(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=TS(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=TS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return ov.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Xd(e)}function Xd(e,t){const n=new Mr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=lA+"#cannot-handle-mdx-estrees-without-createevaluater",n}function nH(e){const t={};let n;for(n in e)ov.call(e,n)&&(t[rH(n)]=e[n]);return t}function rH(e){let t=e.replace(z4,sH);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function sH(e){return"-"+e.toLowerCase()}const yy={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},iH={};function oH(e,t){const n=iH,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return fA(e,r,s)}function fA(e,t,n){if(aH(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return VS(e.children,t,n)}return Array.isArray(e)?VS(e,t,n):""}function VS(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=fA(e[s],t,n);return r.join("")}function aH(e){return!!(e&&typeof e=="object")}const WS=document.createElement("i");function cv(e){const t="&"+e+";";WS.innerHTML=t;const n=WS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function to(e,t,n,r){const s=e.length;let i=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Ks(e,t){return e.length>0?(to(e,e.length,0,t),e):t}const US={}.hasOwnProperty;function lH(e){const t={};let n=-1;for(;++n<e.length;)cH(t,e[n]);return t}function cH(e,t){let n;for(n in t){const s=(US.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){US.call(s,a)||(s[a]=[]);const l=i[a];uH(s[a],Array.isArray(l)?l:l?[l]:[])}}}function uH(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);to(e,0,0,r)}function pA(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ac(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ki=$a(/[A-Za-z]/),Ss=$a(/[\dA-Za-z]/),dH=$a(/[#-'*+\--9=?A-Z^-~]/);function xw(e){return e!==null&&(e<32||e===127)}const ww=$a(/\d/),fH=$a(/[\dA-Fa-f]/),pH=$a(/[!-/:-@[-`{-~]/);function ut(e){return e!==null&&e<-2}function ds(e){return e!==null&&(e<0||e===32)}function qt(e){return e===-2||e===-1||e===32}const hH=$a(new RegExp("\\p{P}|\\p{S}","u")),mH=$a(/\s/);function $a(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ru(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Ss(e.charCodeAt(n+1))&&Ss(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function fn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return qt(c)?(e.enter(n),l(c)):t(c)}function l(c){return qt(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const gH={tokenize:yH};function yH(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),fn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return ut(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const xH={tokenize:wH},KS={tokenize:bH};function wH(e){const t=this,n=[];let r=0,s,i,a;return l;function l(w){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,c,d)(w)}return d(w)}function c(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&b();const S=t.events.length;let C=S,N;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){N=t.events[C][1].end;break}y(r);let I=S;for(;I<t.events.length;)t.events[I][1].end={...N},I++;return to(t.events,C+1,0,t.events.slice(S)),t.events.length=I,d(w)}return l(w)}function d(w){if(r===n.length){if(!s)return p(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(KS,u,f)(w)}function u(w){return s&&b(),y(r),p(w)}function f(w){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(w)}function p(w){return t.containerState={},e.attempt(KS,h,g)(w)}function h(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){s&&b(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),v(w)}function v(w){if(w===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return ut(w)?(e.consume(w),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),v)}function k(w,S){const C=t.sliceStream(w);if(S&&C.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(C),t.parser.lazy[w.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<a&&(!s.events[N][1].end||s.events[N][1].end.offset>a))return;const I=t.events.length;let M=I,R,F;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){if(R){F=t.events[M][1].end;break}R=!0}for(y(r),N=I;N<t.events.length;)t.events[N][1].end={...F},N++;to(t.events,M+1,0,t.events.slice(I)),t.events.length=N}}function y(w){let S=n.length;for(;S-- >w;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=w}function b(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function bH(e,t,n){return fn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function qS(e){if(e===null||ds(e)||mH(e))return 1;if(hH(e))return 2}function uv(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const bw={name:"attention",resolveAll:vH,tokenize:kH};function vH(e,t){let n=-1,r,s,i,a,l,c,d,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};YS(f,-c),YS(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Ks(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ks(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=Ks(d,uv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ks(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,d=Ks(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,to(e,r-1,n-r+3,d),n=r+d.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function kH(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=qS(r);let i;return a;function a(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const d=e.exit("attentionSequence"),u=qS(c),f=!u||u===2&&s||n.includes(c),p=!s||s===2&&u||n.includes(r);return d._open=!!(i===42?f:f&&(s||!p)),d._close=!!(i===42?p:p&&(u||!f)),t(c)}}function YS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const SH={name:"autolink",tokenize:NH};function NH(e,t,n){let r=0;return s;function s(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(h){return Ki(h)?(e.consume(h),a):h===64?n(h):d(h)}function a(h){return h===43||h===45||h===46||Ss(h)?(r=1,l(h)):d(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||Ss(h))&&r++<32?(e.consume(h),l):(r=0,d(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||xw(h)?n(h):(e.consume(h),c)}function d(h){return h===64?(e.consume(h),u):dH(h)?(e.consume(h),d):n(h)}function u(h){return Ss(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,u):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||Ss(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const Jm={partial:!0,tokenize:jH};function jH(e,t,n){return r;function r(i){return qt(i)?fn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||ut(i)?t(i):n(i)}}const hA={continuation:{tokenize:EH},exit:_H,name:"blockQuote",tokenize:CH};function CH(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return qt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function EH(e,t,n){const r=this;return s;function s(a){return qt(a)?fn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(hA,t,n)(a)}}function _H(e){e.exit("blockQuote")}const mA={name:"characterEscape",tokenize:PH};function PH(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return pH(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const gA={name:"characterReference",tokenize:AH};function AH(e,t,n){const r=this;let s=0,i,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=Ss,u(f))}function d(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=fH,u):(e.enter("characterReferenceValue"),i=7,a=ww,u(f))}function u(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===Ss&&!cv(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<i?(e.consume(f),u):n(f)}}const GS={partial:!0,tokenize:TH},XS={concrete:!0,name:"codeFenced",tokenize:IH};function IH(e,t,n){const r=this,s={partial:!0,tokenize:C};let i=0,a=0,l;return c;function c(N){return d(N)}function d(N){const I=r.events[r.events.length-1];return i=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(N)}function u(N){return N===l?(a++,e.consume(N),u):a<3?n(N):(e.exit("codeFencedFenceSequence"),qt(N)?fn(e,f,"whitespace")(N):f(N))}function f(N){return N===null||ut(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(GS,v,S)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(N))}function p(N){return N===null||ut(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):qt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),fn(e,h,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),p)}function h(N){return N===null||ut(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||ut(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===l?n(N):(e.consume(N),g)}function v(N){return e.attempt(s,S,k)(N)}function k(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),y}function y(N){return i>0&&qt(N)?fn(e,b,"linePrefix",i+1)(N):b(N)}function b(N){return N===null||ut(N)?e.check(GS,v,S)(N):(e.enter("codeFlowValue"),w(N))}function w(N){return N===null||ut(N)?(e.exit("codeFlowValue"),b(N)):(e.consume(N),w)}function S(N){return e.exit("codeFenced"),t(N)}function C(N,I,M){let R=0;return F;function F($){return N.enter("lineEnding"),N.consume($),N.exit("lineEnding"),O}function O($){return N.enter("codeFencedFence"),qt($)?fn(N,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):L($)}function L($){return $===l?(N.enter("codeFencedFenceSequence"),W($)):M($)}function W($){return $===l?(R++,N.consume($),W):R>=a?(N.exit("codeFencedFenceSequence"),qt($)?fn(N,D,"whitespace")($):D($)):M($)}function D($){return $===null||ut($)?(N.exit("codeFencedFence"),I($)):M($)}}}function TH(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const xy={name:"codeIndented",tokenize:LH},RH={partial:!0,tokenize:OH};function LH(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),fn(e,i,"linePrefix",5)(d)}function i(d){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):ut(d)?e.attempt(RH,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||ut(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function OH(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):ut(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):fn(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):ut(a)?s(a):n(a)}}const MH={name:"codeText",previous:DH,resolve:$H,tokenize:FH};function $H(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function DH(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function FH(e,t,n){let r=0,s,i;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(i=e.enter("codeTextSequence"),s=0,u(f)):ut(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||ut(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),d)}function u(f){return f===96?(e.consume(f),s++,u):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(i.type="codeTextData",d(f))}}class zH{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Du(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Du(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Du(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Du(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Du(this.left,n.reverse())}}}function Du(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function yA(e){const t={};let n=-1,r,s,i,a,l,c,d;const u=new zH(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,BH(u,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=u.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(u.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...u.get(s)[1].start},l=u.slice(s,n),l.unshift(r),u.splice(s,n-s+1,l))}}return to(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!d}function BH(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let u,f,p=-1,h=n,g=0,v=0;const k=[v];for(;h;){for(;e.get(++s)[1]!==h;);i.push(s),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(v=p+1,k.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):k.pop(),p=k.length;p--;){const y=l.slice(k[p],k[p+1]),b=i.pop();c.push([b,b+y.length-1]),e.splice(b,2,y)}for(c.reverse(),p=-1;++p<c.length;)d[g+c[p][0]]=g+c[p][1],g+=c[p][1]-c[p][0]-1;return d}const HH={resolve:WH,tokenize:UH},VH={partial:!0,tokenize:KH};function WH(e){return yA(e),e}function UH(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):ut(l)?e.check(VH,a,i)(l):(e.consume(l),s)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function KH(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),fn(e,i,"linePrefix")}function i(a){if(a===null||ut(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function xA(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let u=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),p):y===null||y===32||y===41||xw(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(y))}function p(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||ut(y)?n(y):(e.consume(y),y===92?g:h)}function g(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function v(y){return!u&&(y===null||y===41||ds(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):u<d&&y===40?(e.consume(y),u++,v):y===41?(e.consume(y),u--,v):y===null||y===32||y===40||xw(y)?n(y):(e.consume(y),y===92?k:v)}function k(y){return y===40||y===41||y===92?(e.consume(y),v):v(y)}}function wA(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(i),u}function u(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(i),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):ut(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||ut(h)||l++>999?(e.exit("chunkString"),u(h)):(e.consume(h),c||(c=!qt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function bA(e,t,n,r,s,i){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(i),d(p))}function d(p){return p===a?(e.exit(i),c(a)):p===null?n(p):ut(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),fn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===a||p===null||ut(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?f:u)}function f(p){return p===a||p===92?(e.consume(p),u):u(p)}}function gd(e,t){let n;return r;function r(s){return ut(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):qt(s)?fn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const qH={name:"definition",tokenize:GH},YH={partial:!0,tokenize:XH};function GH(e,t,n){const r=this;let s;return i;function i(h){return e.enter("definition"),a(h)}function a(h){return wA.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return ds(h)?gd(e,d)(h):d(h)}function d(h){return xA(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return e.attempt(YH,f,f)(h)}function f(h){return qt(h)?fn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||ut(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function XH(e,t,n){return r;function r(l){return ds(l)?gd(e,s)(l):n(l)}function s(l){return bA(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return qt(l)?fn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||ut(l)?t(l):n(l)}}const JH={name:"hardBreakEscape",tokenize:QH};function QH(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return ut(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const ZH={name:"headingAtx",resolve:e6,tokenize:t6};function e6(e,t){let n=e.length-2,r=3,s,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},to(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function t6(e,t,n){let r=0;return s;function s(u){return e.enter("atxHeading"),i(u)}function i(u){return e.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&r++<6?(e.consume(u),a):u===null||ds(u)?(e.exit("atxHeadingSequence"),l(u)):n(u)}function l(u){return u===35?(e.enter("atxHeadingSequence"),c(u)):u===null||ut(u)?(e.exit("atxHeading"),t(u)):qt(u)?fn(e,l,"whitespace")(u):(e.enter("atxHeadingText"),d(u))}function c(u){return u===35?(e.consume(u),c):(e.exit("atxHeadingSequence"),l(u))}function d(u){return u===null||u===35||ds(u)?(e.exit("atxHeadingText"),l(u)):(e.consume(u),d)}}const n6=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],JS=["pre","script","style","textarea"],r6={concrete:!0,name:"htmlFlow",resolveTo:o6,tokenize:a6},s6={partial:!0,tokenize:c6},i6={partial:!0,tokenize:l6};function o6(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function a6(e,t,n){const r=this;let s,i,a,l,c;return d;function d(U){return u(U)}function u(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),f}function f(U){return U===33?(e.consume(U),p):U===47?(e.consume(U),i=!0,v):U===63?(e.consume(U),s=3,r.interrupt?t:E):Ki(U)?(e.consume(U),a=String.fromCharCode(U),k):n(U)}function p(U){return U===45?(e.consume(U),s=2,h):U===91?(e.consume(U),s=5,l=0,g):Ki(U)?(e.consume(U),s=4,r.interrupt?t:E):n(U)}function h(U){return U===45?(e.consume(U),r.interrupt?t:E):n(U)}function g(U){const re="CDATA[";return U===re.charCodeAt(l++)?(e.consume(U),l===re.length?r.interrupt?t:L:g):n(U)}function v(U){return Ki(U)?(e.consume(U),a=String.fromCharCode(U),k):n(U)}function k(U){if(U===null||U===47||U===62||ds(U)){const re=U===47,ue=a.toLowerCase();return!re&&!i&&JS.includes(ue)?(s=1,r.interrupt?t(U):L(U)):n6.includes(a.toLowerCase())?(s=6,re?(e.consume(U),y):r.interrupt?t(U):L(U)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(U):i?b(U):w(U))}return U===45||Ss(U)?(e.consume(U),a+=String.fromCharCode(U),k):n(U)}function y(U){return U===62?(e.consume(U),r.interrupt?t:L):n(U)}function b(U){return qt(U)?(e.consume(U),b):F(U)}function w(U){return U===47?(e.consume(U),F):U===58||U===95||Ki(U)?(e.consume(U),S):qt(U)?(e.consume(U),w):F(U)}function S(U){return U===45||U===46||U===58||U===95||Ss(U)?(e.consume(U),S):C(U)}function C(U){return U===61?(e.consume(U),N):qt(U)?(e.consume(U),C):w(U)}function N(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),c=U,I):qt(U)?(e.consume(U),N):M(U)}function I(U){return U===c?(e.consume(U),c=null,R):U===null||ut(U)?n(U):(e.consume(U),I)}function M(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||ds(U)?C(U):(e.consume(U),M)}function R(U){return U===47||U===62||qt(U)?w(U):n(U)}function F(U){return U===62?(e.consume(U),O):n(U)}function O(U){return U===null||ut(U)?L(U):qt(U)?(e.consume(U),O):n(U)}function L(U){return U===45&&s===2?(e.consume(U),A):U===60&&s===1?(e.consume(U),B):U===62&&s===4?(e.consume(U),Y):U===63&&s===3?(e.consume(U),E):U===93&&s===5?(e.consume(U),T):ut(U)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(s6,Q,W)(U)):U===null||ut(U)?(e.exit("htmlFlowData"),W(U)):(e.consume(U),L)}function W(U){return e.check(i6,D,Q)(U)}function D(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),$}function $(U){return U===null||ut(U)?W(U):(e.enter("htmlFlowData"),L(U))}function A(U){return U===45?(e.consume(U),E):L(U)}function B(U){return U===47?(e.consume(U),a="",P):L(U)}function P(U){if(U===62){const re=a.toLowerCase();return JS.includes(re)?(e.consume(U),Y):L(U)}return Ki(U)&&a.length<8?(e.consume(U),a+=String.fromCharCode(U),P):L(U)}function T(U){return U===93?(e.consume(U),E):L(U)}function E(U){return U===62?(e.consume(U),Y):U===45&&s===2?(e.consume(U),E):L(U)}function Y(U){return U===null||ut(U)?(e.exit("htmlFlowData"),Q(U)):(e.consume(U),Y)}function Q(U){return e.exit("htmlFlow"),t(U)}}function l6(e,t,n){const r=this;return s;function s(a){return ut(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function c6(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Jm,t,n)}}const u6={name:"htmlText",tokenize:d6};function d6(e,t,n){const r=this;let s,i,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),d):E===47?(e.consume(E),C):E===63?(e.consume(E),w):Ki(E)?(e.consume(E),M):n(E)}function d(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),i=0,g):Ki(E)?(e.consume(E),b):n(E)}function u(E){return E===45?(e.consume(E),h):n(E)}function f(E){return E===null?n(E):E===45?(e.consume(E),p):ut(E)?(a=f,B(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?A(E):E===45?p(E):f(E)}function g(E){const Y="CDATA[";return E===Y.charCodeAt(i++)?(e.consume(E),i===Y.length?v:g):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),k):ut(E)?(a=v,B(E)):(e.consume(E),v)}function k(E){return E===93?(e.consume(E),y):v(E)}function y(E){return E===62?A(E):E===93?(e.consume(E),y):v(E)}function b(E){return E===null||E===62?A(E):ut(E)?(a=b,B(E)):(e.consume(E),b)}function w(E){return E===null?n(E):E===63?(e.consume(E),S):ut(E)?(a=w,B(E)):(e.consume(E),w)}function S(E){return E===62?A(E):w(E)}function C(E){return Ki(E)?(e.consume(E),N):n(E)}function N(E){return E===45||Ss(E)?(e.consume(E),N):I(E)}function I(E){return ut(E)?(a=I,B(E)):qt(E)?(e.consume(E),I):A(E)}function M(E){return E===45||Ss(E)?(e.consume(E),M):E===47||E===62||ds(E)?R(E):n(E)}function R(E){return E===47?(e.consume(E),A):E===58||E===95||Ki(E)?(e.consume(E),F):ut(E)?(a=R,B(E)):qt(E)?(e.consume(E),R):A(E)}function F(E){return E===45||E===46||E===58||E===95||Ss(E)?(e.consume(E),F):O(E)}function O(E){return E===61?(e.consume(E),L):ut(E)?(a=O,B(E)):qt(E)?(e.consume(E),O):R(E)}function L(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,W):ut(E)?(a=L,B(E)):qt(E)?(e.consume(E),L):(e.consume(E),D)}function W(E){return E===s?(e.consume(E),s=void 0,$):E===null?n(E):ut(E)?(a=W,B(E)):(e.consume(E),W)}function D(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ds(E)?R(E):(e.consume(E),D)}function $(E){return E===47||E===62||ds(E)?R(E):n(E)}function A(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function B(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),P}function P(E){return qt(E)?fn(e,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):T(E)}function T(E){return e.enter("htmlTextData"),a(E)}}const dv={name:"labelEnd",resolveAll:m6,resolveTo:g6,tokenize:y6},f6={tokenize:x6},p6={tokenize:w6},h6={tokenize:b6};function m6(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&to(e,0,e.length,n),e}function g6(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},u={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=Ks(l,e.slice(i+1,i+r+3)),l=Ks(l,[["enter",u,t]]),l=Ks(l,uv(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Ks(l,[["exit",u,t],e[a-2],e[a-1],["exit",d,t]]),l=Ks(l,e.slice(a+1)),l=Ks(l,[["exit",c,t]]),to(e,i,e.length,l),e}function y6(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?f(p):(a=r.parser.defined.includes(Ac(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(f6,u,a?u:f)(p):p===91?e.attempt(p6,u,a?d:f)(p):a?u(p):f(p)}function d(p){return e.attempt(h6,u,f)(p)}function u(p){return t(p)}function f(p){return i._balanced=!0,n(p)}}function x6(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return ds(f)?gd(e,i)(f):i(f)}function i(f){return f===41?u(f):xA(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return ds(f)?gd(e,c)(f):u(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?bA(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function d(f){return ds(f)?gd(e,u)(f):u(f)}function u(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function w6(e,t,n){const r=this;return s;function s(l){return wA.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function b6(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const v6={name:"labelStartImage",resolveAll:dv.resolveAll,tokenize:k6};function k6(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const S6={name:"labelStartLink",resolveAll:dv.resolveAll,tokenize:N6};function N6(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const wy={name:"lineEnding",tokenize:j6};function j6(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),fn(e,t,"linePrefix")}}const ch={name:"thematicBreak",tokenize:C6};function C6(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||ut(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),qt(d)?fn(e,l,"whitespace")(d):l(d))}}const Zr={continuation:{tokenize:A6},exit:T6,name:"list",tokenize:P6},E6={partial:!0,tokenize:R6},_6={partial:!0,tokenize:I6};function P6(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:ww(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(ch,n,d)(h):d(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return ww(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),d(h)):n(h)}function d(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Jm,r.interrupt?n:u,e.attempt(E6,p,f))}function u(h){return r.containerState.initialBlankLine=!0,i++,p(h)}function f(h){return qt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function A6(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Jm,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,fn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!qt(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(_6,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,fn(e,e.attempt(Zr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function I6(e,t,n){const r=this;return fn(e,s,"listItemIndent",r.containerState.size+1);function s(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function T6(e){e.exit(this.containerState.type)}function R6(e,t,n){const r=this;return fn(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!qt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const QS={name:"setextUnderline",resolveTo:L6,tokenize:O6};function L6(e,t){let n=e.length,r,s,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function O6(e,t,n){const r=this;let s;return i;function i(d){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),qt(d)?fn(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||ut(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const M6={tokenize:$6};function $6(e){const t=this,n=e.attempt(Jm,r,e.attempt(this.parser.constructs.flowInitial,s,fn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(HH,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const D6={resolveAll:kA()},F6=vA("string"),z6=vA("text");function vA(e){return{resolveAll:kA(e==="text"?B6:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(u){return d(u)?i(u):l(u)}function l(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),c}function c(u){return d(u)?(n.exit("data"),i(u)):(n.consume(u),c)}function d(u){if(u===null)return!0;const f=s[u];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function kA(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function B6(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let i=s.length,a=-1,l=0,c;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const H6={42:Zr,43:Zr,45:Zr,48:Zr,49:Zr,50:Zr,51:Zr,52:Zr,53:Zr,54:Zr,55:Zr,56:Zr,57:Zr,62:hA},V6={91:qH},W6={[-2]:xy,[-1]:xy,32:xy},U6={35:ZH,42:ch,45:[QS,ch],60:r6,61:QS,95:ch,96:XS,126:XS},K6={38:gA,92:mA},q6={[-5]:wy,[-4]:wy,[-3]:wy,33:v6,38:gA,42:bw,60:[SH,u6],91:S6,92:[JH,mA],93:dv,95:bw,96:MH},Y6={null:[bw,D6]},G6={null:[42,95]},X6={null:[]},J6=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:G6,contentInitial:V6,disable:X6,document:H6,flow:U6,flowInitial:W6,insideSpan:Y6,string:K6,text:q6},Symbol.toStringTag,{value:"Module"}));function Q6(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],l=[];const c={attempt:I(C),check:I(N),consume:b,enter:w,exit:S,interrupt:I(N,{interrupt:!0})},d={code:null,containerState:{},defineSkip:v,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let u=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function f(O){return a=Ks(a,O),k(),a[a.length-1]!==null?[]:(M(t,0),d.events=uv(i,d.events,d),d.events)}function p(O,L){return e8(h(O),L)}function h(O){return Z6(a,O)}function g(){const{_bufferIndex:O,_index:L,line:W,column:D,offset:$}=r;return{_bufferIndex:O,_index:L,line:W,column:D,offset:$}}function v(O){s[O.line]=O.column,F()}function k(){let O;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<L.length;)y(L.charCodeAt(r._bufferIndex));else y(L)}}function y(O){u=u(O)}function b(O){ut(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,F()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=O}function w(O,L){const W=L||{};return W.type=O,W.start=g(),d.events.push(["enter",W,d]),l.push(W),W}function S(O){const L=l.pop();return L.end=g(),d.events.push(["exit",L,d]),L}function C(O,L){M(O,L.from)}function N(O,L){L.restore()}function I(O,L){return W;function W(D,$,A){let B,P,T,E;return Array.isArray(D)?Q(D):"tokenize"in D?Q([D]):Y(D);function Y(ge){return le;function le(ce){const de=ce!==null&&ge[ce],Ae=ce!==null&&ge.null,Ne=[...Array.isArray(de)?de:de?[de]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return Q(Ne)(ce)}}function Q(ge){return B=ge,P=0,ge.length===0?A:U(ge[P])}function U(ge){return le;function le(ce){return E=R(),T=ge,ge.partial||(d.currentConstruct=ge),ge.name&&d.parser.constructs.disable.null.includes(ge.name)?ue():ge.tokenize.call(L?Object.assign(Object.create(d),L):d,c,re,ue)(ce)}}function re(ge){return O(T,E),$}function ue(ge){return E.restore(),++P<B.length?U(B[P]):A}}}function M(O,L){O.resolveAll&&!i.includes(O)&&i.push(O),O.resolve&&to(d.events,L,d.events.length-L,O.resolve(d.events.slice(L),d)),O.resolveTo&&(d.events=O.resolveTo(d.events,d))}function R(){const O=g(),L=d.previous,W=d.currentConstruct,D=d.events.length,$=Array.from(l);return{from:D,restore:A};function A(){r=O,d.previous=L,d.currentConstruct=W,d.events.length=D,l=$,F()}}function F(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Z6(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function e8(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
68
+ `;break}case-3:{a=`\r
69
+ `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(i)}s=i===-2,r.push(a)}return r.join("")}function t8(e){const r={constructs:lH([J6,...(e||{}).extensions||[]]),content:s(gH),defined:[],document:s(xH),flow:s(M6),lazy:{},string:s(F6),text:s(z6)};return r;function s(i){return a;function a(l){return Q6(r,i,l)}}}function n8(e){for(;!yA(e););return e}const ZS=/[\0\t\n\r]/g;function r8(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let d,u,f,p,h;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),f=0,t="",n&&(i.charCodeAt(0)===65279&&f++,n=void 0);f<i.length;){if(ZS.lastIndex=f,d=ZS.exec(i),p=d&&d.index!==void 0?d.index:i.length,h=i.charCodeAt(p),!d){t=i.slice(f);break}if(h===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(i.slice(f,p)),e+=p-f),h){case 0:{c.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,c.push(-2);e++<u;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const s8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function i8(e){return e.replace(s8,o8)}function o8(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return pA(n.slice(i?2:1),i?16:10)}return cv(n)||e}const SA={}.hasOwnProperty;function a8(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),l8(n)(n8(t8(n).document().write(r8()(e,t,!0))))}function l8(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ee),autolinkProtocol:R,autolinkEmail:R,atxHeading:i(ct),blockQuote:i(Ae),characterEscape:R,characterReference:R,codeFenced:i(Ne),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Ne,a),codeText:i(Pe,a),codeTextData:R,data:R,codeFlowValue:R,definition:i(Ie),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(qe),hardBreakEscape:i(Ge),hardBreakTrailing:i(Ge),htmlFlow:i(xt,a),htmlFlowData:R,htmlText:i(xt,a),htmlTextData:R,image:i(Fe),label:a,link:i(ee),listItem:i(tt),listItemValue:p,listOrdered:i(De,f),listUnordered:i(De),paragraph:i(Nt),reference:U,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ct),strong:i(en),thematicBreak:i(jr)},exit:{atxHeading:c(),atxHeadingSequence:C,autolink:c(),autolinkEmail:de,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:ge,characterReference:le,codeFenced:c(k),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:F,codeIndented:c(y),codeText:c($),codeTextData:F,data:F,definition:c(),definitionDestinationString:S,definitionLabelString:b,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(W),htmlFlowData:F,htmlText:c(D),htmlTextData:F,image:c(B),label:T,labelText:P,lineEnding:O,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:re,resourceDestinationString:E,resourceTitleString:Y,resource:Q,setextHeading:c(M),setextHeadingLineSequence:I,setextHeadingText:N,strong:c(),thematicBreak:c()}};NA(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ae){let ve={type:"root",children:[]};const Xe={stack:[ve],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:u,data:n},ot=[];let nt=-1;for(;++nt<ae.length;)if(ae[nt][1].type==="listOrdered"||ae[nt][1].type==="listUnordered")if(ae[nt][0]==="enter")ot.push(nt);else{const hn=ot.pop();nt=s(ae,hn,nt)}for(nt=-1;++nt<ae.length;){const hn=t[ae[nt][0]];SA.call(hn,ae[nt][1].type)&&hn[ae[nt][1].type].call(Object.assign({sliceSerialize:ae[nt][2].sliceSerialize},Xe),ae[nt][1])}if(Xe.tokenStack.length>0){const hn=Xe.tokenStack[Xe.tokenStack.length-1];(hn[1]||eN).call(Xe,void 0,hn[0])}for(ve.position={start:ta(ae.length>0?ae[0][1].start:{line:1,column:1,offset:0}),end:ta(ae.length>0?ae[ae.length-2][1].end:{line:1,column:1,offset:0})},nt=-1;++nt<t.transforms.length;)ve=t.transforms[nt](ve)||ve;return ve}function s(ae,ve,Xe){let ot=ve-1,nt=-1,hn=!1,Mn,Tn,tr,pr;for(;++ot<=Xe;){const Bt=ae[ot];switch(Bt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Bt[0]==="enter"?nt++:nt--,pr=void 0;break}case"lineEndingBlank":{Bt[0]==="enter"&&(Mn&&!pr&&!nt&&!tr&&(tr=ot),pr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pr=void 0}if(!nt&&Bt[0]==="enter"&&Bt[1].type==="listItemPrefix"||nt===-1&&Bt[0]==="exit"&&(Bt[1].type==="listUnordered"||Bt[1].type==="listOrdered")){if(Mn){let nr=ot;for(Tn=void 0;nr--;){const ye=ae[nr];if(ye[1].type==="lineEnding"||ye[1].type==="lineEndingBlank"){if(ye[0]==="exit")continue;Tn&&(ae[Tn][1].type="lineEndingBlank",hn=!0),ye[1].type="lineEnding",Tn=nr}else if(!(ye[1].type==="linePrefix"||ye[1].type==="blockQuotePrefix"||ye[1].type==="blockQuotePrefixWhitespace"||ye[1].type==="blockQuoteMarker"||ye[1].type==="listItemIndent"))break}tr&&(!Tn||tr<Tn)&&(Mn._spread=!0),Mn.end=Object.assign({},Tn?ae[Tn][1].start:Bt[1].end),ae.splice(Tn||ot,0,["exit",Mn,Bt[2]]),ot++,Xe++}if(Bt[1].type==="listItemPrefix"){const nr={type:"listItem",_spread:!1,start:Object.assign({},Bt[1].start),end:void 0};Mn=nr,ae.splice(ot,0,["enter",nr,Bt[2]]),ot++,Xe++,tr=void 0,pr=!0}}}return ae[ve][1]._spread=hn,Xe}function i(ae,ve){return Xe;function Xe(ot){l.call(this,ae(ot),ot),ve&&ve.call(this,ot)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ae,ve,Xe){this.stack[this.stack.length-1].children.push(ae),this.stack.push(ae),this.tokenStack.push([ve,Xe||void 0]),ae.position={start:ta(ve.start),end:void 0}}function c(ae){return ve;function ve(Xe){ae&&ae.call(this,Xe),d.call(this,Xe)}}function d(ae,ve){const Xe=this.stack.pop(),ot=this.tokenStack.pop();if(ot)ot[0].type!==ae.type&&(ve?ve.call(this,ae,ot[0]):(ot[1]||eN).call(this,ae,ot[0]));else throw new Error("Cannot close `"+ae.type+"` ("+md({start:ae.start,end:ae.end})+"): it’s not open");Xe.position.end=ta(ae.end)}function u(){return oH(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(ae){if(this.data.expectingFirstListItemValue){const ve=this.stack[this.stack.length-2];ve.start=Number.parseInt(this.sliceSerialize(ae),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.lang=ae}function g(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.meta=ae}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ae.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ae.replace(/(\r?\n|\r)$/g,"")}function b(ae){const ve=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=ve,Xe.identifier=Ac(this.sliceSerialize(ae)).toLowerCase()}function w(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ae}function S(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ae}function C(ae){const ve=this.stack[this.stack.length-1];if(!ve.depth){const Xe=this.sliceSerialize(ae).length;ve.depth=Xe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function I(ae){const ve=this.stack[this.stack.length-1];ve.depth=this.sliceSerialize(ae).codePointAt(0)===61?1:2}function M(){this.data.setextHeadingSlurpLineEnding=void 0}function R(ae){const Xe=this.stack[this.stack.length-1].children;let ot=Xe[Xe.length-1];(!ot||ot.type!=="text")&&(ot=fr(),ot.position={start:ta(ae.start),end:void 0},Xe.push(ot)),this.stack.push(ot)}function F(ae){const ve=this.stack.pop();ve.value+=this.sliceSerialize(ae),ve.position.end=ta(ae.end)}function O(ae){const ve=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Xe=ve.children[ve.children.length-1];Xe.position.end=ta(ae.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ve.type)&&(R.call(this,ae),F.call(this,ae))}function L(){this.data.atHardBreak=!0}function W(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ae}function D(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ae}function $(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ae}function A(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ve,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function B(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ve,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function P(ae){const ve=this.sliceSerialize(ae),Xe=this.stack[this.stack.length-2];Xe.label=i8(ve),Xe.identifier=Ac(ve).toLowerCase()}function T(){const ae=this.stack[this.stack.length-1],ve=this.resume(),Xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Xe.type==="link"){const ot=ae.children;Xe.children=ot}else Xe.alt=ve}function E(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ae}function Y(){const ae=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ae}function Q(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function re(ae){const ve=this.resume(),Xe=this.stack[this.stack.length-1];Xe.label=ve,Xe.identifier=Ac(this.sliceSerialize(ae)).toLowerCase(),this.data.referenceType="full"}function ue(ae){this.data.characterReferenceType=ae.type}function ge(ae){const ve=this.sliceSerialize(ae),Xe=this.data.characterReferenceType;let ot;Xe?(ot=pA(ve,Xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ot=cv(ve);const nt=this.stack[this.stack.length-1];nt.value+=ot}function le(ae){const ve=this.stack.pop();ve.position.end=ta(ae.end)}function ce(ae){F.call(this,ae);const ve=this.stack[this.stack.length-1];ve.url=this.sliceSerialize(ae)}function de(ae){F.call(this,ae);const ve=this.stack[this.stack.length-1];ve.url="mailto:"+this.sliceSerialize(ae)}function Ae(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Pe(){return{type:"inlineCode",value:""}}function Ie(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function ct(){return{type:"heading",depth:0,children:[]}}function Ge(){return{type:"break"}}function xt(){return{type:"html",value:""}}function Fe(){return{type:"image",title:null,url:"",alt:null}}function ee(){return{type:"link",title:null,url:"",children:[]}}function De(ae){return{type:"list",ordered:ae.type==="listOrdered",start:null,spread:ae._spread,children:[]}}function tt(ae){return{type:"listItem",spread:ae._spread,checked:null,children:[]}}function Nt(){return{type:"paragraph",children:[]}}function en(){return{type:"strong",children:[]}}function fr(){return{type:"text",value:""}}function jr(){return{type:"thematicBreak"}}}function ta(e){return{line:e.line,column:e.column,offset:e.offset}}function NA(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?NA(e,r):c8(e,r)}}function c8(e,t){let n;for(n in t)if(SA.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function eN(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+md({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+md({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+md({start:t.start,end:t.end})+") is still open")}function u8(e){const t=this;t.parser=n;function n(r){return a8(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function d8(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function f8(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function p8(e,t){const n=t.value?t.value+`
71
+ `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function h8(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function m8(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function g8(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=ru(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=i+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const d={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,d),e.applyData(t,d)}function y8(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function x8(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function jA(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),i=s[0];i&&i.type==="text"?i.value="["+i.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function w8(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return jA(e,t);const s={src:ru(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function b8(e,t){const n={src:ru(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function v8(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function k8(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return jA(e,t);const s={href:ru(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function S8(e,t){const n={href:ru(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function N8(e,t,n){const r=e.all(t),s=n?j8(n):CA(t),i={},a=[];if(typeof t.checked=="boolean"){const u=r[0];let f;u&&u.type==="element"&&u.tagName==="p"?f=u:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const u=r[l];(s||l!==0||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
72
+ `}),u.type==="element"&&u.tagName==="p"&&!s?a.push(...u.children):a.push(u)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
+ `});const d={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,d),e.applyData(t,d)}function j8(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=CA(n[r])}return t}function CA(e){const t=e.spread;return t??e.children.length>1}function C8(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function E8(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _8(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function P8(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function A8(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=iv(t.children[1]),c=oA(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function I8(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const d=[];for(;++c<l;){const f=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let g={type:"element",tagName:i,properties:p,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),d.push(g)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,u),e.applyData(t,u)}function T8(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const tN=9,nN=32;function R8(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(rN(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(rN(t.slice(s),s>0,!1)),i.join("")}function rN(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===tN||i===nN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===tN||i===nN;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function L8(e,t){const n={type:"text",value:R8(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function O8(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const M8={blockquote:d8,break:f8,code:p8,delete:h8,emphasis:m8,footnoteReference:g8,heading:y8,html:x8,imageReference:w8,image:b8,inlineCode:v8,linkReference:k8,link:S8,listItem:N8,list:C8,paragraph:E8,root:_8,strong:P8,table:A8,tableCell:T8,tableRow:I8,text:L8,thematicBreak:O8,toml:Ap,yaml:Ap,definition:Ap,footnoteDefinition:Ap};function Ap(){}const EA=-1,Qm=0,yd=1,Jh=2,fv=3,pv=4,hv=5,mv=6,_A=7,PA=8,sN=typeof self=="object"?self:globalThis,$8=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=t[s];switch(i){case Qm:case EA:return n(a,s);case yd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Jh:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case fv:return n(new Date(a),s);case pv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case hv:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case mv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case _A:{const{name:l,message:c}=a;return n(new sN[l](c),s)}case PA:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new sN[i](a),s)};return r},iN=e=>$8(new Map,e)(0),Xl="",{toString:D8}={},{keys:F8}=Object,Fu=e=>{const t=typeof e;if(t!=="object"||!e)return[Qm,t];const n=D8.call(e).slice(8,-1);switch(n){case"Array":return[yd,Xl];case"Object":return[Jh,Xl];case"Date":return[fv,Xl];case"RegExp":return[pv,Xl];case"Map":return[hv,Xl];case"Set":return[mv,Xl];case"DataView":return[yd,n]}return n.includes("Array")?[yd,n]:n.includes("Error")?[_A,n]:[Jh,n]},Ip=([e,t])=>e===Qm&&(t==="function"||t==="symbol"),z8=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},i=a=>{if(n.has(a))return n.get(a);let[l,c]=Fu(a);switch(l){case Qm:{let u=a;switch(c){case"bigint":l=PA,u=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);u=null;break;case"undefined":return s([EA],a)}return s([l,u],a)}case yd:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const u=[],f=s([l,u],a);for(const p of a)u.push(i(p));return f}case Jh:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const u=[],f=s([l,u],a);for(const p of F8(a))(e||!Ip(Fu(a[p])))&&u.push([i(p),i(a[p])]);return f}case fv:return s([l,a.toISOString()],a);case pv:{const{source:u,flags:f}=a;return s([l,{source:u,flags:f}],a)}case hv:{const u=[],f=s([l,u],a);for(const[p,h]of a)(e||!(Ip(Fu(p))||Ip(Fu(h))))&&u.push([i(p),i(h)]);return f}case mv:{const u=[],f=s([l,u],a);for(const p of a)(e||!Ip(Fu(p)))&&u.push(i(p));return f}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},oN=(e,{json:t,lossy:n}={})=>{const r=[];return z8(!(t||n),!!t,new Map,r)(e),r},Qh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?iN(oN(e,t)):structuredClone(e):(e,t)=>iN(oN(e,t));function B8(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function H8(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function V8(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||B8,r=e.options.footnoteBackLabel||H8,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[c]);if(!d)continue;const u=e.all(d),f=String(d.identifier).toUpperCase(),p=ru(f.toLowerCase());let h=0;const g=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){g.length>0&&g.push({type:"text",value:" "});let b=typeof n=="string"?n:n(c,h);typeof b=="string"&&(b={type:"text",value:b}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const k=u[u.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const b=k.children[k.children.length-1];b&&b.type==="text"?b.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else u.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(u,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Qh(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
74
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
75
+ `}]}}const AA=function(e){if(e==null)return q8;if(typeof e=="function")return Zm(e);if(typeof e=="object")return Array.isArray(e)?W8(e):U8(e);if(typeof e=="string")return K8(e);throw new Error("Expected function, string, or object as test")};function W8(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=AA(e[n]);return Zm(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function U8(e){const t=e;return Zm(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function K8(e){return Zm(t);function t(n){return n&&n.type===e}}function Zm(e){return t;function t(n,r,s){return!!(Y8(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function q8(){return!0}function Y8(e){return e!==null&&typeof e=="object"&&"type"in e}const IA=[],G8=!0,aN=!1,X8="skip";function J8(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=AA(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,u){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=IA,g,v,k;if((!t||i(c,d,u[u.length-1]||void 0))&&(h=Q8(n(c,u)),h[0]===aN))return h;if("children"in c&&c.children){const y=c;if(y.children&&h[0]!==X8)for(v=(r?y.children.length:-1)+a,k=u.concat(y);v>-1&&v<y.children.length;){const b=y.children[v];if(g=l(b,v,k)(),g[0]===aN)return g;v=typeof g[1]=="number"?g[1]:v+a}}return h}}}function Q8(e){return Array.isArray(e)?e:typeof e=="number"?[G8,e]:e==null?IA:[e]}function TA(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),J8(e,i,l,s);function l(c,d){const u=d[d.length-1],f=u?u.children.indexOf(c):void 0;return a(c,f,u)}}const vw={}.hasOwnProperty,Z8={};function e9(e,t){const n=t||Z8,r=new Map,s=new Map,i=new Map,a={...M8,...n.handlers},l={all:d,applyData:n9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:t9,wrap:s9};return TA(e,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const f=u.type==="definition"?r:s,p=String(u.identifier).toUpperCase();f.has(p)||f.set(p,u)}}),l;function c(u,f){const p=u.type,h=l.handlers[p];if(vw.call(l.handlers,p)&&h)return h(l,u,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in u){const{children:v,...k}=u,y=Qh(k);return y.children=l.all(u),y}return Qh(u)}return(l.options.unknownHandler||r9)(l,u,f)}function d(u){const f=[];if("children"in u){const p=u.children;let h=-1;for(;++h<p.length;){const g=l.one(p[h],u);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=lN(g.value)),!Array.isArray(g)&&g.type==="element")){const v=g.children[0];v&&v.type==="text"&&(v.value=lN(v.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function t9(e,t){e.position&&(t.position=D4(e))}function n9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,Qh(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function r9(e,t){const n=t.data||{},r="value"in t&&!(vw.call(n,"hProperties")||vw.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function s9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
76
+ `});++r<e.length;)r&&n.push({type:"text",value:`
77
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
78
+ `}),n}function lN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function cN(e,t){const n=e9(e,t),r=n.one(e,void 0),s=V8(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
79
+ `},s),i}function i9(e,t){return e&&"run"in e?async function(n,r){const s=cN(n,{file:r,...t});await e.run(s,r)}:function(n,r){return cN(n,{file:r,...e||t})}}function uN(e){if(e)throw e}var uh=Object.prototype.hasOwnProperty,RA=Object.prototype.toString,dN=Object.defineProperty,fN=Object.getOwnPropertyDescriptor,pN=function(t){return typeof Array.isArray=="function"?Array.isArray(t):RA.call(t)==="[object Array]"},hN=function(t){if(!t||RA.call(t)!=="[object Object]")return!1;var n=uh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&uh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||uh.call(t,s)},mN=function(t,n){dN&&n.name==="__proto__"?dN(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},gN=function(t,n){if(n==="__proto__")if(uh.call(t,n)){if(fN)return fN(t,n).value}else return;return t[n]},o9=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,u=!1;for(typeof l=="boolean"&&(u=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=gN(l,n),s=gN(t,n),l!==s&&(u&&s&&(hN(s)||(i=pN(s)))?(i?(i=!1,a=r&&pN(r)?r:[]):a=r&&hN(r)?r:{},mN(l,{name:n,newValue:e(u,a,s)})):typeof s<"u"&&mN(l,{name:n,newValue:s}));return l};const by=Ta(o9);function kw(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function a9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...d){const u=e[++i];let f=-1;if(c){a(c);return}for(;++f<s.length;)(d[f]===null||d[f]===void 0)&&(d[f]=s[f]);s=d,u?l9(u,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function l9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(d){const u=d;if(l&&n)throw u;return s(u)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const Bi={basename:c9,dirname:u9,extname:d9,join:f9,sep:"/"};function c9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');kf(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else a<0&&(i=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function u9(e){if(kf(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function d9(e){kf(e);let t=e.length,n=-1,r=0,s=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function f9(...e){let t=-1,n;for(;++t<e.length;)kf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":p9(n)}function p9(e){kf(e);const t=e.codePointAt(0)===47;let n=h9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function h9(e,t){let n="",r=0,s=-1,i=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function kf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const m9={cwd:g9};function g9(){return"/"}function Sw(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function y9(e){if(typeof e=="string")e=new URL(e);else if(!Sw(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return x9(e)}function x9(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const vy=["history","path","basename","stem","extname","dirname"];class LA{constructor(t){let n;t?Sw(t)?n={path:t}:typeof t=="string"||w9(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":m9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<vy.length;){const i=vy[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)vy.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Bi.basename(this.path):void 0}set basename(t){Sy(t,"basename"),ky(t,"basename"),this.path=Bi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Bi.dirname(this.path):void 0}set dirname(t){yN(this.basename,"dirname"),this.path=Bi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Bi.extname(this.path):void 0}set extname(t){if(ky(t,"extname"),yN(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Bi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Sw(t)&&(t=y9(t)),Sy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Bi.basename(this.path,this.extname):void 0}set stem(t){Sy(t,"stem"),ky(t,"stem"),this.path=Bi.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Mr(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ky(e,t){if(e&&e.includes(Bi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Bi.sep+"`")}function Sy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function yN(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function w9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b9=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},v9={}.hasOwnProperty;class gv extends b9{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=a9()}copy(){const t=new gv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(by(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Cy("data",this.frozen),this.namespace[t]=n,this):v9.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Cy("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Tp(t),r=this.parser||this.Parser;return Ny("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ny("process",this.parser||this.Parser),jy("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=Tp(t),c=r.parse(l);r.run(c,l,function(u,f,p){if(u||!f||!p)return d(u);const h=f,g=r.stringify(h,p);N9(g)?p.value=g:p.result=g,d(u,p)});function d(u,f){u||!f?a(u):i?i(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Ny("processSync",this.parser||this.Parser),jy("processSync",this.compiler||this.Compiler),this.process(t,s),wN("processSync","process",n),r;function s(i,a){n=!0,uN(i),r=a}}run(t,n,r){xN(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const c=Tp(n);s.run(t,c,d);function d(u,f,p){const h=f||t;u?l(u):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),wN("runSync","run",r),s;function i(a,l){uN(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Tp(n),s=this.compiler||this.Compiler;return jy("stringify",s),xN(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Cy("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[u,...f]=d;c(u,f)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(s.settings=by(!0,s.settings,d.settings))}function l(d){let u=-1;if(d!=null)if(Array.isArray(d))for(;++u<d.length;){const f=d[u];i(f)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,u){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===d){p=f;break}if(p===-1)r.push([d,...u]);else if(u.length>0){let[h,...g]=u;const v=r[p][1];kw(v)&&kw(h)&&(h=by(!0,v,h)),r[p]=[d,h,...g]}}}}const k9=new gv().freeze();function Ny(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function jy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cy(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xN(e){if(!kw(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function wN(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Tp(e){return S9(e)?e:new LA(e)}function S9(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function N9(e){return typeof e=="string"||j9(e)}function j9(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const C9="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",bN=[],vN={allowDangerousHtml:!0},E9=/^(https?|ircs?|mailto|xmpp)$/i,_9=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Sf(e){const t=P9(e),n=A9(e);return I9(t.runSync(t.parse(n),n),e)}function P9(e){const t=e.rehypePlugins||bN,n=e.remarkPlugins||bN,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...vN}:vN;return k9().use(u8).use(n).use(i9,r).use(t)}function A9(e){const t=e.children||"",n=new LA;return typeof t=="string"&&(n.value=t),n}function I9(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||T9;for(const u of _9)Object.hasOwn(t,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+C9+u.id,void 0);return TA(e,d),V4(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(u,f,p){if(u.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:u.value},f;if(u.type==="element"){let h;for(h in yy)if(Object.hasOwn(yy,h)&&Object.hasOwn(u.properties,h)){const g=u.properties[h],v=yy[h];(v===null||v.includes(u.tagName))&&(u.properties[h]=c(String(g||""),h,u))}}if(u.type==="element"){let h=n?!n.includes(u.tagName):i?i.includes(u.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(u,f,p)),h&&p&&typeof f=="number")return l&&u.children?p.children.splice(f,1,...u.children):p.children.splice(f,1),f}}}function T9(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||E9.test(e.slice(0,t))?e:""}function R9(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Zh(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Zh(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Zh(t[r])}`).join(",")}}`}function kN(e){return Zh({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function Jd(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function SN(e){return Zh({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function NN(e,t){return!R9(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function jN(e,t=!1){const n=new Map;for(const r of e){const s=Jd(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function L9(e,t,n,r){const s=new Map(e.map(b=>[b.id,b])),i=new Set(n.map(b=>b.id)),a=new Set,l=[],c=[],d=n.map(b=>{const w=s.get(b.id);return w?kN(w)===kN(b)?(a.add(b.id),w):(c.push(b.id),NN(b,w)):(l.push(b.id),b)}),u=jN(t),f=jN(r,!0),p=new Set,h=[],g=[],v=r.map(b=>{const w=Jd(b),S=u.get(w);return S?SN(S)===SN(b)?(p.add(w),S):(g.push(w),NN(b,S)):(h.push(w),b)}),k=e.filter(b=>!i.has(b.id)).map(b=>b.id),y=t.map(b=>Jd(b)).filter(b=>!f.has(b));return{nodes:d,edges:v,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:k,addedEdgeKeys:h,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:h.length,edgeRemoved:y.length,edgeReused:p.size,nextEdgeCount:f.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function OA(e){return typeof e>"u"||e===null}function O9(e){return typeof e=="object"&&e!==null}function M9(e){return Array.isArray(e)?e:OA(e)?[]:[e]}function $9(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function D9(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function F9(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var z9=OA,B9=O9,H9=M9,V9=D9,W9=F9,U9=$9,Zn={isNothing:z9,isObject:B9,toArray:H9,repeat:V9,isNegativeZero:W9,extend:U9};function MA(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
80
+
81
+ `+e.mark.snippet),r+" "+n):r}function Qd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=MA(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Qd.prototype=Object.create(Error.prototype);Qd.prototype.constructor=Qd;Qd.prototype.toString=function(t){return this.name+": "+MA(this,t)};var Vr=Qd;function Ey(e,t,n,r,s){var i="",a="",l=Math.floor(s/2)-1;return r-t>l&&(i=" ... ",t=r-l+i.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function _y(e,t){return Zn.repeat(" ",t-e.length)+e}function K9(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],i,a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",c,d,u=Math.min(e.line+t.linesAfter,s.length).toString().length,f=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=Ey(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),f),l=Zn.repeat(" ",t.indent)+_y((e.line-c+1).toString(),u)+" | "+d.str+`
82
+ `+l;for(d=Ey(e.buffer,r[a],s[a],e.position,f),l+=Zn.repeat(" ",t.indent)+_y((e.line+1).toString(),u)+" | "+d.str+`
83
+ `,l+=Zn.repeat("-",t.indent+u+3+d.pos)+`^
84
+ `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=Ey(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),f),l+=Zn.repeat(" ",t.indent)+_y((e.line+c+1).toString(),u)+" | "+d.str+`
85
+ `;return l.replace(/\n$/,"")}var q9=K9,Y9=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],G9=["scalar","sequence","mapping"];function X9(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function J9(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(Y9.indexOf(n)===-1)throw new Vr('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=X9(t.styleAliases||null),G9.indexOf(this.kind)===-1)throw new Vr('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var kr=J9;function CN(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(i,a){i.tag===r.tag&&i.kind===r.kind&&i.multi===r.multi&&(s=a)}),n[s]=r}),n}function Q9(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(s){s.multi?(e.multi[s.kind].push(s),e.multi.fallback.push(s)):e[s.kind][s.tag]=e.fallback[s.tag]=s}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function Nw(e){return this.extend(e)}Nw.prototype.extend=function(t){var n=[],r=[];if(t instanceof kr)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new Vr("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof kr))throw new Vr("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new Vr("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new Vr("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(i){if(!(i instanceof kr))throw new Vr("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Nw.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=CN(s,"implicit"),s.compiledExplicit=CN(s,"explicit"),s.compiledTypeMap=Q9(s.compiledImplicit,s.compiledExplicit),s};var $A=Nw,DA=new kr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),FA=new kr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),zA=new kr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),BA=new $A({explicit:[DA,FA,zA]});function Z9(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function eV(){return null}function tV(e){return e===null}var HA=new kr("tag:yaml.org,2002:null",{kind:"scalar",resolve:Z9,construct:eV,predicate:tV,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function nV(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function rV(e){return e==="true"||e==="True"||e==="TRUE"}function sV(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var VA=new kr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:nV,construct:rV,predicate:sV,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function iV(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function oV(e){return 48<=e&&e<=55}function aV(e){return 48<=e&&e<=57}function lV(e){if(e===null)return!1;var t=e.length,n=0,r=!1,s;if(!t)return!1;if(s=e[n],(s==="-"||s==="+")&&(s=e[++n]),s==="0"){if(n+1===t)return!0;if(s=e[++n],s==="b"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(s!=="0"&&s!=="1")return!1;r=!0}return r&&s!=="_"}if(s==="x"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!iV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!oV(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!aV(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function cV(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function uV(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Zn.isNegativeZero(e)}var WA=new kr("tag:yaml.org,2002:int",{kind:"scalar",resolve:lV,construct:cV,predicate:uV,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),dV=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function fV(e){return!(e===null||!dV.test(e)||e[e.length-1]==="_")}function pV(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var hV=/^[-+]?[0-9]+e/;function mV(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Zn.isNegativeZero(e))return"-0.0";return n=e.toString(10),hV.test(n)?n.replace("e",".e"):n}function gV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Zn.isNegativeZero(e))}var UA=new kr("tag:yaml.org,2002:float",{kind:"scalar",resolve:fV,construct:pV,predicate:gV,represent:mV,defaultStyle:"lowercase"}),KA=BA.extend({implicit:[HA,VA,WA,UA]}),qA=KA,YA=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),GA=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function yV(e){return e===null?!1:YA.exec(e)!==null||GA.exec(e)!==null}function xV(e){var t,n,r,s,i,a,l,c=0,d=null,u,f,p;if(t=YA.exec(e),t===null&&(t=GA.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(i=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(u=+t[10],f=+(t[11]||0),d=(u*60+f)*6e4,t[9]==="-"&&(d=-d)),p=new Date(Date.UTC(n,r,s,i,a,l,c)),d&&p.setTime(p.getTime()-d),p}function wV(e){return e.toISOString()}var XA=new kr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:yV,construct:xV,instanceOf:Date,represent:wV});function bV(e){return e==="<<"||e===null}var JA=new kr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:bV}),yv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
+ \r`;function vV(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=yv;for(n=0;n<s;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function kV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=yv,a=0,l=[];for(t=0;t<s;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|i.indexOf(r.charAt(t));return n=s%4*6,n===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):n===18?(l.push(a>>10&255),l.push(a>>2&255)):n===12&&l.push(a>>4&255),new Uint8Array(l)}function SV(e){var t="",n=0,r,s,i=e.length,a=yv;for(r=0;r<i;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return s=i%3,s===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):s===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):s===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function NV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var QA=new kr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:vV,construct:kV,predicate:NV,represent:SV}),jV=Object.prototype.hasOwnProperty,CV=Object.prototype.toString;function EV(e){if(e===null)return!0;var t=[],n,r,s,i,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,CV.call(s)!=="[object Object]")return!1;for(i in s)if(jV.call(s,i))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function _V(e){return e!==null?e:[]}var ZA=new kr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:EV,construct:_V}),PV=Object.prototype.toString;function AV(e){if(e===null)return!0;var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],PV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function IV(e){if(e===null)return[];var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),i[t]=[s[0],r[s[0]]];return i}var eI=new kr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:AV,construct:IV}),TV=Object.prototype.hasOwnProperty;function RV(e){if(e===null)return!0;var t,n=e;for(t in n)if(TV.call(n,t)&&n[t]!==null)return!1;return!0}function LV(e){return e!==null?e:{}}var tI=new kr("tag:yaml.org,2002:set",{kind:"mapping",resolve:RV,construct:LV}),xv=qA.extend({implicit:[XA,JA],explicit:[QA,ZA,eI,tI]}),_a=Object.prototype.hasOwnProperty,em=1,nI=2,rI=3,tm=4,Py=1,OV=2,EN=3,MV=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,$V=/[\x85\u2028\u2029]/,DV=/[,\[\]\{\}]/,sI=/^(?:!|!!|![a-z\-]+!)$/i,iI=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function _N(e){return Object.prototype.toString.call(e)}function Ji(e){return e===10||e===13}function pl(e){return e===9||e===32}function ss(e){return e===9||e===32||e===10||e===13}function xc(e){return e===44||e===91||e===93||e===123||e===125}function FV(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function zV(e){return e===120?2:e===117?4:e===85?8:0}function BV(e){return 48<=e&&e<=57?e-48:-1}function PN(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
87
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function HV(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function oI(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var aI=new Array(256),lI=new Array(256);for(var Jl=0;Jl<256;Jl++)aI[Jl]=PN(Jl)?1:0,lI[Jl]=PN(Jl);function VV(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||xv,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function cI(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=q9(n),new Vr(t,n)}function Je(e,t){throw cI(e,t)}function nm(e,t){e.onWarning&&e.onWarning.call(null,cI(e,t))}var AN={YAML:function(t,n,r){var s,i,a;t.version!==null&&Je(t,"duplication of %YAML directive"),r.length!==1&&Je(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&Je(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&Je(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&nm(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&Je(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],sI.test(s)||Je(t,"ill-formed tag handle (first argument) of the TAG directive"),_a.call(t.tagMap,s)&&Je(t,'there is a previously declared suffix for "'+s+'" tag handle'),iI.test(i)||Je(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{Je(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function Sa(e,t,n,r){var s,i,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,i=l.length;s<i;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||Je(e,"expected valid JSON character");else MV.test(l)&&Je(e,"the stream contains non-printable characters");e.result+=l}}function IN(e,t,n,r){var s,i,a,l;for(Zn.isObject(n)||Je(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)i=s[a],_a.call(t,i)||(oI(t,i,n[i]),r[i]=!0)}function wc(e,t,n,r,s,i,a,l,c){var d,u;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,u=s.length;d<u;d+=1)Array.isArray(s[d])&&Je(e,"nested arrays are not supported inside keys"),typeof s=="object"&&_N(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&_N(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,u=i.length;d<u;d+=1)IN(e,t,i[d],n);else IN(e,t,i,n);else!e.json&&!_a.call(n,s)&&_a.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,Je(e,"duplicated mapping key")),oI(t,s,i),delete n[s];return t}function wv(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):Je(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function qn(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;pl(s);)s===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),s=e.input.charCodeAt(++e.position);if(t&&s===35)do s=e.input.charCodeAt(++e.position);while(s!==10&&s!==13&&s!==0);if(Ji(s))for(wv(e),s=e.input.charCodeAt(e.position),r++,e.lineIndent=0;s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&nm(e,"deficient indentation"),r}function eg(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||ss(n)))}function bv(e,t){t===1?e.result+=" ":t>1&&(e.result+=Zn.repeat(`
88
+ `,t-1))}function WV(e,t,n){var r,s,i,a,l,c,d,u,f=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),ss(h)||xc(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(s=e.input.charCodeAt(e.position+1),ss(s)||n&&xc(s)))return!1;for(e.kind="scalar",e.result="",i=a=e.position,l=!1;h!==0;){if(h===58){if(s=e.input.charCodeAt(e.position+1),ss(s)||n&&xc(s))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),ss(r))break}else{if(e.position===e.lineStart&&eg(e)||n&&xc(h))break;if(Ji(h))if(c=e.line,d=e.lineStart,u=e.lineIndent,qn(e,!1,-1),e.lineIndent>=t){l=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=c,e.lineStart=d,e.lineIndent=u;break}}l&&(Sa(e,i,a,!1),bv(e,e.line-c),i=a=e.position,l=!1),pl(h)||(a=e.position+1),h=e.input.charCodeAt(++e.position)}return Sa(e,i,a,!1),e.result?!0:(e.kind=f,e.result=p,!1)}function UV(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(Sa(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,s=e.position;else return!0;else Ji(n)?(Sa(e,r,s,!0),bv(e,qn(e,!1,t)),r=s=e.position):e.position===e.lineStart&&eg(e)?Je(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);Je(e,"unexpected end of the stream within a single quoted scalar")}function KV(e,t){var n,r,s,i,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return Sa(e,n,e.position,!0),e.position++,!0;if(l===92){if(Sa(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Ji(l))qn(e,!1,t);else if(l<256&&aI[l])e.result+=lI[l],e.position++;else if((a=zV(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=FV(l))>=0?i=(i<<4)+a:Je(e,"expected hexadecimal character");e.result+=HV(i),e.position++}else Je(e,"unknown escape sequence");n=r=e.position}else Ji(l)?(Sa(e,n,r,!0),bv(e,qn(e,!1,t)),n=r=e.position):e.position===e.lineStart&&eg(e)?Je(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}Je(e,"unexpected end of the stream within a double quoted scalar")}function qV(e,t){var n=!0,r,s,i,a=e.tag,l,c=e.anchor,d,u,f,p,h,g=Object.create(null),v,k,y,b;if(b=e.input.charCodeAt(e.position),b===91)u=93,h=!1,l=[];else if(b===123)u=125,h=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),b=e.input.charCodeAt(++e.position);b!==0;){if(qn(e,!0,t),b=e.input.charCodeAt(e.position),b===u)return e.position++,e.tag=a,e.anchor=c,e.kind=h?"mapping":"sequence",e.result=l,!0;n?b===44&&Je(e,"expected the node content, but found ','"):Je(e,"missed comma between flow collection entries"),k=v=y=null,f=p=!1,b===63&&(d=e.input.charCodeAt(e.position+1),ss(d)&&(f=p=!0,e.position++,qn(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Yc(e,t,em,!1,!0),k=e.tag,v=e.result,qn(e,!0,t),b=e.input.charCodeAt(e.position),(p||e.line===r)&&b===58&&(f=!0,b=e.input.charCodeAt(++e.position),qn(e,!0,t),Yc(e,t,em,!1,!0),y=e.result),h?wc(e,l,g,k,v,y,r,s,i):f?l.push(wc(e,null,g,k,v,y,r,s,i)):l.push(v),qn(e,!0,t),b=e.input.charCodeAt(e.position),b===44?(n=!0,b=e.input.charCodeAt(++e.position)):n=!1}Je(e,"unexpected end of the stream within a flow collection")}function YV(e,t){var n,r,s=Py,i=!1,a=!1,l=t,c=0,d=!1,u,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)Py===s?s=f===43?EN:OV:Je(e,"repeat of a chomping mode identifier");else if((u=BV(f))>=0)u===0?Je(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?Je(e,"repeat of an indentation width identifier"):(l=t+u-1,a=!0);else break;if(pl(f)){do f=e.input.charCodeAt(++e.position);while(pl(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!Ji(f)&&f!==0)}for(;f!==0;){for(wv(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),Ji(f)){c++;continue}if(e.lineIndent<l){s===EN?e.result+=Zn.repeat(`
89
+ `,i?1+c:c):s===Py&&i&&(e.result+=`
90
+ `);break}for(r?pl(f)?(d=!0,e.result+=Zn.repeat(`
91
+ `,i?1+c:c)):d?(d=!1,e.result+=Zn.repeat(`
92
+ `,c+1)):c===0?i&&(e.result+=" "):e.result+=Zn.repeat(`
93
+ `,c):e.result+=Zn.repeat(`
94
+ `,i?1+c:c),i=!0,a=!0,c=0,n=e.position;!Ji(f)&&f!==0;)f=e.input.charCodeAt(++e.position);Sa(e,n,e.position,!1)}return!0}function TN(e,t){var n,r=e.tag,s=e.anchor,i=[],a,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,Je(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!ss(a))));){if(l=!0,e.position++,qn(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Yc(e,t,rI,!1,!0),i.push(e.result),qn(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)Je(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=i,!0):!1}function GV(e,t,n){var r,s,i,a,l,c,d=e.tag,u=e.anchor,f={},p=Object.create(null),h=null,g=null,v=null,k=!1,y=!1,b;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),b=e.input.charCodeAt(e.position);b!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,Je(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(b===63||b===58)&&ss(r))b===63?(k&&(wc(e,f,p,h,g,null,a,l,c),h=g=v=null),y=!0,k=!0,s=!0):k?(k=!1,s=!0):Je(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,b=r;else{if(a=e.line,l=e.lineStart,c=e.position,!Yc(e,n,nI,!1,!0))break;if(e.line===i){for(b=e.input.charCodeAt(e.position);pl(b);)b=e.input.charCodeAt(++e.position);if(b===58)b=e.input.charCodeAt(++e.position),ss(b)||Je(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(wc(e,f,p,h,g,null,a,l,c),h=g=v=null),y=!0,k=!1,s=!1,h=e.tag,g=e.result;else if(y)Je(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=u,!0}else if(y)Je(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=u,!0}if((e.line===i||e.lineIndent>t)&&(k&&(a=e.line,l=e.lineStart,c=e.position),Yc(e,t,tm,!0,s)&&(k?g=e.result:v=e.result),k||(wc(e,f,p,h,g,v,a,l,c),h=g=v=null),qn(e,!0,-1),b=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&b!==0)Je(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&wc(e,f,p,h,g,null,a,l,c),y&&(e.tag=d,e.anchor=u,e.kind="mapping",e.result=f),y}function XV(e){var t,n=!1,r=!1,s,i,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&Je(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):Je(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!ss(a);)a===33&&(r?Je(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),sI.test(s)||Je(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),DV.test(i)&&Je(e,"tag suffix cannot contain flow indicator characters")}i&&!iI.test(i)&&Je(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{Je(e,"tag name is malformed: "+i)}return n?e.tag=i:_a.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:Je(e,'undeclared tag handle "'+s+'"'),!0}function JV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&Je(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!ss(n)&&!xc(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&Je(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function QV(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!ss(r)&&!xc(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&Je(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),_a.call(e.anchorMap,n)||Je(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],qn(e,!0,-1),!0}function Yc(e,t,n,r,s){var i,a,l,c=1,d=!1,u=!1,f,p,h,g,v,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=a=l=tm===n||rI===n,r&&qn(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;XV(e)||JV(e);)qn(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||s),(c===1||tm===n)&&(em===n||nI===n?v=t:v=t+1,k=e.position-e.lineStart,c===1?l&&(TN(e,k)||GV(e,k,v))||qV(e,v)?u=!0:(a&&YV(e,v)||UV(e,v)||KV(e,v)?u=!0:QV(e)?(u=!0,(e.tag!==null||e.anchor!==null)&&Je(e,"alias node should not have any properties")):WV(e,v,em===n)&&(u=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(u=l&&TN(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&Je(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,p=e.implicitTypes.length;f<p;f+=1)if(g=e.implicitTypes[f],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(_a.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,h=e.typeMap.multi[e.kind||"fallback"],f=0,p=h.length;f<p;f+=1)if(e.tag.slice(0,h[f].tag.length)===h[f].tag){g=h[f];break}g||Je(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&Je(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Je(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||u}function ZV(e){var t=e.position,n,r,s,i=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(qn(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(i=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!ss(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&Je(e,"directive name must not be less than one character in length");a!==0;){for(;pl(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!Ji(a));break}if(Ji(a))break;for(n=e.position;a!==0&&!ss(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&wv(e),_a.call(AN,r)?AN[r](e,r,s):nm(e,'unknown document directive "'+r+'"')}if(qn(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,qn(e,!0,-1)):i&&Je(e,"directives end mark is expected"),Yc(e,e.lineIndent-1,tm,!1,!0),qn(e,!0,-1),e.checkLineBreaks&&$V.test(e.input.slice(t,e.position))&&nm(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&eg(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,qn(e,!0,-1));return}if(e.position<e.length-1)Je(e,"end of the stream or a document separator is expected");else return}function uI(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
95
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new VV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,Je(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)ZV(n);return n.documents}function eW(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=uI(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function tW(e,t){var n=uI(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new Vr("expected a single document in the stream, but found more")}}var nW=eW,rW=tW,dI={loadAll:nW,load:rW},fI=Object.prototype.toString,pI=Object.prototype.hasOwnProperty,vv=65279,sW=9,Zd=10,iW=13,oW=32,aW=33,lW=34,jw=35,cW=37,uW=38,dW=39,fW=42,hI=44,pW=45,rm=58,hW=61,mW=62,gW=63,yW=64,mI=91,gI=93,xW=96,yI=123,wW=124,xI=125,$r={};$r[0]="\\0";$r[7]="\\a";$r[8]="\\b";$r[9]="\\t";$r[10]="\\n";$r[11]="\\v";$r[12]="\\f";$r[13]="\\r";$r[27]="\\e";$r[34]='\\"';$r[92]="\\\\";$r[133]="\\N";$r[160]="\\_";$r[8232]="\\L";$r[8233]="\\P";var bW=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],vW=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function kW(e,t){var n,r,s,i,a,l,c;if(t===null)return{};for(n={},r=Object.keys(t),s=0,i=r.length;s<i;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),c=e.compiledTypeMap.fallback[a],c&&pI.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function SW(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new Vr("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+Zn.repeat("0",r-t.length)+t}var NW=1,ef=2;function jW(e){this.schema=e.schema||xv,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=Zn.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=kW(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?ef:NW,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function RN(e,t){for(var n=Zn.repeat(" ",t),r=0,s=-1,i="",a,l=e.length;r<l;)s=e.indexOf(`
96
+ `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
+ `&&(i+=n),i+=a;return i}function Cw(e,t){return`
98
+ `+Zn.repeat(" ",e.indent*t)}function CW(e,t){var n,r,s;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(s=e.implicitTypes[n],s.resolve(t))return!0;return!1}function sm(e){return e===oW||e===sW}function tf(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==vv||65536<=e&&e<=1114111}function LN(e){return tf(e)&&e!==vv&&e!==iW&&e!==Zd}function ON(e,t,n){var r=LN(e),s=r&&!sm(e);return(n?r:r&&e!==hI&&e!==mI&&e!==gI&&e!==yI&&e!==xI)&&e!==jw&&!(t===rm&&!s)||LN(t)&&!sm(t)&&e===jw||t===rm&&s}function EW(e){return tf(e)&&e!==vv&&!sm(e)&&e!==pW&&e!==gW&&e!==rm&&e!==hI&&e!==mI&&e!==gI&&e!==yI&&e!==xI&&e!==jw&&e!==uW&&e!==fW&&e!==aW&&e!==wW&&e!==hW&&e!==mW&&e!==dW&&e!==lW&&e!==cW&&e!==yW&&e!==xW}function _W(e){return!sm(e)&&e!==rm}function Qu(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function wI(e){var t=/^\n* /;return t.test(e)}var bI=1,Ew=2,vI=3,kI=4,tc=5;function PW(e,t,n,r,s,i,a,l){var c,d=0,u=null,f=!1,p=!1,h=r!==-1,g=-1,v=EW(Qu(e,0))&&_W(Qu(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Qu(e,c),!tf(d))return tc;v=v&&ON(d,u,l),u=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Qu(e,c),d===Zd)f=!0,h&&(p=p||c-g-1>r&&e[g+1]!==" ",g=c);else if(!tf(d))return tc;v=v&&ON(d,u,l),u=d}p=p||h&&c-g-1>r&&e[g+1]!==" "}return!f&&!p?v&&!a&&!s(e)?bI:i===ef?tc:Ew:n>9&&wI(e)?tc:a?i===ef?tc:Ew:p?kI:vI}function AW(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===ef?'""':"''";if(!e.noCompatMode&&(bW.indexOf(t)!==-1||vW.test(t)))return e.quotingType===ef?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return CW(e,d)}switch(PW(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case bI:return t;case Ew:return"'"+t.replace(/'/g,"''")+"'";case vI:return"|"+MN(t,e.indent)+$N(RN(t,i));case kI:return">"+MN(t,e.indent)+$N(RN(IW(t,a),i));case tc:return'"'+TW(t)+'"';default:throw new Vr("impossible error: invalid scalar style")}}()}function MN(e,t){var n=wI(e)?String(t):"",r=e[e.length-1]===`
99
+ `,s=r&&(e[e.length-2]===`
100
+ `||e===`
101
+ `),i=s?"+":r?"":"-";return n+i+`
102
+ `}function $N(e){return e[e.length-1]===`
103
+ `?e.slice(0,-1):e}function IW(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var d=e.indexOf(`
104
+ `);return d=d!==-1?d:e.length,n.lastIndex=d,DN(e.slice(0,d),t)}(),s=e[0]===`
105
+ `||e[0]===" ",i,a;a=n.exec(e);){var l=a[1],c=a[2];i=c[0]===" ",r+=l+(!s&&!i&&c!==""?`
106
+ `:"")+DN(c,t),s=i}return r}function DN(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,i,a=0,l=0,c="";r=n.exec(e);)l=r.index,l-s>t&&(i=a>s?a:l,c+=`
107
+ `+e.slice(s,i),s=i+1),a=l;return c+=`
108
+ `,e.length-s>t&&a>s?c+=e.slice(s,a)+`
109
+ `+e.slice(a+1):c+=e.slice(s),c.slice(1)}function TW(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Qu(e,s),r=$r[n],!r&&tf(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||SW(n);return t}function RW(e,t,n){var r="",s=e.tag,i,a,l;for(i=0,a=n.length;i<a;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),(Lo(e,t,l,!1,!1)||typeof l>"u"&&Lo(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function FN(e,t,n,r){var s="",i=e.tag,a,l,c;for(a=0,l=n.length;a<l;a+=1)c=n[a],e.replacer&&(c=e.replacer.call(n,String(a),c)),(Lo(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&Lo(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=Cw(e,t)),e.dump&&Zd===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function LW(e,t,n){var r="",s=e.tag,i=Object.keys(n),a,l,c,d,u;for(a=0,l=i.length;a<l;a+=1)u="",r!==""&&(u+=", "),e.condenseFlow&&(u+='"'),c=i[a],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),Lo(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+="? "),u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Lo(e,t,d,!1,!1)&&(u+=e.dump,r+=u));e.tag=s,e.dump="{"+r+"}"}function OW(e,t,n,r){var s="",i=e.tag,a=Object.keys(n),l,c,d,u,f,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new Vr("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=Cw(e,t)),d=a[l],u=n[d],e.replacer&&(u=e.replacer.call(n,d,u)),Lo(e,t+1,d,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&Zd===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,f&&(p+=Cw(e,t)),Lo(e,t+1,u,!0,f)&&(e.dump&&Zd===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function zN(e,t,n){var r,s,i,a,l,c;for(s=n?e.explicitTypes:e.implicitTypes,i=0,a=s.length;i<a;i+=1)if(l=s[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,fI.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(pI.call(l.represent,c))r=l.represent[c](t,c);else throw new Vr("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function Lo(e,t,n,r,s,i,a){e.tag=null,e.dump=n,zN(e,n,!1)||zN(e,n,!0);var l=fI.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var u=l==="[object Object]"||l==="[object Array]",f,p;if(u&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(u&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(OW(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(LW(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?FN(e,t-1,e.dump,s):FN(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(RW(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&AW(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new Vr("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function MW(e,t){var n=[],r=[],s,i;for(_w(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function _w(e,t,n){var r,s,i;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,i=e.length;s<i;s+=1)_w(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)_w(e[r[s]],t,n)}function $W(e,t){t=t||{};var n=new jW(t);n.noRefs||MW(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),Lo(n,0,r,!0,!0)?n.dump+`
110
+ `:""}var DW=$W,FW={dump:DW};function kv(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var zW=kr,BW=$A,HW=BA,VW=KA,WW=qA,UW=xv,KW=dI.load,qW=dI.loadAll,YW=FW.dump,GW=Vr,XW={binary:QA,float:UA,map:zA,null:HA,pairs:eI,set:tI,timestamp:XA,bool:VA,int:WA,merge:JA,omap:ZA,seq:FA,str:DA},JW=kv("safeLoad","load"),QW=kv("safeLoadAll","loadAll"),ZW=kv("safeDump","dump"),SI={Type:zW,Schema:BW,FAILSAFE_SCHEMA:HW,JSON_SCHEMA:VW,CORE_SCHEMA:WW,DEFAULT_SCHEMA:UW,load:KW,loadAll:qW,dump:YW,YAMLException:GW,types:XW,safeLoad:JW,safeLoadAll:QW,safeDump:ZW};const Pa=["requirement","planning","code","test","normal"],Pw={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},eU=["agent","control","provide","condition","jump","condition_jump","start","end"];function tU(e){return eU.includes(e)?e:"agent"}function nU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function rU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=SI.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},i=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},c=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,u=new Set(Object.keys(s));for(const h of i)h!=null&&h.source&&u.add(String(h.source)),h!=null&&h.target&&u.add(String(h.target));const f=Array.from(u).map(h=>{const g=s[h],v=l[h]&&typeof l[h].x=="number"&&typeof l[h].y=="number"?{x:l[h].x,y:l[h].y}:{x:0,y:0},k=c[h]&&typeof c[h].width=="number"&&typeof c[h].height=="number"?{width:c[h].width,height:c[h].height}:null,y=(g==null?void 0:g.definitionId)??h,b=nU(y),w=(g==null?void 0:g.label)!=null?String(g.label):h,S=(g==null?void 0:g.role)!=null?String(g.role).trim():"",C=Pw[S]||S,N=Pa.includes(C)?C:"normal",I=(g==null?void 0:g.model)!=null?String(g.model).trim():void 0,M=(g==null?void 0:g.body)!=null?String(g.body):"",R=(g==null?void 0:g.script)!=null?String(g.script):"",F=Array.isArray(g==null?void 0:g.images)?g.images:[];return{id:h,type:tU(b),position:v,...k?{width:k.width,height:k.height}:{},data:{label:w,definitionId:y,schemaType:b,role:N,model:I||void 0,body:M,images:F,...k?{displaySize:k}:{},...R.trim()!==""?{script:R}:{}}}}),p=i.filter(h=>(h==null?void 0:h.source)&&(h==null?void 0:h.target)).map((h,g)=>({id:`e-${h.source}-${h.target}-${g}`,source:String(h.source),target:String(h.target),sourceHandle:h.sourceHandle??void 0,targetHandle:h.targetHandle??void 0,markerEnd:{type:us.ArrowClosed}}));return{nodes:f,edges:p,instances:s,description:d}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const i=r.match(/\((\d+):/);s=`
111
+
112
+ 💡 提示:通常由 ${i?`第 ${i[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
+ YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
+
115
+ ✅ 正确写法:
116
+ \`\`\`yaml
117
+ script: |
118
+ node -e "console.log('TODO: scripts/x.mjs')"
119
+ \`\`\`
120
+ ❌ 错误写法(当前文件):
121
+ \`\`\`yaml
122
+ script: node -e "console.log('TODO: scripts/x.mjs')"
123
+ \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function Nf(e,t){var s,i,a,l,c,d,u,f,p,h,g,v;const n=k=>{const y={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(y.required=!0),(k==null?void 0:k.showOnNode)!=null&&(y.showOnNode=!!k.showOnNode),y},r={};for(const k of e){const y=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},b=((s=k.data)==null?void 0:s.definitionId)||k.id,w=((i=k.data)==null?void 0:i.inputs)??[],S=((a=k.data)==null?void 0:a.outputs)??[],C=((l=k.data)==null?void 0:l.role)!=null?String(k.data.role).trim():"",N=y.role!=null?String(y.role).trim():"",I=Pw[C]||C,M=Pw[N]||N,R=Pa.includes(I)?I:Pa.includes(M)?M:"normal",F=Array.isArray(w)?w.map(n):Array.isArray(y.input)?y.input.map(U=>n(U)):[],O=Array.isArray(S)?S.map(n):Array.isArray(y.output)?y.output.map(U=>n(U)):[],L=((c=k.data)==null?void 0:c.label)!=null?String(k.data.label):y.label!=null?String(y.label):k.id,W=(d=k.data)==null?void 0:d.body,D=W!=null?String(W):y.body!=null?String(y.body):"";let $=((u=k.data)==null?void 0:u.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():y.model!=null&&String(y.model).trim()!==""?String(y.model).trim():void 0;($===""||$==="default")&&($=void 0);const A={...y,definitionId:b,label:L,role:R,model:$,input:F,output:O},B=((f=k.data)==null?void 0:f.marketplaceRef)||y.marketplaceRef;B?A.marketplaceRef=String(B):delete A.marketplaceRef;const P=((p=k.data)==null?void 0:p.marketplacePackageId)||y.marketplacePackageId;P?A.marketplacePackageId=String(P):delete A.marketplacePackageId;const T=((h=k.data)==null?void 0:h.marketplaceVersion)||y.marketplaceVersion;T?A.marketplaceVersion=String(T):delete A.marketplaceVersion,b.startsWith("provide_")||D.trim()===""?delete A.body:A.body=D;const E=Array.isArray((g=k.data)==null?void 0:g.images)?k.data.images:Array.isArray(y.images)?y.images:[];E.length>0?A.images=E:delete A.images;const Y=(v=k.data)==null?void 0:v.script,Q=Y!=null?String(Y):y.script!=null?String(y.script):"";Q.trim()===""?delete A.script:A.script=Q,delete A.temperature,delete A.maxTokens,delete A.description,r[k.id]=A}return r}function xd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function sU(e,t){const n=String(e||"node").replace(/_copy(?:_\d+)?$/i,"");let r=`${n}_copy`,s=2;for(;t.has(r);)r=`${n}_copy_${s}`,s+=1;return t.add(r),r}function NI(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const s=new Set(r.map(a=>a.id)),i=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>xd(a)),edges:i.map(a=>xd(a)),instances:Nf(r,n||{})}}function jI(e,t,n,r,s={}){var f;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const i=s.offset||{x:48,y:48},a=new Set((t||[]).map(p=>p.id)),l=new Map;for(const p of e.nodes)l.set(p.id,sU(p.id,a));const c=e.nodes.map(p=>{var g,v;const h=l.get(p.id);return{...xd(p),id:h,selected:!0,dragging:!1,position:{x:Number(((g=p.position)==null?void 0:g.x)||0)+i.x,y:Number(((v=p.position)==null?void 0:v.y)||0)+i.y}}}),d=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,h)=>{const g=l.get(p.source),v=l.get(p.target);return{...xd(p),id:`e-${g}-${v}-${Date.now()}-${h}`,source:g,target:v,selected:!1}}),u={...r||{}};for(const[p,h]of l.entries()){const g=(f=e.instances)==null?void 0:f[p];g&&(u[h]={...xd(g),label:g.label!=null?String(g.label):h})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...d],instances:u,pastedNodeIds:c.map(p=>p.id)}}function BN(e,t,n,r){var u,f,p,h;const s=Nf(e,n),i=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const v=g.position??{x:0,y:0};a[g.id]={x:v.x,y:v.y};const k=Number(((f=(u=g.data)==null?void 0:u.displaySize)==null?void 0:f.width)||g.width||0),y=Number(((h=(p=g.data)==null?void 0:p.displaySize)==null?void 0:h.height)||g.height||0);k>0&&y>0&&(l[g.id]={width:Math.round(k),height:Math.round(y)})}const c={nodePositions:a};Object.keys(l).length>0&&(c.nodeSizes=l),(r==null?void 0:r.description)!=null&&String(r.description).trim()!==""&&(c.description=String(r.description).trim());const d={instances:s,edges:i,ui:c};return SI.dump(d,{lineWidth:-1})}function iU(e){var s,i;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((i=e.data)==null?void 0:i.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],c=(l&&l.name!=null?String(l.name).trim():"")||`input-${a}`;t.inputNames.push(c)}for(let a=0;a<r.length;a++){const l=r[a],c=(l&&l.name!=null?String(l.name).trim():"")||`output-${a}`;t.outputNames.push(c)}return t}function oU(e,t,n){var c,d,u;const r=new Set(e.map(f=>f.id)),s={};for(const f of e)s[f.id]=iU(f);const i=new Map,a=new Map;for(const f of t)f.target&&r.has(f.target)&&(i.has(f.target)||i.set(f.target,new Set),f.targetHandle&&i.get(f.target).add(f.targetHandle)),f.source&&r.has(f.source)&&(a.has(f.source)||a.set(f.source,new Set),f.sourceHandle&&a.get(f.source).add(f.sourceHandle));const l=[];for(const f of e){const p=((c=f.data)==null?void 0:c.definitionId)!=null?String(f.data.definitionId):"",h=s[f.id]||{inputNames:[],outputNames:[]},g=h.inputNames.length,v=h.outputNames.length;if(!(p==="control_start"||p.startsWith("provide_"))&&g>0)for(let b=0;b<g;b++){const w=`input-${b}`;if(!((d=i.get(f.id))==null?void 0:d.has(w))){const C=h.inputNames[b]||w;l.push({nodeId:f.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:C,handle:w}),key:`${f.id}-${w}-in`})}}if(!(p==="control_end")&&v>0)for(let b=0;b<v;b++){const w=`output-${b}`;if(!((u=a.get(f.id))==null?void 0:u.has(w))){const C=h.outputNames[b]||w;l.push({nodeId:f.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:C,handle:w}),key:`${f.id}-${w}-out`})}}}return l}const im=/\[image\s+(\d+)\]/gi;function is(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map((t,n)=>({id:String(t.id||`image-${n+1}`),label:String(t.label||`image ${n+1}`),name:String(t.name||`image-${n+1}`),mimeType:String(t.mimeType||t.type||"image/png"),dataUrl:String(t.dataUrl||t.data||"")})).filter(t=>t.dataUrl.startsWith("data:image/")):[]}function aU(e){return`image ${is(e).length+1}`}function lU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function cU(e,t){const n=is(e),r=String(t||""),s=new Set;im.lastIndex=0;let i;for(;i=im.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function uU(e){return new Promise((t,n)=>{if(!e||!String(e.type||"").startsWith("image/")){n(new Error("Only image files are supported"));return}const r=new FileReader;r.onload=()=>{t({name:e.name||"image",mimeType:e.type||"image/png",dataUrl:String(r.result||"")})},r.onerror=()=>n(r.error||new Error("Failed to read image")),r.readAsDataURL(e)})}function CI(e){var n;return Array.from(((n=e==null?void 0:e.clipboardData)==null?void 0:n.items)||[]).filter(r=>r.kind==="file"&&String(r.type||"").startsWith("image/")).map(r=>r.getAsFile()).filter(Boolean)}function om(e){var t;return Array.from(((t=e==null?void 0:e.dataTransfer)==null?void 0:t.files)||[]).filter(n=>String(n.type||"").startsWith("image/"))}async function EI({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=is(n);for(const a of r){const l=await uU(a),c=aU(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=lU(s,c)}return{body:s,images:i}}function Aw(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const dU={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function fU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(dU[e]||[]).includes(s)?r:s}const pU={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),control_load_mcp:new Set(["workspaceContext","mcpContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext","mcpContext"])},hU={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])};function mU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function gU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();if(!n)return t;const r=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(r.entry||r.command)&&n==="tool_nodejs"?t:n}function HN(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,u;const i=n[s],l=n.find(f=>(f==null?void 0:f.name)&&f.name===r.name)||i;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((d=pU[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...(u=hU[e])!=null&&u.has(r.name)?{showOnNode:!1}:{}}})}function _I(e){var s,i;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=Aw(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function nf(e,t,n,r,s){var B,P,T,E,Y,Q,U,re,ue,ge,le,ce,de,Ae,Ne,Pe,Ie,qe,ct,Ge,xt;const i=((B=e.data)==null?void 0:B.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Fe=>Fe.id===i),l=t[e.id];let c=[],d=[],u=((P=e.data)==null?void 0:P.label)??e.id,f,p,h,g,v;const k=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(Aw)),Array.isArray(l.output)&&(d=l.output.map(Aw)),l.label&&(u=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(v=String(l.script)));const y=f??(typeof((T=e.data)==null?void 0:T.role)=="string"?e.data.role:"普通"),b=p??((E=e.data)==null?void 0:E.model)??void 0,w=(a==null?void 0:a.description)!=null?String(a.description).trim():"",S=w!==""?w:void 0,C=h??((Y=e.data)==null?void 0:Y.body)??"",N=Array.isArray(g)?g:Array.isArray((Q=e.data)==null?void 0:Q.images)?e.data.images:[],I=v!==void 0?v:((U=e.data)==null?void 0:U.script)!=null?String(e.data.script):"",M=String(e.id),R=(re=r==null?void 0:r[s])==null?void 0:re[M],F=(ue=R==null?void 0:R.label)==null?void 0:ue.label,O=R==null?void 0:R.body,L=R==null?void 0:R.description;k||(c.length===0&&((ge=a==null?void 0:a.inputs)!=null&&ge.length)&&(c=a.inputs.map(Fe=>({...Fe}))),d.length===0&&((le=a==null?void 0:a.outputs)!=null&&le.length)&&(d=a.outputs.map(Fe=>({...Fe}))));const W=gU(a,(a==null?void 0:a.id)??i),D=(l==null?void 0:l.marketplaceRef)||((ce=e.data)==null?void 0:ce.marketplaceRef)||mU(a);if(W==="agent_subAgent"&&!d.some(Fe=>(Fe==null?void 0:Fe.name)==="result")){const Fe=(de=a==null?void 0:a.outputs)==null?void 0:de.find(ee=>(ee==null?void 0:ee.name)==="result");d=[...d,Fe?{...Fe}:{type:"text",name:"result",default:""}]}if((W==="display_markdown"||W==="display_mermaid"||W==="display_ascii"||W==="display_chart"||W==="display_table")&&!d.some(Fe=>(Fe==null?void 0:Fe.name)==="next")){const Fe=(Ae=a==null?void 0:a.outputs)==null?void 0:Ae.find(ee=>(ee==null?void 0:ee.name)==="next");d=[...d,Fe?{...Fe}:{type:"node",name:"next",default:""}]}if(W==="workspace_run"){if(!c.some(Fe=>(Fe==null?void 0:Fe.name)==="prev")){const Fe=(Ne=a==null?void 0:a.inputs)==null?void 0:Ne.find(ee=>(ee==null?void 0:ee.name)==="prev");c=[Fe?{...Fe}:{type:"node",name:"prev",default:""},...c]}if(!d.some(Fe=>(Fe==null?void 0:Fe.name)==="next")){const Fe=(Pe=a==null?void 0:a.outputs)==null?void 0:Pe.find(ee=>(ee==null?void 0:ee.name)==="next");d=[...d,Fe?{...Fe}:{type:"node",name:"next",default:""}]}}c=HN(W,c,a==null?void 0:a.inputs),d=HN(W,d,a==null?void 0:a.outputs),W.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(C).trim()!==""&&(d=d.map((Fe,ee)=>ee===0?{...Fe,default:C,value:C}:Fe));const $=fU(W,F||u,a),A=W==="tool_nodejs"||String(I).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:F||u,displayLabel:$,definitionDisplayName:a==null?void 0:a.displayName,definitionId:W,...D?{marketplaceRef:D}:{},...l!=null&&l.marketplacePackageId||(Ie=e.data)!=null&&Ie.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((qe=e.data)==null?void 0:qe.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ct=e.data)!=null&&ct.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((Ge=e.data)==null?void 0:Ge.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((xt=e.data)==null?void 0:xt.schemaType)??e.type??"agent",role:y,model:b,body:O||C,images:N,script:I,inputs:c,outputs:d,description:L||S,originalLabel:u,originalBody:C,...A?{script:I}:{}}}}function PI(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var u,f,p,h;const s=n.get(r.source),i=n.get(r.target),a=((f=(u=s==null?void 0:s.data)==null?void 0:u.outputs)==null?void 0:f.length)??0,l=((h=(p=i==null?void 0:i.data)==null?void 0:p.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,d=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&c>=0&&c<a&&d>=0&&d<l})}function VN(e,t){const n=new RegExp(`^${t}-(\\d+)$`).exec(String(e||""));if(!n)return 0;const r=Number.parseInt(n[1],10);return Number.isFinite(r)&&r>=0?r:0}function WN(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function am(e,t){const n=String((t==null?void 0:t.source)||""),r=String((t==null?void 0:t.target)||"");if(!n||!r)return e;const s=VN(t==null?void 0:t.sourceHandle,"output"),i=VN(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var d,u,f,p;if(c.id===n){const h=WN((d=c.data)==null?void 0:d.outputs,s);if(h!==((u=c.data)==null?void 0:u.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=WN((f=c.data)==null?void 0:f.inputs,i);if(h!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}const UN=80,yU=220;function xU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function wU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Rp(e,t,n){const r={nodes:Array.isArray(e)?e.map(xU):[],edges:Array.isArray(t)?t.map(wU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function Ay(e,t){const n=[...e,t];return n.length>UN?n.slice(n.length-UN):n}function AI({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),d=m.useRef(null),u=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(C=>C+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),k=m.useCallback(()=>{v();const C=u.current,N=f.current;return u.current=null,f.current=null,!C||!N||C.signature===N.signature?(N&&(d.current=N),!1):(l.current=Ay(l.current,C),c.current=[],d.current=N,g(),!0)},[g,v]),y=m.useCallback((C=[],N=[],I={})=>{v(),l.current=[],c.current=[],u.current=null,f.current=null,d.current=Rp(C,N,I),h.current=!1,g()},[g,v]),b=m.useCallback(C=>{h.current=!0,d.current=C,u.current=null,f.current=null,v(),s==null||s(C.value),g()},[g,v,s]),w=m.useCallback(()=>{k();const C=d.current||Rp(e,t,n),N=l.current.pop();return N?(c.current=Ay(c.current,C),b(N),!0):(g(),!1)},[g,t,n,k,e,b]),S=m.useCallback(()=>{k();const C=d.current||Rp(e,t,n),N=c.current.pop();return N?(l.current=Ay(l.current,C),b(N),!0):(g(),!1)},[g,t,n,k,e,b]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const C=Rp(e,t,n);if(!d.current){d.current=C;return}if(h.current){h.current=!1,d.current=C;return}C.signature!==d.current.signature&&(u.current||(u.current=d.current),f.current=C,v(),p.current=window.setTimeout(()=>{k()},yU))},[v,t,r,n,k,e]),{canUndo:l.current.length>0||!!u.current,canRedo:c.current.length>0,resetHistory:y,undo:w,redo:S,version:i}}function On(e){switch(lm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function lm(e){const t=String(e??"").trim().toLowerCase();return t==="文本"||t==="str"||t==="string"?"text":t==="文件"||t==="path"?"file":t==="节点"||t==="flow"||t==="control"?"node":t==="boolean"||t==="布尔"?"bool":t||"node"}function bU(e,t){const n=lm(e),r=lm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const vU=new Set(["workspaceContext","skillsContext","mcpContext"]);function Iw(e){const t=lm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&vU.has(n)?`${t}+${n}`:t}function II(e){return Iw(e)}function Gc(e,t){if(!e||!t||!bU(e.type,t.type))return!1;const n=Iw(e),r=Iw(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function kU(e,t){const n=new RegExp(`^${t}-(\\d+)$`).exec(String(e||""));if(!n)return-1;const r=Number.parseInt(n[1],10);return Number.isFinite(r)?r:-1}function Xc(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=kU(t,n==="source"?"output":"input");return i<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[i]||null}function xo(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function SU(e){var r;const t=(r=e==null?void 0:e.definitionId)==null?void 0:r.trim();if(t&&t!=="普通")return t;const n=((e==null?void 0:e.schemaType)??"agent").toLowerCase();return n&&n!=="普通"?n:"agent"}function NU(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function jU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Wn(e){e.stopPropagation()}function CU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function EU(e,t){const n=`\\[${CU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
+ `).replace(/\n{3,}/g,`
125
+
126
+ `).trimEnd()}function Iy(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _U(e){const t=String(e||"");let n="",r=0;im.lastIndex=0;let s;for(;s=im.exec(t);)n+=Iy(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Iy(s[0])}</span>`,r=s.index+s[0].length;return n+=Iy(t.slice(r)),n||" "}function PU(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+i+a+l)}function TI({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var Bt,nr;const{t:u}=pn(),f=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=SU(e),v=NU(g),k=(e==null?void 0:e.isRunMode)??!1,y=(e==null?void 0:e.isExecuting)??!1,b=(e==null?void 0:e.isDim)??!1,w=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",N=C.startsWith("provide_"),I=C==="provide_bool",M=C==="provide_str",R=C==="provide_file",F=C==="agent_subAgent",O=F&&!k,L=I?jU(p[0]):!1,W=N?String(((Bt=p[0])==null?void 0:Bt.value)??((nr=p[0])==null?void 0:nr.default)??(e==null?void 0:e.body)??""):"",D=String((e==null?void 0:e.body)||""),$=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||u("flow:node.fallbackLabel"),A=!N&&!O&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",B=is(e==null?void 0:e.images),P=m.useRef(!1),T=m.useRef(!1),E=m.useRef(null),Y=m.useRef(null),[Q,U]=m.useState(W),[re,ue]=m.useState(D);m.useEffect(()=>{P.current||U(W)},[n,W]),m.useEffect(()=>{T.current||ue(D)},[n,D]),m.useEffect(()=>{const ye=E.current;if(!ye)return;const ze=PU(ye,re);ye.style.minHeight=`${ze}px`,ye.style.height="",Y.current&&(Y.current.style.minHeight=`${ze}px`,Y.current.style.height="")},[re]);const ge=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],le=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],ce=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],de=((e==null?void 0:e.model)??"").trim(),Ae=h==="agent"&&!C.startsWith("tool_nodejs"),Ne=new Set(ge.map(xo)),Pe=new Set(le.map(xo)),Ie=new Set(ce.map(xo)),qe=de?de.startsWith("cursor:")||de.startsWith("opencode:")||de.startsWith("claude-code:")?de:Ie.has(de)?`claude-code:${de}`:Pe.has(de)?`opencode:${de}`:Ne.has(de)?`cursor:${de}`:de:"",ct=de&&!qe.startsWith("cursor:")&&!qe.startsWith("opencode:")&&!qe.startsWith("claude-code:")&&!Ne.has(de)&&!Pe.has(de)&&!Ie.has(de),Ge=de.startsWith("cursor:")?de.slice(7):de.startsWith("opencode:")?de.slice(9):de.startsWith("claude-code:")?de.slice(12):de,xt=ye=>{const ze=ye.target.value;d&&d(n,ze)},Fe=ye=>{ye.stopPropagation(),r&&r(n)},ee=ye=>{ye.stopPropagation(),s&&s()},De=ye=>{ye.stopPropagation(),i==null||i(n,ye.target.value==="true"?"true":"false")},tt=ye=>{ye.stopPropagation();const ze=ye.target.value;U(ze),P.current||i==null||i(n,ze)},Nt=ye=>{ye.stopPropagation(),P.current=!0},en=ye=>{ye.stopPropagation(),P.current=!1;const ze=ye.currentTarget.value;U(ze),i==null||i(n,ze)},fr=()=>{i==null||i(n,Q)},jr=ye=>{ye.stopPropagation();const ze=window.prompt("文件路径",Q);ze!=null&&(U(ze),i==null||i(n,ze))},ae=ye=>{if(ue(ye),a==null||a(n,ye),l){const ze=cU(B,ye);(ze.length!==B.length||ze.some(($t,kt)=>{var Ut;return $t.id!==((Ut=B[kt])==null?void 0:Ut.id)}))&&l(n,ze)}},ve=ye=>{ye.stopPropagation();const ze=ye.target.value;T.current?ue(ze):ae(ze)},Xe=ye=>{ye.stopPropagation(),T.current=!0},ot=ye=>{ye.stopPropagation(),T.current=!1;const ze=ye.currentTarget.value;ae(ze)},nt=()=>{ae(re)},hn=async ye=>{const ze=await EI({files:ye,body:re,images:B});ze&&(ue(ze.body),a==null||a(n,ze.body),l==null||l(n,ze.images))},Mn=(ye,ze)=>{ye.stopPropagation();const $t=B.filter(Ut=>Ut.id!==ze.id),kt=EU(re,ze.label);ue(kt),a==null||a(n,kt),l==null||l(n,$t)},Tn=ye=>{const ze=CI(ye);ze.length!==0&&(ye.preventDefault(),ye.stopPropagation(),hn(ze).catch(()=>{}))},tr=ye=>{const ze=om(ye);ze.length!==0&&(ye.preventDefault(),ye.stopPropagation(),hn(ze).catch(()=>{}))},pr=()=>{const ye=E.current,ze=Y.current;!ye||!ze||(ze.scrollTop=ye.scrollTop,ze.scrollLeft=ye.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(w==="success"?" af-flow-node--done":"")+(w==="failed"?" af-flow-node--failed":"")+(w==="running"&&!y?" af-flow-node--running-disk":"")+(b?" af-flow-node--dim":"")+(O?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+h.replace(/[^a-z0-9_-]/g,""),"data-schema":h,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:v}),!k&&Ae&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:qe,onChange:xt,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,"aria-label":u("flow:node.model"),title:Ge||u("flow:node.defaultModel"),children:[o.jsx("option",{value:"",children:u("flow:node.defaultModel")}),ct&&o.jsx("option",{value:de,children:de}),ge.length>0&&o.jsx("optgroup",{label:"Cursor",children:ge.map(ye=>o.jsx("option",{value:`cursor:${xo(ye)}`,children:xo(ye)},`c-${ye}`))}),le.length>0&&o.jsx("optgroup",{label:"OpenCode",children:le.map(ye=>o.jsx("option",{value:`opencode:${xo(ye)}`,children:xo(ye)},`o-${ye}`))}),ce.length>0&&o.jsx("optgroup",{label:"Claude Code",children:ce.map(ye=>o.jsx("option",{value:`claude-code:${xo(ye)}`,children:xo(ye)},`cc-${ye}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),w==="running"&&!y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:u("flow:node.diskRunning"),children:"RUNNING"}),w==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),w==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&N&&!I&&!M&&!R&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:ee,"aria-label":u("flow:node.expandProvide"),title:u("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&o.jsx("button",{type:"button",className:"af-flow-node__delete",onClick:Fe,"aria-label":u("flow:node.deleteNode"),title:u("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:f.map((ye,ze)=>{if(ye.showOnNode===!1)return null;const $t=u("flow:node.inputTooltip",{name:ye.name||`#${ze}`,type:ye.type})+(ye.default!=null&&ye.default!==""?u("flow:node.defaultSuffix",{value:ye.default}):""),kt=ye.name||`#${ze+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:$t,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[kt,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(fs,{type:"target",position:Ue.Left,id:`input-${ze}`,className:"af-flow-node__handle",style:{background:On(ye.type)},title:$t})]},`in-${ze}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:$}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,I?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(L?" af-flow-node__bool-select--true":""),value:L?"true":"false",onChange:De,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,"aria-label":"Boolean value",title:L?"true":"false",children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):M?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:Q,onChange:tt,onCompositionStart:Nt,onCompositionEnd:en,onBlur:fr,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,placeholder:"输入文本",rows:2}):R?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:Q,onChange:tt,onCompositionStart:Nt,onCompositionEnd:en,onBlur:fr,placeholder:"选择或输入文件路径",title:Q||"选择或输入文件路径"}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",onClick:jr,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):F&&!k?o.jsxs("div",{className:"af-flow-node__prompt-stack nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsx("pre",{ref:Y,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:_U(re)+`
127
+ `}}),o.jsx("textarea",{ref:E,className:"af-flow-node__prompt-editor nodrag",value:re,onChange:ve,onCompositionStart:Xe,onCompositionEnd:ot,onBlur:nt,onPaste:Tn,onDrop:tr,onScroll:pr,onDragOver:ye=>{om(ye).length>0&&ye.preventDefault()},placeholder:"输入 prompt",rows:2})]}):null,F&&B.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:B.map((ye,ze)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ye.name,children:[o.jsx("img",{src:ye.dataUrl,alt:""}),o.jsxs("span",{children:["[",ye.label||`image ${ze+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",onClick:$t=>Mn($t,ye),onPointerDown:Wn,onMouseDown:Wn,"aria-label":`删除 ${ye.label||`image ${ze+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ye.id||ze))}):null,A?o.jsx("span",{className:"af-flow-node__prompt-preview",title:A,children:A}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((ye,ze)=>{if(ye.showOnNode===!1)return null;const $t=u("flow:node.outputTooltip",{name:ye.name||`#${ze}`,type:ye.type})+(ye.default!=null&&ye.default!==""?u("flow:node.defaultSuffix",{value:ye.default}):""),kt=ye.name||`#${ze+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:$t,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[kt,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(fs,{type:"source",position:Ue.Right,id:`output-${ze}`,className:"af-flow-node__handle",style:{background:On(ye.type)},title:$t})]},`out-${ze}`)})})]})]})}const jf="flowNode";function RI(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function cm(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function AU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function IU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=pn(),a=m.useId(),l=m.useRef(null),[c,d]=m.useState(""),[u,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),h(""),f(!1);const y=requestAnimationFrame(()=>{var b;return(b=l.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),v=g===n;async function k(y){if(y.preventDefault(),!(!v||u)){f(!0),h("");try{const b=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await b.json().catch(()=>({}));if(!b.ok){h(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(b){h(String((b==null?void 0:b.message)||b))}finally{f(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!v})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||u,children:i(u?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function KN({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:u}){const{t:f}=pn(),p=m.useId(),h=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=h.current)==null?void 0:w.focus()});function b(w){w.key==="Escape"&&u(),w.key==="Enter"&&d()}return window.addEventListener("keydown",b),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",b)}},[e,u,d]),!e)return null;const g=r??f("common:common.confirm","确定"),v=s??f("common:common.cancel","取消"),k=t??f("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&u()},children:o.jsxs("div",{ref:h,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:k}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:u,"aria-label":v,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:u,children:v}),a&&c?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function TU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=pn(),l=m.useId(),c=m.useRef(null),[d,u]=m.useState(""),[f,p]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),g(""),p(!1);const b=requestAnimationFrame(()=>{var w;return(w=c.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(b)},[e,n]),!e)return null;const v=d.trim(),k=v===n;async function y(b){if(b.preventDefault(),!k||f)return;p(!0),g("");let w=null;try{const S=new AbortController;w=setTimeout(()=>S.abort(),15e3);const C=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:v,flowArchived:s}),signal:S.signal}),N=await C.json().catch(()=>({}));if(!C.ok){g(typeof N.error=="string"?N.error:a("project:deleteModal.deleteFailed"));return}try{for(let I=localStorage.length-1;I>=0;I--){const M=localStorage.key(I);M&&(M.startsWith(`af:composer-sessions:${n}:${r}`)||M.startsWith(`af:composer-active-session:${n}:${r}`)||M.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(M)}}catch{}await i()}catch(S){if((S==null?void 0:S.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((S==null?void 0:S.message)||S))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:b=>b.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:b=>u(b.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":v.length>0&&!k})]}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||f,children:a(f?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function RU({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Di({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(RU,{children:t})]},n))})}function LI({open:e,onClose:t}){const{t:n}=pn(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=AU()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(Di,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(Di,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Di,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(Di,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(Di,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(Di,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(Di,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Di,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(Di,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(Di,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function LU(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function OU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=pn(),[i,a]=m.useState(""),[l,c]=m.useState(0),d=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var v;return(v=d.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(g)},[e]);const f=m.useMemo(()=>{const g=(r||[]).map(y=>{var b,w,S;return{id:y.id,label:((b=y.data)==null?void 0:b.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((S=y.data)==null?void 0:S.schemaType)||""}}),v=i.trim(),k=g.map(y=>({e:y,s:LU(y,v)})).filter(y=>y.s>0);return k.sort((y,b)=>b.s-y.s||y.e.id.localeCompare(b.e.id)),k.slice(0,50).map(y=>y.e)},[r,i]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const g=(v=u.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const v=f[g];v&&(n(v.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(v=>Math.max(0,v-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),c(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:u,className:"af-jump-panel__list",role:"listbox",children:f.map((g,v)=>o.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:k=>{k.preventDefault(),p(v)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function MU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=pn(),u=m.useId(),f=m.useRef(null),p=m.useRef(null),[h,g]=m.useState(""),[v,k]=m.useState(""),[y,b]=m.useState(!1),[w,S]=m.useState(!1),[C,N]=m.useState(!1),[I,M]=m.useState(""),[R,F]=m.useState("");if(m.useEffect(()=>{if(!e||!i)return;g(""),k(""),M(""),F(""),b(!0),S(!1),N(!1);const A=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const P=await fetch(`/api/pipeline-file-content?${A}`),T=await P.json();if(!P.ok)throw new Error(T.error||"HTTP "+P.status);g(T.content||""),k(T.content||"")}catch(P){M(P.message||String(P))}finally{b(!1)}})();const B=requestAnimationFrame(()=>{var P;return(P=f.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(B)},[e,i,n,r,s]),!e)return null;const O=h!==v;async function L(A){if(A.preventDefault(),!w){S(!0),M(""),F("");try{const B=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),P=await fetch(`/api/pipeline-file-save?${B}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),T=await P.json();if(!P.ok)throw new Error(T.error||"HTTP "+P.status);k(h),F(d("flow:fileEdit.saved")),l&&l()}catch(B){M(B.message||String(B))}finally{S(!1)}}}async function W(){if(!(!c||C||!h)){N(!0),M("");try{const A=await c(h);typeof A=="string"&&A&&g(A)}catch(A){M(A.message||String(A))}finally{N(!1)}}}function D(){g(v),M(""),F("")}const $=h.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:A=>{A.target===A.currentTarget&&t()},children:o.jsxs("div",{ref:f,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:A=>A.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):I&&!h?o.jsx("div",{className:"af-file-edit-error",children:I}):o.jsxs(o.Fragment,{children:[$&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:h,onChange:A=>g(A.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(I||R)&&!y&&o.jsx("div",{className:`af-file-edit-status${R?" af-file-edit-status--success":""}`,children:R||I}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:D,disabled:!O||w||C,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:C||w||!h,children:d(C?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:L,disabled:!O||w||C,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const OI=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),$U=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function DU(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function FU(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function qN(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function MI(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(OI.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function $I(e){return{inputNames:qN(e==null?void 0:e.inputs),outputNames:qN(e==null?void 0:e.outputs)}}function zU(e,t,n){const r=$I(t),s=FU(e),i=[];for(const a of s)if(!MI(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function BU(e,t){const n=$I(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=MI(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function HU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function VU(e){return e.map(t=>{const n=HU(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function WU(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of $U)OI.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function UU(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function KU(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function Lp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:u}=pn(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[g,v]=m.useState(0),[k,y]=m.useState(0),[b,w]=m.useState(null),S=m.useMemo(()=>is(c),[c]),C=m.useMemo(()=>zU(e,a,u),[e,a,u]),N=C.length>0,I=m.useMemo(()=>BU(e,a),[e,a]),M=m.useMemo(()=>VU(I),[I]),R=m.useMemo(()=>n?null:DU(e,g),[e,g,n]),F=m.useMemo(()=>{if(!R)return[];const A=WU(a,u);return UU(A,R.query)},[R,a,u]);m.useEffect(()=>{y(A=>{const B=Math.max(0,F.length-1);return Math.min(Math.max(0,A),B)})},[F.length]);const O=m.useCallback(()=>{const A=p.current;if(!A||!R||F.length===0){w(null);return}const B=KU(A,g);if(!B){w(null);return}const P=4,T=44,E=13.5*16,Y=Math.min(F.length*T+8,E);let Q=B.bottom+P;Q+Y>window.innerHeight-8&&(Q=Math.max(8,B.top-Y-P));const U=288;let re=B.left;re=Math.max(8,Math.min(re,window.innerWidth-U-8)),w({top:Q,left:re})},[R,F.length,g]);m.useLayoutEffect(()=>{if(!R||F.length===0){w(null);return}const A=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(A)},[R,F.length,g,e,O]),m.useEffect(()=>{if(!R||F.length===0)return;const A=()=>O();return window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[R,F.length,O]);const L=m.useCallback(A=>{if(!R)return;const{atIndex:B}=R,P=e.slice(0,B)+"${"+A+"}"+e.slice(g);t(P);const T=B+A.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(T,T)),v(T)})},[R,e,g,t]),W=m.useCallback(()=>{const A=p.current,B=h.current;!A||!B||(B.scrollTop=A.scrollTop,B.scrollLeft=A.scrollLeft,R&&F.length>0&&queueMicrotask(()=>O()))},[R,F.length,O]),D=m.useCallback(A=>{if(!n&&R&&F.length>0&&(A.key==="ArrowDown"||A.key==="ArrowUp"||A.key==="Enter")){if(A.key==="ArrowDown")A.preventDefault(),y(B=>(B+1)%F.length);else if(A.key==="ArrowUp")A.preventDefault(),y(B=>(B-1+F.length)%F.length);else if(A.key==="Enter"&&!A.shiftKey){A.preventDefault();const B=F[k];B&&L(B.insert)}}},[n,R,F,k,L]),$=m.useCallback(async A=>{if(n||typeof d!="function")return!1;const B=await EI({files:A,body:e,images:S});return B?(t(B.body),d(B.images),queueMicrotask(()=>{const P=p.current;if(!P)return;P.focus();const T=B.body.length;P.setSelectionRange(T,T),v(T)}),!0):!1},[n,S,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[S.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:S.map((A,B)=>o.jsxs("span",{className:"af-body-image-chip",title:A.name,children:[o.jsx("img",{src:A.dataUrl,alt:""}),o.jsxs("span",{children:["[",A.label||`image ${B+1}`,"]"]})]},A.id||B))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:M+`
128
+ `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?f:void 0,onChange:A=>{t(A.target.value),v(A.target.selectionStart??A.target.value.length)},onSelect:A=>{const B=A.target;B instanceof HTMLTextAreaElement&&v(B.selectionStart??0)},onClick:A=>{const B=A.target;B instanceof HTMLTextAreaElement&&v(B.selectionStart??0)},onKeyUp:A=>{const B=A.target;B instanceof HTMLTextAreaElement&&v(B.selectionStart??B.value.length)},onKeyDown:D,onPaste:A=>{const B=CI(A);B.length!==0&&(A.preventDefault(),$(B).catch(()=>{}))},onDragOver:A=>{om(A).length>0&&A.preventDefault()},onDrop:A=>{const B=om(A);B.length!==0&&(A.preventDefault(),$(B).catch(()=>{}))},onScroll:W})]}),R&&F.length>0&&b?ts.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":u("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:F.map((A,B)=>o.jsx("li",{role:"option","aria-selected":B===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(B===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(B),onClick:()=>L(A.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${A.insert}}`}),A.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:A.subtitle}):null]})},`${A.section}-${A.insert}`))}),document.body):null,N?o.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:C.map(A=>A.message).join(" · ")}):null]})}const DI=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Op(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function YN({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=pn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),d=(f,p,h)=>{const g=n.map((v,k)=>{if(k!==f)return v;const y={...v,[p]:h};return p==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},u=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:u})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((f,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${u}-${p}`,children:[u,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>d(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>d(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>d(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{i||d(p,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>d(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${u}-${p}`))]}):null]})}function FI({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:u,ioSlots:f}){const{t:p}=pn(),[h,g]=m.useState(!1),[v,k]=m.useState(!1),[y,b]=m.useState({status:"idle",message:""}),w=m.useCallback(L=>{t(W=>W&&{...W,...L})},[t]),{cursorList:S,opencodeList:C,claudeCodeList:N,currentNotInLists:I}=m.useMemo(()=>{const L=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],D=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],$=new Set([...L,...W,...D].map(Op)),A=((e==null?void 0:e.model)??"").trim(),B=A.startsWith("cursor:")?A.slice(7):A.startsWith("opencode:")?A.slice(9):A.startsWith("claude-code:")?A.slice(12):A,P=A&&!$.has(B)?A:"";return{cursorList:L,opencodeList:W,claudeCodeList:D,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const M=String(e.script??""),R=n==="tool_nodejs"||M.trim()!=="",F=typeof c=="function"&&!i&&(e==null?void 0:e.newId),O=async()=>{if(F){b({status:"running",message:p("flow:nodeProps.publishRunning")});try{const L=await c(e,n);b({status:"success",message:L!=null&&L.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(L){b({status:"error",message:String((L==null?void 0:L.message)||L)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:O,disabled:!F||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[u?o.jsx("p",{className:"af-err af-node-props-err",children:u}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:L=>w({newId:L.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:L=>w({label:L.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:Pa.includes(e.role)?e.role:p("flow:roles.normal"),onChange:L=>w({role:L.target.value}),disabled:i,children:Pa.map(L=>o.jsx("option",{value:L,children:L},L))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?I||L:""})(),onChange:L=>w({model:L.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),I?o.jsxs("option",{value:I,children:[I,p("flow:nodeProps.yamlValueNotInList")]}):null,S.length>0?o.jsx("optgroup",{label:"Cursor",children:S.map(L=>o.jsx("option",{value:Op(L),children:L},`c-${L}`))}):null,C.length>0?o.jsx("optgroup",{label:"OpenCode",children:C.map(L=>o.jsx("option",{value:Op(L),children:L},`o-${L}`))}):null,N.length>0?o.jsx("optgroup",{label:"Claude Code",children:N.map(L=>o.jsx("option",{value:`claude-code:${Op(L)}`,children:L},`cc-${L}`))}):null]})]}),o.jsx(YN,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>w({inputs:L}),disabled:i,requiredReadonly:!d}),o.jsx(YN,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>w({outputs:L}),disabled:i,requiredReadonly:!d}),R?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lp,{value:M,onChange:L=>w({script:L}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Lp,{value:e.body,onChange:L=>w({body:L}),images:e.images,onImagesChange:L=>w({images:L}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Lp,{value:M,onChange:L=>w({script:L}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Lp,{value:e.body,onChange:L=>w({body:L}),images:e.images,onImagesChange:L=>w({images:L}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function Sv(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function qU(e){const t=Sv(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function zI(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function GN({text:e}){const{t}=pn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Sf,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function XN({o:e}){var r;const{t}=pn(),n=Sv(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:zI(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Sf,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function JN(e){return qU(e)}function QN(e){var r;if(!e)return null;const t=Sv(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?zI(String(n)):String(n)}function ZN({text:e,title:t,copiedLabel:n}){const[r,s]=m.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const ej=2e4,BI="af:run-node-ctx-width";function dh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function da(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):da(dh())}function YU(){try{const e=localStorage.getItem(BI);if(e==null)return da(dh());const t=parseInt(e,10);return Number.isFinite(t)?da(t):da(dh())}catch{return da(dh())}}async function tj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function GU(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function XU({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=pn(),[a,l]=m.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=m.useState(YU),u=m.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[f,p]=m.useState(!0),[h,g]=m.useState(""),[v,k]=m.useState([]),[y,b]=m.useState(null),[w,S]=m.useState(null),C=m.useRef(null),N=m.useRef(null),I=m.useRef(0),M=m.useRef(0);m.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),T=()=>l(P.matches);return P.addEventListener("change",T),()=>P.removeEventListener("change",T)},[]),m.useEffect(()=>{function P(){d(T=>da(T))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const R=m.useCallback(()=>{d(P=>{const T=da(P);try{localStorage.setItem(BI,String(T))}catch{}return T})},[]),F=m.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const T=P.currentTarget;u.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},T.setPointerCapture(P.pointerId)},[a,c]),O=m.useCallback(P=>{const T=u.current;if(!T.active||P.pointerId!==T.pointerId)return;const E=T.startX-P.clientX;d(da(T.startW+E))},[]),L=m.useCallback(P=>{const T=u.current;if(!(!T.active||P.pointerId!==T.pointerId)){T.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}R()}},[R]),W=m.useCallback(()=>{const P=u.current;P.active&&(P.active=!1,R())},[R]),D=m.useCallback(P=>{const T=Array.isArray(P)?P:[];k(T),b(E=>E&&T.some(Y=>Y.execId===E)?E:T.length>0?T[T.length-1].execId:null)},[]),$=m.useCallback(()=>{if(!e||!t)return;const P=++I.current,T=new AbortController,E=window.setTimeout(()=>T.abort(),ej);(async()=>{try{const Y=await tj(t,e,n,T.signal);if(P!==I.current)return;D(Array.isArray(Y.rounds)?Y.rounds:[])}catch{}finally{window.clearTimeout(E)}})()},[e,t,n,D]);m.useEffect(()=>{if(!e||!t){p(!1),g(""),k([]);return}const P=++M.current;p(!0),g(""),k([]),b(null);const T=new AbortController,E=window.setTimeout(()=>T.abort(),ej);return(async()=>{try{const Y=await tj(t,e,n,T.signal);if(P!==M.current)return;D(Array.isArray(Y.rounds)?Y.rounds:[])}catch(Y){if(P!==M.current)return;const Q=(Y==null?void 0:Y.name)==="AbortError"?"requestTimeout":Y.message||String(Y);g(Q)}finally{window.clearTimeout(E),P===M.current&&p(!1)}})(),()=>{T.abort(),M.current++,I.current++}},[e,t,n,D]),m.useEffect(()=>{r&&$()},[r,$]),m.useEffect(()=>{clearInterval(N.current);const P=v.length>0?v[v.length-1]:null;return(r==="running"&&v.length===0||!!(P&&P.status==="running"))&&e&&t&&(N.current=setInterval(()=>$(),2e3)),()=>clearInterval(N.current)},[v,e,t,n,r,$]),m.useEffect(()=>{C.current&&(C.current.scrollTop=0)},[y]);const A=v.find(P=>P.execId===y),B=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:B,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:F,onPointerMove:O,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),f&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),h&&o.jsx("div",{className:"af-run-ctx-error",children:GU(i,h)}),!f&&!h&&v.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),v.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+QU((A==null?void 0:A.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const T=P.target.value;b(T==="latest"?"latest":Number(T))},children:[...v].reverse().map(P=>{const T=P.execId==="latest"?i("flow:runContext.latest"):`#${P.execId}`,E=ZU(i,P.status),Y=P.finishedAt?` · ${JU(P.finishedAt)}`:"";return o.jsx("option",{value:String(P.execId),children:`${T} · ${E}${Y}`},P.execId)})})]}),A&&o.jsxs("div",{className:"af-run-ctx-body",ref:C,children:[A.inputs&&A.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),A.inputs.map((P,T)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${T}`))]}),A.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>S("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(GN,{text:A.prompt})]}),A.outputs&&A.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>S("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),A.outputs.map((P,T)=>{const E=JN(P),Y=QN(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:E}):null,o.jsx(ZN,{text:Y,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(XN,{o:P})]},`${P.slot}-${T}`)})]}),!A.prompt&&(!A.outputs||A.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&A&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&S(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>S(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&A.prompt!=null&&o.jsx(GN,{text:A.prompt}),w==="output"&&A.outputs&&A.outputs.map((P,T)=>{const E=JN(P),Y=QN(P);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",children:E}):null,o.jsx(ZN,{text:Y,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(XN,{o:P})]},`${P.slot}-${T}`)})]})]})})]})}function JU(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function QU(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function ZU(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function e7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=pn(),[d,u]=m.useState({}),[f,p]=m.useState(null),[h,g]=m.useState({}),[v,k]=m.useState(!0),[y,b]=m.useState(!1),[w,S]=m.useState(""),[C,N]=m.useState(!1),[I,M]=m.useState(null),R=m.useRef(null),F=m.useRef(!0),O=m.useRef({});m.useMemo(()=>{var E,Y,Q;const T={};for(const U of r){const re=(Q=(Y=(E=U.data)==null?void 0:E.outputs)==null?void 0:Y[0])==null?void 0:Q.default;re!=null&&re!==""&&(T[U.id]=String(re))}return O.current=T,T},[r]);const L=m.useMemo(()=>{var E;const T={};for(const Y of i){if(!((E=Y.data)!=null&&E.inputs))continue;const Q=Y.data.inputs;for(let U=0;U<Q.length;U++){const re=Q[U];if(!(re!=null&&re.name))continue;const ue=s.find(le=>le.target===Y.id&&le.targetHandle===`input-${U}`);if(!(ue!=null&&ue.source))continue;r.find(le=>le.id===ue.source)&&(T[ue.source]=re.name)}}return T},[i,s,r]);m.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),m.useEffect(()=>{if(!e){k(!1);return}k(!0);const T=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&T.set("archived","1"),fetch(`/api/flow/run-config?${T.toString()}`).then(E=>{if(!E.ok)throw new Error(`HTTP ${E.status}`);return E.json()}).then(E=>{var Q;if(!F.current)return;u(E.presets||{}),p(E.activePreset||null);const Y=E.activePreset&&((Q=E.presets)!=null&&Q[E.activePreset])?E.presets[E.activePreset]:{};g({...O.current,...Y}),k(!1)}).catch(()=>{F.current&&(g(O.current),k(!1))})},[e,t,n]),m.useEffect(()=>{var E;if(!a)return;const T={};for(const[Y,Q]of Object.entries(h)){const U=L[Y];if(!U)continue;const re=r.find(ge=>ge.id===Y);if(!re)continue;(((E=re.data)==null?void 0:E.definitionId)||"").startsWith("provide_file")?T[U]={type:"file",path:Q}:T[U]={type:"str",value:Q}}a(T)},[h,L,r,a]);const W=m.useCallback((T,E)=>{g(Y=>({...Y,[T]:E}))},[]),D=m.useCallback(T=>{T!==f&&(p(T),T&&d[T]?g({...O.current,...d[T]}):g(O.current))},[f,d]),$=m.useCallback(async()=>{if(w.trim()){b(!0);try{const T={...d,[w.trim()]:h},E={flowId:e,flowSource:t,archived:n,presets:T,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&(u(T),p(w.trim()),S(""),N(!1))}finally{b(!1)}}},[e,t,n,d,h,w]),A=m.useCallback(async()=>{if(f){b(!0);try{const T={...d};delete T[f];const E=Object.keys(T)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:T,activePreset:E})})).ok&&(u(T),p(E),E&&T[E]?g({...O.current,...T[E]}):g(O.current))}finally{b(!1)}}},[e,t,n,d,f]),B=m.useCallback(async()=>{if(f){b(!0);try{const T={...d,[f]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:T,activePreset:f})})).ok&&u(T)}finally{b(!1)}}},[e,t,n,d,f,h]),P=Object.keys(d);return P.length>0,v?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:f||"",onChange:T=>D(T.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(T=>o.jsx("option",{value:T,children:T},T))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>N(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),f&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:B,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),f&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:A,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),C&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:w,onChange:T=>S(T.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{N(!1),S("")},disabled:y,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(T=>{var le,ce;const E=((le=T.data)==null?void 0:le.definitionId)||"",Y=E.startsWith("provide_file"),Q=E==="provide_bool",U=((ce=T.data)==null?void 0:ce.label)||T.id,re=T.id,ue=h[re]||"",ge=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(Y?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:Y?"description":Q?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:U}),Q?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>M({instanceId:re,label:U,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:re}),Q?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ge?" af-run-config-bool-toggle--true":""),onClick:()=>W(re,ge?"false":"true"),"aria-pressed":ge,children:ge?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:de=>W(re,de.target.value),placeholder:c(Y?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},re)})})]}),I&&ts.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:I.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>M(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:R,className:"af-provide-edit-modal__textarea",defaultValue:I.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!I||!R.current||(W(I.instanceId,R.current.value),M(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>M(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const HI={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},t7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function n7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function r7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function s7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function nj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(HI))if(r.includes(e))return n;return"other"}function i7({event:e,defaultExpanded:t}){const[n,r]=m.useState(!!t),s=t7[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=m.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const g=i[h];return g==null?`${h}:null`:typeof g=="object"?`${h}:{…}`:`${h}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),u=m.useCallback(f=>{f.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(f=>!f),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:r7(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:u,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function o7({open:e,onClose:t,flowId:n}){var M;const[r,s]=m.useState([]),[i,a]=m.useState(!1),[l,c]=m.useState(null),[d,u]=m.useState(null),[f,p]=m.useState(!1),[h,g]=m.useState(!0),[v,k]=m.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=m.useState(""),w=m.useRef(null),S=m.useCallback(async()=>{a(!0);try{const R=h&&n?`?flowId=${encodeURIComponent(n)}`:"",O=await(await fetch(`/api/composer-logs${R}`)).json();s(Array.isArray(O.sessions)?O.sessions:[])}catch{s([])}finally{a(!1)}},[n,h]),C=m.useCallback(async R=>{if(!R){u(null);return}p(!0);try{const O=await(await fetch(`/api/composer-logs/${encodeURIComponent(R)}`)).json();u(O)}catch{u(null)}finally{p(!1)}},[]);m.useEffect(()=>{e&&S()},[e,S]),m.useEffect(()=>{if(!(!e||!l))return C(l),w.current=setInterval(()=>C(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,C]);const N=m.useMemo(()=>{const R=(d==null?void 0:d.events)||[],F=y.trim().toLowerCase();return R.filter(O=>{const L=nj(O.tag,O.payload);return!v[L]&&L!=="other"?!1:F?[O.tag,JSON.stringify(O.payload||"")].join(" ").toLowerCase().includes(F):!0})},[d,v,y]),I=m.useMemo(()=>{const R=(d==null?void 0:d.events)||[],F={};for(const O of R){const L=nj(O.tag,O.payload);F[L]=(F[L]||0)+1}return F},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:h,onChange:R=>g(R.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:S,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:h&&n?"no sessions for this flow":"no sessions"}),r.map(R=>{const F=l===R.sessionId;return o.jsxs("div",{onClick:()=>c(R.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:F?"rgba(124,77,255,0.18)":"transparent",borderLeft:F?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:s7(R.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:R.flowId||"(no flow)"}),R.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:R.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[n7(R.size)," · ",R.model||"default"]})]},R.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(HI).map(R=>o.jsxs("button",{type:"button",onClick:()=>k(F=>({...F,[R]:!F[R]})),style:{background:v[R]?"rgba(124,77,255,0.25)":"transparent",color:v[R]?"#e8deff":"#6a6a6a",border:`1px solid ${v[R]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[R," ",I[R]!=null?`(${I[R]})`:""]},R)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:R=>b(R.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),f&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&N.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((M=d.events)==null?void 0:M.length)||0," total)"]}),N.map((R,F)=>o.jsx(i7,{event:R,defaultExpanded:R.tag==="error"},`${R.ts}_${F}`))]})]})]})]}):null}const a7="0.1.39";function rj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Ty(e,t){return t==="running"?rj(e):e==null||!Number.isFinite(e)||e<=0?"--":rj(e)}const VI=m.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function l7(e){const{setNodes:t}=_l(),{modelLists:n,onModelChange:r}=m.useContext(VI),s=m.useCallback(d=>{t(u=>u.filter(f=>f.id!==d))},[t]),i=m.useCallback(()=>{var p,h,g,v,k,y,b,w;const d=((p=e.data)==null?void 0:p.definitionId)||"",u=((h=e.data)==null?void 0:h.label)||e.id,f=((k=(v=(g=e.data)==null?void 0:g.outputs)==null?void 0:v[0])==null?void 0:k.value)||((w=(b=(y=e.data)==null?void 0:y.outputs)==null?void 0:b[0])==null?void 0:w.default)||"";window.__provideEditContent={instanceId:e.id,label:u,definitionId:d,content:f},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),a=m.useCallback((d,u)=>{t(f=>f.map(p=>{var g;if(p.id!==d)return p;const h=Array.isArray((g=p.data)==null?void 0:g.outputs)&&p.data.outputs.length?p.data.outputs.map((v,k)=>k===0?{...v,default:u,value:u}:v):[{type:"bool",name:"value",default:u,value:u}];return{...p,data:{...p.data,body:"",outputs:h}}}))},[t]),l=m.useCallback((d,u)=>{t(f=>f.map(p=>p.id===d?{...p,data:{...p.data,body:u}}:p))},[t]),c=m.useCallback((d,u)=>{t(f=>f.map(p=>p.id===d?{...p,data:{...p.data,images:is(u)}}:p))},[t]);return o.jsx(TI,{...e,deleteNode:s,onProvideExpand:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:c,modelLists:n,onModelChange:r})}const c7={[jf]:l7},Zu=["CONTROL","TOOL","PROVIDE","AGENT"],u7=1200,sj="af-flow-node--sync-flash",ij="af-flow-edge--sync-flash";function oj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function aj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function Nv(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function d7(e){const t=Nv(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Mp(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function WI(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function UI(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Ry(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function lj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function cj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function f7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function p7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function KI(e,t,n,r,s){const i=d7(e),a={id:t,type:jf,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return nf(a,r,s)}function uj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=Xc(i,e.sourceHandle||"output-0","source"),c=Xc(a,e.targetHandle||"input-0","target");return!l||!c?!1:Gc(l,c)}function h7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Xc(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:II(a)}:null}function m7(e,t,n){var a;const r=KI(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Gc(n.slot,c):Gc(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function g7(e,t){return t?e.map((n,r)=>{const s=m7(n,e,t);if(!s)return null;const i=Nv(n);return{def:n,order:r,category:i,categoryRank:Zu.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:WI(s.hydrated.data||n),description:UI(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const y7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function x7(e){const t=new Set,n=[];let r;const s=new RegExp(y7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function dj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function vo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function $p(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(vo),d=a.map(vo);return l.map(vo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function w7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Ly(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function b7({steps:e}){const{t}=pn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
+ `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:w7(s)}):null]}):null})]},n.index)})})}function v7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function k7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
+ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function S7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function N7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function fj({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=pn(),a=m.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return m.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(pj,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(pj,{segments:t,running:n})})]})}function pj({segments:e,running:t=!1}){const{t:n}=pn(),r=e.filter(f=>f.kind==="assistant").map(f=>f.text).join(""),s=e.filter(f=>f.kind==="result").map(f=>f.text).join(""),i=v7(r,s),a=e.filter(f=>f.kind==="error").map(f=>f.text).join(`
131
+ `),l=e.filter(f=>f.kind!=="error"),c=i?l.filter(f=>f.kind!=="result"):l,d=k7(c),u=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((f,p)=>o.jsxs("section",{className:N7(f.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:S7(f.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:f.text})]},`${f.kind}-${p}`)),t&&!u?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function j7({fitViewEpoch:e}){const{fitView:t}=_l(),n=m.useRef(t);return n.current=t,m.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function C7({onReady:e}){const t=KP();return m.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function hj(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}const fh=1500,mj=500,E7=262144,_7=2e3;function Oy(e){return typeof e!="string"?"":e.length<=_7?e:`[log line truncated, ${e.length} chars]`}const P7=fh;function A7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Oy(s)}}catch{return{ts:n,type:"info",text:Oy(s)}}return{ts:n,type:"log",text:Oy(`[${r}] ${s}`)}}function gj(e){if(!e)return[];const t=[],n=e.split(`
132
+ `);for(let r=n.length-1;r>=0&&t.length<P7;r--){const s=n[r];if(!s)continue;const i=A7(s);i&&t.push(i)}return t.reverse(),t}function I7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function T7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function R7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:u,onNodeClick:f,onNodeDoubleClick:p,onEdgeClick:h,onFlowInit:g,onDrop:v,onDragOver:k,hideMinimapAndControls:y,bottomSlot:b}){const{t:w}=pn(),S=!s,C=S||t==="pan"?!0:[1,2],N=S?!1:t==="select",I="af-flow-canvas"+(S?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),M=m.useCallback(()=>{},[]),R=m.useMemo(()=>{const F=new Map(n.map($=>[$.id,$])),O=new Set(n.filter($=>$.selected).map($=>$.id)),L=O.size>0,W=($,A)=>{const B=/^#([0-9a-f]{6})$/i.exec($);if(!B)return $;const P=parseInt(B[1],16);return`rgba(${P>>16&255}, ${P>>8&255}, ${P&255}, ${A})`},D="#ff5169";return r.map($=>{var Ne,Pe,Ie,qe;const A=F.get($.source),B=F.get($.target),P=/^output-(\d+)$/.exec($.sourceHandle||""),T=/^input-(\d+)$/.exec($.targetHandle||""),E=A&&P?(Pe=(Ne=A.data)==null?void 0:Ne.outputs)==null?void 0:Pe[parseInt(P[1],10)]:null,Y=B&&T?(qe=(Ie=B.data)==null?void 0:Ie.inputs)==null?void 0:qe[parseInt(T[1],10)]:null,Q=E!=null&&E.type?On(E.type):null,U=Y!=null&&Y.type?On(Y.type):null,re=Q&&U&&Q!==U,ue=L&&(O.has($.source)||O.has($.target)),ge=$.style||{};if(re){const ct=$.selected?.95:ue?.85:.78,Ge=W(D,ct);return{...$,className:(($.className||"")+" af-flow-edge--type-mismatch"+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...ge,stroke:Ge,strokeWidth:ue?2.75:2.5,strokeDasharray:"6 4"},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:Ge}:{type:us.ArrowClosed,color:Ge}}}const le=Q||U;if(!le)return ue?{...$,className:(($.className||"")+" af-flow-edge--adjacent").trim(),style:{...ge,strokeWidth:2.5}}:$;const ce=ue||$.selected?.7:.38,de=W(le,ce),Ae=ue?2.5:ge.strokeWidth??2;return{...$,className:(($.className||"")+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...ge,stroke:de,strokeWidth:Ae},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:de}:{type:us.ArrowClosed,color:de}}})},[n,r]);return o.jsxs(UP,{className:I,nodes:n,edges:R,onNodesChange:s||M,onEdgesChange:i||M,onConnect:S?void 0:a,onConnectStart:S?void 0:l,onConnectEnd:S?void 0:c,isValidConnection:S?void 0:d,onNodesDelete:S?void 0:u,onNodeClick:f,onNodeDoubleClick:S?void 0:p,onEdgeClick:S?void 0:h,onInit:g,onDrop:S?void 0:v,onDragOver:S?void 0:k,nodeTypes:c7,selectionOnDrag:N,panOnDrag:C,nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S,edgesFocusable:!S,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(XP,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(qc,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(HB,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:F=>{var L;const O=(((L=F.data)==null?void 0:L.schemaType)??"agent").toLowerCase();return O==="control"?"rgba(237, 108, 2, 0.85)":O==="provide"?"rgba(0, 228, 117, 0.35)":O==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:b}),y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(PB,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(qc,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:F,color:O})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:O}}),o.jsx("span",{className:"af-pin-legend__label",children:F})]},F))}),o.jsx(j7,{fitViewEpoch:e}),!S&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:w("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:w("flow:emptyCanvas.composerSub")}})]}):null]})}function yj(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&t.set("flowArchived","1"),window.history.replaceState({},"","/flow?"+t.toString())}function L7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function Hs(e){return e==="builtin"||e==="admin"}function Ql(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function O7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const qI="af:run-console-height",wd=230,zu={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Dp={};function ph(e){if(!Number.isFinite(e))return wd;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function M7(){try{const e=localStorage.getItem(qI);if(e==null)return wd;const t=parseInt(e,10);return Number.isFinite(t)?ph(t):wd}catch{return wd}}function $7(){var c0,u0;const{t:e,i18n:t}=pn(),{navigate:n,path:r}=Ma(),s=m.useRef(null),i=m.useCallback(x=>{s.current=typeof x=="function"?x:null},[]),[a,l]=m.useState([]),[c,d]=m.useState(""),[u,f]=m.useState(null),[p,h]=m.useState(0),[g,v]=m.useState(""),[k,y]=m.useState(""),[b,w]=m.useState(""),[S,C]=m.useState(""),[N,I]=m.useState(!1),[M,R]=m.useState(""),[F,O]=m.useState(!1),[L,W]=m.useState(""),[D,$]=m.useState(!1),[A,B]=m.useState(!1),[P,T]=m.useState(!1),[E,Y]=m.useState(null),[Q,U]=m.useState(!1),[re,ue]=m.useState(!1),ge=m.useRef(!1),[le,ce]=m.useState([]),[de,Ae]=m.useState(""),[Ne,Pe]=m.useState("nodes"),Ie=m.useRef(null),[qe,ct]=m.useState([]),[Ge,xt]=m.useState(!1),[Fe,ee]=m.useState(""),[De,tt]=m.useState(!1),[Nt,en]=m.useState({name:"",id:"",description:""}),[fr,jr]=m.useState(!1),[ae,ve]=m.useState(""),[Xe,ot]=m.useState(""),nt=m.useRef(null),[hn,Mn]=m.useState([]),[Tn,tr]=m.useState(!1),[pr,Bt]=m.useState(""),[nr,ye]=m.useState(""),[ze,$t]=m.useState(null),[kt,Ut]=m.useState(null),[qr,$n]=m.useState([]),[Gn,rr]=m.useState(""),[Fo,so]=m.useState(!1),zo=m.useCallback(x=>{nt.current&&window.clearTimeout(nt.current),ot(x),nt.current=window.setTimeout(()=>{ot(""),nt.current=null},3800)},[]),Qs=m.useCallback(x=>{const j=String(x||"").trim();j&&window.requestAnimationFrame(()=>{var z;(z=s.current)==null||z.call(s,j)})},[]);m.useEffect(()=>()=>{nt.current&&window.clearTimeout(nt.current)},[]);const[Zs,Ni]=m.useState(!1),[Cr,hr]=m.useState({files:[]}),[io,ji]=m.useState(!1),[oo,As]=m.useState(!0);m.useEffect(()=>{let x=!1;const j=()=>{fetch("/api/flows",{method:"HEAD"}).then(K=>{x||As(K.ok)}).catch(()=>{x||As(!1)})};j();const z=window.setInterval(j,5e3);return()=>{x=!0,window.clearInterval(z)}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/dev-info").then(j=>j.json()).then(j=>{x||Ci(!!(j!=null&&j.isDev))}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{u!=null&&u.id&&YE(u.id,u.source??"user","pipeline",!!u.archived)},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[_e,Xt]=m.useState("edit"),[Bn,rt]=m.useState([]),hs=m.useRef(0),[Er,mn]=m.useState(new Set),[mr,Jt]=m.useState({}),[at,Ht]=m.useState(null),[Kt,Xn]=m.useState(0),[Me,Dn]=m.useState(!1),[Is,Ci]=m.useState(!1),[ei,Bo]=m.useState(!1),[Ts,Ei]=m.useState(M7),ti=m.useRef({active:!1,pointerId:-1,startY:0,startH:wd}),[Vt,gr]=m.useState(null),[Rs,ms]=m.useState(null),[Yr,Ls]=m.useState({}),V=m.useRef(Yr);m.useEffect(()=>{V.current=Yr},[Yr]);const[he,Se]=m.useState(!1),[Te,$e]=m.useState(!1),[Dt,wt]=m.useState({}),[Ft,Dr]=m.useState({}),[_r,ao]=m.useState(null),[gn,Da]=m.useState(zu),[gt,Os]=m.useState(!1),[Ms,cu]=m.useState(!1),[sr,_i]=m.useState(""),[Hn,Al]=m.useState(""),[Yt,uu]=m.useState(Dp),[Sn,Il]=m.useState(null),Fa=m.useRef(0),Fr=m.useRef(null),Tl=m.useRef(null),Rl=m.useRef(!0),Ho=m.useRef(!1),[Jn,lo]=m.useState(null),[Pi,za]=m.useState(null),[du,Vo]=m.useState(!1),[Ba,co]=m.useState(""),[Ll,Ha]=m.useState(!1),If=m.useRef(null),[$s,Va]=m.useState(null),[Rt,uo]=m.useState(!1),[fu,Ol]=m.useState(null),[Ml,$l]=m.useState(!1),[Ds,Ai]=m.useState(null),pu=m.useRef(null),[Gr,fo]=m.useState(""),[ni,En]=m.useState(0),[Ii,Wa]=m.useState(0),[hu,Wo]=m.useState("pan"),[Ua,Uo]=m.useState(!1),[po,Tf]=m.useState(!1),mu=m.useRef(null),gu=m.useRef(null),Fs=m.useRef(null),[lg,Ko]=m.useState(0),[ft,gs]=m.useState(null),[cg,Dl]=m.useState(""),[pt,ug]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[ho,yu]=m.useState(""),[Fl,Dv]=m.useState(""),[ri,dg]=m.useState([]),[zs,Ka]=m.useState([]),[Rf,fg]=m.useState(!1),[qa,Lf]=m.useState([]),[Of,Mf]=m.useState(!1),[Pr,pg]=m.useState(()=>new Set),[Ya,xu]=m.useState(!1),zl=m.useRef(null),wu=m.useRef(null),[_,H]=m.useState({}),X=m.useCallback(x=>{if(!x)return null;const j=x.id,z=x.source??"user",K=x.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${j}:${z}${K?":"+K:""}`,activeKey:`af:composer-active-session:${j}:${z}${K?":"+K:""}`}},[]),J=m.useCallback(x=>{if(!x)return"";const j=x.id,z=x.source??"user",K=x.archived?"archived":"";return`af:composer-skills:pipeline:${j}:${z}${K?":"+K:""}`},[]),Z=m.useCallback(x=>{const j=X(x);if(!j)return{sessions:[],activeSessionId:null};try{const z=localStorage.getItem(j.sessionsKey);if(!z)return{sessions:[],activeSessionId:null};const K=JSON.parse(z);if(!Array.isArray(K))return{sessions:[],activeSessionId:null};const q=K.filter(te=>te&&typeof te.id=="string").map(te=>({...te,running:!1,statusLine:te.running?e("flow:composer.pageRefreshReset"):te.statusLine,steps:[]}));let G=null;try{G=localStorage.getItem(j.activeKey),G&&!q.some(te=>te.id===G)&&(G=null)}catch{G=null}return{sessions:q,activeSessionId:G}}catch{return{sessions:[],activeSessionId:null}}},[X]),ie=m.useCallback((x,j,z)=>{const K=X(x);if(K)try{localStorage.setItem(K.sessionsKey,JSON.stringify(j)),z?localStorage.setItem(K.activeKey,z):localStorage.removeItem(K.activeKey)}catch{}},[X]),se=m.useRef(0),fe=m.useRef({sessions:[],activeSessionId:null,flowKey:null}),[xe,Ce]=m.useState([]),[Ke,Lt]=m.useState(null),dt=m.useMemo(()=>J(u),[J,u]),[_t,_n]=m.useState(""),yn=m.useMemo(()=>{if(!u)return null;const x=u.id,j=u.source??"user",z=u.archived?"archived":"";return`${x}:${j}${z?":"+z:""}`},[u]),ir=m.useRef(!1);m.useEffect(()=>{if(!yn){Ce([]),Lt(null),fe.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=fe.current;if(x.flowKey===yn)return;x.flowKey=yn,ir.current&&x.sessions.length>0&&ie(u,x.sessions,x.activeSessionId);const{sessions:j,activeSessionId:z}=Z(u);if(j.length===0){const K=`session-1-${Date.now()}`,q={id:K,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};x.sessions=[q],x.activeSessionId=K,Ce([q]),Lt(K)}else{const K=j[j.length-1];if(K&&(!K.thread||K.thread.length===0))se.current=Ly(j),x.sessions=j,x.activeSessionId=K.id,Ce(j),Lt(K.id);else{const G=Ly(j)+1;se.current=G;const te=`session-${G}-${Date.now()}`,ne={id:te,label:e("flow:composer.conversationLabel",{n:G}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},pe=[...j,ne];x.sessions=pe,x.activeSessionId=te,Ce(pe),Lt(te)}}ir.current=!0},[yn,u,Z,ie]);const Ye=m.useMemo(()=>xe.find(x=>x.id===Ke)||null,[xe,Ke]),Qe=(Ye==null?void 0:Ye.running)??!1,jt=(Ye==null?void 0:Ye.statusLine)??"",Qt=(Ye==null?void 0:Ye.segments)??[],or=(Ye==null?void 0:Ye.thread)??[],me=(Ye==null?void 0:Ye.steps)??[];Ye==null||Ye.outputDismissed;const be=(Ye==null?void 0:Ye.phaseContext)??null,Ze=m.useRef([]),[st,Le]=m.useState(!1),Pt=m.useRef(null),ln=m.useRef(null);m.useEffect(()=>{const x=ln.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[or,Qt]);const Ct=m.useRef(null),St=m.useRef(!1),Gt=m.useRef(null),tn=m.useCallback(x=>{const j=++se.current,z=`session-${j}-${Date.now()}`,K={id:z,label:x||e("flow:composer.conversationLabel",{n:j}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Ce(q=>[...q,K]),Lt(z),z},[]);m.useEffect(()=>{!u||!ir.current||(fe.current.sessions=xe,fe.current.activeSessionId=Ke,ie(u,xe,Ke))},[xe,Ke,u,ie]),m.useEffect(()=>{se.current=Math.max(se.current,Ly(xe))},[xe]);const yr=m.useCallback(x=>{var j;Ct.current===x&&((j=Pt.current)==null||j.abort()),Ce(z=>{const K=z.filter(G=>G.id!==x);if(z.some((G,te)=>G.id===x&&z.findIndex(ne=>ne.id===Ke)===te)||Ke===x){const G=K;G.length>0?Lt(G[G.length-1].id):setTimeout(()=>{se.current=0;const te=++se.current,ne=`session-${te}-${Date.now()}`,pe={id:ne,label:e("flow:composer.conversationLabel",{n:te}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Ce(we=>[...we,pe]),Lt(ne)},0)}return K})},[Ke]),Vn=m.useCallback(x=>{Ce(j=>{const z=j.findIndex(G=>G.id===Ke);if(z<0)return j;const K={...j[z]};x(K);const q=[...j];return q[z]=K,q})},[Ke]),mo=m.useCallback(x=>{Vn(j=>{j.running=x})},[Vn]),Ar=m.useCallback(x=>{Vn(j=>{j.statusLine=x})},[Vn]),ar=m.useCallback(x=>{Vn(j=>{typeof x=="function"?j.segments=x(j.segments):j.segments=x})},[Vn]),$f=m.useCallback(x=>{Vn(j=>{typeof x=="function"?j.thread=x(j.thread):j.thread=x})},[Vn]),Ga=m.useCallback(x=>{Vn(j=>{typeof x=="function"?j.steps=x(j.steps):j.steps=x})},[Vn]),Fv=m.useCallback(x=>{Vn(j=>{j.outputDismissed=x})},[Vn]),bu=m.useCallback(x=>{Vn(j=>{j.phaseContext=typeof x=="function"?x(j.phaseContext):x})},[Vn]),zv=m.useCallback(x=>{Lt(x),Ce(j=>{const z=j.findIndex(q=>q.id===x);if(z<0||!j[z].outputDismissed)return j;const K=[...j];return K[z]={...j[z],outputDismissed:!1},K})},[]);m.useEffect(()=>{Ze.current=Qt},[Qt]);const xr=m.useRef({}),Bv=m.useRef(!1),Xa=m.useRef(null),qo=m.useRef(null),Bl=m.useRef(!1),hg=m.useRef(0),Df=m.useRef(""),[It,yt,BT]=qP([]),[xn,nn,HT]=YP([]),Ti=m.useRef(It),Hl=m.useRef(xn),Hv=m.useRef(null),mg=m.useRef(null),Vv=m.useRef(null),Ff=m.useRef(null),[Xr,go]=m.useState(null),VT=m.useCallback(x=>{var j;xr.current=(j=x==null?void 0:x.extra)!=null&&j.instances&&typeof x.extra.instances=="object"?x.extra.instances:{},yt(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),nn(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),go(null)},[nn,yt]),WT=m.useMemo(()=>({instances:xr.current}),[xn,It]),{resetHistory:Wv,undo:Uv,redo:Kv}=AI({nodes:It,edges:xn,extra:WT,enabled:!!u&&Bl.current&&_e==="edit",onRestore:VT}),si=m.useMemo(()=>It.filter(x=>{var j;return(((j=x.data)==null?void 0:j.definitionId)||"").startsWith("provide_")}),[It]),Vl=m.useMemo(()=>{var j;const x={};for(const z of It){if(!((j=z.data)!=null&&j.inputs))continue;const K=z.data.inputs;for(let q=0;q<K.length;q++){const G=K[q];if(!(G!=null&&G.name))continue;const te=xn.find(pe=>pe.target===z.id&&pe.targetHandle===`input-${q}`);if(!(te!=null&&te.source))continue;si.find(pe=>pe.id===te.source)&&(x[te.source]=G.name)}}return x},[It,xn,si]),vu=m.useMemo(()=>{if(_e==="edit"||Er.size===0)return null;const x=new Set(Er);for(const j of xn)Er.has(j.source)&&x.add(j.target),Er.has(j.target)&&x.add(j.source);return x},[_e,Er,xn]),UT=m.useMemo(()=>_e==="edit"?It:It.map(x=>{var j,z;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:Er.has(x.id),nodeStatus:((j=mr[x.id])==null?void 0:j.status)??null,nodeElapsed:((z=mr[x.id])==null?void 0:z.elapsed)??null,isDim:vu?!vu.has(x.id):!1}}}),[_e,It,Er,mr,vu]),KT=m.useMemo(()=>vu?xn.map(x=>{const j=Er.has(x.source)||Er.has(x.target),z=x.className?x.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",K=j?"af-flow-edge--focus":"af-flow-edge--dim";return{...x,className:(z?z+" ":"")+K}}):xn,[xn,Er,vu]);m.useEffect(()=>{if(!u){Dr({}),ao(null),Da(zu),uu(Dp),Il(null),_i(""),Al("");return}const x=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&x.set("archived","1"),fetch(`/api/flow/run-config?${x.toString()}`).then(j=>j.json()).then(j=>{Dr(j.presets||{}),ao(j.activePreset||null)}).catch(()=>{Dr({}),ao(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const Yo=m.useCallback(x=>{Fa.current+=1,Da(x)},[]),Go=m.useCallback(async(x,j={})=>{if(!x)return;const z=!!j.quiet,K=!!j.force,q=Fa.current;z||(Os(!0),_i(""),Al(""));const G=new URLSearchParams({flowId:x.id,flowSource:x.source||"user"});x.archived&&G.set("archived","1");try{const te=await fetch(`/api/flow/schedule?${G.toString()}`),ne=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ne.error||`HTTP ${te.status}`);if(!K&&Fa.current!==q)return;Da({...zu,...ne.schedule||{}}),uu(ne.state&&typeof ne.state=="object"?ne.state:Dp),Il(ne.status||null)}catch(te){if(!K&&Fa.current!==q)return;Da(zu),uu(Dp),Il(null),_i(String(te.message||te))}finally{Os(!1)}},[]);m.useEffect(()=>{if(!u)return;let x=!1;return(async()=>{await Go(u)})(),()=>{x=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Go]),m.useEffect(()=>{var z,K,q,G;if(!_r||!Ft[_r]||si.length===0)return;const x=Ft[_r],j={};for(const te of si){const ne=Vl[te.id];if(!ne)continue;const pe=((z=te.data)==null?void 0:z.definitionId)||"",we=x[te.id]??((G=(q=(K=te.data)==null?void 0:K.outputs)==null?void 0:q[0])==null?void 0:G.default)??"";pe.startsWith("provide_file")?j[ne]={type:"file",path:we}:j[ne]={type:"str",value:we}}Object.keys(j).length>0&&Ls(j)},[_r,Ft,si,Vl]);const qT=m.useCallback(()=>{if(!Ds||!pu.current)return;const x=pu.current.value;yt(j=>j.map(z=>{var K,q;return z.id!==Ds.instanceId?z:{...z,data:{...z.data,outputs:((q=(K=z.data)==null?void 0:K.outputs)==null?void 0:q.map((G,te)=>te===0?{...G,default:x}:G))||[{type:"text",name:"value",default:x}]}}})),Ai(null)},[Ds,yt]),it=m.useMemo(()=>{const x=It.filter(j=>j.selected);return x.length===1?x[0]:null},[It]),Ri=m.useMemo(()=>u?oU(It,xn,e):[],[u,It,xn,e]),YT=m.useMemo(()=>Ri.map(x=>x.key).join("|"),[Ri]),qv=m.useMemo(()=>Ri.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[Ri]);m.useLayoutEffect(()=>{U(Ri.length>0&&!qv)},[YT,u==null?void 0:u.id,u==null?void 0:u.source,Ri.length,qv]),Fs.current=it,m.useEffect(()=>{Ti.current=It},[It]),m.useEffect(()=>{Hl.current=xn},[xn]),m.useEffect(()=>{Vv.current=Xr},[Xr]),m.useEffect(()=>{if(!Xr)return;const x=z=>{z.key==="Escape"&&go(null)},j=z=>{var K,q;(q=(K=z.target)==null?void 0:K.closest)!=null&&q.call(K,".af-connect-node-menu")||go(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",j)}},[Xr]),m.useEffect(()=>()=>{qo.current!=null&&(clearTimeout(qo.current),qo.current=null)},[]);const gg=m.useMemo(()=>{var j;if(!it)return null;const x=(j=it.data)==null?void 0:j.definitionId;return le.find(z=>z.id===x)??null},[it,le]),yg=m.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const j of le){const z=Nv(j);x[z].push(j)}for(const j of Zu)x[j].sort((z,K)=>z.id.localeCompare(K.id));return x},[le]),zf=m.useMemo(()=>{const x=de.trim().toLowerCase();if(!x)return yg;const j={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const z of Zu)j[z]=yg[z].filter(K=>p7(K,x));return j},[yg,de]),GT=m.useMemo(()=>Zu.reduce((x,j)=>x+zf[j].length,0),[zf]),Bf=m.useMemo(()=>le.filter(x=>{const j=String(x.id??""),z=String(x.source??"");return j.startsWith("marketplace:")||z==="marketplace"||z==="collection"}),[le]),Yv=m.useMemo(()=>{const x=new Set;for(const j of Bf){const z=String(j.id??"");if(z&&(x.add(z),z.startsWith("marketplace:"))){const K=z.slice(12),[q]=K.split("@");q&&x.add(`marketplace:${q}`)}}return x},[Bf]),Hf=m.useCallback(async()=>{d("");try{const x=await fetch("/api/flows");if(!x.ok)throw new Error("HTTP "+x.status);l(await x.json())}catch(x){d(String(x.message||x))}},[]);m.useEffect(()=>{Hf()},[Hf]),m.useEffect(()=>{if(r!=="/flow")return;const x=new URLSearchParams(window.location.search);x.get("new")==="1"&&!x.get("flowId")&&n("/projects?new=1")},[r,n]),m.useEffect(()=>{let x=!1;const j=()=>{fetch("/api/model-lists").then(K=>K.json()).then(K=>{x||ug({cursor:Array.isArray(K.cursor)?K.cursor.map(String):[],opencode:Array.isArray(K.opencode)?K.opencode.map(String):[],claudeCode:Array.isArray(K.claudeCode)?K.claudeCode.map(String):[]})}).catch(()=>{})};j();const z=setTimeout(j,4e3);return()=>{x=!0,clearTimeout(z)}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/skills").then(j=>j.json()).then(j=>{if(x)return;const z=Array.isArray(j.skills)?j.skills.filter(K=>K&&typeof K.key=="string"&&K.key.trim()).map(K=>({key:String(K.key),name:String(K.name||K.id||K.key),description:K.description?String(K.description):"",sourceLabel:K.sourceLabel?String(K.sourceLabel):""})):[];dg(z),fg(!0)}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(j=>j.json()).then(j=>{x||(Lf(va(j)),Mf(!0))}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{if(_n(""),!(!Rf||!Of)){if(!dt){Ka([]);return}Ka(QE(dt,"pipeline",ri,qa)),_n(dt)}},[qa,Of,ri,Rf,dt]),m.useEffect(()=>{if(!(_t!==dt||!dt))try{localStorage.setItem(dt,JSON.stringify(zs))}catch{}},[zs,dt,_t]);const Gv=m.useCallback(async x=>{const j=x.source??"user",z=!!x.archived,K=new URLSearchParams({flowId:x.id,flowSource:j});z&&K.set("archived","1");const q=new URLSearchParams({flowId:x.id,flowSource:j});z&&q.set("archived","1"),q.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[G,te]=await Promise.all([fetch("/api/flow?"+K.toString()),fetch("/api/nodes?"+q.toString())]),ne=await G.json();if(!G.ok||ne.error)throw new Error(ne.error||e("flow:nodePropsError.loadFlowFailed"));const pe=await te.json();if(!te.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const we=Array.isArray(pe)?pe:Array.isArray(pe==null?void 0:pe.nodes)?pe.nodes:[],Oe=!Array.isArray(pe)&&(pe==null?void 0:pe.pipelineTranslations)||{},oe=rU(ne.flowYaml||"");if(oe.error)throw new Error(oe.error);const Re={...oe.instances||{}},ke=oe.nodes.map(rn=>nf(rn,Re,we,Oe,x.id)),lt=PI(oe.edges,ke);return{flowSource:j,paletteList:we,instances:Re,flowDescriptionText:oe.description??"",nodes:ke,edges:lt}},[t.language,e]),Bs=m.useCallback(async(x,j={})=>{const z=!!j.preserveComposer,K=z&&!!j.incrementalSync;Bl.current=!1,hg.current+=1,f(x),y(""),z||(w(""),Ae(""),Ut(null),v(""),R(""),W(""),fo(""),$f([]),ar([]),Ga([]),Fv(!1),bu(null),Wo("pan")),K||(xr.current={},yt([]),nn([])),yj(x);try{const q=await Gv(x);if(ce(q.paletteList),xr.current=q.instances,v(q.flowDescriptionText),R(x.id||""),K){const G=Ti.current,te=Hl.current;try{const ne=L9(G,te,q.nodes,q.edges),pe=new Set([...ne.changes.addedNodeIds,...ne.changes.updatedNodeIds]),we=new Set([...ne.changes.addedEdgeKeys,...ne.changes.updatedEdgeKeys]),Oe=pe.size>0?ne.nodes.map(Re=>pe.has(Re.id)?{...Re,className:oj(Re.className,sj)}:Re):ne.nodes,oe=we.size>0?ne.edges.map(Re=>we.has(Jd(Re))?{...Re,className:oj(Re.className,ij)}:Re):ne.edges;yt(Oe),nn(oe),qo.current!=null&&(clearTimeout(qo.current),qo.current=null),(pe.size>0||we.size>0)&&(qo.current=window.setTimeout(()=>{qo.current=null,pe.size>0&&yt(Re=>Re.map(ke=>{if(!pe.has(ke.id))return ke;const lt=aj(ke.className,sj);return lt===String(ke.className||"")?ke:{...ke,className:lt}})),we.size>0&&nn(Re=>Re.map(ke=>{if(!we.has(Jd(ke)))return ke;const lt=aj(ke.className,ij);return lt===String(ke.className||"")?ke:{...ke,className:lt}}))},u7))}catch{yt(q.nodes),nn(q.edges)}}else yt(q.nodes),nn(q.edges),h(G=>G+1);xp(x.id,q.flowSource),Ko(G=>G+1),Wv(q.nodes,q.edges,{instances:q.instances});try{Df.current=BN(q.nodes,q.edges,q.instances,{description:q.flowDescriptionText})}catch{Df.current=""}Bl.current=!0}catch(q){y(String(q.message||q))}},[Gv,Wv,yt,nn]),Vf=m.useCallback(async()=>{if(!(u!=null&&u.id))return;const x=u.source??"user",j=new URLSearchParams({flowId:u.id,flowSource:x});u.archived&&j.set("archived","1"),j.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const z=await fetch("/api/nodes?"+j.toString()),K=await z.json();if(!z.ok)throw new Error((K==null?void 0:K.error)||e("flow:nodePropsError.loadNodesFailed"));const q=Array.isArray(K)?K:Array.isArray(K==null?void 0:K.nodes)?K.nodes:[];ce(q)},[u,e,t.language]),xg=m.useCallback(async()=>{tr(!0),Bt("");try{const x=await fetch("/api/marketplace/nodes"),j=await x.json().catch(()=>({}));if(!x.ok)throw new Error((j==null?void 0:j.error)||"Failed to load marketplace nodes");Mn(Array.isArray(j==null?void 0:j.nodes)?j.nodes:[])}catch(x){Bt(String(x.message||x)),Mn([])}finally{tr(!1)}},[]),Wf=m.useCallback(async()=>{xt(!0),ee("");try{const x=await fetch("/api/marketplace/flow-snippets"),j=await x.json().catch(()=>({}));if(!x.ok)throw new Error((j==null?void 0:j.error)||"Failed to load flow snippets");ct(Array.isArray(j==null?void 0:j.snippets)?j.snippets:[])}catch(x){ee(String(x.message||x)),ct([])}finally{xt(!1)}},[]);m.useEffect(()=>{u&&(xg(),Wf())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,xg,Wf]);const XT=m.useCallback(async x=>{if(!u||!x)return;const j=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(j){ye(j),Bt("");try{const z=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,nodeSpec:j})}),K=await z.json().catch(()=>({}));if(!z.ok||(K==null?void 0:K.ok)===!1)throw new Error((K==null?void 0:K.error)||"Failed to install marketplace node");await Vf()}catch(z){Bt(String(z.message||z))}finally{ye("")}}},[u,Vf]),JT=m.useCallback(async(x,j)=>{const z={packageId:(x==null?void 0:x.newId)||(x==null?void 0:x.id)||(x==null?void 0:x.label),label:(x==null?void 0:x.label)||(x==null?void 0:x.newId)||(x==null?void 0:x.id),version:"1.0.0",definitionId:j,body:(x==null?void 0:x.body)||"",script:(x==null?void 0:x.script)||"",inputs:Array.isArray(x==null?void 0:x.inputs)?x.inputs:[],outputs:Array.isArray(x==null?void 0:x.outputs)?x.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},K=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),q=await K.json();if(!K.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Publish failed");return await Vf(),q},[Vf,u]),Xv=m.useCallback(async()=>{var K;if(!u||ge.current)return;const x=u.id,j=u.source??"user",z=((K=Fs.current)==null?void 0:K.id)??null;ge.current=!0,ue(!0);try{await Bs({id:x,source:j,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),z&&yt(q=>q.map(G=>({...G,selected:G.id===z})))}finally{ge.current=!1,ue(!1)}},[u,u==null?void 0:u.archived,Bs,yt]);m.useEffect(()=>{if(Bv.current||a.length===0)return;const x=new URLSearchParams(window.location.search),j=x.get("flowId");if(!j)return;const z=x.get("flowSource")??"user",K=x.get("flowArchived")==="1",q=a.find(G=>G.id===j&&(G.source??"user")===z&&!!G.archived===K);q&&(Bv.current=!0,Bs(q))},[a,Bs]);const Uf=m.useRef(0);m.useEffect(()=>{if(!u)return;const x=u.id,j=u.source??"user",z=!!u.archived;Uf.current=0;let K=!1;const q=async()=>{var ne;if(K)return;const te=new URLSearchParams({flowId:x,flowSource:j,v:String(Uf.current)});z&&te.set("archived","1");try{const pe=await fetch("/api/flow-editor-sync-poll?"+te.toString());if(!pe.ok||K)return;const we=await pe.json();if(K)return;if(we.changed){Uf.current=we.version;const Oe=((ne=Fs.current)==null?void 0:ne.id)??null;await Bs({id:x,source:j,archived:z},{preserveComposer:!0,incrementalSync:!0}),await Go({id:x,source:j,archived:z},{quiet:!0,force:!0}),Oe&&yt(oe=>oe.map(Re=>({...Re,selected:Re.id===Oe})))}else Uf.current=we.version}catch{}},G=window.setInterval(q,2e3);return q(),()=>{K=!0,window.clearInterval(G)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Bs,Go,yt]);const QT=m.useMemo(()=>b?b.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":b===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[b]);m.useEffect(()=>{if(!b)return;b===e("flow:status.saved")||b.startsWith(e("flow:status.runInTerminal"));const x=b.startsWith(e("flow:status.runInTerminal"))?5200:2800,j=window.setTimeout(()=>w(""),x);return()=>clearTimeout(j)},[b,e]),m.useEffect(()=>{C("")},[u==null?void 0:u.id,u==null?void 0:u.source]),m.useEffect(()=>{const x=()=>{window.__provideEditContent&&(Ai(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),m.useEffect(()=>{var ne,pe,we,Oe,oe,Re,ke;if(!it){gs(null);return}const x=xr.current[it.id]||{},{inputs:j,outputs:z}=_I(it),K=String(((ne=it.data)==null?void 0:ne.definitionId)??it.id??""),q=((pe=it.data)==null?void 0:pe.script)!=null?String(it.data.script):void 0,G=x.script!=null?String(x.script):void 0,te=K==="tool_nodejs"||q&&q.trim()!==""||G&&G.trim()!==""?String(q??G??""):"";gs({id:it.id,newId:it.id,label:String(((we=it.data)==null?void 0:we.label)??it.id),role:((Oe=it.data)==null?void 0:Oe.role)??"普通",model:String(((oe=it.data)==null?void 0:oe.model)??x.model??""),body:String(((Re=it.data)==null?void 0:Re.body)??x.body??""),images:is(((ke=it.data)==null?void 0:ke.images)??x.images),script:te,inputs:j,outputs:z})},[it==null?void 0:it.id,lg]),m.useEffect(()=>{u&&(it||(gu.current=null,Ut(x=>x==="node"?null:x)))},[u,it==null?void 0:it.id]);const Kf=m.useCallback(()=>{gu.current=null,Ut(x=>x==="settings"||x==="history"?x:"node")},[]),ZT=m.useCallback((x,j)=>{x.metaKey||x.ctrlKey||x.shiftKey||_e!=="edit"&&ms((j==null?void 0:j.id)??null)},[_e]),e2=m.useCallback((x,j)=>{_e==="edit"&&(x.preventDefault(),yt(z=>z.map(K=>({...K,selected:K.id===j.id}))),nn(z=>z.map(K=>({...K,selected:!1}))),Kf())},[Kf,_e,nn,yt]),t2=m.useCallback((x,j)=>{if(_e!=="edit")return;const z=x.metaKey||x.ctrlKey||x.shiftKey;nn(K=>K.map(q=>q.id===j.id?{...q,selected:!q.selected||!z}:z?q:{...q,selected:!1})),z||yt(K=>K.map(q=>({...q,selected:!1})))},[_e,nn,yt]),n2=m.useCallback(x=>uj(x,Ti.current),[]),r2=m.useCallback(x=>{if(!uj(x,Ti.current)){w("端口类型不匹配,已取消连线");return}go(null),yt(j=>am(j,x)),nn(j=>{const z=j.filter(K=>!(K.target===x.target&&K.targetHandle===x.targetHandle));return Yd({...x,markerEnd:{type:us.ArrowClosed}},z)})},[nn,yt]),s2=m.useCallback((x,j)=>{mg.current=h7(j,Ti.current),go(null)},[]),i2=m.useCallback((x,j)=>{var ke,lt,rn,sn;const z=mg.current;if(mg.current=null,!u||!z||j!=null&&j.toNode)return;const K=g7(le,z);if(K.length===0){w(`没有匹配 ${z.slotType} 端口的节点`);return}const q=((lt=(ke=x==null?void 0:x.changedTouches)==null?void 0:ke[0])==null?void 0:lt.clientX)??(x==null?void 0:x.clientX),G=((sn=(rn=x==null?void 0:x.changedTouches)==null?void 0:rn[0])==null?void 0:sn.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(q)||!Number.isFinite(G))return;const te=Xa.current,ne=document.querySelector(".af-pipeline-flow .react-flow");if(!te||!ne)return;const pe=ne.getBoundingClientRect(),we=320,Oe=Math.min(440,104+K.length*58),oe=Math.max(12,Math.min(q-pe.left,pe.width-we-12)),Re=Math.max(12,Math.min(G-pe.top,pe.height-Oe-12));go({left:oe,top:Re,flowPosition:te.screenToFlowPosition({x:q,y:G}),draft:z,candidates:K,query:""})},[le,u]),o2=m.useCallback(x=>{for(const j of x)delete xr.current[j.id]},[]),a2=m.useCallback(x=>{Xa.current=x},[]),l2=m.useCallback(x=>{yt(z=>z.map(K=>({...K,selected:K.id===x}))),nn(z=>z.map(K=>({...K,selected:!1}))),Kf();const j=()=>{var pe,we,Oe;const z=Xa.current;if(!(z!=null&&z.getNode))return;const K=z.getNode(x);if(!K)return;const q=(pe=z.getInternalNode)==null?void 0:pe.call(z,x),G=((we=q==null?void 0:q.measured)==null?void 0:we.width)??(q==null?void 0:q.width)??K.width??200,te=((Oe=q==null?void 0:q.measured)==null?void 0:Oe.height)??(q==null?void 0:q.height)??K.height??88,{zoom:ne}=z.getViewport();z.setCenter(K.position.x+G/2,K.position.y+te/2,{zoom:hj(ne),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(j))},[yt,nn,Kf]),c2=m.useCallback(x=>{yt(z=>z.map(K=>({...K,selected:K.id===x}))),nn(z=>z.map(K=>({...K,selected:!1})));const j=()=>{var we,Oe,oe;const z=Xa.current;if(!(z!=null&&z.getNode))return;const K=z.getNode(x);if(!K)return;const q=(we=z.getInternalNode)==null?void 0:we.call(z,x),G=((Oe=q==null?void 0:q.measured)==null?void 0:Oe.width)??(q==null?void 0:q.width)??K.width??200,te=((oe=q==null?void 0:q.measured)==null?void 0:oe.height)??(q==null?void 0:q.height)??K.height??88,{zoom:ne}=z.getViewport(),pe=hj(ne);z.setCenter(K.position.x+G/2,K.position.y+te/2,{zoom:pe,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(j))},[yt,nn]),Wl=m.useCallback((x,j)=>{const z=`node-${Date.now()}`;return KI(x,z,j,xr.current,le)},[le]),Jv=m.useCallback(x=>{if(!u||!x)return;let j={x:180,y:160};const z=Xa.current,K=document.querySelector(".af-pipeline-flow .react-flow");if(z&&K){const q=K.getBoundingClientRect();j=z.screenToFlowPosition({x:q.left+q.width*.45,y:q.top+q.height*.38})}yt(q=>[...q,Wl(x,j)])},[u,yt,Wl]),u2=m.useCallback(x=>{const j=Vv.current;if(!u||!j||!(x!=null&&x.def))return;const z=Wl(x.def,j.flowPosition),K=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:z.id,targetHandle:`input-${x.slotIndex}`}:{source:z.id,sourceHandle:`output-${x.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};yt(q=>am([...q,z],K)),nn(q=>{const G=q.filter(te=>!(te.target===K.target&&te.targetHandle===K.targetHandle));return Yd({...K,markerEnd:{type:us.ArrowClosed}},G)}),go(null)},[u,Wl,yt,nn]),d2=m.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),f2=m.useCallback(x=>{var te;if(x.preventDefault(),!u)return;const j=Xa.current;if(!j)return;const z=j.screenToFlowPosition({x:x.clientX,y:x.clientY}),K=x.dataTransfer.getData("application/agentflow-snippet");if(K){const ne=qe.find(pe=>`${pe.id}@${pe.version}`===K);ne&&((te=Ff.current)==null||te.call(Ff,ne,z));return}const q=x.dataTransfer.getData("application/agentflow-node");if(!q)return;const G=le.find(ne=>ne.id===q);G&&yt(ne=>[...ne,Wl(G,z)])},[u,le,qe,yt,Wl]),Li=m.useCallback(async(x,j)=>{if(!u)return;const z=BN(x,j,xr.current,{description:g});if(z!==Df.current){w(e("flow:status.saving"));try{const K=L7(u.source),q=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:K,flowYaml:z,...u.archived?{flowArchived:!0}:{}})}),G=await q.json();if(!q.ok||!G.success)throw new Error(G.error||e("flow:status.saveFailed"));if(Df.current=z,w(e("flow:status.saved")),Hs(u.source)&&K==="workspace"){const te={id:u.id,source:"workspace",path:void 0};f(te),yj(te),xp(u.id,"workspace")}}catch(K){w(e("flow:status.saveFailed")+": "+(K.message||K))}}},[u,g]);m.useEffect(()=>{if(!u||!Bl.current||_e!=="edit"||u.archived)return;const x=hg.current,j=setTimeout(()=>{x===hg.current&&Bl.current&&Li(Ti.current,Hl.current)},400);return()=>clearTimeout(j)},[It,xn,g,_e,u,Li]);const qf=m.useCallback(async x=>{if(!u||u.archived)return;const j=u.source??"user";if(!(j!=="user"&&j!=="workspace")&&j!==x){I(!0),C("");try{const z=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:j,toSource:x})}),K=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof K.error=="string"?K.error:e("flow:composer.requestFailed"));const q=K.flowSource==="workspace"||K.flowSource==="user"?K.flowSource:x;let G={id:u.id,source:q,archived:u.archived};try{const te=await fetch("/api/flows");if(te.ok){const ne=await te.json(),pe=Array.isArray(ne)?ne.find(we=>we.id===u.id&&(we.source??"user")===q&&!!we.archived==!!u.archived):null;pe&&(G=pe)}}catch{}await Bs(G,{preserveComposer:!0}),xp(u.id,q)}catch(z){C(String(z.message||z))}finally{I(!1)}}},[u,Bs]),wg=m.useCallback(async()=>{if(u){cu(!0),_i(""),Al("");try{const x=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,schedule:gn})}),j=await x.json().catch(()=>({}));if(!x.ok||!j.success)throw new Error(j.error||"Failed to save schedule");Da({...zu,...j.schedule||{}}),Al(e("flow:schedule.saved")),await Go(u,{quiet:!0,force:!0})}catch(x){_i(String(x.message||x))}finally{cu(!1)}}},[u,gn,Go,e]),p2=m.useCallback(async()=>{u&&(await Li(Ti.current,Hl.current),!u.archived&&u.source!=="builtin"&&await wg())},[u,Li,wg]),Yf=m.useCallback(async()=>{if(!u||!M.trim())return;const x=M.trim();if(x===u.id){W("");return}O(!0),W("");try{const j=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:x})}),z=await j.json().catch(()=>({}));if(!j.ok)throw new Error(typeof z.error=="string"?z.error:e("flow:composer.requestFailed"));let K={id:z.flowId,source:z.flowSource??u.source,archived:u.archived};try{const q=await fetch("/api/flows");if(q.ok){const G=await q.json(),te=Array.isArray(G)?G.find(ne=>ne.id===z.flowId&&(ne.source??"user")===(z.flowSource??u.source)):null;te&&(K=te)}}catch{}await Bs(K,{preserveComposer:!0}),xp(z.flowId,z.flowSource??u.source)}catch(j){W(String(j.message||j))}finally{O(!1)}},[u,M,Bs]),Qv=m.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{$(!0),setTimeout(()=>$(!1),2e3)}).catch(()=>{})},[]),bg=m.useCallback(()=>{Li(It,xn)},[Li,It,xn]),h2=m.useCallback((x,j)=>{const z=j.trim()===""||j==="default"?void 0:j.trim(),K=It.map(q=>q.id===x?{...q,data:{...q.data,model:z}}:q);yt(K),Li(K,xn)},[It,xn,yt,Li]),Gf=m.useCallback(()=>{var lt,rn;if(!ft||!u||!it)return!1;const x=it.id,j=ft.newId.trim();if(Dl(""),!DI.test(j))return Dl(e("flow:nodePropsError.invalidInstanceId")),!1;if(It.some(sn=>sn.id===j&&sn.id!==x))return Dl(e("flow:nodePropsError.duplicateInstanceId")),!1;const z=ft.role.trim(),K=Pa.includes(z)?z:"普通",q=ft.model.trim(),G=sn=>(Array.isArray(sn)?sn:[]).map(Ot=>({type:String((Ot==null?void 0:Ot.type)??"节点").trim()||"节点",name:String((Ot==null?void 0:Ot.name)??""),default:String((Ot==null?void 0:Ot.default)??""),required:!!(Ot!=null&&Ot.required),showOnNode:(Ot==null?void 0:Ot.showOnNode)!=null?Ot.showOnNode!==!1:!!(Ot!=null&&Ot.required)||String((Ot==null?void 0:Ot.type)??"节点").trim().toLowerCase()==="node"})),te=G(ft.inputs),ne=G(ft.outputs),pe=String(((lt=it.data)==null?void 0:lt.definitionId)??j),we=pe.startsWith("provide_"),Oe={...it.data,label:ft.label.trim()||j,role:K,model:q===""||q==="default"?void 0:q,body:we?"":ft.body,images:we?[]:is(ft.images),inputs:te,outputs:we&&Array.isArray((rn=it.data)==null?void 0:rn.outputs)?it.data.outputs:ne},oe=String(ft.script??"").trim();pe==="tool_nodejs"||oe!==""?Oe.script=String(ft.script??""):delete Oe.script;let Re,ke=xn;if(j!==x){const sn={...xr.current},Ot={...sn[x]||{}};delete sn[x],sn[j]=Ot,xr.current=sn,Re=It.map(ht=>ht.id!==x?ht:{...ht,id:j,selected:!0,data:Oe}),ke=xn.map((ht,Wt)=>({...ht,source:ht.source===x?j:ht.source,target:ht.target===x?j:ht.target,id:`e-${ht.source===x?j:ht.source}-${ht.target===x?j:ht.target}-${Wt}`}))}else Re=It.map(sn=>sn.id===x?{...sn,data:Oe}:sn);return yt(Re),nn(ke),Qs(j),Li(Re,ke),!0},[ft,u,it,It,xn,yt,nn,Qs,Li]),vg=m.useCallback(()=>{var rn,sn;if(!ft||!u||!it)return!1;const x=it.id,j=ft.role.trim(),z=Pa.includes(j)?j:"普通",K=ft.model.trim(),q=Ot=>(Array.isArray(Ot)?Ot:[]).map(ht=>({type:String((ht==null?void 0:ht.type)??"节点").trim()||"节点",name:String((ht==null?void 0:ht.name)??""),default:String((ht==null?void 0:ht.default)??""),required:!!(ht!=null&&ht.required),showOnNode:(ht==null?void 0:ht.showOnNode)!=null?ht.showOnNode!==!1:!!(ht!=null&&ht.required)||String((ht==null?void 0:ht.type)??"节点").trim().toLowerCase()==="node"})),G=q(ft.inputs),te=q(ft.outputs),ne=String(((rn=it.data)==null?void 0:rn.definitionId)??x),pe=ne.startsWith("provide_"),we=ft.label.trim()||x,Oe=K===""||K==="default"?void 0:K,oe={...it.data,label:we,role:z,model:Oe,body:pe?"":ft.body,images:pe?[]:is(ft.images),inputs:G,outputs:pe&&Array.isArray((sn=it.data)==null?void 0:sn.outputs)?it.data.outputs:te},Re=String(ft.script??"").trim();ne==="tool_nodejs"||Re!==""?oe.script=String(ft.script??""):delete oe.script;const ke=it.data||{};return(ke.label!==oe.label||ke.role!==oe.role||ke.model!==oe.model||ke.body!==oe.body||JSON.stringify(is(ke.images))!==JSON.stringify(oe.images)||(ke.script??void 0)!==(oe.script??void 0)||JSON.stringify(ke.inputs||[])!==JSON.stringify(G)||JSON.stringify(ke.outputs||[])!==JSON.stringify(te))&&(yt(Ot=>Ot.map(ht=>ht.id===x?{...ht,data:oe}:ht)),Qs(x)),!0},[ft,u,it,yt,Qs]),Zv=m.useRef(vg);m.useEffect(()=>{Zv.current=vg},[vg]),m.useEffect(()=>{if(!ft||!u||!Bl.current||_e!=="edit")return;const x=setTimeout(()=>{Zv.current()},400);return()=>clearTimeout(x)},[ft,u,_e]);const m2=m.useCallback(()=>{if(!(!ft||!it)){if(ft.newId.trim()===it.id){Dl("");return}Gf()}},[ft,it,Gf]);m.useEffect(()=>{const x=j=>{var te,ne,pe;if(_e!=="edit")return;const z=RI(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){if(kt==="node"&&it&&ft){j.preventDefault(),j.stopPropagation(),Gf()||bg();return}if(z)return;j.preventDefault(),j.stopPropagation(),bg();return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),Tf(we=>!we);return}if(po)return;if(Ua){if(j.key==="Escape"){j.preventDefault(),Uo(!1);return}if(cm(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Uo(!1);return}(j.key==="v"||j.key==="V"||j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&j.preventDefault();return}if(z)return;const K=j.key.toLowerCase(),q=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&K==="z",G=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&K==="z"||K==="y");if(q||G){j.preventDefault(),j.stopPropagation();const we=q?Uv():Kv();w(we?q?"Undo canvas change":"Redo canvas change":q?"Nothing to undo":"Nothing to redo");return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="c"){const we=NI(Ti.current,Hl.current,xr.current);we&&(j.preventDefault(),j.stopPropagation(),Hv.current=we,w(`Copied ${we.nodes.length} node${we.nodes.length>1?"s":""}`));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="v"){const we=jI(Hv.current,Ti.current,Hl.current,xr.current);we&&(j.preventDefault(),j.stopPropagation(),xr.current=we.instances,yt(we.nodes),nn(we.edges),w(`Pasted ${we.pastedNodeIds.length} node${we.pastedNodeIds.length>1?"s":""}`));return}if((j.key==="a"||j.key==="A")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),j.stopPropagation(),(te=Ie.current)==null||te.focus(),(pe=(ne=Ie.current)==null?void 0:ne.select)==null||pe.call(ne);return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="a"){j.preventDefault(),j.stopPropagation(),yt(we=>we.map(Oe=>({...Oe,selected:!0}))),nn(we=>we.map(Oe=>({...Oe,selected:!1})));return}if(cm(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Uo(we=>!we);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Wo("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Wo("pan");return}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[bg,Ua,po,kt,it,ft,Gf,_e,Uv,Kv]),m.useEffect(()=>{if(_e!=="running"||at==null)return;let x=Math.floor((Date.now()-at)/1e3);const j=setInterval(()=>{const z=Date.now()-at,K=Math.floor(z/1e3);K!==x&&(x=K,Xn(z))},500);return()=>clearInterval(j)},[_e,at]),m.useEffect(()=>{const x=Tl.current;!x||!x.parentElement||Rl.current&&(Ho.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ho.current=!1}))},[Bn]),m.useEffect(()=>{const x=Tl.current;if(!x)return;const j=x.parentElement;if(!j)return;const z=()=>{if(Ho.current)return;const K=j.scrollHeight-j.scrollTop-j.clientHeight;Rl.current=K<40};return j.addEventListener("scroll",z,{passive:!0}),()=>j.removeEventListener("scroll",z)},[Me,_e]),m.useEffect(()=>{if(_e==="edit"||!Me)return;Rl.current=!0;const x=Tl.current;x&&(Ho.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ho.current=!1}))},[_e,Me]),m.useEffect(()=>{Bn.length>fh+mj&&rt(x=>x.length>fh+mj?x.slice(-fh):x)},[Bn]);const g2=m.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const j=x.currentTarget;ti.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:Ts},j.setPointerCapture(x.pointerId)},[Ts]),y2=m.useCallback(x=>{const j=ti.current;if(!j.active||x.pointerId!==j.pointerId)return;const z=j.startY-x.clientY;Ei(ph(j.startH+z))},[]),Xf=m.useCallback(()=>{Ei(x=>{const j=ph(x);try{localStorage.setItem(qI,String(j))}catch{}return j})},[]),e0=m.useCallback(x=>{const j=ti.current;if(!(!j.active||x.pointerId!==j.pointerId)){j.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}Xf()}},[Xf]),x2=m.useCallback(()=>{const x=ti.current;x.active&&(x.active=!1,Xf())},[Xf]);m.useEffect(()=>{function x(){Ei(j=>ph(j))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const Oi=m.useCallback(async(x={})=>{if(!u)return;const j=x.runUuid!=null&&String(x.runUuid).trim()?String(x.runUuid).trim():null,z=x.cliInputsOverride??V.current,K=!!x.prepareOnly;if(Xt(K?"ready":"running"),rt(K?[]:[{ts:new Date().toISOString(),type:"info",text:j?e("flow:run.connectingApiResume",{uuid:j}):e("flow:run.connectingApi")}]),mn(new Set),Jt({}),Dn(!K),Ut(null),j||gr(null),K)return;if(!j){const G=Date.now();Ht(G),Xn(0)}const q=new AbortController;Fr.current=q;try{const G=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",...j?{uuid:j}:{},cliInputs:z}),signal:q.signal});if(!G.ok){const oe=await G.json().catch(()=>({error:e("flow:composer.requestFailed")}));rt(Re=>[...Re,{ts:new Date().toISOString(),type:"error",text:oe.error||e("flow:composer.requestFailed")}]),Xt("error");return}if(rt(oe=>[...oe,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!G.body){rt(oe=>[...oe,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),Xt("error");return}const te=G.body.getReader(),ne=new TextDecoder;let pe="";const we=oe=>{const Re=oe.ts||new Date().toISOString();if(oe.type==="event")if(oe.event==="node-start")mn(ke=>new Set(ke).add(oe.instanceId)),Jt(ke=>({...ke,[oe.instanceId]:{status:"running",startMs:Date.now()}})),rt(ke=>[...ke,{ts:Re,type:"node-start",text:oe.label?e("flow:run.nodeStartWithLabel",{instanceId:oe.instanceId,label:oe.label}):e("flow:run.nodeStart",{instanceId:oe.instanceId})}]);else if(oe.event==="node-done"){mn(lt=>{const rn=new Set(lt);return rn.delete(oe.instanceId),rn});const ke=oe.elapsed??null;Jt(lt=>({...lt,[oe.instanceId]:{status:"success",elapsed:ke}})),rt(lt=>[...lt,{ts:Re,type:"node-done",text:ke?e("flow:run.nodeDoneWithElapsed",{instanceId:oe.instanceId,elapsed:ke}):e("flow:run.nodeDone",{instanceId:oe.instanceId})}])}else if(oe.event==="node-failed")mn(ke=>{const lt=new Set(ke);return lt.delete(oe.instanceId),lt}),Jt(ke=>({...ke,[oe.instanceId]:{status:"failed",elapsed:oe.elapsed??null}})),rt(ke=>[...ke,{ts:Re,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:oe.instanceId})}]);else if(oe.event==="apply-start"){if(oe.uuid&&gr(String(oe.uuid)),typeof oe.runStartTime=="number"&&oe.runStartTime>0)Ht(oe.runStartTime),Xn(Math.max(0,Date.now()-oe.runStartTime));else if(typeof oe.totalExecutedMs=="number"&&oe.totalExecutedMs>0){const ke=Date.now()-oe.totalExecutedMs;Ht(ke),Xn(oe.totalExecutedMs)}rt(ke=>[...ke,{ts:Re,type:"info",text:e("flow:run.pipelineStart",{uuid:oe.uuid||"?"})}])}else oe.event==="apply-done"?rt(ke=>[...ke,{ts:Re,type:"info",text:oe.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:oe.totalElapsed}):e("flow:run.pipelineDone")}]):oe.event==="apply-paused"?rt(ke=>[...ke,{ts:Re,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(oe.pendingNodes||[]).join(", ")})}]):rt(ke=>[...ke,{ts:Re,type:"event",text:`[${oe.event}] ${JSON.stringify(oe)}`}]);else oe.type==="user-check-content"?(lo({instanceId:oe.instanceId,execId:oe.execId??1,inputPath:oe.inputPath,outputPath:oe.outputPath,content:oe.content||""}),za(oe.content||""),Vo(!1),co(""),Ha(!1),rt(ke=>[...ke,{ts:Re,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:oe.instanceId})}])):oe.type==="user-ask-prompt"?(Va({instanceId:oe.instanceId,execId:oe.execId??1,question:oe.question||"",options:Array.isArray(oe.options)?oe.options:[]}),uo(!1),rt(ke=>[...ke,{ts:Re,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:oe.instanceId,defaultValue:`等待用户选择 (${oe.instanceId})`})}])):oe.type==="tool-print-content"?(Ol({instanceId:oe.instanceId,execId:oe.execId??1,content:oe.content||"",createdAt:Date.now()}),$l(!1)):oe.type==="log"?rt(ke=>[...ke,{ts:Re,type:"log",text:oe.text!=null?String(oe.text):""}]):oe.type==="error"?rt(ke=>[...ke,{ts:Re,type:"error",text:oe.message||e("flow:run.unknownError")}]):oe.type==="done"?rt(ke=>[...ke,{ts:Re,type:"done",text:e("flow:run.executionEnd",{exitCode:oe.exitCode??"?"})}]):rt(ke=>[...ke,{ts:Re,type:"log",text:JSON.stringify(oe)}])},Oe=oe=>{if(oe.trim())try{we(JSON.parse(oe))}catch{rt(Re=>[...Re,{ts:new Date().toISOString(),type:"log",text:oe}])}};for(;;){const{done:oe,value:Re}=await te.read();pe+=ne.decode(Re??new Uint8Array,{stream:!oe});const ke=pe.split(`
133
+ `);pe=ke.pop()??"";for(const lt of ke)Oe(lt);if(oe)break}pe.trim()&&Oe(pe),Xt("done")}catch(G){G.name==="AbortError"?(rt(te=>[...te,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),Xt("stopped")):(rt(te=>[...te,{ts:new Date().toISOString(),type:"error",text:G.message||e("flow:run.unknownError")}]),Xt("error"))}finally{Fr.current=null,mn(new Set)}},[u]),[w2,kg]=m.useState(!1),b2=m.useCallback(()=>{kg(!0)},[]),v2=m.useCallback(async()=>{if(kg(!1),Fr.current&&(Fr.current.abort(),Fr.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Xt("stopped"),mn(new Set)},[u]),Ja=m.useCallback(()=>{Xt("edit"),mn(new Set),Jt({}),ms(null),gr(null)},[]),[k2,Jf]=m.useState(!1),S2=m.useCallback(async()=>{if(Jf(!1),Fr.current&&(Fr.current.abort(),Fr.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Ja()},[u,Ja]),N2=m.useCallback(()=>{Jf(!1),n("/projects")},[n]),j2=m.useCallback(x=>{const j=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,z=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;gr(j);const K=x.status||"unknown";let q="stopped";K==="success"?q="done":K==="failed"?q="error":K==="running"?q="running":q="stopped",Xt(q);const G=typeof x.at=="number"?x.at:null;if(q==="running"&&G!=null?(Ht(G),Xn(Math.max(0,Date.now()-G))):G!=null&&typeof x.endedAt=="number"&&x.endedAt>G?(Ht(null),Xn(x.endedAt-G)):(Ht(null),Xn(Math.max(0,x.durationMs??0))),rt([]),mn(new Set),Jt({}),ms(null),Ut(null),Dn(!1),j&&z){const te=new URLSearchParams({flowId:z,runId:j});fetch(`/api/run-node-statuses?${te}`).then(ne=>ne.json()).then(ne=>{const pe=ne.statuses&&typeof ne.statuses=="object"?ne.statuses:{},we={};for(const[Oe,oe]of Object.entries(pe))oe&&typeof oe=="object"&&typeof oe.status=="string"&&(we[Oe]={status:oe.status,...oe.elapsed!=null&&String(oe.elapsed).trim()!==""?{elapsed:String(oe.elapsed)}:{}});Jt(we)}).catch(()=>{})}},[u==null?void 0:u.id]);m.useEffect(()=>{if(!(u!=null&&u.id)||_e!=="edit")return;let x=!1;return(async()=>{try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(x||!j.ok)return;const q=(Array.isArray(z.runs)?z.runs:[]).find(ne=>ne.flowId===u.id&&ne.status==="running");if(!q||x)return;const G=q.runId||null;gr(G),Xt("running"),Dn(!0),Ht(q.at||Date.now()),hs.current=0;const te=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${G},已恢复运行视图`}];if(G){const ne=new URLSearchParams({flowId:u.id,runId:G}),we=await(await fetch(`/api/run-node-statuses?${ne}`)).json();if(x)return;const Oe=we.statuses&&typeof we.statuses=="object"?we.statuses:{},oe={},Re=new Set;for(const[ke,lt]of Object.entries(Oe))lt&&typeof lt=="object"&&typeof lt.status=="string"&&(oe[ke]={status:lt.status,...lt.elapsed!=null&&String(lt.elapsed).trim()!==""?{elapsed:String(lt.elapsed)}:{}},lt.status==="running"&&Re.add(ke));Jt(oe),mn(Re);try{const ke=new URLSearchParams({flowId:u.id,runId:G,sinceBytes:"0",tailBytes:"262144"}),lt=await fetch(`/api/run-log?${ke}`);if(lt.ok){const rn=await lt.json();if(!x){hs.current=Number(rn.bytes||0);const sn=gj(typeof rn.text=="string"?rn.text:"");rt([...sn,...te]);return}}}catch{}}rt(te)}catch{}})(),()=>{x=!0}},[u==null?void 0:u.id]),m.useEffect(()=>{if(_e==="edit"||!(u!=null&&u.id)||!Vt)return;let x=!1,j=null;const z=async()=>{try{const K=new URLSearchParams({flowId:u.id,runId:Vt}),q=await fetch(`/api/run-node-statuses?${K}`);if(!q.ok)return;const G=await q.json();if(x)return;const te=G.statuses&&typeof G.statuses=="object"?G.statuses:{},ne={},pe=new Set;for(const[we,Oe]of Object.entries(te))Oe&&typeof Oe=="object"&&typeof Oe.status=="string"&&(ne[we]={status:Oe.status,...Oe.elapsed!=null&&String(Oe.elapsed).trim()!==""?{elapsed:String(Oe.elapsed)}:{}},Oe.status==="running"&&pe.add(we));Jt(we=>I7(we,ne)?we:ne),mn(we=>T7(we,pe)?we:pe);try{const we=new URLSearchParams({flowId:u.id,runId:Vt,sinceBytes:String(hs.current||0),tailBytes:String(E7)}),Oe=await fetch(`/api/run-log?${we}`);if(Oe.ok){const oe=await Oe.json();if(x)return;const Re=Number(oe.bytes||0),ke=typeof oe.text=="string"?oe.text:"";if(ke){const lt=gj(ke);lt.length>0&&rt(rn=>[...rn,...lt])}hs.current=Re}}catch{}try{const we=await fetch("/api/pipeline-recent-runs");if(!we.ok)return;const Oe=await we.json();if(x)return;const Re=(Array.isArray(Oe.runs)?Oe.runs:[]).find(ke=>ke.flowId===u.id&&ke.runId===Vt);if(Re&&Re.status){const ke=Re.status;ke==="running"?Xt(lt=>lt==="running"?lt:"running"):ke==="success"?Xt("done"):ke==="failed"?Xt("error"):(ke==="stopped"||ke==="interrupted")&&Xt("stopped")}}catch{}}catch{}};return z(),j=window.setInterval(z,2500),()=>{x=!0,j&&window.clearInterval(j)}},[_e,u==null?void 0:u.id,Vt]),m.useEffect(()=>{if(kt!=="history"||!u)return;let x=!1;return(async()=>{so(!0),rr("");try{const j=await fetch("/api/pipeline-recent-runs"),z=await j.json();if(!j.ok)throw new Error(z.error||"HTTP "+j.status);x||$n(Array.isArray(z.runs)?z.runs:[])}catch(j){x||(rr(String(j.message||j)),$n([]))}finally{x||so(!1)}})(),()=>{x=!0}},[kt,u]),m.useEffect(()=>{if(!u){hr({files:[]});return}let x=!1;return(async()=>{ji(!0);try{const j=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),z=await fetch(`/api/pipeline-files?${j}`),K=await z.json();if(!z.ok)throw new Error(K.error||"HTTP "+z.status);x||hr({files:Array.isArray(K.files)?K.files:[],path:K.path,error:K.error})}catch(j){x||hr({files:[],error:j.message||String(j)})}finally{x||ji(!1)}})(),()=>{x=!0}},[u]);const ku=m.useMemo(()=>u?qr.filter(x=>x&&x.flowId===u.id).sort((x,j)=>j.at-x.at):[],[qr,u]),zr=m.useMemo(()=>{let x=0,j=0,z=0,K=0,q=0;for(const G of ku){const te=G.status||"unknown";te==="success"?x+=1:te==="failed"?j+=1:te==="running"?z+=1:te==="stopped"?K+=1:te==="interrupted"&&(q+=1)}return{success:x,failed:j,running:z,stopped:K,interrupted:q}},[ku]),Su=m.useMemo(()=>u?dj(Gr,ni):null,[u,Gr,ni]),ii=m.useMemo(()=>{if(!Su||!u)return[];const x=Su.query.toLowerCase(),j=q=>x?q.some(G=>G&&String(G).toLowerCase().includes(x)):!0,z=It.map(q=>{var we,Oe;const G=q.id,te=String(((we=q.data)==null?void 0:we.label)??G),ne=(Oe=q.data)!=null&&Oe.definitionId?String(q.data.definitionId):"",pe=[te!==G?te:"",ne&&ne!==G?ne:""].filter(Boolean);return{id:G,label:te,defId:ne,subs:pe}}).filter(({id:q,label:G,defId:te})=>j([q,G,te])).sort((q,G)=>q.id.localeCompare(G.id)).slice(0,18).map(({id:q,label:G,defId:te})=>{const ne=[G!==q?G:null,te||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:q,title:q,subtitle:ne}}),K=le.filter(q=>q&&q.id&&j([q.id,q.label,q.description])).sort((q,G)=>q.id.localeCompare(G.id)).slice(0,22).map(q=>({kind:"definition",id:q.id,title:q.id,subtitle:q.label&&q.label!==q.id?String(q.label):String(q.type||"")}));return[...z,...K]},[Su,It,le,u]),Nu=m.useMemo(()=>{const x=ii.filter(z=>z.kind==="instance"),j=ii.filter(z=>z.kind==="definition");return{instances:x,definitions:j}},[ii]);m.useEffect(()=>{Wa(x=>{const j=Math.max(0,ii.length-1);return Math.min(Math.max(0,x),j)})},[ii]);const t0=m.useMemo(()=>x7(Gr),[Gr]),wr=m.useMemo(()=>It.filter(x=>x.selected),[It]),Sg=m.useMemo(()=>new Set(wr.map(x=>x.id)),[wr]),Qf=m.useMemo(()=>xn.filter(x=>Sg.has(x.source)&&Sg.has(x.target)),[xn,Sg]),n0=m.useMemo(()=>{const x=de.trim().toLowerCase();return x?qe.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(z=>String(z).toLowerCase().includes(x))):qe},[qe,de]),r0=m.useCallback((x,j)=>{const z=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",K=Date.now().toString(36);let q=`${z}-${K}`,G=2;for(;j.has(q);)q=`${z}-${K}-${G}`,G+=1;return j.add(q),q},[]),s0=m.useCallback((x,j)=>{var Wt,Br;if(!u||!x)return;const z=x.snippet&&typeof x.snippet=="object"?x.snippet:{},K=z.instances&&typeof z.instances=="object"?z.instances:{},q=Object.keys(K);if(q.length===0)return;const G=new Set(Ti.current.map(Ve=>Ve.id)),te={};for(const Ve of q)te[Ve]=r0(Ve,G);const ne=(Wt=z.ui)!=null&&Wt.nodePositions&&typeof z.ui.nodePositions=="object"?z.ui.nodePositions:{},pe=(Br=z.ui)!=null&&Br.nodeSizes&&typeof z.ui.nodeSizes=="object"?z.ui.nodeSizes:{},we=q.map(Ve=>{const on=ne[Ve];return{id:Ve,x:typeof(on==null?void 0:on.x)=="number"?on.x:0,y:typeof(on==null?void 0:on.y)=="number"?on.y:0}}),Oe=Math.min(...we.map(Ve=>Ve.x)),oe=Math.min(...we.map(Ve=>Ve.y));let Re=j||{x:180,y:160};const ke=Xa.current,lt=document.querySelector(".af-pipeline-flow .react-flow");if(!j&&ke&&lt){const Ve=lt.getBoundingClientRect();Re=ke.screenToFlowPosition({x:Ve.left+Ve.width*.48,y:Ve.top+Ve.height*.32})}const rn={};for(const Ve of q)rn[te[Ve]]={...K[Ve]||{}};xr.current={...xr.current,...rn};const sn=q.map(Ve=>{const on=K[Ve]||{},Mi=we.find(Cu=>Cu.id===Ve)||{x:0,y:0},oi=pe[Ve]&&typeof pe[Ve].width=="number"&&typeof pe[Ve].height=="number"?{width:pe[Ve].width,height:pe[Ve].height}:null,Za={id:te[Ve],type:"flowNode",selected:!0,position:{x:Re.x+(Mi.x-Oe),y:Re.y+(Mi.y-oe)},...oi?{width:oi.width,height:oi.height}:{},data:{label:on.label||te[Ve],definitionId:on.definitionId||Ve,role:on.role||"normal",body:on.body||"",script:on.script||"",...oi?{displaySize:oi}:{}}};return nf(Za,xr.current,le,{},u.id)}),Ot=new Set(q),ht=(Array.isArray(z.edges)?z.edges:[]).filter(Ve=>Ot.has(Ve==null?void 0:Ve.source)&&Ot.has(Ve==null?void 0:Ve.target)).map((Ve,on)=>({id:`e-${te[Ve.source]}-${te[Ve.target]}-${Date.now()}-${on}`,source:te[Ve.source],target:te[Ve.target],sourceHandle:Ve.sourceHandle??void 0,targetHandle:Ve.targetHandle??void 0,markerEnd:{type:us.ArrowClosed}}));yt(Ve=>[...Ve.map(on=>({...on,selected:!1})),...sn]),nn(Ve=>[...Ve.map(on=>({...on,selected:!1})),...ht]),w(`已添加流程片段:${x.displayName||x.id}`)},[r0,le,u,nn,yt]);Ff.current=s0;const C2=m.useCallback(()=>{var z,K;if(wr.length<2){ee("请先在画布上选择至少两个节点。"),Pe("flows");return}const x=wr[0],j=wr.length===2?`${((z=x.data)==null?void 0:z.label)||x.id} 片段`:`${((K=x.data)==null?void 0:K.label)||x.id} 等 ${wr.length} 个节点`;en({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ve(""),tt(!0),Pe("flows")},[wr]),E2=m.useCallback(async()=>{var G,te;if(!u||wr.length<2)return;const x=Nt.name.trim();if(!x){ve("请填写片段名称。");return}const j=Nf(wr,xr.current),z={},K={};for(const ne of wr){z[ne.id]={x:((G=ne.position)==null?void 0:G.x)||0,y:((te=ne.position)==null?void 0:te.y)||0};const pe=O7(ne);pe&&(K[ne.id]=pe)}const q=Qf.map(ne=>({source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle??null,targetHandle:ne.targetHandle??null}));jr(!0),ve("");try{const ne=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Nt.id,name:x,displayName:x,version:"1.0.0",description:Nt.description,snippet:{instances:j,edges:q,ui:{nodePositions:z,nodeSizes:K}}})}),pe=await ne.json().catch(()=>({}));if(!ne.ok||(pe==null?void 0:pe.ok)===!1)throw new Error((pe==null?void 0:pe.error)||"Publish failed");tt(!1),w(`流程片段已发布:${pe.id||x}`),zo(`流程片段已发布:${pe.id||x}`),await Wf(),Pe("flows")}catch(ne){ve(String(ne.message||ne))}finally{jr(!1)}},[u,wr,Qf,Nt,Wf,zo]),Zf=m.useMemo(()=>{const x=[],j=new Set;for(const q of wr)j.add(q.id),x.push({node:q,kind:"canvas"});const z=new Map(It.map(q=>[q.id,q])),K=new Map(le.map(q=>[q.id,q]));for(const q of t0){if(j.has(q))continue;const G=z.get(q);if(G){j.add(q),x.push({node:G,kind:"mention"});continue}const te=K.get(q);te&&(j.add(q),x.push({definition:te,kind:"definition"}))}return x},[wr,t0,It,le]),Jr=m.useMemo(()=>{const x=Array.isArray(pt==null?void 0:pt.cursor)?pt.cursor:[],j=Array.isArray(pt==null?void 0:pt.opencode)?pt.opencode:[],z=Array.isArray(pt==null?void 0:pt.claudeCode)?pt.claudeCode:[],K=j.map(we=>`opencode:${vo(we)}`),q=z.map(we=>`claude-code:${vo(we)}`),G=new Set([...x,...j,...z].map(vo).concat(K).concat(q)),te=(ho||"").trim(),ne=$p(ho,x,j,z),pe=ne&&!G.has(ne)&&!G.has(te)?te:"";return{cursorList:x,opencodeList:j,claudeCodeList:z,currentNotInLists:pe}},[pt,ho]),Ng=m.useMemo(()=>new Set(zs),[zs]),jg=zs.length,ep=m.useMemo(()=>{const x=new Map(ri.map(G=>[G.key,G])),j=new Set,z=new Set,K=qa.map(G=>{const te=Ea(G,ri).map(ne=>x.get(ne)).filter(Boolean);for(const ne of te)j.add(ne.key),z.add(String(ne.name||ne.id||ne.key||"").trim());return{...G,skills:te}}).filter(G=>G.skills.length>0),q=ri.filter(G=>{const te=String(G.name||G.id||G.key||"").trim();return!j.has(G.key)&&!z.has(te)});return{groups:K,ungrouped:q}},[qa,ri]),Ul=m.useCallback(()=>{const x=zl.current;if(!x)return;const j=x.getBoundingClientRect(),z=Math.min(400,Math.max(300,window.innerWidth-24)),K=Math.min(Math.max(12,j.right-z),window.innerWidth-z-12),q=Math.max(140,j.top-22),G=Math.min(360,q);H({position:"fixed",left:`${K}px`,top:`${Math.max(12,j.top-G-10)}px`,width:`${z}px`,maxHeight:`${G}px`})},[]);m.useEffect(()=>{const x=Array.isArray(pt==null?void 0:pt.cursor)?pt.cursor:[],j=Array.isArray(pt==null?void 0:pt.opencode)?pt.opencode:[],z=Array.isArray(pt==null?void 0:pt.claudeCode)?pt.claudeCode:[];yu(K=>{const q=$p(K,x,j,z);return q===K?K:q})},[pt.cursor,pt.opencode,pt.claudeCode]),m.useEffect(()=>{if(!Ya)return;Ul();const x=z=>{var q,G;const K=z.target;(q=zl.current)!=null&&q.contains(K)||(G=wu.current)!=null&&G.contains(K)||xu(!1)},j=z=>{z.key==="Escape"&&xu(!1)};return window.addEventListener("resize",Ul),window.addEventListener("scroll",Ul,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",j),()=>{window.removeEventListener("resize",Ul),window.removeEventListener("scroll",Ul,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",j)}},[Ya,Ul]);const Qa=m.useCallback(async(x,j={})=>{var ht;if(!u||St.current)return;const z=j.phaseContextSnapshot,K=(typeof x=="string"?x:Gr).trim();if(!K)return;const q=Ze.current;St.current=!0,mo(!0),Ar(e("flow:composer.connecting")),Ut(Wt=>Wt!=="composer"?"composer":Wt);const G=[...or];if(q.length>0&&G.push({type:"assistant",segments:[...q]}),$f([...G,{type:"user",text:K}]),G.filter(Wt=>Wt.type==="user").length===0){const Wt=K.replace(/\s+/g," ").slice(0,30)+(K.length>30?"…":"");Ce(Br=>Br.map(Ve=>Ve.id===Ke?{...Ve,label:Wt}:Ve))}const te=G.map(Wt=>Wt.type==="user"?{role:"user",text:Wt.text}:{role:"assistant",text:(Wt.segments||[]).filter(Ve=>Ve.kind==="assistant"||Ve.kind==="result").map(Ve=>Ve.text).join(`
134
+ `)}).filter(Wt=>Wt.text),ne=z??be;fo(""),ar([]),Ga([]),Fv(!1);const pe=new AbortController;Pt.current=pe,Ct.current=Ke;let we=null;const Oe=Array.isArray(pt==null?void 0:pt.cursor)?pt.cursor:[],oe=Array.isArray(pt==null?void 0:pt.opencode)?pt.opencode:[],Re=Array.isArray(pt==null?void 0:pt.claudeCode)?pt.claudeCode:[],ke=$p(ho,Oe,oe,Re),lt=Zf.filter(Wt=>Wt.kind!=="definition"&&Wt.node).map(Wt=>Wt.node.id),rn=u;let sn=!1,Ot=!1;try{we=setTimeout(()=>pe.abort(),12e4);const Wt={prompt:K,model:ke,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:lt,thread:te,selectedSkills:zs};ne&&ne.nextPhase&&!ne.isLastPhase&&(Wt.phaseContext={phaseIndex:ne.nextPhase.index,phases:ne.phases,userPromptOriginal:ne.userPromptOriginal||K}),Fl&&(Wt.phaseRole=Fl);const Br=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Wt),signal:pe.signal});if(we&&(clearTimeout(we),we=null),!Br.ok){let oi=Br.statusText||e("flow:composer.requestFailed");try{const Za=await Br.json();Za&&Za.error&&(oi=String(Za.error))}catch{}Ar(oi),ar([{kind:"error",text:oi}]);return}const Ve=(ht=Br.body)==null?void 0:ht.getReader();if(!Ve){Ar(e("flow:composer.cannotReadStream"));return}const on=new TextDecoder;let Mi="";for(;;){const{done:oi,value:Za}=await Ve.read();if(oi)break;for(Mi+=on.decode(Za,{stream:!0});;){const Cu=Mi.indexOf(`
135
+ `);if(Cu<0)break;const d0=Mi.slice(0,Cu).trim();if(Mi=Mi.slice(Cu+1),!d0)continue;let We;try{We=JSON.parse(d0)}catch{continue}if(We.type==="status"&&typeof We.line=="string"&&Ar(We.line),We.type==="natural"&&typeof We.text=="string"&&We.text){const cn=typeof We.kind=="string"&&We.kind?We.kind:"assistant";ar(an=>[...an,{kind:cn,text:We.text}])}if(We.type==="error"&&We.message){Ot=!0;const cn=We.code?` [${We.code}]`:"",an=String(We.message)+cn;Ar(an),ar(Qr=>[...Qr,{kind:"error",text:an}])}if(We.type==="plan"&&Array.isArray(We.steps)){Ga(We.steps.map(an=>({...an,status:"pending"})));const cn=We.steps.map((an,Qr)=>`${Qr+1}. ${an.description||an.type}`).join(`
136
+ `);ar(an=>[...an,{kind:"assistant",text:e("flow:composer.taskPlan",{count:We.steps.length,summary:cn})}])}if(We.type==="step-start"){const cn=We.index??0,an=We.total??0,Qr=We.tier?` [${We.tier}]`:"",R2=We.model?` (${We.model})`:"";Ar(e("flow:composer.step",{current:cn+1,total:an,description:(We.description||"")+Qr+R2})),Ga(L2=>L2.map(Kl=>Kl.index===cn?{...Kl,status:"running",model:We.model,tier:We.tier,nodeRole:We.nodeRole??Kl.nodeRole,instanceId:We.instanceId??Kl.instanceId,instanceLabel:We.instanceLabel??Kl.instanceLabel}:Kl))}if(We.type==="step-progress"){const cn=We.index??0,an=We.total??0;Ar(e("flow:composer.step",{current:cn+1,total:an,description:We.description||""}))}if(We.type==="step-done"){const cn=We.index??0;Ga(an=>an.map(Qr=>Qr.index===cn?{...Qr,status:We.success?"done":"error"}:Qr))}if(We.type==="phase-plan"&&Array.isArray(We.phases)){bu(an=>({...an||{},phases:We.phases,currentPhase:We.currentPhase??0,phaseTotal:We.phaseTotal??We.phases.length,phaseName:We.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(an==null?void 0:an.userPromptOriginal)||K}));const cn=We.phases.map((an,Qr)=>`${Qr+1}. ${an.label}`).join(" → ");ar(an=>[...an,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:We.phases.length,labels:cn,current:We.phaseName||""})}])}We.type==="phase-complete"&&(bu(cn=>{var Qr;return{...cn||{},phases:We.phases||(cn==null?void 0:cn.phases)||[],currentPhase:We.phaseIndex??0,phaseTotal:We.phaseTotal??((Qr=We.phases)==null?void 0:Qr.length)??0,phaseName:We.phaseName||"",isLastPhase:!!We.isLastPhase,nextPhase:We.nextPhase||null,userPromptOriginal:We.userPromptOriginal||(cn==null?void 0:cn.userPromptOriginal)||K}}),!We.isLastPhase&&We.nextPhase&&ar(cn=>[...cn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:We.phaseName||e("flow:composer.nextPhase"),nextPhase:We.nextPhase.label})}])),We.type==="done"&&(sn=!0,Ar(cn=>cn||e("flow:composer.done")))}}}catch(Wt){const Br=Wt;if(Br.name==="AbortError"){const Ve=e(we?"flow:composer.connectTimeout":"flow:composer.aborted");Ar(Ve),ar(on=>[...on,{kind:"error",text:Ve}])}else{const Ve=Br.code||Br.name||"UNKNOWN",on=`${Br.message||String(Wt)} [${Ve}]`;Ar(on),ar(Mi=>[...Mi,{kind:"error",text:on}])}}finally{if(St.current=!1,mo(!1),Pt.current=null,Ct.current=null,we&&clearTimeout(we),sn&&rn){const Wt={id:rn.id,source:rn.source??"user",archived:rn.archived};(async()=>(await Bs(Wt,{preserveComposer:!0,incrementalSync:!0}),await Go(Wt,{quiet:!0,force:!0})))()}}},[u,Gr,ho,pt,Zf,Bs,Go,or,Ke,be,Fl,zs]);Gt.current=Qa;const i0=m.useCallback(()=>{!be||be.isLastPhase||(bu(null),Qa(e("flow:composer.skipRemainingPhases")))},[be,Qa]),o0=m.useCallback(()=>{if(!be||be.isLastPhase||!be.nextPhase)return;const x=String(be.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Qa(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:be})},[be,Qa]);m.useEffect(()=>{if(!st)return;const x=j=>{j.key==="Escape"&&Le(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[st]),m.useEffect(()=>{_e!=="edit"&&Le(!1)},[_e]),m.useLayoutEffect(()=>{const x=mu.current;if(!x)return;if(!u){x.style.height="";return}x.style.height="0px";const j=getComputedStyle(x),z=parseFloat(j.lineHeight),K=(parseFloat(j.paddingTop)||0)+(parseFloat(j.paddingBottom)||0),q=Number.isFinite(z)&&z>0?z:13*1.45,G=K+q*2,te=K+q*10,ne=Math.min(Math.max(x.scrollHeight,G),te);x.style.height=`${ne}px`},[Gr,u]);const Cg=m.useCallback(x=>{const j=Gr,z=ni,K=dj(j,z);if(!K)return;const q=j.slice(0,K.atIndex)+`@${x} `+j.slice(z);fo(q);const G=K.atIndex+x.length+2;queueMicrotask(()=>{const te=mu.current;te&&(te.focus(),te.setSelectionRange(G,G)),En(G)})},[Gr,ni]),Eg=m.useCallback(x=>{fo(j=>{const z=`@${x}`,K=j.indexOf(z);return K<0?j:j.slice(0,K)+j.slice(K+z.length)})},[]),a0=m.useCallback(x=>{x.kind==="canvas"?yt(j=>j.map(z=>z.id===x.node.id?{...z,selected:!1}:z)):x.kind==="mention"?Eg(x.node.id):Eg(x.definition.id)},[yt,Eg]),_2=m.useCallback(()=>{Ut(x=>x==="history"?null:"history")},[]),P2=m.useCallback(()=>{Ut(x=>x==="settings"?null:"settings")},[]),A2=m.useCallback(()=>{Ut(x=>x==="composer"?null:"composer")},[]),ju=m.useCallback(()=>{Ut(x=>(x==="node"&&Fs.current&&(gu.current=Fs.current.id),null))},[]),l0=m.useCallback(()=>{Uo(x=>!x)},[]),I2=()=>{if(!u)return null;const x=Ms||u.archived||Hs(u.source),j=Sn!=null&&Sn.running?e("flow:schedule.running"):gn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),z=Sn!=null&&Sn.running?"running":gn.enabled?"waiting":"disabled",K=hn.slice(0,12),q=u.archived||Hs(u.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:ju,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:G=>{R(G.target.value),W("")},onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Yf())},onBlur:()=>{M.trim()&&M.trim()!==u.id&&Yf()},placeholder:u.id,disabled:F,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Ql(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Ql(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),L?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:L}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),u.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:g,onChange:G=>v(G.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>Qv(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:D?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:N,onClick:()=>qf("workspace"),children:e(N?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:N,onClick:()=>qf("user"),children:e(N?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),S?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:S}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[hn.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:xg,disabled:Tn,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(Tn?"common:common.loading":"common:common.refresh")]})]}),pr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:pr}):null,Tn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):K.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:K.map(G=>{const te=G.definitionId||`marketplace:${G.id}${G.version?`@${G.version}`:""}`,ne=Yv.has(te)||Yv.has(`marketplace:${G.id}`),pe=Bf.find(Re=>String(Re.id)===te||String(Re.id)===`marketplace:${G.id}`),we=nr===te,Oe=Mp(G.inputs||G.input),oe=Mp(G.outputs||G.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ne?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:G.displayName||G.label||G.id}),o.jsx("span",{children:G.version?`v${G.version}`:te})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:G.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:Oe.length>0?Oe.map(Re=>o.jsx("span",{className:"af-pipeline-market-chip",children:Re},`in-${te}-${Re}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:oe.length>0?oe.map(Re=>o.jsx("span",{className:"af-pipeline-market-chip",children:Re},`out-${te}-${Re}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>$t(G),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:ne?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:q||we,onClick:()=>{ne&&pe?(Jv(pe),Ut(null)):XT(G)},children:e(we?"flow:settings.installingNode":ne?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},te)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),gt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!gn.enabled,disabled:x,onChange:G=>Yo(te=>({...te,enabled:G.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:gn.cron||"",disabled:x,onChange:G=>Yo(te=>({...te,cron:G.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:gn.timezone||"",disabled:x,onChange:G=>Yo(te=>({...te,timezone:G.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:gn.preset||"",disabled:x,onChange:G=>Yo(te=>({...te,preset:G.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Ft).map(G=>o.jsx("option",{value:G,children:G},G))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${z}`}),o.jsx("span",{children:gn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(gn.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",j]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Yt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Yt.lastTriggeredAt).toLocaleString()})]}):null,Yt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Yt.lastSkippedAt).toLocaleString(),Yt.lastSkipReason?` · ${Yt.lastSkipReason}`:""]})]}):null,Yt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Yt.lastRunUuid})]}):null,Yt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Yt.lastExitCode)})]}):null,Yt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Yt.lastFinishedAt).toLocaleString()})]}):null]}),Sn!=null&&Sn.lastError||Yt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Sn==null?void 0:Sn.lastError)||Yt.lastError}):null,u.archived||Hs(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,sr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:sr}):null,Hn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Hn}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[It.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:Bf.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Ql(u.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:u.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${z}`,children:j})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:It.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:u.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Ql(u.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void p2(),disabled:Ms,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(Ms?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:ju,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},T2=()=>{const x=ze;if(!x)return null;const j=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,z=x.displayName||x.label||x.id,K=Mp(x.inputs||x.input),q=Mp(x.outputs||x.output);return ts.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:G=>{G.target===G.currentTarget&&$t(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:z})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>$t(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(K.length>0?K:[""]).slice(0,4).map((G,te)=>o.jsx("span",{title:G},`preview-in-${te}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:z}),o.jsx("span",{children:j})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(q.length>0?q:[""]).slice(0,4).map((G,te)=>o.jsx("span",{title:G},`preview-out-${te}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:K.length>0?K.map(G=>o.jsx("span",{className:"af-pipeline-market-chip",children:G},`preview-input-${G}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(G=>o.jsx("span",{className:"af-pipeline-market-chip",children:G},`preview-output-${G}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:j})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(G=>G.to||G).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(tv,{children:[o.jsx(C7,{onReady:i}),o.jsxs(VI.Provider,{value:{modelLists:pt,onModelChange:h2},children:[o.jsxs("div",{className:"af-pipeline-page"+(_e!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{_e==="running"?Jf(!0):_e!=="edit"?Ja():n("/projects")},"aria-label":e(_e!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(_e!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",a7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Mb(u,"workspace")),children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[Is&&o.jsx("button",{type:"button",className:"af-icon-btn"+(ei?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Bo(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),_e==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:Ty(Kt,"running")})]}),_e==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:Ty(Kt,"stopped")})]}),(_e==="done"||_e==="error")&&o.jsxs("div",{className:"af-run-timer"+(_e==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:_e==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:Ty(Kt,_e)})]}),_e!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Me?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Dn(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),_e==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(kt==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!u,onClick:_2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(kt==="settings"?" af-icon-btn--active":""),onClick:P2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!u,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(kt==="composer"?" af-composer-topbar-btn--active":"")+(Qe?" af-composer-topbar-btn--running":""),onClick:A2,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(Ua?" af-icon-btn--active":""),onClick:l0,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!u,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!u||Hs(u.source)||u.source!=="user"&&u.source!=="workspace",onClick:()=>T(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!u||Hs(u.source)||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>B(!0),children:"Archive"})]}),_e==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:b2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):_e==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Oi(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ja,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):_e==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Oi({runUuid:Vt}),title:Vt?e("flow:topbar.resumeTitle",{uuid:Vt}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ja,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):_e==="done"||_e==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Oi(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Ja,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!u,onClick:()=>void Oi(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>Se(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":he,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),he&&u&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var j,z,K,q,G;Se(!1);const x={};for(const te of si){const ne=Vl[te.id];ne&&(x[ne]=((j=Yr[ne])==null?void 0:j.value)??((z=Yr[ne])==null?void 0:z.path)??((G=(q=(K=te.data)==null?void 0:K.outputs)==null?void 0:q[0])==null?void 0:G.default)??"")}wt(x),$e(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Se(!1),Oi({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Se(!1),Oi()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Ft).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var K;Se(!1);const j=Ft[x]||{},z={};for(const q of si){const G=Vl[q.id];if(!G)continue;const te=((K=q.data)==null?void 0:K.definitionId)||"",ne=j[q.id]??"";te.startsWith("provide_file")?z[G]={type:"file",path:ne}:z[G]={type:"str",value:ne}}Oi({cliInputsOverride:z})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),Xe?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:Xe}),o.jsx("button",{type:"button",onClick:()=>ot(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(_e!=="edit"?" af-pipeline-body--run-mode":""),children:[_e==="edit"&&kt!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${Zs?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Ni(x=>!x),"aria-expanded":Zs,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Zs?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||Cr.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),Zs&&o.jsx("div",{className:"af-palette-workspace-tree",children:io?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Cr.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Cr.error}):u?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:u.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",Cr.files.length,")"]})]}),Cr.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Cr.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Y({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):Cr.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Cr.files.filter(x=>{var j;return x.type==="directory"&&((j=x.children)==null?void 0:j.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(j=>o.jsxs("li",{className:`af-palette-workspace-item${j.type==="file"?" af-palette-workspace-item--clickable":""}`,title:j.path,onClick:j.type==="file"?()=>Y({filePath:j.path,fileName:j.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:j.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:j.name}),j.type==="file"&&j.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:j.size<1024?`${j.size}B`:j.size<1024*1024?`${(j.size/1024).toFixed(1)}KB`:`${(j.size/1024/1024).toFixed(1)}MB`})]},j.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Ne==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Ie,type:"search",className:"af-palette-search-input",value:de,onChange:x=>Ae(x.target.value),placeholder:(Ne==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Ne==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Ne==="nodes",className:"af-palette-tab"+(Ne==="nodes"?" af-palette-tab--active":""),onClick:()=>Pe("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Ne==="flows",className:"af-palette-tab"+(Ne==="flows"?" af-palette-tab--active":""),onClick:()=>Pe("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),c?o.jsx("p",{className:"af-err af-palette-list-err",children:c}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Ne==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:C2,disabled:!u||wr.length<2,title:wr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",wr.length," 节点 / ",Qf.length," 连线"]})]})}),Fe?o.jsx("p",{className:"af-err af-palette-list-err",children:Fe}):null,Ge?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):n0.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:n0.map(x=>{const j=`${x.id}@${x.version}`,z=x.displayName||x.name||x.id,K=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>s0(x),draggable:!!u,onDragStart:q=>{q.dataTransfer.setData("application/agentflow-snippet",j),q.dataTransfer.effectAllowed="move"},disabled:!u,title:K,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:z}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),K?o.jsx("span",{className:"af-palette-card-desc",children:K}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},j)})})]}):o.jsx("p",{className:"af-palette-empty",children:de.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Zu.filter(x=>zf[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:zf[x].map(j=>{const z=cj(j.inputs,"input"),K=cj(j.outputs,"output"),G=j.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":UI(j),te=WI(j);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>Jv(j),draggable:!!u,onDragStart:ne=>{ne.dataTransfer.setData("application/agentflow-node",j.id),ne.dataTransfer.effectAllowed="move"},disabled:!u,title:G||j.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:f7(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:te}),te!==j.id?o.jsx("span",{className:"af-palette-card-id",children:j.id}):null]})]}),G?o.jsx("span",{className:"af-palette-card-desc",children:G}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[z.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[z.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:lj("input",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:On(ne==null?void 0:ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Ry(ne,pe)})]},`in-${pe}`)),z.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",z.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[K.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[K.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:lj("output",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Ry(ne,pe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:On(ne==null?void 0:ne.type)}})]},`out-${pe}`)),K.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",K.hidden]}):null]})]})]})]},j.id)})})]},x)),u&&le.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,u&&le.length>0&&de.trim()&&GT===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,u?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(oo?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(oo?"common:engine.online":"common:engine.offline")})]}),b?o.jsx("div",{className:"af-palette-tip"+QT,role:"status","aria-live":"polite",children:b}):null]})]}):_e!=="edit"&&u?o.jsx(e7,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:si,edges:xn,nodes:It,onCliInputsChange:Ls,onBackToEdit:Ja}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[k?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:k}):null,u&&Ri.length>0&&!Q?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:re,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void Xv(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>U(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:Ri.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:j=>{j.preventDefault(),l2(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,u&&Ri.length>0&&Q?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Ri.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:l0,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>U(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:re,onClick:()=>void Xv(),children:e("common:common.refresh")})]})]}):null,kt==="settings"&&u&&_e==="edit"?I2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?o.jsxs(o.Fragment,{children:[o.jsx(R7,{fitViewEpoch:p,canvasTool:hu,nodes:UT,edges:KT,onNodesChange:_e!=="edit"?void 0:BT,onEdgesChange:_e!=="edit"?void 0:HT,onConnect:_e!=="edit"?void 0:r2,onConnectStart:_e!=="edit"?void 0:s2,onConnectEnd:_e!=="edit"?void 0:i2,isValidConnection:_e!=="edit"?void 0:n2,onNodesDelete:_e!=="edit"?void 0:o2,onNodeClick:ZT,onNodeDoubleClick:e2,onEdgeClick:t2,onFlowInit:a2,onDrop:f2,onDragOver:d2,hideMinimapAndControls:!!(u&&kt),bottomSlot:_e==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Zf.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Zf.map((x,j)=>{var pe,we;if(x.kind==="definition"){const Oe=x.definition,oe=String(Oe.label??Oe.id),Re=[Oe.id,Oe.description?String(Oe.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Re,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:oe}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>a0(x),"aria-label":e("flow:composer.removeFromInput",{id:Oe.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Oe.id}`)}const z=x.node,K=x.kind,q=String(((pe=z.data)==null?void 0:pe.label)??z.id),G=(we=z.data)!=null&&we.definitionId?String(z.data.definitionId):"",te=G&&G!==q?`${q} · ${z.id} · ${G}`:`${q} · ${z.id}`,ne=K==="canvas"?e("flow:composer.deselectNode",{id:z.id}):e("flow:composer.removeFromInput",{id:z.id});return o.jsxs("div",{className:"af-composer-node-chip"+(K==="mention"?" af-composer-node-chip--mention":""),title:te,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:q}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>a0(x),"aria-label":ne,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},z.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:mu,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:Gr,rows:2,onChange:x=>{fo(x.target.value),En(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const j=x.target;j instanceof HTMLTextAreaElement&&En(j.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Qa();return}if(Su&&ii.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),Wa(j=>(j+1)%ii.length);else if(x.key==="ArrowUp")x.preventDefault(),Wa(j=>(j-1+ii.length)%ii.length);else if(x.key==="Enter"){x.preventDefault();const j=ii[Ii];j&&Cg(j.id)}}},onKeyUp:x=>{const j=x.target;j instanceof HTMLTextAreaElement&&En(j.selectionStart??j.value.length)},onClick:x=>{const j=x.target;j instanceof HTMLTextAreaElement&&En(j.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),Su&&u&&ii.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[Nu.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,Nu.instances.map((x,j)=>{const z=j;return o.jsx("li",{role:"option","aria-selected":z===Ii,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ii?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Wa(z),onClick:()=>Cg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),Nu.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,Nu.definitions.map((x,j)=>{const z=Nu.instances.length+j;return o.jsx("li",{role:"option","aria-selected":z===Ii,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===Ii?" af-composer-mention-item--active":""),onMouseDown:K=>K.preventDefault(),onMouseEnter:()=>Wa(z),onClick:()=>Cg(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[xe.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Ke||"",onChange:x=>{x.target.value==="__new__"?tn():zv(x.target.value)},disabled:Qe,"aria-label":e("flow:composer.switchConversation"),children:[xe.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:zl,type:"button",className:"af-composer-skills-button"+(jg>0?" af-composer-skills-button--active":""),disabled:!u||Qe,"aria-haspopup":"listbox","aria-expanded":Ya,onClick:()=>xu(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:jg>0?`Skills ${jg}`:"Skills"})]}),Ya&&!Qe?ts.createPortal(o.jsx("div",{ref:wu,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:_,children:ri.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[ep.groups.map(x=>{const j=Ea(x,ri),z=JE(x,Ng,ri),K=Pr.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(K?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:z==="all",disabled:j.length===0,onChange:q=>{const G=q.target.checked;Ka(te=>G?GE(te,j):XE(te,j))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,z==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":K?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{pg(q=>{const G=new Set(q);return G.has(x.id)?G.delete(x.id):G.add(x.id),G})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:K?"expand_more":"expand_less"})]})]}),K?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ng.has(q.key),onChange:G=>{const te=G.target.checked;Ka(ne=>te?ne.includes(q.key)?ne:[...ne,q.key]:ne.filter(pe=>pe!==q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:q.description}):null]})]},`${x.id}:${q.key}`))})]},x.id)}),ep.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:ep.ungrouped.length})]}),ep.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Ng.has(x.key),onChange:j=>{const z=j.target.checked;Ka(K=>z?K.includes(x.key)?K:[...K,x.key]:K.filter(q=>q!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(ho||"").trim()?Jr.currentNotInLists?Jr.currentNotInLists:$p(ho,Jr.cursorList,Jr.opencodeList,Jr.claudeCodeList):"",onChange:x=>yu(x.target.value),disabled:!u||Qe,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Jr.currentNotInLists?o.jsxs("option",{value:Jr.currentNotInLists,children:[Jr.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Jr.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:Jr.cursorList.map(x=>o.jsx("option",{value:vo(x),children:x},`composer-c-${x}`))}):null,Jr.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:Jr.opencodeList.map(x=>o.jsx("option",{value:`opencode:${vo(x)}`,children:x},`composer-o-${x}`))}):null,Jr.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:Jr.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${vo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(u&&Gr.trim()&&!Qe?" af-composer-send--active":"")+(Qe?" af-composer-send--stop":""),disabled:!u||!Qe&&!Gr.trim(),"aria-label":e(Qe?"flow:composer.stopGeneration":"flow:composer.send"),title:Qe?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(Qe){(x=Pt.current)==null||x.abort();return}Qa()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Qe?"stop":"arrow_upward"})})]})]}),st?ts.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&Le(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(Qe?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:jt||void 0,children:Qe&&!jt?e("flow:composer.executing"):jt||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Le(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),me.length>1&&!(be&&Array.isArray(be.phases)&&be.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(b7,{steps:me})}):null,be&&Array.isArray(be.phases)&&be.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:be.phases.map((x,j)=>{const z=x.status||(j<(be.currentPhase??0)?"done":j===(be.currentPhase??0)?Qe?"running":be.nextPhase||be.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:j+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||j)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(fj,{thread:or,liveSegments:Qt,running:Qe})}),be&&!be.isLastPhase&&be.nextPhase&&!Qe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:be.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:o0,children:e("flow:composer.phaseReviewContinue",{label:be.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:i0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),Xr&&_e==="edit"?(()=>{var K;const x=String(Xr.query||"").trim().toLowerCase(),j=x?Xr.candidates.filter(q=>{var G,te,ne;return[(G=q.def)==null?void 0:G.id,q.displayLabel,q.description,(te=q.slot)==null?void 0:te.name,(ne=q.slot)==null?void 0:ne.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(x))}):Xr.candidates,z=Xr.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:Xr.left,top:Xr.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:On((K=Xr.draft.slot)==null?void 0:K.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",Xr.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>go(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:Xr.query,onChange:q=>go(G=>G&&{...G,query:q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[j.map(q=>{var ne,pe;const G=q.displayLabel||((ne=q.def)==null?void 0:ne.id),te=Ry(q.slot,q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>u2(q),title:q.description||q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:G}),G!==q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:z}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:On((pe=q.slot)==null?void 0:pe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:te})]})]},`${q.def.id}-${q.slotIndex}`)}),j.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),_e!=="edit"&&Me&&o.jsxs("div",{className:"af-run-console",style:{height:Ts},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:g2,onPointerMove:y2,onPointerUp:e0,onPointerCancel:e0,onLostPointerCapture:x2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[_e==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>Dn(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[Bn.map((x,j)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},j)),o.jsx("div",{ref:Tl})]})]})]}),_e!=="edit"&&Rs&&u?o.jsx(XU,{instanceId:Rs,flowId:u.id,runId:Vt,nodeStatus:((c0=mr[Rs])==null?void 0:c0.status)??null,onClose:()=>ms(null)}):null,kt&&kt!=="settings"&&u&&_e==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(kt==="node"?" af-pipeline-drawer--wide":"")+(kt==="composer"?" af-pipeline-drawer--wide":""),"aria-label":kt==="settings"?e("flow:settings.title"):kt==="history"?e("flow:history.title"):kt==="composer"?"AI Composer":e("flow:nodeProps.title"),children:kt==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:ju,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),xe.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[xe.map(x=>o.jsxs("button",{type:"button",ref:j=>{j&&x.id===Ke&&j.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Ke?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>zv(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:j=>{j.stopPropagation(),yr(x.id)},onKeyDown:j=>{j.key!=="Enter"&&j.key!==" "||(j.preventDefault(),j.stopPropagation(),yr(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>tn(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Qe?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Qe&&!jt?e("flow:composer.executing"):jt||e("flow:composer.ready")}),be&&Array.isArray(be.phases)&&be.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:be.phases.map((x,j)=>{const z=x.status||(j<(be.currentPhase??0)?"done":j===(be.currentPhase??0)?Qe?"running":be.isLastPhase&&j===be.phases.length-1||be.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(z==="done"?" af-composer-phase-item--done":"")+(z==="running"?" af-composer-phase-item--running":"")+(z==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:z==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:j+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||j)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:ln,children:o.jsx(fj,{thread:or,liveSegments:Qt,running:Qe})}),be&&!be.isLastPhase&&be.nextPhase&&!Qe?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:be.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:o0,children:e("flow:composer.phaseReviewContinue",{label:be.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:i0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):kt==="node"&&it?ft?o.jsx(FI,{draft:ft,setDraft:gs,definitionId:String(((u0=it.data)==null?void 0:u0.definitionId)??it.id),systemPromptReadonly:String((gg==null?void 0:gg.description)??""),modelLists:pt,disabled:!u,onIdBlur:m2,onClose:ju,onPublishToMarketplace:JT,error:cg,ioSlots:{inputs:Array.isArray(ft==null?void 0:ft.inputs)?ft.inputs:[],outputs:Array.isArray(ft==null?void 0:ft.outputs)?ft.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(kt==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:ju,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:kt==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:M,onChange:x=>{R(x.target.value),W("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Yf())},onBlur:()=>{M.trim()&&M.trim()!==u.id&&Yf()},placeholder:u.id,disabled:F,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Ql(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Ql(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),L?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:L}):null]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>Qv(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:D?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:N,onClick:()=>qf("workspace"),children:e(N?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:N,onClick:()=>qf("user"),children:e(N?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),S?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:S}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:g,onChange:x=>v(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),gt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!gn.enabled,disabled:Ms||u.archived||Hs(u.source),onChange:x=>Yo(j=>({...j,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:gn.cron||"",disabled:Ms||u.archived||Hs(u.source),onChange:x=>Yo(j=>({...j,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:gn.timezone||"",disabled:Ms||u.archived||Hs(u.source),onChange:x=>Yo(j=>({...j,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:gn.preset||"",disabled:Ms||u.archived||Hs(u.source),onChange:x=>Yo(j=>({...j,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Ft).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),gn.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(gn.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:Sn!=null&&Sn.running?e("flow:schedule.running"):gn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Yt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Yt.lastTriggeredAt).toLocaleString()})]}):null,Yt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Yt.lastSkippedAt).toLocaleString(),Yt.lastSkipReason?` · ${Yt.lastSkipReason}`:""]})]}):null,Yt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Yt.lastRunUuid})]}):null,Yt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Yt.lastExitCode)})]}):null,Yt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Yt.lastFinishedAt).toLocaleString()})]}):null]}),Sn!=null&&Sn.lastError||Yt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Sn==null?void 0:Sn.lastError)||Yt.lastError}):null,u.archived||Hs(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,sr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:sr}):null,Hn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Hn}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:Ms||u.archived||Hs(u.source),onClick:wg,children:e(Ms?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[It.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:u.id})]}),Fo?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Gn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Gn}):ku.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[zr.success+zr.failed+zr.running+zr.stopped+zr.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[zr.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:zr.success})}):null,zr.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:zr.failed})}):null,zr.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:zr.stopped})}):null,zr.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:zr.interrupted})}):null,zr.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:zr.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:ku.map((x,j)=>{const z=x.status||"unknown",K=z==="success"?"af-exec-history-card--success":z==="failed"?"af-exec-history-card--failed":z==="stopped"?"af-exec-history-card--stopped":z==="interrupted"?"af-exec-history-card--interrupted":z==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",q=e(z==="success"?"flow:history.success":z==="failed"?"flow:history.failed":z==="stopped"?"flow:history.stopped":z==="interrupted"?"flow:history.interrupted":z==="running"?"flow:history.running":"flow:history.unknown"),G=z==="success"?"check_circle":z==="failed"?"error":z==="stopped"?"stop_circle":z==="interrupted"?"sync_disabled":z==="running"?"progress_activity":"help",te=x.runId||`${x.at}-${j}`,ne=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:ku.length-j});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${K}`,onClick:()=>j2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:ne}),o.jsx("span",{className:"af-exec-history-card-time",children:Ux(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:G}),q]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),RO(x.durationMs,e)]})]})]})},`${u.id}-${te}`)})})]})]})})]})}):null]}),o.jsx(KN,{open:w2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:v2,onCancel:()=>kg(!1)}),o.jsx(KN,{open:k2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:N2,onSecondary:S2,onCancel:()=>Jf(!1)}),o.jsx(LI,{open:Ua,onClose:()=>Uo(!1)}),T2(),o.jsx(OU,{open:po,onClose:()=>Tf(!1),onJump:c2,nodes:It}),o.jsx(o7,{open:ei,onClose:()=>Bo(!1),flowId:(u==null?void 0:u.id)??""}),o.jsx(IU,{open:A,onClose:()=>B(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{B(!1),await Hf(),n("/projects?tab=archived")}}),o.jsx(TU,{open:P&&!!(u!=null&&u.id),onClose:()=>T(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),onDeleted:async()=>{T(!1),f(null),yt([]),nn([]),bu(null),await Hf(),n("/projects")}}),De&&ts.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>tt(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Nt.name,onChange:x=>{const j=x.target.value;en(z=>({...z,name:j,id:z.id?z.id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Nt.id,onChange:x=>en(j=>({...j,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Nt.description,onChange:x=>en(j=>({...j,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",wr.length," 个节点和 ",Qf.length," 条内部连线。"]}),ae?o.jsx("div",{className:"af-flow-snippet-error",children:ae}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>tt(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:fr||!Nt.name.trim(),onClick:()=>void E2(),children:fr?"发布中…":"发布"})]})]})}),document.body),o.jsx(MU,{open:!!E,onClose:()=>Y(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(E==null?void 0:E.filePath)??"",fileName:(E==null?void 0:E.fileName)??"",onSaved:()=>{hr(x=>({...x}))}})]}),Jn&&_e!=="edit"&&ts.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:Jn.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:du?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!Jn||!u||!Vt)return;const x=Pi||Jn.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:Vt,instanceId:Jn.instanceId,content:x})})).ok?(lo(z=>z&&{...z,content:x}),Vo(!1),rt(z=>[...z,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):rt(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{rt(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{za(Jn.content),Vo(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Vo(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>lo(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:du?o.jsx("textarea",{ref:If,className:"af-user-check-modal__textarea",value:Pi||Jn.content,onChange:x=>za(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:Pi||Jn.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:Ba,onChange:x=>co(x.target.value),disabled:Ll}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Ll||!Ba.trim(),onClick:()=>{!Jn||!u||!Vt||!Ba.trim()||(Ha(!0),rt(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"ai-edit-user-check-content",runUuid:Vt,instanceId:Jn.instanceId,content:Pi||Jn.content,prompt:Ba})}).then(x=>x.json()).then(x=>{Ha(!1),x.ok&&x.content?(za(x.content),Vo(!0),co(""),rt(j=>[...j,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):rt(j=>[...j,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{Ha(!1),rt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Ll?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!Jn||!u||!Vt)return;const x=Pi||Jn.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:Vt,instanceId:Jn.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-check",runUuid:Vt,instanceId:Jn.instanceId,execId:Jn.execId})}),lo(null),co(""),Oi({runUuid:Vt})):rt(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{rt(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),$s&&_e!=="edit"&&ts.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:$s.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Va(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[$s.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:$s.question})}):null,$s.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:$s.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:Rt,onClick:async()=>{if(!(!$s||!u||!Vt)){uo(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-ask",runUuid:Vt,instanceId:$s.instanceId,execId:$s.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Va(null),uo(!1),Oi({runUuid:Vt})):(uo(!1),rt(z=>[...z,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{uo(!1),rt(j=>[...j,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(Rt?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),fu&&_e!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(Ml?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:fu.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>$l(x=>!x),"aria-label":e(Ml?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(Ml?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:Ml?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Ol(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(Sf,{children:fu.content})})})]}),Ds&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:Ds.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Ai(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:pu,className:"af-provide-edit-modal__textarea",defaultValue:Ds.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:qT,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Ai(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Te&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>$e(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:si.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:si.map(x=>{var pe,we;const j=Vl[x.id];if(!j)return null;const z=((pe=x.data)==null?void 0:pe.definitionId)||"",K=z.startsWith("provide_file"),q=z==="provide_bool",G=((we=x.data)==null?void 0:we.label)||x.id,te=Dt[j]??"",ne=["true","1","yes","on"].includes(String(te).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(K?" af-run-params-item__icon--file":""),children:K?"description":q?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:G}),o.jsx("span",{className:"af-run-params-item__slot",children:j})]}),q?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ne?" af-run-config-bool-toggle--true":""),onClick:()=>wt(Oe=>({...Oe,[j]:ne?"false":"true"})),"aria-pressed":ne,children:ne?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:te,onChange:Oe=>wt(oe=>({...oe,[j]:Oe.target.value})),placeholder:e(K?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var j;const x={};for(const z of si){const K=Vl[z.id];if(!K)continue;const q=((j=z.data)==null?void 0:j.definitionId)||"",G=Dt[K]??"";q.startsWith("provide_file")?x[K]={type:"file",path:G}:x[K]={type:"str",value:G}}$e(!1),Se(!1),Oi({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>$e(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const D7="modulepreload",F7=function(e){return"/"+e},xj={},z7=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=F7(c),c in xj)return;xj[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":D7,d||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},B7=new Set(["echarts"]),H7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),V7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),W7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Na(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Nl(e,t){if(!Na(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Na(n[r])&&Na(s)&&(n[r]=Nl(n[r],s));return n}function tg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Na(n)?Nl(n,t):n):Na(e)?Nl(e,t):e}function U7(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function Tw(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>Tw(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||V7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Tw(r,`${t}.${n}`)}}}function K7(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!H7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function q7(e){const t={trigger:"item",renderMode:"richText",backgroundColor:"rgba(20, 22, 28, 0.96)",borderColor:"rgba(124, 156, 255, 0.28)",textStyle:{color:"rgba(255, 255, 255, 0.92)"}};return!e||typeof e!="object"||Array.isArray(e)?t:Nl(e,t)}function Y7(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Na(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return Nl(i,n)}):Na(e)?Nl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function G7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:tg(e,n)}function wj(e,t="rgba(255, 255, 255, 0.62)"){return tg(e,{nameTextStyle:{color:t},axisLabel:{color:"rgba(255, 255, 255, 0.58)"},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.22)"}},axisTick:{lineStyle:{color:"rgba(255, 255, 255, 0.18)"}},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}}})}function X7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:tg(e,n)}function J7(e){const t={axisName:{color:"rgba(255, 255, 255, 0.68)"},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}},splitArea:{areaStyle:{color:["rgba(255, 255, 255, 0.025)","rgba(255, 255, 255, 0.045)"]}},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.16)"}}};return e==null?e:tg(e,t)}function Q7(e,t,n){const r=Y7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Na(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??W7,textStyle:Nl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:q7(e.tooltip),legend:G7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?X7(e.grid,s||i):e.grid,xAxis:wj(e.xAxis),yAxis:wj(e.yAxis),radar:J7(e.radar),series:t}}function Z7(e){const t=U7(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!B7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");Tw(n);const r=K7(n.option.series),s=n.title==null?"":String(n.title),i=Q7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}const eK="af:workspace-graph:v2",nc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],tK=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),nK={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},rK={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},sK={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},iK="0.1.39";function oK(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Bu(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function aK(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function lK(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function cK(e){const t=String(e||"").trim();if(!t)return"";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function bj(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function YI(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function GI(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function jv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function ed(e){const t=String(jv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function vj(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function um(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function td(e){return um(e)}function Rw(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function My(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function kj(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Sj(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function Nj(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),i=Xc(s.get(n),e.sourceHandle||"output-0","source"),a=Xc(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Gc(i,a))}function uK(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const i=t.find(l=>l.id===n),a=Xc(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:II(a)}:null}function dK(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Gc(t.slot,a):Gc(a,t.slot)))continue;const c=ed(n);return{def:n,order:r,category:c,categoryRank:nc.indexOf(c),slot:a,slotIndex:i,displayLabel:td(n),description:Rw(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function nd(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function fK(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function pK(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Fp(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:pK(t),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function $y(e,t){var f,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=JI(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(f=e==null?void 0:e.ui)!=null&&f.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const h of s)h!=null&&h.source&&l.add(String(h.source)),h!=null&&h.target&&l.add(String(h.target));const d=Array.from(l).map(h=>{const g=r[h]||{},v=g.definitionId||h,k=t.find(I=>I.id===v),y=jv(k)||v,b=t.find(I=>I.id===y)||k,w=g.marketplaceRef||GI(k),S=i[h]&&typeof i[h].x=="number"&&typeof i[h].y=="number"?i[h]:{x:320+l.size*20,y:180+l.size*12},C=a[h]&&typeof a[h].width=="number"&&typeof a[h].height=="number"?{width:a[h].width,height:a[h].height}:null,N=!!vs(y);return{id:h,type:jf,position:S,...C?{width:C.width,height:C.height}:{},data:{label:g.label||um(k)||um(b)||h,definitionId:y,...w?{marketplaceRef:w}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:YI(y,b||k),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...N&&C?{displaySize:C}:{}}}}).map(h=>nf(h,r,t)),u=s.filter(h=>(h==null?void 0:h.source)&&(h==null?void 0:h.target)).map((h,g)=>({id:h.id||`we-${h.source}-${h.target}-${g}`,source:String(h.source),target:String(h.target),sourceHandle:h.sourceHandle??void 0,targetHandle:h.targetHandle??void 0,markerEnd:{type:us.ArrowClosed}}));return{nodes:d,edges:PI(u,d),instances:r}}function XI(e){var s,i,a,l,c,d,u;const t=!!vs((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||(e==null?void 0:e.width)||(t?(l=e==null?void 0:e.measured)==null?void 0:l.width:0)||0),r=Number(((d=(c=e==null?void 0:e.data)==null?void 0:c.displaySize)==null?void 0:d.height)||(e==null?void 0:e.height)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.height:0)||0);return n>0&&r>0?{width:Math.round(n),height:Math.round(r)}:null}function zp(e,t,n){var l,c;const r=JI(Nf(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const u=XI(d);u&&(a[d.id]=u)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function JI(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!vs(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function vs(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function bd(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=vs(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function QI(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function hK(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function mK(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Co(e){let t=String(e||"").trim();return t.includes("|")?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())):[]}function ZI(e){const t=Co(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function eT(e){return Co(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function gK(e){const t=String(e||"").replace(/\r\n/g,`
137
+ `).split(`
138
+ `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
+ `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"";if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&Co(l).length>1&&ZI(t[a+1])){i();const c=Co(l),d=eT(t[a+1]),u=[];for(a+=2;a<t.length&&t[a].trim()&&Co(t[a]).length>1;)u.push(Co(t[a])),a++;n.push({type:"table",headers:c,align:d,rows:u});continue}r.push(l),a++}return i(),n}function jj({children:e}){return o.jsx(Sf,{components:{p:({children:t})=>o.jsx(o.Fragment,{children:t})},children:String(e||"")})}function yK({content:e}){const t=m.useMemo(()=>gK(e),[e]);return o.jsx(o.Fragment,{children:t.map((n,r)=>n.type!=="table"?o.jsx(Sf,{children:n.text},`md-${r}`):o.jsx("div",{className:"af-work-display-table-wrap",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:n.headers.map((s,i)=>o.jsx("th",{style:{textAlign:n.align[i]||"left"},children:o.jsx(jj,{children:s})},i))})}),o.jsx("tbody",{children:n.rows.map((s,i)=>o.jsx("tr",{children:n.headers.map((a,l)=>o.jsx("td",{style:{textAlign:n.align[l]||"left"},children:o.jsx(jj,{children:s[l]||""})},l))},i))})]})},`table-${r}`))})}function xK(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
140
+ `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(i){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
141
+ `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function Fi(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function wK(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>Fi(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>Fi(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>Fi(i[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:Fi(s)||`Column ${i+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,i)=>({key:String(i),label:Fi(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>Fi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>Fi(s[a])):s&&typeof s=="object"?r.map(i=>Fi(s[i.key])):r.map((i,a)=>a===0?Fi(s):""))}}function bK(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=wK(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
142
+ `).split(`
143
+ `).filter(l=>l.trim());if(s.length>=2&&Co(s[0]).length>1&&ZI(s[1])){const l=Co(s[0]),c=eT(s[1]);return{columns:l.map((d,u)=>({key:String(u),label:d,align:c[u]||"left"})),rows:s.slice(2).map(d=>Co(d)),error:""}}const i=r.includes(" ")?" ":",",a=xK(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function vK({content:e}){const t=m.useMemo(()=>bK(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:Fi(n[i])},`${s.key}-${i}`))},r))})]})})}function kK(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const i=(l,c="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?c&&(n.get(d).label=c):n.set(d,{id:d,label:c||d}),d},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),d=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?i(d[1],d[2]||d[3]||d[4]||d[1]):i(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){s=c[2].toUpperCase();continue}const d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function SK({code:e}){const t=m.useMemo(()=>kK(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,i=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((u,f)=>{l.set(u.id,{x:24+(n?f*(r+i):f%3*(r+i)),y:24+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(u=>u.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(u=>u.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((u,f)=>{const p=l.get(u.from),h=l.get(u.to);if(!p||!h)return null;const g=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return o.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${u.from}-${u.to}-${f}`)}),t.nodes.map(u=>{const f=l.get(u.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:u.label.slice(0,22)})]},u.id)})]})})}function na({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,i]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const u=n.current;if(!u)return;const f=Math.max(1,u.scrollHeight),p=Math.max(1,u.clientHeight),h=f>p+1,g=h?Math.max(12,p/f*100):100,v=Math.max(0,100-g),k=h?Math.min(v,u.scrollTop/Math.max(1,f-p)*v):0;i({visible:h,top:k,height:g})},[]);m.useEffect(()=>{const u=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(u);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(u),p.disconnect()}},[t,a]);const l=m.useCallback(u=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,u))*p,a()},[a]),c=m.useCallback((u,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),g=s.height/100*h.height,v=Math.max(1,h.height-g);return(u-h.top-f)/v},[s.height]),d=m.useCallback(u=>{var S,C;if(!s.visible)return;u.preventDefault(),u.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,g=s.height/100*p.height,k=u.clientY>=p.top+h&&u.clientY<=p.top+h+g?u.clientY-p.top-h:g/2;l(c(u.clientY,k));const y=u.pointerId;(C=(S=u.currentTarget).setPointerCapture)==null||C.call(S,y);const b=N=>{N.preventDefault(),l(c(N.clientY,k))},w=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",b),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[o.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function NK({content:e}){const t=m.useRef(null),n=m.useMemo(()=>Z7(e),[e]),[r,s]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),z7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,u;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(u=a==null?void 0:a.dispose)==null||u.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}function jK({data:e,htmlFrameRef:t,htmlFrameVersion:n=0}){const r=vs(e==null?void 0:e.definitionId);if(!r)return null;const s=bd(e),i=r==="html"?QI(s):s;return i.trim()?r==="html"?o.jsx(na,{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:t,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals",srcDoc:i},n)}):r==="image"?o.jsx(na,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:i,alt:hK(e),loading:"lazy"})}):r==="markdown"?o.jsx(na,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(yK,{content:i})}):r==="chart"?o.jsx(na,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(NK,{content:i})}):r==="table"?o.jsx(na,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(vK,{content:i})}):r==="mermaid"?o.jsxs(na,{className:"af-work-display-body",children:[o.jsx(SK,{code:i}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:i})]}):o.jsx(na,{className:"af-work-display-body af-work-display-body--ascii",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:i})}):o.jsx(na,{className:"af-work-display-empty",children:"No display content"})}function CK({value:e,onChange:t}){return o.jsx("div",{className:"af-work-display-editor nodrag nopan",onClick:n=>n.stopPropagation(),children:o.jsx("textarea",{className:"af-work-display-editor__textarea",value:e,onChange:n=>t==null?void 0:t(n.target.value),onKeyDown:n=>{n.key==="Escape"&&n.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1})})}function EK({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},i=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=m.useState(a),d=m.useRef(!1),u=String(s.candidateContent||""),f=!!s.running,p=String(s.error||"");return m.useEffect(()=>{d.current||c(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"af-work-node-chat__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"继续微调"}),o.jsx("span",{children:(t==null?void 0:t.label)||e})]}),o.jsx("button",{type:"button",onClick:()=>{var h;return(h=t==null?void 0:t.onCloseNodeChat)==null?void 0:h.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||f||p||u.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[i.slice(-4).map((h,g)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${h.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:h.role==="assistant"?"AI":"你"}),o.jsx("p",{children:h.text})]},`${h.at||g}-${g}`)),f?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,p?o.jsx("div",{className:"af-work-node-chat__error",children:p}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f,"aria-label":"添加上下文",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),o.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:f,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:h=>{var v;d.current=!1;const g=h.currentTarget.value;c(g),(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,g)},onChange:h=>{var v;const g=h.target.value;c(g),d.current||(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,g)},onKeyDown:h=>{var g,v;h.isComposing||(g=h.nativeEvent)!=null&&g.isComposing||h.keyCode===229||(h.metaKey||h.ctrlKey)&&h.key==="Enter"&&(h.preventDefault(),(v=t==null?void 0:t.onSendNodeChat)==null||v.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||!l.trim(),onClick:()=>{var h;return(h=t==null?void 0:t.onSendNodeChat)==null?void 0:h.call(t,e,l)},"aria-label":"发送",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),o.jsxs("div",{className:"af-work-node-chat__actions",children:[o.jsx("button",{type:"button",disabled:f||!u.trim(),onClick:()=>{var h;return(h=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:h.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:f||!u.trim(),onClick:()=>{var h;return(h=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:h.call(t,e,"append")},children:"追加"})]})]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:h=>{var g;h.stopPropagation(),(g=t==null?void 0:t.onToggleNodeChat)==null||g.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function _K(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function PK(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function AK(e,t){const n=vs(t==null?void 0:t.definitionId)||"markdown";return`outputs/${PK((t==null?void 0:t.label)||e||n)}.${_K(n)}`}function IK({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((S,C)=>({slot:S,idx:C})).sort((S,C)=>{var F,O,L,W;const N=String(((F=S.slot)==null?void 0:F.name)||"").trim(),I=String(((O=C.slot)==null?void 0:O.name)||"").trim();if(N==="next"&&I!=="next")return-1;if(I==="next"&&N!=="next")return 1;const M=String(((L=S.slot)==null?void 0:L.type)||"").trim(),R=String(((W=C.slot)==null?void 0:W.type)||"").trim();return M==="node"&&R!=="node"?-1:R==="node"&&M!=="node"?1:S.idx-C.idx}),l=vs(t==null?void 0:t.definitionId),c=m.useRef(null),[d,u]=m.useState(0),[f,p]=m.useState(!1),[h,g]=m.useState(!1),[v,k]=m.useState(""),y=l==="markdown"?bd(t):"";m.useEffect(()=>{if(!f)return;const S=()=>p(!1);return window.addEventListener("pointerup",S,!0),window.addEventListener("pointercancel",S,!0),window.addEventListener("mouseup",S,!0),window.addEventListener("blur",S),()=>{window.removeEventListener("pointerup",S,!0),window.removeEventListener("pointercancel",S,!0),window.removeEventListener("mouseup",S,!0),window.removeEventListener("blur",S)}},[f]),m.useEffect(()=>{h||k(String(y||""))},[y,h]);const b=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),w=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null;return o.jsxs("div",{className:"af-work-display-card"+(w?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(f?" af-work-display-card--resizing":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:w?{width:w.width,height:w.height}:void 0,children:[o.jsx(KB,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,maxWidth:1200,maxHeight:1e3,onResizeStart:()=>p(!0),onResizeEnd:()=>p(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((S,C)=>{if(S.showOnNode===!1)return null;const N=`${4.15+C*1.75}rem`,I=S.name||`#${C+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:N},children:I}),o.jsx(fs,{type:"target",position:Ue.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:N,background:On(S.type)},title:`${I} · ${S.type}`})]},`in-${C}`)}),a.map(({slot:S,idx:C},N)=>{if(S.showOnNode===!1)return null;const I=`${4.15+N*1.75}rem`,M=S.name||`#${C+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:I},children:M}),o.jsx(fs,{type:"source",position:Ue.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:I,background:On(S.type)},title:`${M} · ${S.type}`})]},`out-${C}`)}),o.jsxs("div",{className:"af-work-display-card__head",children:[o.jsxs("div",{className:"af-work-display-card__title",children:[o.jsx("span",{className:"material-symbols-outlined",children:mK(l)}),o.jsx("strong",{children:b}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:S=>S.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var S,C,N,I;try{(I=(N=(C=(S=c.current)==null?void 0:S.contentWindow)==null?void 0:C.history)==null?void 0:N.back)==null||I.call(N)}catch{}},"aria-label":"后退",title:"后退",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var S,C,N,I;try{(I=(N=(C=(S=c.current)==null?void 0:S.contentWindow)==null?void 0:C.history)==null?void 0:N.forward)==null||I.call(N)}catch{}},"aria-label":"前进",title:"前进",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>u(S=>S+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}):null,l==="markdown"?h?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:S=>S.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var S;(S=t==null?void 0:t.onSetDisplayNodeContent)==null||S.call(t,e,v,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),g(!1)},"aria-label":"保存并预览",title:"保存并预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"done"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{k(String(y||"")),g(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:S=>{S.stopPropagation(),k(String(y||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:()=>{var S;return(S=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:S.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"save"})}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&h?o.jsx(CK,{value:v,onChange:k}):o.jsx(jK,{data:t,htmlFrameRef:c,htmlFrameVersion:d}),o.jsx(EK,{nodeId:e,data:t})]})}function TK({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=(t==null?void 0:t.runningRunNodeId)===e,l=(t==null?void 0:t.nodeStatus)==="stopped";return o.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(l?" af-work-run-card--stopped":""),children:[s.map((c,d)=>{if(c.showOnNode===!1)return null;const u=`${2.25+d*1.75}rem`,f=c.name||`#${d+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:u},children:f}),o.jsx(fs,{type:"target",position:Ue.Left,id:`input-${d}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:u,background:On(c.type)},title:`${f} · ${c.type}`})]},`in-${d}`)}),i.map((c,d)=>{if(c.showOnNode===!1)return null;const u=`${2.25+d*1.75}rem`,f=c.name||`#${d+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:u},children:f}),o.jsx(fs,{type:"source",position:Ue.Right,id:`output-${d}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:u,background:On(c.type)},title:`${f} · ${c.type}`})]},`out-${d}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),onClick:c=>{var d,u;c.stopPropagation(),a?(d=t==null?void 0:t.onStopWorkspaceNode)==null||d.call(t,e):(u=t==null?void 0:t.onRunWorkspaceNode)==null||u.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),o.jsx("span",{children:a?"Stop":"Run line"})]})]})}function RK(e){var d,u,f,p,h,g,v,k,y,b,w;const{setEdges:t,setNodes:n}=_l(),r=(d=e.data)==null?void 0:d.onSyncNodePropDraft,s=m.useCallback(S=>{n(C=>C.filter(N=>N.id!==S)),t(C=>C.filter(N=>N.source!==S&&N.target!==S))},[t,n]),i=m.useCallback((S,C)=>{n(N=>N.map(I=>I.id===S?{...I,data:{...I.data,model:C}}:I)),r==null||r(S,{model:C})},[n,r]),a=m.useCallback((S,C)=>{n(N=>N.map(I=>{var R;if(I.id!==S)return I;const M=Array.isArray((R=I.data)==null?void 0:R.outputs)&&I.data.outputs.length?I.data.outputs.map((F,O)=>O===0?{...F,default:C,value:C}:F):[{type:"bool",name:"value",default:C,value:C}];return{...I,data:{...I.data,body:"",outputs:M}}})),r==null||r(S,N=>({body:"",outputs:Array.isArray(N==null?void 0:N.outputs)&&N.outputs.length?N.outputs.map((M,R)=>R===0?{...M,default:C,value:C}:M):[{type:"bool",name:"value",default:C,value:C}]}))},[n,r]),l=m.useCallback((S,C)=>{n(N=>N.map(I=>I.id===S?{...I,data:{...I.data,body:C}}:I)),r==null||r(S,{body:C})},[n,r]),c=m.useCallback((S,C)=>{const N=is(C);n(I=>I.map(M=>M.id===S?{...M,data:{...M.data,images:N}}:M)),r==null||r(S,{images:N})},[n,r]);return vs((u=e.data)==null?void 0:u.definitionId)?o.jsx(IK,{...e,deleteNode:s}):((f=e.data)==null?void 0:f.definitionId)==="workspace_run"?o.jsx(TK,{...e,deleteNode:s}):((p=e.data)==null?void 0:p.definitionId)==="control_load_skills"?o.jsx(WK,{...e,deleteNode:s,skills:(h=e.data)==null?void 0:h.skills,skillCollections:(g=e.data)==null?void 0:g.skillCollections,onChangeSkillKeys:(v=e.data)==null?void 0:v.onChangeLoadSkillKeys}):((k=e.data)==null?void 0:k.definitionId)==="control_load_mcp"?o.jsx(UK,{...e,deleteNode:s,servers:(y=e.data)==null?void 0:y.mcpServers,onChangeMcpNames:(b=e.data)==null?void 0:b.onChangeLoadMcpNames}):o.jsx("div",{className:"af-work-flow-node",children:o.jsx(TI,{...e,deleteNode:s,modelLists:(w=e.data)==null?void 0:w.modelLists,onModelChange:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:c})})}const LK={[jf]:RK};function tT(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&tT(n.children,t);return t}function nT(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&nT(n.children,t));return t}function Dy(e){const t=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean),n=[];for(let r=1;r<t.length;r++)n.push(t.slice(0,r).join("/"));return n}function OK(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function MK(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(i,a,l)=>{const c=r[a],d=l?`${l}/${c}`:c,u=a===r.length-1;let f=!1;const p=(Array.isArray(i)?i:[]).map(h=>h.name!==c?h:(f=!0,u?{...h,type:"file",name:c,path:d,icon:nd(c),size:n}:{...h,type:"directory",name:c,path:d,icon:nd(c,!0),children:s(h.children||[],a+1,d)}));return f||p.push(u?{type:"file",name:c,path:d,icon:nd(c),size:n}:{type:"directory",name:c,path:d,icon:nd(c,!0),children:s([],a+1,d)}),OK(p)};return s(e||[],0,"")}function rT({items:e,onOpen:t,collapsedDirs:n,onToggleDir:r,onCreateFile:s,onCreateFolder:i,onDelete:a,onFileDragStart:l}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(c=>{var f;const d=c.type==="directory",u=d&&(n==null?void 0:n.has(c.path));return o.jsxs("li",{children:[o.jsxs("div",{className:"af-work-file-row",children:[o.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+c.type,draggable:!d,onDragStart:p=>{d||l==null||l(p,c)},onClick:()=>d?r==null?void 0:r(c.path):t(c),title:c.path,children:[d?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:u?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:c.icon||nd(c.name,d)}),o.jsx("span",{children:c.name})]}),d?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>s==null?void 0:s(c.path),title:"新增文件","aria-label":`在 ${c.name} 新增文件`,children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>i==null?void 0:i(c.path),title:"新增文件夹","aria-label":`在 ${c.name} 新增文件夹`,children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:()=>a==null?void 0:a(c),title:"删除","aria-label":`删除 ${c.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),d&&!u&&((f=c.children)!=null&&f.length)?o.jsx(rT,{items:c.children,onOpen:t,collapsedDirs:n,onToggleDir:r,onCreateFile:s,onCreateFolder:i,onDelete:a,onFileDragStart:l}):null]},c.path)})})}function $K({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return o.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,i)=>{const a=s.kind==="run-log"||s.kind==="run-summary"||s.kind==="activity"||s.kind==="prompt"||s.kind==="raw"||s.kind==="thinking"||s.kind==="result"||s.kind==="assistant"?"reply":s.role==="user"?"user-msg":s.error?"error":"reply",l=s.kind==="run-summary"?"Steps":s.kind==="run-log"?"Run":s.kind==="activity"?"Activity":s.kind==="prompt"?"Prompt":s.kind==="raw"?"Raw Trace":s.kind==="thinking"?"Thinking":s.kind==="result"?"Result":s.kind==="assistant"?"Response":s.role==="user"?"You":s.error?"Error":"Reply";return o.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[o.jsx("div",{className:"af-composer-ai-block-label",children:l}),o.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${i}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function dm(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(String).filter(Boolean)}catch{}return t.split(/[\n,]+/).map(n=>n.trim()).filter(Boolean)}function DK(e){const t=dm((e==null?void 0:e.body)||"");if(t.length>0)return t;const r=(Array.isArray(e==null?void 0:e.inputs)?e.inputs:[]).find(s=>(s==null?void 0:s.name)==="skillsContext"||(s==null?void 0:s.name)==="skillKeys"||(s==null?void 0:s.type)==="text");return dm((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function FK(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function zK(e){const t=dm((e==null?void 0:e.body)||"");if(t.length>0)return t;const r=(Array.isArray(e==null?void 0:e.inputs)?e.inputs:[]).find(s=>(s==null?void 0:s.name)==="mcpContext"||(s==null?void 0:s.name)==="serverNames"||(s==null?void 0:s.type)==="text");return dm((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function BK(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function Cj(e){var r,s,i,a,l,c;if(!e)return null;const{inputs:t,outputs:n}=_I(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((s=e.data)==null?void 0:s.role)??"normal"),model:String(((i=e.data)==null?void 0:i.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:is((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),inputs:t,outputs:n}}function HK(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function VK(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","inputs","outputs"])HK(e[s],t[s])&&(r[s]=n[s]);return r}function WK({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],d=Array.isArray(s)?s:[],u=Array.isArray(i)?i:[],[f,p]=m.useState(!1),[h,g]=m.useState(""),[v,k]=m.useState(()=>new Set),y=m.useRef(null),b=m.useRef(null),[w,S]=m.useState({visible:!1,top:0,height:100}),C=m.useMemo(()=>new Set(DK(t)),[t]),N=m.useMemo(()=>new Map(d.map($=>[$.key,$])),[d]),I=m.useMemo(()=>{const $=new Set,A=u.map(P=>{const T=Ea(P,d).map(E=>N.get(E)).filter(Boolean);for(const E of T)$.add(E.key);return{...P,skills:T}}).filter(P=>P.skills.length>0),B=d.filter(P=>!$.has(P.key));return{collectionGroups:A,ungrouped:B}},[N,u,d]);m.useEffect(()=>{k($=>{let A=!1;const B=new Set($);for(const P of I.collectionGroups)B.has(P.id)||(B.add(P.id),A=!0);return A?B:$})},[I.collectionGroups]);const M=m.useMemo(()=>{const $=h.trim().toLowerCase();if(!$)return I;const A=P=>[P==null?void 0:P.key,P==null?void 0:P.name,P==null?void 0:P.description].map(E=>String(E||"").toLowerCase()).join(" ").includes($);return{collectionGroups:I.collectionGroups.map(P=>{const E=[P==null?void 0:P.id,P==null?void 0:P.name,P==null?void 0:P.description].map(Y=>String(Y||"").toLowerCase()).join(" ").includes($)?P.skills:P.skills.filter(A);return{...P,skills:E}}).filter(P=>P.skills.length>0),ungrouped:I.ungrouped.filter(A)}},[I,h]),R=m.useCallback(($,A)=>{const B=new Set(C);for(const P of $)A?B.add(P):B.delete(P);a==null||a(e,Array.from(B))},[e,C,a]),F=m.useCallback($=>{k(A=>{const B=new Set(A);return B.has($)?B.delete($):B.add($),B})},[]),O=m.useCallback(()=>{const $=y.current;if(!$)return;const A=Math.max(1,$.scrollHeight),B=Math.max(1,$.clientHeight),P=A>B+1,T=P?Math.max(12,B/A*100):100,E=Math.max(0,100-T),Y=P?Math.min(E,$.scrollTop/Math.max(1,A-B)*E):0;S({visible:P,top:Y,height:T})},[]);m.useEffect(()=>{if(!f)return;const $=requestAnimationFrame(O);return()=>cancelAnimationFrame($)},[v,M,C.size,f,O]);const L=m.useCallback($=>{const A=y.current;if(!A)return;const B=Math.max(0,A.scrollHeight-A.clientHeight);A.scrollTop=Math.min(1,Math.max(0,$))*B,O()},[O]),W=m.useCallback(($,A=0)=>{const B=b.current;if(!B)return 0;const P=B.getBoundingClientRect(),T=w.height/100*P.height,E=Math.max(1,P.height-T);return($-P.top-A)/E},[w.height]),D=m.useCallback($=>{var ue,ge;if(!w.visible)return;$.preventDefault(),$.stopPropagation();const A=b.current;if(!A)return;const B=A.getBoundingClientRect(),P=w.top/100*B.height,T=w.height/100*B.height,Y=$.clientY>=B.top+P&&$.clientY<=B.top+P+T?$.clientY-B.top-P:T/2;L(W($.clientY,Y));const Q=$.pointerId;(ge=(ue=$.currentTarget).setPointerCapture)==null||ge.call(ue,Q);const U=le=>{le.preventDefault(),L(W(le.clientY,Y))},re=()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",re),window.removeEventListener("pointercancel",re)};window.addEventListener("pointermove",U),window.addEventListener("pointerup",re),window.addEventListener("pointercancel",re)},[W,L,w.height,w.top,w.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[l.map(($,A)=>{if($.showOnNode===!1)return null;const B=`${2.6+A*1.7}rem`,P=$.name||`#${A+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:B},children:P}),o.jsx(fs,{type:"target",position:Ue.Left,id:`input-${A}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:B,background:On($.type)},title:`${P} · ${$.type}`})]},`in-${A}`)}),c.map(($,A)=>{if($.showOnNode===!1)return null;const B=`${2.6+A*1.7}rem`,P=$.name||`#${A+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:B},children:P}),o.jsx(fs,{type:"source",position:Ue.Right,id:`output-${A}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:B,background:On($.type)},title:`${P} · ${$.type}`})]},`out-${A}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:$=>{var A;$.stopPropagation(),f||(A=t==null?void 0:t.onRefreshSkills)==null||A.call(t),p(B=>!B)},children:[o.jsx("span",{children:C.size>0?`${C.size} skills selected`:"选择 Skills"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:h,onChange:$=>g($.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?o.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:O,children:[M.collectionGroups.map($=>{const A=$.skills.map(E=>E.key),B=A.filter(E=>C.has(E)).length,P=A.length>0&&B===A.length,T=v.has($.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(T?" af-work-load-skills-menu__group--collapsed":""),children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[o.jsx("input",{type:"checkbox",checked:P,onChange:E=>R(A,E.target.checked),"aria-label":`选择 ${$.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>F($.id),"aria-expanded":!T,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:$.name}),$.description?o.jsx("em",{children:$.description}):null]})}),o.jsxs("small",{children:[B,"/",A.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>F($.id),"aria-label":T?`展开 ${$.name}`:`收起 ${$.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:T?"chevron_right":"expand_more"})})]}),T?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:$.skills.map(E=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:C.has(E.key),onChange:Y=>R([E.key],Y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:E.name}),E.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:E.description}):null]})]},`${$.id}:${E.key}`))})]},$.id)}),M.ungrouped.length>0?o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("small",{children:M.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:M.ungrouped.map($=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:C.has($.key),onChange:A=>R([$.key],A.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:$.name}),$.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:$.description}):null]})]},`ungrouped:${$.key}`))})]}):null,M.collectionGroups.length===0&&M.ungrouped.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),o.jsx("div",{ref:b,className:"af-work-load-skills-scrollbar"+(w.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:D,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${w.height}%`,top:`${w.top}%`}})})]}):null]})]})}function UK({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:i}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,d]=m.useState(!1),[u,f]=m.useState(""),p=m.useMemo(()=>new Set(zK(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(k=>({name:String((k==null?void 0:k.name)||""),description:String((k==null?void 0:k.description)||""),detail:String((k==null?void 0:k.url)||[k==null?void 0:k.command,...Array.isArray(k==null?void 0:k.args)?k.args:[]].filter(Boolean).join(" ")||""),type:String((k==null?void 0:k.type)||"")})).filter(k=>k.name),[s]),g=m.useMemo(()=>{const k=u.trim().toLowerCase();return k?h.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(k)):h},[u,h]),v=m.useCallback((k,y)=>{const b=new Set(p);for(const w of k)y?b.add(w):b.delete(w);i==null||i(e,Array.from(b))},[e,p,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[a.map((k,y)=>{if(k.showOnNode===!1)return null;const b=`${2.6+y*1.7}rem`,w=k.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:b},children:w}),o.jsx(fs,{type:"target",position:Ue.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:b,background:On(k.type)},title:`${w} · ${k.type}`})]},`in-${y}`)}),l.map((k,y)=>{if(k.showOnNode===!1)return null;const b=`${2.6+y*1.7}rem`,w=k.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:b},children:w}),o.jsx(fs,{type:"source",position:Ue.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:b,background:On(k.type)},title:`${w} · ${k.type}`})]},`out-${y}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"hub"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:k=>{var y;k.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(b=>!b)},children:[o.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:u,onChange:k=>f(k.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),u?o.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{className:"af-work-load-skills-menu",children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"MCP Servers"}),o.jsx("small",{children:g.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(k=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:p.has(k.name),onChange:y=>v([k.name],y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:k.name}),k.description||k.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:k.description||k.detail}):null]})]},k.name))})]}),g.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空"})]})]}):null]})]})}function KK(){var zl,wu;const{i18n:e}=pn(),{navigate:t}=Ma(),n=_l(),r=KP(),s=m.useMemo(oK,[]),[i,a]=qP([]),[l,c,d]=YP([]),u=m.useRef([]),f=m.useRef([]),p=m.useRef(null),h=m.useRef(null),g=m.useRef(null),[v,k]=m.useState(null),[y,b]=m.useState({}),w=m.useRef({}),S=m.useRef(!1),C=m.useRef(null),[N,I]=m.useState([]),[M,R]=m.useState(""),[F,O]=m.useState("nodes"),[L,W]=m.useState([]),[D,$]=m.useState(!1),[A,B]=m.useState(""),[P,T]=m.useState(!1),[E,Y]=m.useState({name:"",id:"",description:""}),[Q,U]=m.useState(!1),[re,ue]=m.useState(""),[ge,le]=m.useState(""),ce=m.useRef(null),[de,Ae]=m.useState(!1),[Ne,Pe]=m.useState("nodes"),[Ie,qe]=m.useState(""),[ct,Ge]=m.useState(0),[xt,Fe]=m.useState(""),[ee,De]=m.useState(null),[tt,Nt]=m.useState(""),[en,fr]=m.useState([]),[jr,ae]=m.useState(""),[ve,Xe]=m.useState(""),[ot,nt]=m.useState(()=>new Set),hn=m.useRef(null),[Mn,Tn]=m.useState(()=>{try{const _=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(_)&&_>=160)return _}catch{}return 360}),[tr,pr]=m.useState(!1),[Bt,nr]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[ye,ze]=m.useState(""),[$t,kt]=m.useState([]),[Ut,qr]=m.useState(!1),[$n,Gn]=m.useState([]),[rr,Fo]=m.useState([]),[so,zo]=m.useState(!1),[Qs,Zs]=m.useState([]),Ni=m.useCallback(_=>{ce.current&&window.clearTimeout(ce.current),le(_),ce.current=window.setTimeout(()=>{le(""),ce.current=null},3800)},[]),Cr=m.useCallback(_=>{const H=String(_||"").trim();H&&window.requestAnimationFrame(()=>{r(H)})},[r]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Mn)))}catch{}},[Mn]);const hr=m.useCallback(_=>{const H=hn.current;if(!H)return;const X=H.getBoundingClientRect(),J=16,Z=150,ie=230,se=X.top+J,fe=X.bottom-J,xe=Math.max(Z,fe-se-ie),Ce=Math.min(Math.max(_-se,Z),xe);Tn(Ce)},[]),io=m.useCallback(_=>{_.preventDefault(),_.stopPropagation(),pr(!0),hr(_.clientY);const H=J=>{J.preventDefault(),hr(J.clientY)},X=()=>{pr(!1),window.removeEventListener("pointermove",H,!0),window.removeEventListener("pointerup",X,!0),window.removeEventListener("pointercancel",X,!0)};window.addEventListener("pointermove",H,!0),window.addEventListener("pointerup",X,!0),window.addEventListener("pointercancel",X,!0)},[hr]);m.useEffect(()=>()=>{ce.current&&window.clearTimeout(ce.current)},[]);const[ji,oo]=m.useState(()=>new Set),[As,_e]=m.useState(!1),Xt=m.useRef(null),Bn=m.useRef(null),rt=m.useRef(null),[hs,Er]=m.useState({}),[mn,mr]=m.useState(""),[Jt,at]=m.useState(!1),[Ht,Kt]=m.useState([]),[Xn,Me]=m.useState([]),[Dn,Is]=m.useState("workspace"),[Ci,ei]=m.useState(!1),[Bo,Ts]=m.useState(!0),[Ei,ti]=m.useState(""),[Vt,gr]=m.useState({}),[Rs,ms]=m.useState(!1),[Yr,Ls]=m.useState(!1),[V,he]=m.useState("pan"),[Se,Te]=m.useState(null),[$e,Dt]=m.useState(""),wt=m.useRef(null),Ft=m.useRef(!1),[Dr,_r]=m.useState(()=>new Set),[ao,gn]=m.useState({}),[Da,gt]=m.useState(""),Os=m.useMemo(()=>aK(s),[s]),[Ms,cu]=m.useState("");m.useEffect(()=>{s.flowId&&YE(s.flowId,s.flowSource||"user","workspace",!!s.archived)},[s]),m.useEffect(()=>{Kt([]),Me([]),Is("workspace"),Ts(!0)},[s]);const sr=m.useCallback(async()=>{const _=Bu(s),H=await fetch(`/api/workspace/files?${_.toString()}`),X=await H.json();if(!H.ok)throw new Error(X.error||"读取 workspace 失败");const J=X.files||[];fr(J),nt(new Set(nT(J))),ae(X.root||"")},[s]),_i=m.useCallback(async()=>{$(!0),B("");try{const _=await fetch("/api/marketplace/flow-snippets"),H=await _.json().catch(()=>({}));if(!_.ok)throw new Error(H.error||"读取流程片段失败");W(Array.isArray(H.snippets)?H.snippets:[])}catch(_){B(String(_.message||_)),W([])}finally{$(!1)}},[]),Hn=m.useCallback(async(_=i,H=l)=>{var ie;if(!S.current)return;const X=zp(_,H,w.current),J=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,graph:X})}),Z=await J.json();if(!J.ok)throw new Error(Z.error||"保存 workspace graph 失败");w.current=((ie=Z.graph)==null?void 0:ie.instances)||X.instances,b(w.current),gt("Workspace graph saved")},[l,s,i]),Al=m.useCallback(_=>{var X;const H=(X=_==null?void 0:_.extra)!=null&&X.instances&&typeof _.extra.instances=="object"?_.extra.instances:{};w.current=H,b(H),a(Array.isArray(_==null?void 0:_.nodes)?_.nodes:[]),c(Array.isArray(_==null?void 0:_.edges)?_.edges:[]),Fe(""),k(null)},[c,a]),Yt=m.useMemo(()=>({instances:y}),[y]),uu=AI({nodes:i,edges:l,extra:Yt,enabled:S.current,onRestore:Al}),{resetHistory:Sn,undo:Il,redo:Fa}=uu,Fr=m.useCallback(async()=>{S.current=!1;const _=Bu(s),H=Bu(s);H.set("lang",String(e.language||"zh").startsWith("zh")?"zh":"en");const[X,J]=await Promise.all([fetch(`/api/nodes?${H.toString()}`),fetch(`/api/workspace/graph?${_.toString()}`),sr()]),Z=await X.json(),ie=await J.json();if(!X.ok)throw new Error(Z.error||"读取节点定义失败");if(!J.ok)throw new Error(ie.error||"读取 workspace graph 失败");const se=[...(Array.isArray(Z)?Z:Z.nodes||[]).filter(Ce=>!tK.has(Ce.id)),rK,sK,nK];I(se);const fe=ie.graph||JSON.parse(localStorage.getItem(eK)||"null")||{},xe=$y(fe,se);w.current=xe.instances,b(xe.instances),a(xe.nodes),c(xe.edges),Sn(xe.nodes,xe.edges,{instances:xe.instances}),gt(ie.writable?"Workspace ready":"Readonly workspace"),S.current=!0},[s,e.language,sr,Sn,c,a]),Tl=m.useCallback(async(_,H)=>{const X={packageId:(_==null?void 0:_.newId)||(_==null?void 0:_.id)||(_==null?void 0:_.label),label:(_==null?void 0:_.label)||(_==null?void 0:_.newId)||(_==null?void 0:_.id),version:"1.0.0",definitionId:H,body:(_==null?void 0:_.body)||"",script:(_==null?void 0:_.script)||"",inputs:Array.isArray(_==null?void 0:_.inputs)?_.inputs:[],outputs:Array.isArray(_==null?void 0:_.outputs)?_.outputs:[],flowId:s.flowId,flowSource:s.flowSource||"user",archived:!!s.archived},J=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X)}),Z=await J.json().catch(()=>({}));if(!J.ok||(Z==null?void 0:Z.ok)===!1)throw new Error((Z==null?void 0:Z.error)||"Publish failed");return await Fr(),gt(`Published node ${Z.definitionId||Z.id||X.packageId}`),Z},[s,Fr]),Rl=m.useCallback((_="workspace")=>{ei(!0),De(null),Is(_||"workspace")},[]),Ho=m.useCallback(async(_="")=>{const H=String(_||$e||"").trim();if(H){Ft.current=!0,wt.current&&(wt.current.abort(),wt.current=null),Dt(""),_r(new Set),gn(X=>{const J={...X};for(const[Z,ie]of Object.entries(J))(ie==null?void 0:ie.status)==="running"&&(J[Z]={status:"stopped"});return J[H]={status:"stopped"},J}),gt(`Workspace run stopped: ${H}`),Me(X=>X.map(J=>J.runNodeId===H&&J.status==="running"?{...J,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(J.messages)?J.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:J));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,runNodeId:H})})}catch{}}},[s,$e]),Jn=m.useCallback(async _=>{if(!_||$e)return;const H=zp(i,l,w.current),X=`run-${Date.now()}-${String(_).replace(/[^a-z0-9_-]+/gi,"_")}`,J=`Run ${_}`,Z=new AbortController;wt.current=Z,Ft.current=!1,Dt(_),_r(new Set([_])),gn({[_]:{status:"running"}}),gt(`Running ${_}...`),Is(X),Me(ie=>[...ie.slice(-7),{id:X,label:J,runNodeId:_,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await Hn(i,l);const ie=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:Z.signal,body:JSON.stringify({...s,graph:H,runNodeId:_,model:ye,selectedSkills:$n,stream:!0})});if(!ie.ok){const me=await ie.json().catch(()=>({}));throw new Error(me.error||"Workspace run failed")}if(!ie.body)throw new Error("Workspace run stream unavailable");const se=ie.body.getReader(),fe=new TextDecoder;let xe="",Ce=[],Ke=[],Lt=_;const dt=(me,be)=>{var Pt,ln;const Ze=i.find(Ct=>Ct.id===me),st=String(((Pt=Ze==null?void 0:Ze.data)==null?void 0:Pt.label)||me||"").trim(),Le=String(be||((ln=Ze==null?void 0:Ze.data)==null?void 0:ln.definitionId)||"").trim();return Le&&Le!==st?`${st} (${Le})`:st},_t=(me,be,Ze)=>{const st=String(me||"").trim();st&&Me(Le=>Le.map(Pt=>{if(Pt.id!==X)return Pt;const Ct=[...Array.isArray(Pt.steps)?Pt.steps:[]],St=Ct.findIndex(ar=>ar.id===st),Gt={id:st,label:dt(st,be),status:Ze};St>=0?Ct[St]={...Ct[St],...Gt}:Ct.push(Gt);const tn=Ct.map((ar,$f)=>{const Ga=ar.status==="done"?"[done]":ar.status==="failed"?"[failed]":"[running]";return`${$f+1}. ${Ga} ${ar.label}`}).join(`
144
+ `),yr=Array.isArray(Pt.messages)?Pt.messages:[],Vn=yr.findIndex(ar=>ar.kind==="run-summary"),mo={role:"assistant",kind:"run-summary",text:tn||"准备运行...",at:Date.now()},Ar=[...yr];return Vn>=0?Ar[Vn]=mo:Ar.unshift(mo),{...Pt,steps:Ct,messages:Ar.slice(-160)}}))},_n=me=>{const be=String(me||"").trim();if(!be)return;const Ze=Lt;Lt=be,_r(new Set([be])),gn(st=>{var Le;return{...st,...Ze&&Ze!==be&&((Le=st[Ze])==null?void 0:Le.status)==="running"?{[Ze]:{status:"success"}}:{},[be]:{status:"running"}}})},yn=me=>{const be=String(me||"").trim();be&&(_r(Ze=>{const st=new Set(Ze);return st.delete(be),st}),gn(Ze=>({...Ze,[be]:{status:"success"}})))},ir=(me,be)=>{const Ze=String(be||"");if(!Ze.trim())return;const st=["assistant","thinking","result","error","prompt"].includes(me)?me:"assistant";Me(Le=>Le.map(Pt=>{if(Pt.id!==X)return Pt;let ln=Array.isArray(Pt.messages)?Pt.messages:[];if(st==="result"){const Gt=[...ln].reverse().find(tn=>tn.kind==="assistant");if(String((Gt==null?void 0:Gt.text)||"").trim()===Ze.trim())return Pt}if(st==="assistant"){const Gt=ln.findIndex(tn=>tn.kind==="result"&&String(tn.text||"").trim()===Ze.trim());Gt>=0&&(ln=ln.filter((tn,yr)=>yr!==Gt))}const Ct=[...ln],St=Ct[Ct.length-1];return St&&St.kind===st&&!St.error?Ct[Ct.length-1]={...St,text:`${St.text||""}${St.text?`
145
+ `:""}${Ze}`}:Ct.push({role:"assistant",kind:st,text:Ze,...st==="error"?{error:!0}:{},at:Date.now()}),{...Pt,messages:Ct.slice(-160)}}))},Ye=me=>{const be=String(me||"");be.trim()&&Me(Ze=>Ze.map(st=>{var Ct;if(st.id!==X)return st;const Le=Array.isArray(st.messages)?st.messages:[],Pt=Le.findIndex(St=>St.kind==="thinking"),ln=[...Le];if(Pt>=0){const St=String(((Ct=ln[Pt])==null?void 0:Ct.text)||"");ln[Pt]={...ln[Pt],text:`${St}${St&&!St.endsWith(`
146
+ `),""}${be}`,at:Date.now()}}else{const St=ln.findIndex(Gt=>Gt.kind==="activity");ln.splice(St>=0?St+1:ln.length,0,{role:"assistant",kind:"thinking",text:be,at:Date.now()})}return{...st,messages:ln.slice(-160)}}))},Qe=me=>{const be=cK(me);be&&Me(Ze=>Ze.map(st=>{if(st.id!==X)return st;const Le=Array.isArray(st.activities)?st.activities:[],Pt=Le[Le.length-1]===be?Le:[...Le,be].slice(-8),ln=Array.isArray(st.messages)?st.messages:[],Ct=ln.findIndex(tn=>tn.kind==="activity"),St={role:"assistant",kind:"activity",text:Pt.map((tn,yr)=>`${yr+1}. ${tn}`).join(`
147
+ `),at:Date.now()},Gt=[...ln];if(Ct>=0)Gt[Ct]=St;else{const tn=Gt.findIndex(yr=>yr.kind==="run-summary");Gt.splice(tn>=0?tn+1:0,0,St)}return{...st,activities:Pt,messages:Gt.slice(-160)}}))},jt=me=>{const be=String((me==null?void 0:me.source)||"runner"),Ze=String((me==null?void 0:me.stream)||""),st=String((me==null?void 0:me.eventType)||"event"),Le=String((me==null?void 0:me.text)||"").trim();if(!Le)return;const Pt=`[${be}${Ze?`:${Ze}`:""}] ${st}
148
+ ${Le}`;Me(ln=>ln.map(Ct=>{if(Ct.id!==X)return Ct;const Gt=[...Array.isArray(Ct.rawTrace)?Ct.rawTrace:[],Pt].slice(-80),tn=Array.isArray(Ct.messages)?Ct.messages:[],yr=tn.findIndex(Ar=>Ar.kind==="raw"),Vn={role:"assistant",kind:"raw",text:Gt.join(`
149
+
150
+ ---
151
+
152
+ `),at:Date.now()},mo=[...tn];return yr>=0?mo[yr]=Vn:mo.push(Vn),{...Ct,rawTrace:Gt,messages:mo.slice(-160)}}))},Qt=me=>{Me(be=>be.map(Ze=>Ze.id===X?{...Ze,status:me,endedAt:Date.now()}:Ze))},or=me=>{const be=$y(me||H,N),Ze=new Map(be.nodes.map(Le=>[Le.id,Le])),st=be.instances||{};a(Le=>{const Pt=new Set(Le.map(St=>St.id)),Ct={...zp(Le,f.current,w.current).instances||{}};for(const[St,Gt]of Object.entries(st)){if(!Pt.has(St))continue;const tn=Ct[St];vs((Gt==null?void 0:Gt.definitionId)||(tn==null?void 0:tn.definitionId))&&(Ct[St]=Gt)}return w.current=Ct,b(Ct),Le.map(St=>{var tn,yr;const Gt=Ze.get(St.id);return!Gt||!vs(((tn=Gt.data)==null?void 0:tn.definitionId)||((yr=St.data)==null?void 0:yr.definitionId))?St:{...St,data:{...St.data,...Gt.data}}})})};for(;;){const{value:me,done:be}=await se.read();if(be)break;xe+=fe.decode(me,{stream:!0});const Ze=xe.split(`
153
+ `);xe=Ze.pop()||"";for(const st of Ze){if(!st.trim())continue;const Le=JSON.parse(st);if(Le.type==="error")throw new Error(Le.error||"Workspace run failed");if(Le.type==="stopped"){Ft.current=!0,Ce=Array.isArray(Le.order)?Le.order:Ce;continue}if(Le.type==="node-start"&&(gt(`Running ${Le.nodeId}...`),_n(Le.nodeId),_t(Le.nodeId,Le.definitionId,"running")),Le.type==="node-done"&&(yn(Le.nodeId),_t(Le.nodeId,Le.definitionId,"done")),Le.type==="status"&&Qe(Le.line||Le.message||""),Le.type==="paused"&&(Ke=Array.isArray(Le.nodeIds)?Le.nodeIds:[]),Le.type==="natural"&&(Le.kind==="thinking"?Ye(Le.text||""):ir(Le.kind,Le.text||"")),Le.type==="raw"){const Pt=bj(Le);Pt&&Ye(Pt),jt(Le)}Le.type==="graph"&&Le.graph&&or(Le.graph),Le.type==="done"&&(Le.graph&&or(Le.graph),Ce=Array.isArray(Le.order)?Le.order:[],Ke=Array.isArray(Le.pauseNodeIds)?Le.pauseNodeIds:Ke)}}if(xe.trim()){const me=JSON.parse(xe);if(me.type==="error")throw new Error(me.error||"Workspace run failed");if(me.type==="stopped"&&(Ft.current=!0),me.type==="node-start"&&(gt(`Running ${me.nodeId}...`),_n(me.nodeId),_t(me.nodeId,me.definitionId,"running")),me.type==="node-done"&&(yn(me.nodeId),_t(me.nodeId,me.definitionId,"done")),me.type==="status"&&Qe(me.line||me.message||""),me.type==="paused"&&(Ke=Array.isArray(me.nodeIds)?me.nodeIds:[]),me.type==="natural"&&(me.kind==="thinking"?Ye(me.text||""):ir(me.kind,me.text||"")),me.type==="raw"){const be=bj(me);be&&Ye(be),jt(me)}me.type==="graph"&&me.graph&&or(me.graph),me.type==="done"&&(me.graph&&or(me.graph),Ce=Array.isArray(me.order)?me.order:[],Ke=Array.isArray(me.pauseNodeIds)?me.pauseNodeIds:Ke)}Ft.current&&(_r(new Set),gn(me=>{var Ze;const be=((Ze=Object.entries(me).find(([,st])=>(st==null?void 0:st.status)==="running"))==null?void 0:Ze[0])||_;return be?{...me,[be]:{status:"stopped"}}:me})),gt(Ft.current?`Workspace run stopped: ${_}`:Ke.length?`Workspace run paused at ${Ke.join(", ")}`:`Workspace run done: ${Ce.length?Ce.join(" -> "):_}`),Qt(Ft.current?"stopped":Ke.length?"paused":"done"),Ft.current||await sr()}catch(ie){if(Ft.current||(ie==null?void 0:ie.name)==="AbortError"){_r(new Set),gn(se=>{var xe;const fe=((xe=Object.entries(se).find(([,Ce])=>(Ce==null?void 0:Ce.status)==="running"))==null?void 0:xe[0])||_;return fe?{...se,[fe]:{status:"stopped"}}:se}),gt(`Workspace run stopped: ${_}`),Me(se=>se.map(fe=>fe.id===X?{...fe,status:"stopped",endedAt:Date.now()}:fe));return}_r(new Set),gn(se=>{var xe;const fe=(xe=Object.entries(se).find(([,Ce])=>(Ce==null?void 0:Ce.status)==="running"))==null?void 0:xe[0];return fe?{...se,[fe]:{status:"failed"}}:se}),gt(String(ie.message||ie)),Me(se=>se.map(fe=>fe.id===X?{...fe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",error:!0,text:String(ie.message||ie),at:Date.now()}].slice(-160)}:fe))}finally{wt.current===Z&&(wt.current=null),Dt(""),_r(new Set)}},[ye,l,s,sr,i,N,$e,Hn,$n,c,a]),lo=m.useCallback(async()=>{try{const H=await(await fetch("/api/skills")).json().catch(()=>({})),X=Array.isArray(H.skills)?H.skills.map(J=>({key:String(J.key),name:String(J.name||J.id||J.key),description:J.description?String(J.description):"",sourceLabel:J.sourceLabel?String(J.sourceLabel):""})):[];kt(X),qr(!0)}catch{qr(!0)}},[]),Pi=m.useCallback(async()=>{try{const H=await(await fetch("/api/mcps")).json().catch(()=>({})),X=Array.isArray(H.servers)?H.servers.map(J=>({name:String((J==null?void 0:J.name)||""),type:String((J==null?void 0:J.type)||""),url:String((J==null?void 0:J.url)||""),command:String((J==null?void 0:J.command)||""),args:Array.isArray(J==null?void 0:J.args)?J.args.map(String):[],description:String((J==null?void 0:J.description)||"")})).filter(J=>J.name):[];Zs(X)}catch{Zs([])}},[]);m.useEffect(()=>{Fr().catch(_=>gt(String(_.message||_))),_i(),fetch("/api/model-lists").then(_=>_.json()).then(_=>nr({cursor:Array.isArray(_.cursor)?_.cursor.map(String):[],opencode:Array.isArray(_.opencode)?_.opencode.map(String):[],claudeCode:Array.isArray(_.claudeCode)?_.claudeCode.map(String):[]})).catch(()=>{}),lo(),Pi(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{Fo(va(_)),zo(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>Te(_.user||null)).catch(()=>Te(null))},[Fr,_i,Pi,lo,Os]),m.useEffect(()=>{if(cu(""),!(!Ut||!so)){if(!Os){Gn([]);return}Gn(QE(Os,"workspace",$t,rr)),cu(Os)}},[rr,so,$t,Ut,Os]),m.useEffect(()=>{if(!(Ms!==Os||!Os))try{localStorage.setItem(Os,JSON.stringify($n))}catch{}},[$n,Os,Ms]),m.useEffect(()=>{w.current=y},[y]),m.useEffect(()=>{u.current=i},[i]),m.useEffect(()=>{f.current=l},[l]),m.useEffect(()=>{g.current=v},[v]),m.useEffect(()=>{if(!v)return;const _=X=>{X.key==="Escape"&&k(null)},H=X=>{var J,Z;(Z=(J=X.target)==null?void 0:J.closest)!=null&&Z.call(J,".af-connect-node-menu")||k(null)};return document.addEventListener("keydown",_),document.addEventListener("pointerdown",H),()=>{document.removeEventListener("keydown",_),document.removeEventListener("pointerdown",H)}},[v]),m.useEffect(()=>{if(S.current)return C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{Hn().catch(_=>gt(String(_.message||_)))},650),()=>{C.current&&window.clearTimeout(C.current)}},[i,l,Hn]);const za=m.useCallback((_,H)=>{const X=FK(H),J=xe=>Array.isArray(xe)?xe.map(Ce=>(Ce==null?void 0:Ce.name)!=="skillKeys"&&(Ce==null?void 0:Ce.name)!=="skillsContext"&&(Ce==null?void 0:Ce.type)!=="text"?Ce:{...Ce,default:X,value:X}):[],Z=i.map(xe=>{var Ce;return xe.id!==_?xe:{...xe,data:{...xe.data,body:X,inputs:J((Ce=xe.data)==null?void 0:Ce.inputs)}}}),ie=w.current||{},se=ie[_]&&typeof ie[_]=="object"?ie[_]:{},fe={...ie,[_]:{...se,body:X,input:J(se.input)}};w.current=fe,a(Z),b(fe),De(xe=>!xe||xe.id!==_?xe:{...xe,body:X,inputs:J(xe.inputs)}),Hn(Z,l).catch(xe=>gt(String(xe.message||xe)))},[l,i,Hn,a]),du=m.useCallback((_,H)=>{const X=BK(H),J=xe=>Array.isArray(xe)?xe.map(Ce=>(Ce==null?void 0:Ce.name)!=="serverNames"&&(Ce==null?void 0:Ce.name)!=="mcpContext"&&(Ce==null?void 0:Ce.type)!=="text"?Ce:{...Ce,default:X,value:X}):[],Z=i.map(xe=>{var Ce;return xe.id!==_?xe:{...xe,data:{...xe.data,body:X,inputs:J((Ce=xe.data)==null?void 0:Ce.inputs)}}}),ie=w.current||{},se=ie[_]&&typeof ie[_]=="object"?ie[_]:{},fe={...ie,[_]:{...se,body:X,input:J(se.input)}};w.current=fe,a(Z),b(fe),De(xe=>!xe||xe.id!==_?xe:{...xe,body:X,inputs:J(xe.inputs)}),Hn(Z,l).catch(xe=>gt(String(xe.message||xe)))},[l,i,Hn,a]),Vo=m.useCallback(_=>{const H=String(_||"").trim();H&&(ti(X=>X===H?"":H),gr(X=>({...X,[H]:X[H]||{sessionId:`nodechat_${Date.now()}_${H.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Ba=m.useCallback((_,H)=>{const X=String(_||"").trim();X&&gr(J=>({...J,[X]:{...J[X]||{sessionId:`nodechat_${Date.now()}_${X.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(H||""),error:""}}))},[]),co=m.useCallback((_,H,X="replace",J={})=>{var ir;const Z=String(_||"").trim();if(!Z)return;const ie=u.current.find(Ye=>Ye.id===Z),se=vs((ir=ie==null?void 0:ie.data)==null?void 0:ir.definitionId),fe=se==="html"?QI(H):String(H||""),xe=ie?bd(ie.data):"",Ce=X==="append"&&String(xe||"").trim()?`${String(xe).replace(/\s+$/g,"")}
154
+
155
+ ${fe.trim()}`:fe,Ke=se==="image"?"src":"content",Lt=Ye=>{let Qe=!1;return(Array.isArray(Ye)?Ye:[]).map(Qt=>{const or=String((Qt==null?void 0:Qt.name)||""),me=String((Qt==null?void 0:Qt.type)||"");return!Qe&&(or===Ke||or==="filePath"||me==="text")?(Qe=!0,{...Qt,default:Ce,value:Ce}):Qt})},dt=u.current.map(Ye=>{var Qe,jt;return Ye.id!==Z?Ye:{...Ye,data:{...Ye.data,body:Ce,inputs:Lt((Qe=Ye.data)==null?void 0:Qe.inputs),outputs:Lt((jt=Ye.data)==null?void 0:jt.outputs)}}}),_t=w.current||{},_n=_t[Z]&&typeof _t[Z]=="object"?_t[Z]:{},yn={..._t,[Z]:{..._n,body:Ce,input:Lt(_n.input),output:Lt(_n.output)}};w.current=yn,a(dt),b(yn),De(Ye=>(Ye==null?void 0:Ye.id)===Z?{...Ye,body:Ce}:Ye),(J==null?void 0:J.logChat)!==!1&&gr(Ye=>{var Qe;return{...Ye,[Z]:{...Ye[Z]||{},candidateContent:"",messages:[...(Qe=Ye[Z])!=null&&Qe.messages&&Array.isArray(Ye[Z].messages)?Ye[Z].messages:[],{role:"assistant",text:X==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Hn(dt,f.current).catch(Ye=>gt(String(Ye.message||Ye))),gt(String((J==null?void 0:J.statusMessage)||"")||(X==="append"?"已追加节点内容":"已替换节点内容"))},[Hn,a]),Ll=m.useCallback((_,H="replace")=>{var Z;const X=String(_||"").trim(),J=String(((Z=Vt[X])==null?void 0:Z.candidateContent)||"").trim();!X||!J||co(X,J,H)},[Vt,co]),Ha=m.useCallback(async(_,H=void 0)=>{var Ce,Ke,Lt;const X=String(_||"").trim();if(!X)return;const J=Vt[X]||{},Z=String(H!==void 0?H:J.draft||"").trim();if(!Z||J.running)return;const ie=u.current.find(dt=>dt.id===X);if(!ie)return;const se={role:"user",text:Z,at:Date.now()},fe=Array.isArray(J.messages)?J.messages:[],xe=J.sessionId||`nodechat_${Date.now()}_${X.replace(/[^a-z0-9_-]+/gi,"_")}`;gr(dt=>({...dt,[X]:{...J,sessionId:xe,messages:[...fe,se],draft:"",running:!0,error:""}}));try{const dt=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:xe,node:{id:X,label:((Ce=ie.data)==null?void 0:Ce.label)||X,definitionId:((Ke=ie.data)==null?void 0:Ke.definitionId)||""},nodeKind:vs((Lt=ie.data)==null?void 0:Lt.definitionId)||"markdown",currentContent:bd(ie.data),messages:fe,message:Z,model:ye})}),_t=await dt.json().catch(()=>({}));if(!dt.ok)throw new Error(_t.error||"节点微调失败");const _n=String(_t.candidateContent||_t.reply||"").trim();gr(yn=>{var ir;return{...yn,[X]:{...yn[X]||{},sessionId:String(_t.sessionId||xe),running:!1,candidateContent:_n,messages:[...(ir=yn[X])!=null&&ir.messages&&Array.isArray(yn[X].messages)?yn[X].messages:[...fe,se],{role:"assistant",text:_n||"已生成候选内容。",at:Date.now()}]}}})}catch(dt){const _t=String(dt.message||dt);gr(_n=>({..._n,[X]:{..._n[X]||{},running:!1,error:_t}})),gt(_t)}},[ye,s,Vt]),If=m.useCallback(async(_,H)=>{const X=bd(H);if(!String(X||"").trim()){gt("展示节点没有可保存内容");return}const J=AK(_,H),Z=window.prompt("保存到 workspace 相对路径",J);if(Z)try{const ie=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Z,content:X})}),se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(se.error||"保存文件失败");const fe=se.path||Z,xe=Bu(s);xe.set("path",fe);const Ce=await fetch(`/api/workspace/file?${xe.toString()}`);if(!Ce.ok){const Ke=await Ce.json().catch(()=>({}));throw new Error(Ke.error||`保存后读取失败:${fe}`)}await sr(),fr(Ke=>MK(Ke,fe,String(X||"").length)),nt(Ke=>{const Lt=new Set(Ke);for(const dt of Dy(fe))Lt.delete(dt);return Lt}),gt(`已保存 ${fe}`)}catch(ie){gt(String(ie.message||ie))}},[s,sr]),$s=m.useCallback((_,H)=>{const X=String(_||"");X&&De(J=>{if(!J||J.id!==X)return J;const Z=typeof H=="function"?H(J):H;return!Z||typeof Z!="object"?J:{...J,...Z}})},[]),Va=m.useMemo(()=>i.map(_=>{var H,X;return{..._,data:{..._.data,selected:_.selected===!0,modelLists:Bt,showBodyPreview:!0,isExecuting:Dr.has(_.id),nodeStatus:((H=ao[_.id])==null?void 0:H.status)??null,nodeElapsed:((X=ao[_.id])==null?void 0:X.elapsed)??null,onRunWorkspaceNode:Jn,onStopWorkspaceNode:Ho,runningRunNodeId:$e,skills:$t,skillCollections:rr,onChangeLoadSkillKeys:za,onRefreshSkills:lo,mcpServers:Qs,onChangeLoadMcpNames:du,onRefreshMcps:Pi,onSaveDisplayNodeToFile:If,nodeChatActive:Ei===_.id,nodeChat:Vt[_.id]||null,onSetDisplayNodeContent:co,onToggleNodeChat:Vo,onCloseNodeChat:()=>ti(""),onUpdateNodeChatDraft:Ba,onSendNodeChat:Ha,onApplyNodeChatCandidate:Ll,onSyncNodePropDraft:$s}}}),[Ei,Ll,du,za,Qs,Bt,Vt,i,Pi,lo,Jn,$e,If,Ha,co,rr,$t,Ho,$s,Vo,Ba,Dr,ao]),Rt=m.useMemo(()=>i.find(_=>_.id===xt)||null,[i,xt]),uo=m.useRef({id:"",draft:null}),fu=m.useMemo(()=>{const _=Cj(Rt);return _?JSON.stringify(_):""},[Rt]);m.useEffect(()=>{if(!Rt){uo.current={id:"",draft:null},De(null),Nt("");return}const _=Cj(Rt),H=uo.current;uo.current={id:Rt.id,draft:_},De(X=>!X||X.id!==Rt.id||H.id!==Rt.id||!H.draft?_:VK(X,H.draft,_)),Nt("")},[Rt==null?void 0:Rt.id,fu]);const Ol=m.useCallback((_=!1)=>{var ir,Ye;if(!ee||!Rt)return!1;const H=Rt.id,X=String(ee.newId||"").trim(),J=_?X:H;if(Nt(""),_){if(!DI.test(J))return Nt("Invalid instance id"),!1;if(i.some(Qe=>Qe.id===J&&Qe.id!==H))return Nt("Duplicate instance id"),!1}const Z=String(ee.role||"").trim(),ie=Pa.includes(Z)?Z:"normal",se=String(ee.model||"").trim(),fe=Qe=>(Array.isArray(Qe)?Qe:[]).map(jt=>({type:String((jt==null?void 0:jt.type)??"node").trim()||"node",name:String((jt==null?void 0:jt.name)??""),default:String((jt==null?void 0:jt.default)??""),required:!!(jt!=null&&jt.required),showOnNode:(jt==null?void 0:jt.showOnNode)!=null?jt.showOnNode!==!1:!!(jt!=null&&jt.required)||String((jt==null?void 0:jt.type)??"node").trim().toLowerCase()==="node"})),xe=String(((ir=Rt.data)==null?void 0:ir.definitionId)??J),Ce=xe.startsWith("provide_"),Ke={...Rt.data,label:String(ee.label||"").trim()||J,role:ie,model:se===""||se==="default"?void 0:se,body:Ce?"":String(ee.body??""),images:Ce?[]:is(ee.images),inputs:fe(ee.inputs),outputs:Ce&&Array.isArray((Ye=Rt.data)==null?void 0:Ye.outputs)?Rt.data.outputs:fe(ee.outputs)},Lt=String(ee.script??"").trim();xe==="tool_nodejs"||Lt!==""?Ke.script=String(ee.script??""):delete Ke.script;const dt=Rt.data||{};if(!(J!==H||dt.label!==Ke.label||dt.role!==Ke.role||dt.model!==Ke.model||dt.body!==Ke.body||JSON.stringify(is(dt.images))!==JSON.stringify(Ke.images)||(dt.script??void 0)!==(Ke.script??void 0)||JSON.stringify(dt.inputs||[])!==JSON.stringify(Ke.inputs||[])||JSON.stringify(dt.outputs||[])!==JSON.stringify(Ke.outputs||[])))return!0;let _n=i.map(Qe=>Qe.id===H?{...Qe,id:J,selected:!0,data:Ke}:Qe),yn=l;if(J!==H){const Qe={...w.current},jt={...Qe[H]||{}};delete Qe[H],Qe[J]=jt,w.current=Qe,b(Qe),yn=l.map((Qt,or)=>({...Qt,source:Qt.source===H?J:Qt.source,target:Qt.target===H?J:Qt.target,id:`we-${Qt.source===H?J:Qt.source}-${Qt.target===H?J:Qt.target}-${or}`})),Fe(J)}return a(_n),c(yn),Cr(J),!0},[l,ee,i,Rt,c,a,Cr]);m.useEffect(()=>{if(!ee||!Rt)return;const _=window.setTimeout(()=>{Ol(!1)},350);return()=>window.clearTimeout(_)},[ee==null?void 0:ee.label,ee==null?void 0:ee.role,ee==null?void 0:ee.model,ee==null?void 0:ee.body,JSON.stringify((ee==null?void 0:ee.images)||[]),ee==null?void 0:ee.script,JSON.stringify((ee==null?void 0:ee.inputs)||[]),JSON.stringify((ee==null?void 0:ee.outputs)||[]),Ol,Rt==null?void 0:Rt.id]);const Ml=m.useMemo(()=>{const _=new Map(Va.map(H=>[H.id,H]));return l.map(H=>{var Ce,Ke,Lt,dt;const X=_.get(H.source),J=_.get(H.target),Z=/^output-(\d+)$/.exec(H.sourceHandle||""),ie=/^input-(\d+)$/.exec(H.targetHandle||""),se=X&&Z?(Ke=(Ce=X.data)==null?void 0:Ce.outputs)==null?void 0:Ke[parseInt(Z[1],10)]:null,fe=J&&ie?(dt=(Lt=J.data)==null?void 0:Lt.inputs)==null?void 0:dt[parseInt(ie[1],10)]:null,xe=se!=null&&se.type?On(se.type):fe!=null&&fe.type?On(fe.type):"";return xe?{...H,style:{...H.style||{},stroke:xe,strokeWidth:2},markerEnd:{type:us.ArrowClosed,color:xe}}:H})},[l,Va]),$l=m.useMemo(()=>{const _=M.trim().toLowerCase(),H={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const X of N)_&&![X.id,X.label,X.displayName,X.description].some(J=>String(J||"").toLowerCase().includes(_))||H[ed(X)].push(X);for(const X of nc)H[X].sort((J,Z)=>J.id.localeCompare(Z.id));return H},[N,M]),Ds=m.useMemo(()=>{const _=Ie.trim().toLowerCase();return N.filter(H=>!_||[H.id,H.label,H.displayName,H.description].some(X=>String(X||"").toLowerCase().includes(_))).sort((H,X)=>{const J=nc.indexOf(ed(H)),Z=nc.indexOf(ed(X));return J!==Z?J-Z:td(H).localeCompare(td(X))}).slice(0,30)},[N,Ie]),Ai=m.useMemo(()=>{const _=Ie.trim().toLowerCase();return L.filter(H=>!_||[H.id,H.version,H.displayName,H.name,H.description,...Array.isArray(H.tags)?H.tags:[]].some(X=>String(X||"").toLowerCase().includes(_))).sort((H,X)=>String(H.displayName||H.name||H.id).localeCompare(String(X.displayName||X.name||X.id))).slice(0,30)},[L,Ie]);m.useEffect(()=>{Ge(0)},[Ie,de,Ne]),m.useEffect(()=>{if(!de)return;const _=window.setTimeout(()=>{var H;return(H=rt.current)==null?void 0:H.focus()},0);return()=>window.clearTimeout(_)},[de]);const pu=m.useMemo(()=>{const _=ve.trim().toLowerCase();return _?tT(en).filter(H=>H.path.toLowerCase().includes(_)):en},[ve,en]),Gr=[...(Bt.cursor||[]).map(_=>({label:`Cursor · ${_.split(" - ")[0]}`,value:`cursor:${_.split(" - ")[0]}`})),...(Bt.opencode||[]).map(_=>({label:`OpenCode · ${_.split(" - ")[0]}`,value:`opencode:${_.split(" - ")[0]}`})),...(Bt.claudeCode||[]).map(_=>({label:`Claude · ${_.split(" - ")[0]}`,value:`claude-code:${_.split(" - ")[0]}`}))],fo=m.useMemo(()=>new Set($n),[$n]),ni=m.useMemo(()=>{const _=new Map($t.map(ie=>[ie.key,ie])),H=new Set,X=new Set,J=rr.map(ie=>{const se=Ea(ie,$t).map(fe=>_.get(fe)).filter(Boolean);for(const fe of se)H.add(fe.key),X.add(String(fe.name||fe.id||fe.key||"").trim());return{...ie,skills:se}}).filter(ie=>ie.skills.length>0),Z=$t.filter(ie=>{const se=String(ie.name||ie.id||ie.key||"").trim();return!H.has(ie.key)&&!X.has(se)});return{groups:J,ungrouped:Z}},[rr,$t]);m.useEffect(()=>{oo(_=>{let H=!1;const X=new Set(_);for(const J of ni.groups)X.has(J.id)||(X.add(J.id),H=!0);return H?X:_})},[ni.groups]);const En=m.useMemo(()=>{const _=i.filter(H=>H.selected);return _.length>0?_:xt?i.filter(H=>H.id===xt):[]},[i,xt]),Ii=m.useMemo(()=>En.map(_=>_.id),[En]),Wa=m.useMemo(()=>{const _=String((Se==null?void 0:Se.username)||(Se==null?void 0:Se.userId)||"").trim();return _?_.slice(0,1).toUpperCase():"?"},[Se]),hu=m.useMemo(()=>new Set(Ii),[Ii]),Wo=m.useMemo(()=>l.filter(_=>hu.has(_.source)&&hu.has(_.target)),[l,hu]),Ua=m.useMemo(()=>{const _=M.trim().toLowerCase();return _?L.filter(H=>[H.id,H.version,H.displayName,H.name,H.description,...Array.isArray(H.tags)?H.tags:[]].filter(Boolean).some(X=>String(X).toLowerCase().includes(_))):L},[L,M]),Uo=m.useCallback((_,H)=>{const X=String(_||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let J=`${X}_${Date.now().toString(36)}`,Z=2;for(;H.has(J);)J=`${X}_${Date.now().toString(36)}_${Z}`,Z+=1;return H.add(J),J},[]),po=m.useCallback((_,H)=>{var Qt,or;const X=_!=null&&_.snippet&&typeof _.snippet=="object"?_.snippet:{},J=X.instances&&typeof X.instances=="object"?X.instances:{},Z=Object.keys(J);if(Z.length===0)return;const ie=new Set(u.current.map(me=>me.id)),se={};for(const me of Z)se[me]=Uo(me,ie);const fe=(Qt=X.ui)!=null&&Qt.nodePositions&&typeof X.ui.nodePositions=="object"?X.ui.nodePositions:{},xe=(or=X.ui)!=null&&or.nodeSizes&&typeof X.ui.nodeSizes=="object"?X.ui.nodeSizes:{},Ce=Z.map(me=>{const be=fe[me];return{id:me,x:typeof(be==null?void 0:be.x)=="number"?be.x:0,y:typeof(be==null?void 0:be.y)=="number"?be.y:0}}),Ke=Math.min(...Ce.map(me=>me.x)),Lt=Math.min(...Ce.map(me=>me.y));let dt=H||{x:360+u.current.length*24,y:180+u.current.length*18};if(!H){const me=document.querySelector(".af-workspace-canvas .react-flow");if(me){const be=me.getBoundingClientRect();dt=n.screenToFlowPosition({x:be.left+be.width*.48,y:be.top+be.height*.32})}}const _t={},_n={},yn={};for(const me of Ce){const be=se[me.id];_t[be]={...J[me.id]||{}},_n[be]={x:dt.x+(me.x-Ke),y:dt.y+(me.y-Lt)};const Ze=xe[me.id];typeof(Ze==null?void 0:Ze.width)=="number"&&typeof(Ze==null?void 0:Ze.height)=="number"&&(yn[be]={width:Ze.width,height:Ze.height})}const ir=new Set(Z),Ye=(Array.isArray(X.edges)?X.edges:[]).filter(me=>ir.has(me==null?void 0:me.source)&&ir.has(me==null?void 0:me.target)).map(me=>({source:se[me.source],target:se[me.target],sourceHandle:me.sourceHandle??null,targetHandle:me.targetHandle??null})),Qe=$y({instances:_t,edges:Ye,ui:{nodePositions:_n,nodeSizes:yn}},N),jt=Qe.nodes.map(me=>({...me,selected:!0}));w.current={...w.current,...Qe.instances},b(w.current),a(me=>[...me.map(be=>({...be,selected:!1})),...jt]),c(me=>[...me.map(be=>({...be,selected:!1})),...Qe.edges]),gt(`已添加流程片段:${_.displayName||_.id}`)},[Uo,N,n,c,a]),Tf=m.useCallback(()=>{var X,J;if(En.length<2){B("请先在 workspace 画布上选择至少两个节点。"),O("flows");return}const _=En[0],H=En.length===2?`${((X=_.data)==null?void 0:X.label)||_.id} 片段`:`${((J=_.data)==null?void 0:J.label)||_.id} 等 ${En.length} 个节点`;Y({name:H,id:H.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ue(""),T(!0),O("flows")},[En]),mu=m.useCallback(async()=>{var Z,ie;if(En.length<2)return;const _=E.name.trim();if(!_){ue("请填写片段名称。");return}const H={},X={};for(const se of En){H[se.id]={x:((Z=se.position)==null?void 0:Z.x)||0,y:((ie=se.position)==null?void 0:ie.y)||0};const fe=XI(se);fe&&(X[se.id]=fe)}const J=Wo.map(se=>({source:se.source,target:se.target,sourceHandle:se.sourceHandle??null,targetHandle:se.targetHandle??null}));U(!0),ue("");try{const se=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:E.id,name:_,displayName:_,version:"1.0.0",description:E.description,snippet:{instances:Nf(En,w.current),edges:J,ui:{nodePositions:H,nodeSizes:X}}})}),fe=await se.json().catch(()=>({}));if(!se.ok||fe.ok===!1)throw new Error(fe.error||"发布流程片段失败");T(!1),gt(`流程片段已发布:${fe.id||_}`),Ni(`流程片段已发布:${fe.id||_}`),await _i(),O("flows")}catch(se){ue(String(se.message||se))}finally{U(!1)}},[_i,E,Wo,En,Ni]),gu=m.useCallback(_=>{a(H=>H.map(X=>X.id===_?{...X,selected:!1}:X)),Fe(H=>H===_?"":H)},[a]),Fs=m.useCallback(()=>{const _=Xt.current;if(!_)return;const H=_.getBoundingClientRect(),X=Math.min(420,Math.max(320,H.width+160)),J=12,Z=Math.max(180,H.top-J*2),ie=Math.min(560,Z);Er({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-X-12,H.left)),top:Math.max(J,H.top-ie-J),width:X,maxHeight:ie,zIndex:1e4})},[]);m.useEffect(()=>{if(!As)return;Fs();const _=X=>{var Z,ie;const J=X.target;(Z=Xt.current)!=null&&Z.contains(J)||(ie=Bn.current)!=null&&ie.contains(J)||_e(!1)},H=X=>{X.key==="Escape"&&_e(!1)};return window.addEventListener("pointerdown",_),window.addEventListener("keydown",H),window.addEventListener("resize",Fs),window.addEventListener("scroll",Fs,!0),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",H),window.removeEventListener("resize",Fs),window.removeEventListener("scroll",Fs,!0)}},[As,Fs]);const lg=m.useCallback(_=>{var X,J;const H=new Map;for(const Z of _||[])(Z==null?void 0:Z.type)==="dimensions"&&((X=Z.dimensions)!=null&&X.width)&&((J=Z.dimensions)!=null&&J.height)&&H.set(Z.id,{width:Math.round(Number(Z.dimensions.width)),height:Math.round(Number(Z.dimensions.height))});a(Z=>Zb(_,Z).map(ie=>{var fe;const se=H.get(ie.id);return se?vs((fe=ie.data)==null?void 0:fe.definitionId)?{...ie,width:se.width,height:se.height,data:{...ie.data,displaySize:se}}:{...ie,width:se.width,height:se.height}:ie}))},[a]),Ko=m.useCallback(()=>{const _=document.querySelector(".af-workspace-canvas .react-flow");if(_){const H=_.getBoundingClientRect();return n.screenToFlowPosition({x:H.left+H.width*.48,y:H.top+H.height*.32})}return{x:360+i.length*36,y:180+i.length*28}},[i.length,n]),ft=m.useCallback(()=>{var _,H,X;if(Rt){const J=Number(((_=Rt.measured)==null?void 0:_.width)||Rt.width||260);return{x:Number(((H=Rt.position)==null?void 0:H.x)||0)+J+140,y:Number(((X=Rt.position)==null?void 0:X.y)||0)}}return Ko()},[Ko,Rt]),gs=m.useCallback((_,H={})=>{if(!_)return null;const X=jv(_)||_.id,J=GI(_),Z=H.id||fK(X,i),ie=Fp(_.inputs),se=Fp(_.outputs),fe={definitionId:X,...J?{marketplaceRef:J}:{},..._.packageId?{marketplacePackageId:_.packageId}:{},..._.version?{marketplaceVersion:_.version}:{},label:H.label||um(_),role:"normal",body:H.body||"",input:H.inputs||ie,output:H.outputs||se},xe={id:Z,type:jf,position:H.position||Ko(),data:{label:fe.label,definitionId:X,...J?{marketplaceRef:J}:{},..._.packageId?{marketplacePackageId:_.packageId}:{},..._.version?{marketplaceVersion:_.version}:{},schemaType:YI(X,_),role:"normal",body:fe.body,inputs:fe.input,outputs:fe.output}},Ce={...nf(xe,{...w.current,[Z]:fe},N),selected:!0};return a(Ke=>[...Ke.map(Lt=>({...Lt,selected:!1})),Ce]),H.openProperties&&Fe(Z),Z},[Ko,i,N,a]),cg=m.useCallback(_=>Nj(_,u.current),[]),Dl=m.useCallback(_=>{if(!Nj(_,u.current)){gt("端口类型不匹配,已取消连线");return}k(null),a(H=>am(H,_)),c(H=>{const X=H.filter(J=>!(J.target===_.target&&J.targetHandle===_.targetHandle));return Yd({..._,markerEnd:{type:us.ArrowClosed}},X)})},[c,a]),pt=m.useCallback((_,H)=>{h.current=uK(H,u.current),k(null)},[]),ug=m.useCallback((_,H)=>{var dt,_t,_n,yn;const X=h.current;if(h.current=null,!X||H!=null&&H.toNode)return;const J=dK(N,X);if(J.length===0){gt(`没有匹配 ${X.slotType} 端口的节点`);return}const Z=((_t=(dt=_==null?void 0:_.changedTouches)==null?void 0:dt[0])==null?void 0:_t.clientX)??(_==null?void 0:_.clientX),ie=((yn=(_n=_==null?void 0:_.changedTouches)==null?void 0:_n[0])==null?void 0:yn.clientY)??(_==null?void 0:_.clientY);if(!Number.isFinite(Z)||!Number.isFinite(ie))return;const se=document.querySelector(".af-workspace-canvas .react-flow");if(!se)return;const fe=se.getBoundingClientRect(),xe=320,Ce=Math.min(440,104+J.length*58),Ke=Math.max(12,Math.min(Z-fe.left,fe.width-xe-12)),Lt=Math.max(12,Math.min(ie-fe.top,fe.height-Ce-12));k({left:Ke,top:Lt,flowPosition:n.screenToFlowPosition({x:Z,y:ie}),draft:X,candidates:J,query:""})},[N,n]),ho=m.useCallback(_=>{const H=g.current;if(!H||!(_!=null&&_.def))return;const X=gs(_.def,{position:H.flowPosition});if(!X)return;const J=H.draft.handleType==="source"?{source:H.draft.nodeId,sourceHandle:H.draft.handleId,target:X,targetHandle:`input-${_.slotIndex}`}:{source:X,sourceHandle:`output-${_.slotIndex}`,target:H.draft.nodeId,targetHandle:H.draft.handleId};a(Z=>am(Z,J)),c(Z=>{const ie=Z.filter(se=>!(se.target===J.target&&se.targetHandle===J.targetHandle));return Yd({...J,markerEnd:{type:us.ArrowClosed}},ie)}),k(null)},[gs,c]),yu=m.useCallback(_=>{_&&(gs(_,{position:ft()}),Ae(!1),qe(""))},[gs,ft]),Fl=m.useCallback(_=>{_&&(po(_,ft()),Ae(!1),qe(""))},[po,ft]);m.useEffect(()=>{const _=H=>{if(H.defaultPrevented)return;const X=RI(H.target)||lK(H.target);if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="s"){H.preventDefault(),Hn().catch(se=>gt(String(se.message||se)));return}if(Yr){(H.key==="Escape"||cm(H))&&(H.preventDefault(),Ls(!1));return}if(X)return;const J=H.key.toLowerCase(),Z=(H.metaKey||H.ctrlKey)&&!H.shiftKey&&J==="z",ie=(H.metaKey||H.ctrlKey)&&(H.shiftKey&&J==="z"||J==="y");if(Z||ie){H.preventDefault(),H.stopPropagation();const se=Z?Il():Fa();gt(se?Z?"Undo canvas change":"Redo canvas change":Z?"Nothing to undo":"Nothing to redo");return}if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="c"){const se=NI(u.current,f.current,w.current);se&&(H.preventDefault(),H.stopPropagation(),p.current=se,gt(`Copied ${se.nodes.length} node${se.nodes.length>1?"s":""}`));return}if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="v"){const se=jI(p.current,u.current,f.current,w.current);se&&(H.preventDefault(),H.stopPropagation(),w.current=se.instances,b(se.instances),a(se.nodes),c(se.edges),gt(`Pasted ${se.pastedNodeIds.length} node${se.pastedNodeIds.length>1?"s":""}`));return}if(cm(H)&&!H.metaKey&&!H.ctrlKey&&!H.altKey){H.preventDefault(),Ls(!0);return}if(H.key==="a"||H.key==="A"){if(H.metaKey||H.ctrlKey){H.preventDefault(),a(se=>se.map(fe=>({...fe,selected:!0}))),c(se=>se.map(fe=>({...fe,selected:!1})));return}if(H.altKey)return;H.preventDefault(),Ae(!0);return}if((H.key==="v"||H.key==="V")&&!H.metaKey&&!H.ctrlKey&&!H.altKey){H.preventDefault(),he("select");return}(H.key==="h"||H.key==="H")&&!H.metaKey&&!H.ctrlKey&&!H.altKey&&(H.preventDefault(),he("pan"))};return window.addEventListener("keydown",_,!0),()=>window.removeEventListener("keydown",_,!0)},[Fa,Hn,Yr,c,a,Il]);const Dv=m.useCallback(_=>{nt(H=>{const X=new Set(H);return X.has(_)?X.delete(_):X.add(_),X})},[]),ri=m.useCallback((_,H)=>{_.dataTransfer.effectAllowed="copy",_.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:H.path,name:H.name,type:H.type})),_.dataTransfer.setData("text/plain",H.path)},[]),dg=m.useCallback((_,H)=>{_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("application/agentflow-node",H.id),_.dataTransfer.setData("text/plain",H.id)},[]),zs=m.useCallback(async(_,H)=>{const X=String((_==null?void 0:_.name)||(_==null?void 0:_.path)||"").toLowerCase(),J=X.split(".").pop(),Z=J==="html"?"display_html":J==="csv"||J==="tsv"||J==="json"&&/\b(table|data|rows|report)\b/i.test(X)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(J)?"display_image":"display_markdown",ie=N.find(_t=>_t.id===Z);if(!ie){gt("展示节点不可用");return}const se=Bu(s);se.set("path",_.path);const fe=await fetch(`/api/workspace/file?${se.toString()}`),xe=await fe.json();if(!fe.ok)throw new Error(xe.error||"读取文件失败");const Ce=String(xe.content||""),Ke=Z==="display_image"?"src":"content",Lt=Fp(ie.inputs).map(_t=>_t.name===Ke?{..._t,default:Ce,value:Ce}:_t),dt=Fp(ie.outputs).map(_t=>_t.name===Ke?{..._t,default:Ce,value:Ce}:_t);gs(ie,{label:_.name||"Display",body:Ce,inputs:Lt,outputs:dt,position:H}),gt(`已创建展示:${_.path}`)},[gs,s,N]),Ka=m.useCallback(_=>{zs(_,Ko()).catch(H=>gt(String(H.message||H)))},[zs,Ko]),Rf=m.useCallback(_=>{const H=_.dataTransfer.getData("application/x-agentflow-workspace-file");if(H){_.preventDefault();let se;try{se=JSON.parse(H)}catch{return}if(!(se!=null&&se.path))return;const fe=n.screenToFlowPosition({x:_.clientX,y:_.clientY});zs(se,fe).catch(xe=>gt(String(xe.message||xe)));return}const X=_.dataTransfer.getData("application/agentflow-snippet");if(X){const se=L.find(xe=>`${xe.id}@${xe.version}`===X);if(!se)return;_.preventDefault();const fe=n.screenToFlowPosition({x:_.clientX,y:_.clientY});po(se,fe);return}const J=_.dataTransfer.getData("application/agentflow-node");if(!J)return;const Z=N.find(se=>se.id===J);if(!Z)return;_.preventDefault();const ie=n.screenToFlowPosition({x:_.clientX,y:_.clientY});gs(Z,{position:ie})},[zs,gs,L,po,N,n]),fg=m.useCallback(_=>{const H=Array.from(_.dataTransfer.types||[]);!H.includes("application/x-agentflow-workspace-file")&&!H.includes("application/agentflow-node")&&!H.includes("application/agentflow-snippet")||(_.preventDefault(),_.dataTransfer.dropEffect=H.includes("application/agentflow-node")||H.includes("application/agentflow-snippet")?"move":"copy")},[]),qa=m.useCallback(async(_="")=>{const H=window.prompt("新文件名",_?`${_}/notes.md`:"notes.md");if(!H)return;const X=_&&!H.includes("/")?`${_}/${H}`:H;try{const J=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:X,content:""})}),Z=await J.json();if(!J.ok)throw new Error(Z.error||"创建文件失败");await sr(),nt(ie=>{const se=new Set(ie);for(const fe of Dy(Z.path||X))se.delete(fe);return se}),gt(`已创建 ${Z.path}`)}catch(J){gt(String(J.message||J))}},[s,sr]),Lf=m.useCallback(async(_="")=>{const H=window.prompt("新文件夹名",_?`${_}/docs`:"docs");if(!H)return;const X=_&&!H.includes("/")?`${_}/${H}`:H;try{const J=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:X})}),Z=await J.json();if(!J.ok)throw new Error(Z.error||"创建文件夹失败");await sr(),nt(ie=>{const se=new Set(ie);for(const fe of Dy(Z.path||X))se.delete(fe);return Z.path&&se.delete(Z.path),se}),gt(`已创建 ${Z.path}`)}catch(J){gt(String(J.message||J))}},[s,sr]),Of=m.useCallback(async _=>{if(!(!(_!=null&&_.path)||!window.confirm(`删除 ${_.path}?`)))try{const H=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:_.path})}),X=await H.json();if(!H.ok)throw new Error(X.error||"删除失败");gt(`已删除 ${X.path}`),await sr()}catch(H){gt(String(H.message||H))}},[s,sr]),Mf=m.useCallback(async()=>{const _=mn.trim();if(!_||Jt)return;const H=zp(i,l,w.current);mr(""),at(!0),Rl("workspace"),Kt(X=>[...X,{role:"user",text:_,at:Date.now()}]);try{await Hn(i,l);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,prompt:_,outputKind:"markdown",workspaceGraph:H,allowFlowYaml:!1,model:ye,selectedSkills:$n,selectedNodeIds:Ii})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const Z=String(J.content||"").trim();Kt(ie=>[...ie,{role:"assistant",text:Z,at:Date.now()}]),await Fr(),gt("AI 生成完成")}catch(X){const J=String(X.message||X);Kt(Z=>[...Z,{role:"assistant",text:J,error:!0,at:Date.now()}]),gt(J)}finally{at(!1)}},[ye,Jt,mn,l,s,Fr,i,Rl,Hn,Ii,$n]),Pr=Xn.find(_=>_.id===Dn)||null,pg=Pr?Array.isArray(Pr.messages)?Pr.messages:[]:Ht,Ya=Pr?Pr.status==="running":Jt,xu=Pr?Pr.status==="running"?`${Pr.label} running`:Pr.status==="paused"?`${Pr.label} paused`:Pr.status==="failed"?`${Pr.label} failed`:`${Pr.label} done`:Jt?"Workspace agent running":Ht.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>t("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:s.flowId?`${s.flowId} · ${jr}`:jr||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",iK,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(Mb({id:s.flowId,source:s.flowSource||"user",archived:!!s.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:Da}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ls(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Ci?" af-composer-topbar-btn--active":"")+(Jt?" af-composer-topbar-btn--running":""),onClick:()=>ei(_=>!_),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",onClick:()=>Hn().catch(_=>gt(String(_.message||_))),children:"Save"})]})]}),ge?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:ge}),o.jsx("button",{type:"button",onClick:()=>le(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(Ci||ee?" af-workspace-body--drawer":"")+(Rs?" af-workspace-body--sidebar-collapsed":""),children:[Rs?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Ae(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>ms(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>ms(!1),"aria-label":"展开侧边栏",title:(Se==null?void 0:Se.username)||(Se==null?void 0:Se.userId)||"展开侧边栏",children:Wa})]})}):null,o.jsxs("aside",{ref:hn,className:"af-workspace-sidebar"+(tr?" af-workspace-sidebar--resizing":""),"aria-hidden":Rs,style:{"--af-work-files-pane-height":`${Math.round(Mn)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>ms(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>qa(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Lf(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void sr(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:ve,onChange:_=>Xe(_.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(rT,{items:pu,onOpen:Ka,collapsedDirs:ot,onToggleDir:Dv,onCreateFile:qa,onCreateFolder:Lf,onDelete:Of,onFileDragStart:ri})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:io,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:F==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:M,onChange:_=>R(_.target.value),placeholder:F==="flows"?"搜索流程片段...":"搜索节点...","aria-label":F==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":F==="nodes",className:"af-palette-tab"+(F==="nodes"?" af-palette-tab--active":""),onClick:()=>O("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":F==="flows",className:"af-palette-tab"+(F==="flows"?" af-palette-tab--active":""),onClick:()=>O("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:F==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:Tf,disabled:En.length<2,title:En.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",En.length," 节点 / ",Wo.length," 连线"]})]})}),A?o.jsx("p",{className:"af-err af-palette-list-err",children:A}):null,D?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Ua.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:Ua.map(_=>{const H=`${_.id}@${_.version}`,X=_.displayName||_.name||_.id,J=_.description||`${_.nodeCount||0} 个节点,${_.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Z=>{Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("application/agentflow-snippet",H),Z.dataTransfer.setData("text/plain",H)},onClick:()=>po(_),title:J,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:X}),o.jsxs("span",{className:"af-palette-card-id",children:[_.id,"@",_.version]})]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[_.nodeCount||0," nodes"]}),o.jsxs("span",{children:[_.edgeCount||0," edges"]})]})]},H)})})]}):o.jsx("p",{className:"af-palette-empty",children:M.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[nc.map(_=>{var H;return(H=$l[_])!=null&&H.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${_}`,children:[o.jsx("h3",{className:"af-palette-cat",children:_}),o.jsx("div",{className:"af-palette-cards",children:$l[_].map(X=>{const J=Sj(X.inputs,"input"),Z=Sj(X.outputs,"output"),ie=Rw(X),se=td(X);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:fe=>dg(fe,X),onClick:()=>gs(X),title:ie||X.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:vj(_)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:se}),se!==X.id?o.jsx("span",{className:"af-palette-card-id",children:X.id}):null]})]}),ie?o.jsx("span",{className:"af-palette-card-desc",children:ie}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[J.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[J.shown.map((fe,xe)=>o.jsxs("span",{className:"af-palette-card-port",title:kj("input",fe,xe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:On(fe==null?void 0:fe.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:My(fe,xe)})]},`in-${xe}`)),J.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",J.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Z.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Z.shown.map((fe,xe)=>o.jsxs("span",{className:"af-palette-card-port",title:kj("output",fe,xe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:My(fe,xe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:On(fe==null?void 0:fe.type)}})]},`out-${xe}`)),Z.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Z.hidden]}):null]})]})]})]},X.id)})})]},_):null}),N.length>0&&M.trim()&&nc.every(_=>{var H;return!((H=$l[_])!=null&&H.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(UP,{className:"af-flow-canvas af-workspace-flow"+(V==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),nodes:Va,edges:Ml,nodeTypes:LK,onNodesChange:lg,onEdgesChange:d,onConnect:Dl,onConnectStart:pt,onConnectEnd:ug,isValidConnection:cg,onNodeClick:(_,H)=>{xt&&Fe(H.id)},onNodeDoubleClick:(_,H)=>{_.preventDefault(),ei(!1),a(X=>X.map(J=>({...J,selected:J.id===H.id}))),c(X=>X.map(J=>({...J,selected:!1}))),Fe(H.id)},onPaneClick:()=>Fe(""),onDrop:Rf,onDragOver:fg,selectionOnDrag:V==="select",panOnDrag:V==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(XP,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),v?(()=>{var J;const _=String(v.query||"").trim().toLowerCase(),H=_?v.candidates.filter(Z=>{var ie,se,fe;return[(ie=Z.def)==null?void 0:ie.id,Z.displayLabel,Z.description,(se=Z.slot)==null?void 0:se.name,(fe=Z.slot)==null?void 0:fe.type].filter(Boolean).some(xe=>String(xe).toLowerCase().includes(_))}):v.candidates,X=v.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:v.left,top:v.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:On((J=v.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",v.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>k(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:v.query,onChange:Z=>k(ie=>ie&&{...ie,query:Z.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[H.map(Z=>{var fe,xe;const ie=Z.displayLabel||((fe=Z.def)==null?void 0:fe.id),se=My(Z.slot,Z.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>ho(Z),title:Z.description||Z.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:ie}),ie!==Z.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Z.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:X}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:On((xe=Z.slot)==null?void 0:xe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:se})]})]},`${Z.def.id}-${Z.slotIndex}`)}),H.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,Bo?o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Ts(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Ts(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:En.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):En.map(_=>{var Z,ie;const H=String(((Z=_.data)==null?void 0:Z.label)??_.id),X=(ie=_.data)!=null&&ie.definitionId?String(_.data.definitionId):"",J=X&&X!==H?`${H} · ${_.id} · ${X}`:`${H} · ${_.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:J,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:X||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:H}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>gu(_.id),"aria-label":`取消选择 ${_.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},_.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:mn,rows:2,onChange:_=>mr(_.target.value),onKeyDown:_=>{(_.metaKey||_.ctrlKey)&&_.key==="Enter"&&(_.preventDefault(),Mf())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Xt,type:"button",className:"af-composer-skills-button"+($n.length>0?" af-composer-skills-button--active":""),disabled:Jt,"aria-haspopup":"listbox","aria-expanded":As,onClick:()=>_e(_=>!_),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:$n.length>0?`Skills ${$n.length}`:"Skills"})]}),As&&!Jt?ts.createPortal(o.jsx("div",{ref:Bn,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:hs,children:$t.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[ni.groups.map(_=>{const H=Ea(_,$t),X=JE(_,fo,$t),J=ji.has(_.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(J?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:X==="all",disabled:H.length===0,onChange:Z=>{const ie=Z.target.checked;Gn(se=>ie?GE(se,H):XE(se,H))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:_.name}),_.builtin?o.jsx("em",{children:"built-in"}):null,X==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":J?`展开 ${_.name}`:`收起 ${_.name}`,onClick:()=>{oo(Z=>{const ie=new Set(Z);return ie.has(_.id)?ie.delete(_.id):ie.add(_.id),ie})},children:[o.jsx("span",{children:_.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J?"expand_more":"expand_less"})]})]}),J?null:o.jsx("div",{className:"af-composer-skill-group-items",children:_.skills.map(Z=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:fo.has(Z.key),onChange:ie=>{const se=ie.target.checked;Gn(fe=>se?fe.includes(Z.key)?fe:[...fe,Z.key]:fe.filter(xe=>xe!==Z.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Z.name}),Z.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Z.description}):null]})]},`${_.id}:${Z.key}`))})]},_.id)}),ni.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:ni.ungrouped.length})]}),ni.ungrouped.map(_=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:fo.has(_.key),onChange:H=>{const X=H.target.checked;Gn(J=>X?J.includes(_.key)?J:[...J,_.key]:J.filter(Z=>Z!==_.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:_.name}),_.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:_.description}):null]})]},`ungrouped:${_.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:ye,onChange:_=>ze(_.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),Gr.map(_=>o.jsx("option",{value:_.value,children:_.label},_.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(mn.trim()&&!Jt?" af-composer-send--active":"")+(Jt?" af-composer-send--stop":""),disabled:Jt||!mn.trim(),"aria-label":Jt?"Running":"Send",onClick:()=>void Mf(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Jt?"sync":"arrow_upward"})})]})]})]})})]}),Ci?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>ei(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Dn==="workspace"?" af-composer-session-tab--active":""),onClick:()=>Is("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Xn.map(_=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Dn===_.id?" af-composer-session-tab--active":"")+(_.status==="running"?" af-composer-session-tab--running":""),onClick:()=>Is(_.id),title:_.runNodeId||_.label,children:o.jsx("span",{className:"af-composer-session-label",children:_.label})},_.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Ya?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:xu}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx($K,{messages:pg,running:Ya,showRunningIndicator:!Pr})})]})}):ee&&Rt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(FI,{draft:ee,setDraft:De,definitionId:String(((zl=Rt.data)==null?void 0:zl.definitionId)||Rt.id),systemPromptReadonly:String(((wu=Rt.data)==null?void 0:wu.description)||""),modelLists:Bt,disabled:!1,onIdBlur:()=>Ol(!0),onClose:()=>Fe(""),onPublishToMarketplace:Tl,error:tt,ioSlots:{inputs:Array.isArray(ee==null?void 0:ee.inputs)?ee.inputs:[],outputs:Array.isArray(ee==null?void 0:ee.outputs)?ee.outputs:[]}})}):null,o.jsx(LI,{open:Yr,onClose:()=>Ls(!1)}),P?ts.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>T(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:E.name,onChange:_=>{const H=_.target.value;Y(X=>({...X,name:H,id:X.id?X.id:H.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:E.id,onChange:_=>Y(H=>({...H,id:_.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:E.description,onChange:_=>Y(H=>({...H,description:_.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",En.length," 个节点和 ",Wo.length," 条内部连线。"]}),re?o.jsx("div",{className:"af-flow-snippet-error",children:re}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>T(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Q||!E.name.trim(),onClick:()=>void mu(),children:Q?"发布中...":"发布"})]})]})}),document.body):null,de?ts.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Ae(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:_=>_.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":Ne==="nodes",className:"af-workspace-quick-add__tab"+(Ne==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Pe("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":Ne==="flows",className:"af-workspace-quick-add__tab"+(Ne==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Pe("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:rt,value:Ie,onChange:_=>qe(_.target.value),onKeyDown:_=>{if(_.key==="Escape")_.preventDefault(),Ae(!1);else if(_.key==="ArrowDown"){_.preventDefault();const H=Ne==="flows"?Ai.length:Ds.length;Ge(X=>Math.min(Math.max(0,H-1),X+1))}else _.key==="ArrowUp"?(_.preventDefault(),Ge(H=>Math.max(0,H-1))):_.key==="Tab"?(_.preventDefault(),Pe(H=>H==="nodes"?"flows":"nodes")):_.key==="Enter"&&(_.preventDefault(),Ne==="flows"?Fl(Ai[ct]||Ai[0]):yu(Ds[ct]||Ds[0]))},placeholder:Ne==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ne==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:Ne==="flows"?Ai.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:D?"正在加载流程片段...":A||"没有匹配的流程片段"}):Ai.map((_,H)=>{const X=_.displayName||_.name||_.id,J=_.snippet&&typeof _.snippet=="object"?_.snippet.instances:null,Z=_.snippet&&typeof _.snippet=="object"?_.snippet.edges:null,ie=Number.isFinite(Number(_.nodeCount))?Number(_.nodeCount):Object.keys(J||{}).length,se=Number.isFinite(Number(_.edgeCount))?Number(_.edgeCount):Array.isArray(Z)?Z.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(H===ct?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ge(H),onClick:()=>Fl(_),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:X}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[_.id,_.version?` · v${_.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:_.description||`${ie} 节点 / ${se} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${_.id}@${_.version}`)}):Ds.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Ds.map((_,H)=>{const X=ed(_),J=td(_),Z=Rw(_);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(H===ct?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ge(H),onClick:()=>yu(_),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:vj(X)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:J}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:_.id}),Z?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Z}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:X})]},_.id)})})]})}),document.body):null]})]})}function qK(){return o.jsx(tv,{children:o.jsx(KK,{})})}const mt=e=>typeof e=="string",Hu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},Ej=e=>e==null?"":""+e,YK=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},GK=/###/g,_j=e=>e&&e.indexOf("###")>-1?e.replace(GK,"."):e,Pj=e=>!e||mt(e),vd=(e,t,n)=>{const r=mt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(Pj(e))return{};const i=_j(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return Pj(e)?{}:{obj:e,k:_j(r[s])}},Aj=(e,t,n)=>{const{obj:r,k:s}=vd(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=vd(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=vd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},XK=(e,t,n,r)=>{const{obj:s,k:i}=vd(e,t,Object);s[i]=s[i]||[],s[i].push(n)},fm=(e,t)=>{const{obj:n,k:r}=vd(e,t);if(n)return n[r]},JK=(e,t,n)=>{const r=fm(e,n);return r!==void 0?r:fm(t,n)},sT=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?mt(e[r])||e[r]instanceof String||mt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):sT(e[r],t[r],n):e[r]=t[r]);return e},Zl=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var QK={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const ZK=e=>mt(e)?e.replace(/[&<>"'\/]/g,t=>QK[t]):e;class eq{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const tq=[" ",",","?","!",";"],nq=new eq(20),rq=(e,t,n)=>{t=t||"",n=n||"";const r=tq.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=nq.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},Lw=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=i;c<r.length;++c)if(c!==i&&(l+=n),l+=r[c],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;i+=c-i+1;break}s=a}return s},pm=e=>e&&e.replace("_","-"),sq={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class hm{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||sq,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(mt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new hm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new hm(this.logger,t)}}var qi=new hm;class ng{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let d=0;d<c;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let d=0;d<c;d++)l.apply(l,[t,...r])})}}class Ij extends ng{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):mt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=fm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!mt(r)?c:Lw(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),Aj(this.data,l,s),i.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const i in r)(mt(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=fm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?sT(c,r,i):c={...c,...r},Aj(this.data,l,c),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var iT={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const Tj={};class mm extends ng{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),YK(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=qi.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!rq(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:mt(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:mt(i)?[i]:i}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],d=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(u){const S=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${S}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${S}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,g=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!mt(p)&&typeof p!="boolean"&&typeof p!="number";if(b&&p&&w&&k.indexOf(v)<0&&!(mt(y)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const S=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=S,f.usedParams=this.getUsedParamsDetails(n),f):S}if(i){const S=Array.isArray(p),C=S?[]:{},N=S?g:h;for(const I in p)if(Object.prototype.hasOwnProperty.call(p,I)){const M=`${N}${i}${I}`;C[I]=this.translate(M,{...n,joinArrays:!1,ns:l}),C[I]===M&&(C[I]=p[I])}p=C}}else if(b&&mt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let S=!1,C=!1;const N=n.count!==void 0&&!mt(n.count),I=mm.hasDefaultValue(n),M=N?this.pluralResolver.getSuffix(d,n.count,n):"",R=n.ordinal&&N?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",F=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),O=F&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${M}`]||n[`defaultValue${R}`]||n.defaultValue;!this.isValidLookup(p)&&I&&(S=!0,p=O),this.isValidLookup(p)||(C=!0,p=a);const W=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:p,D=I&&O!==p&&this.options.updateMissing;if(C||S||D){if(this.logger.log(D?"updateKey":"missingKey",d,c,a,D?O:p),i){const P=this.resolve(a,{...n,keySeparator:!1});P&&P.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let $=[];const A=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&A&&A[0])for(let P=0;P<A.length;P++)$.push(A[P]);else this.options.saveMissingTo==="all"?$=this.languageUtils.toResolveHierarchy(n.lng||this.language):$.push(n.lng||this.language);const B=(P,T,E)=>{const Y=I&&E!==p?E:W;this.options.missingKeyHandler?this.options.missingKeyHandler(P,c,T,Y,D,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(P,c,T,Y,D,n),this.emit("missingKey",P,c,T,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?$.forEach(P=>{const T=this.pluralResolver.getSuffixes(P,n);F&&n[`defaultValue${this.options.pluralSeparator}zero`]&&T.indexOf(`${this.options.pluralSeparator}zero`)<0&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(E=>{B([P],a+E,n[`defaultValue${E}`]||O)})}):B($,a,O))}p=this.extendTranslation(p,t,n,f,r),C&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(C||S)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,S?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=mt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(d){const p=t.match(this.interpolator.nestingRegexp);u=p&&p.length}let f=r.replace&&!mt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;u<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return i&&i[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=mt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=iT.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,i,a,l;return mt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),u=d.key;s=u;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!mt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(mt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(k=>{this.isValidLookup(r)||(l=k,!Tj[`${v[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(Tj[`${v[0]}-${k}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;a=y;const b=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(b,u,y,k,n);else{let S;p&&(S=this.pluralResolver.getSuffix(y,n.count,n));const C=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(b.push(u+S),n.ordinal&&S.indexOf(N)===0&&b.push(u+S.replace(N,this.options.pluralSeparator)),h&&b.push(u+C)),g){const I=`${u}${this.options.contextSeparator}${n.context}`;b.push(I),p&&(b.push(I+S),n.ordinal&&S.indexOf(N)===0&&b.push(I+S.replace(N,this.options.pluralSeparator)),h&&b.push(I+C))}}let w;for(;w=b.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,k,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!mt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const i of n)delete s[i]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Fy=e=>e.charAt(0).toUpperCase()+e.slice(1);class Rj{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=qi.create("languageUtils")}getScriptPartFromCode(t){if(t=pm(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=pm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(mt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Fy(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Fy(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Fy(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),mt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return mt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):mt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let iq=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],oq={1:e=>+(e>1),2:e=>+(e!=1),3:e=>0,4:e=>e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,5:e=>e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5,6:e=>e==1?0:e>=2&&e<=4?1:2,7:e=>e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,8:e=>e==1?0:e==2?1:e!=8&&e!=11?2:3,9:e=>+(e>=2),10:e=>e==1?0:e==2?1:e<7?2:e<11?3:4,11:e=>e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3,12:e=>+(e%10!=1||e%100==11),13:e=>+(e!==0),14:e=>e==1?0:e==2?1:e==3?2:3,15:e=>e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2,16:e=>e%10==1&&e%100!=11?0:e!==0?1:2,17:e=>e==1||e%10==1&&e%100!=11?0:1,18:e=>e==0?0:e==1?1:2,19:e=>e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3,20:e=>e==1?0:e==0||e%100>0&&e%100<20?1:2,21:e=>e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0,22:e=>e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3};const aq=["v1","v2","v3"],lq=["v4"],Lj={zero:0,one:1,two:2,few:3,many:4,other:5},cq=()=>{const e={};return iq.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:oq[t.fc]}})}),e};class uq{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=qi.create("pluralResolver"),(!this.options.compatibilityJSON||lq.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=cq(),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const r=pm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[i]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,i)=>Lj[s]-Lj[i]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const i=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!aq.includes(this.options.compatibilityJSON)}}const Oj=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=JK(e,t,n);return!i&&s&&mt(n)&&(i=Lw(e,n,r),i===void 0&&(i=Lw(t,n,r))),i},zy=e=>e.replace(/\$/g,"$$$$");class dq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=qi.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:i,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:v,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:b}=t.interpolation;this.escape=n!==void 0?n:ZK,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Zl(i):a||"{{",this.suffix=l?Zl(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=p?Zl(p):h||Zl("$t("),this.nestingSuffix=g?Zl(g):v||Zl(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=y||1e3,this.alwaysFormat=b!==void 0?b:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let i,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const y=Oj(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:h}):y}const g=h.split(this.formatSeparator),v=g.shift().trim(),k=g.join(this.formatSeparator).trim();return this.format(Oj(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const u=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>zy(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?zy(this.escape(h)):zy(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof u=="function"){const k=u(t,i,s);a=mt(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(f){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!mt(a)&&!this.useRawValueToEscape&&(a=Ej(a));const v=h.safeValue(a);if(t=t.replace(i[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=i[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(c,d)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const f=c.split(new RegExp(`${u}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${u}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!mt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const u=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=u.shift(),c=u,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!mt(i))return i;mt(i)||(i=Ej(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=c.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const fq=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),u=l.trim();n[u]||(n[u]=d),d==="false"&&(n[u]=!1),d==="true"&&(n[u]=!0),isNaN(d)||(n[u]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},ec=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(pm(r),s),t[a]=l),l(n)}};class pq{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=qi.create("formatter"),this.options=t,this.formats={number:ec((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:ec((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:ec((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:ec((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:ec((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=ec(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(c=>c.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,c)=>{const{formatName:d,formatOptions:u}=fq(c);if(this.formats[d]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[d](l,h,{...u,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const hq=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class mq extends ng{constructor(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=qi.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const i={},a={},l={},c={};return t.forEach(d=>{let u=!0;n.forEach(f=>{const p=`${d}|${f}`;!r.reload&&this.store.hasResourceBundle(d,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,u=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),c[f]===void 0&&(c[f]=!0)))}),u||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{XK(c.loaded,[i],a),hq(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.forEach(f=>{l[d][f]===void 0&&(l[d][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:i,callback:a});return}this.readingCalls++;const l=(d,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(d&&u&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(u=>l(null,u)).catch(l):l(null,d)}catch(d){l(d)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();mt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),mt(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let u;d.length===5?u=d(t,n,r,s,c):u=d(t,n,r,s),u&&typeof u.then=="function"?u.then(f=>l(null,f)).catch(l):l(null,u)}catch(u){l(u)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const Mj=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),mt(e[1])&&(t.defaultValue=e[1]),mt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),$j=e=>(mt(e.ns)&&(e.ns=[e.ns]),mt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),mt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Bp=()=>{},gq=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class rf extends ng{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=$j(t),this.services={},this.logger=qi,this.modules={external:[]},gq(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(mt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=Mj();this.options={...s,...this.options,...$j(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?qi.init(i(this.modules.logger),this.options):qi.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=pq);const f=new Rj(this.options);this.store=new Ij(this.options.resources,this.options);const p=this.services;p.logger=qi,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new uq(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(u),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new dq(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new mq(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new mm(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,v=new Array(g>1?g-1:0),k=1;k<g;k++)v[k-1]=arguments[k];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=function(){return t.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return t.store[u](...arguments),t}});const c=Hu(),d=()=>{const u=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bp;const s=mt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Hu();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=Bp),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&iT.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const s=Hu();this.emit("languageChanging",t);const i=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const d=mt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,u=>{a(u,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let c;if(typeof l!="object"){for(var d=arguments.length,u=new Array(d>2?d-2:0),f=2;f<d;f++)u[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(u))}else c={...l};c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${c.keyPrefix}${p}${g}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return mt(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Hu();return this.options.ns?(mt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Hu();mt(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new Rj(Mj());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new rf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new rf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new Ij(this.store.data,s),i.services.resourceStore=i.store),i.translator=new mm(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,d=new Array(c>1?c-1:0),u=1;u<c;u++)d[u-1]=arguments[u];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Nr=rf.createInstance();Nr.createInstance=rf.createInstance;Nr.createInstance;Nr.dir;Nr.init;Nr.loadResources;Nr.reloadResources;Nr.use;Nr.changeLanguage;Nr.getFixedT;Nr.t;Nr.exists;Nr.setDefaultNamespace;Nr.hasLoadedNamespace;Nr.loadNamespaces;Nr.loadLanguages;function yq(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sf(e){"@babel/helpers - typeof";return sf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sf(e)}function xq(e,t){if(sf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(sf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function wq(e){var t=xq(e,"string");return sf(t)=="symbol"?t:t+""}function bq(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,wq(r.key),r)}}function vq(e,t,n){return t&&bq(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var oT=[],kq=oT.forEach,Sq=oT.slice;function Nq(e){return kq.call(Sq.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var Dj=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,jq=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!Dj.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!Dj.test(s.path))throw new TypeError("option path is invalid");a+="; Path=".concat(s.path)}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(s.expires.toUTCString())}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite){var c=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},Fj={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=jq(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},Cq={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=Fj.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&Fj.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},Eq={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var c=i[a].substring(0,l);c===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Vu=null,zj=function(){if(Vu!==null)return Vu;try{Vu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Vu=!1}return Vu},_q={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&zj()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&zj()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Wu=null,Bj=function(){if(Wu!==null)return Wu;try{Wu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Wu=!1}return Wu},Pq={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&Bj()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&Bj()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},Aq={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},Iq={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},Tq={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},Rq={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},aT=!1;try{document.cookie,aT=!0}catch{}var lT=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];aT||lT.splice(1,1);function Lq(){return{order:lT,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var cT=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};yq(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return vq(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=Nq(r,this.options||{},Lq()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(Cq),this.addDetector(Eq),this.addDetector(_q),this.addDetector(Pq),this.addDetector(Aq),this.addDetector(Iq),this.addDetector(Tq),this.addDetector(Rq)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();cT.type="languageDetector";const Oq={name:"AgentFlow",tagline:"AI Workflow Orchestration"},Mq={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},$q={loading:"Loading...",saving:"Saving...",save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",create:"Create",close:"Close",confirm:"Confirm",copy:"Copy",copied:"Copied!",refresh:"Refresh",search:"Search",filter:"Filter",success:"Success",error:"Error",warning:"Warning",info:"Info",done:"Done",pending:"Pending",running:"Running",notFound:"Not found",required:"Required",optional:"Optional"},Dq={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},Fq={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},zq={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},Bq={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},Hq={app:Oq,nav:Mq,common:$q,status:Dq,nodeTypes:Fq,engine:zq,links:Bq},Vq="Flow Editor",Wq="Nodes",Uq="Edges",Kq="Properties",qq={label:"Node Label",type:"Node Type",model:"Model",body:"Body",inputs:"Inputs",outputs:"Outputs",addInput:"Add Input",addOutput:"Add Output",remove:"Remove Node",duplicate:"Duplicate Node",nodeType:"Node Type",displayName:"Display Name",displayNameHint:"(letters, numbers, underscores, hyphens, do not start with a number)",role:"Role",modelHint:"From ~/agentflow/model-lists.json; UI service runs agentflow update-model-lists in background on startup",defaultModel:"Default",userPrompt:"User Prompt (USER PROMPT / body)",systemDescription:"System Description (read-only, from node definition)",directCommand:"Direct Command (script)",scriptHint:"(tool_nodejs: skips AI when script exists, executed by pipeline)",diskRunning:"Disk record shows running",deleteNode:"Delete node",inputTooltip:"Input {{name}} | Type: {{type}}",outputTooltip:"Output {{name}} | Type: {{type}}",defaultSuffix:" | Default: {{value}}",fallbackLabel:"Node",expandProvide:"Edit content"},Yq={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},Gq={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},Xq={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},Jq={workspace:"Workspace",loading:"Loading...",archived:"Archived",noPipelines:"No pipelines",more:"more",moreFlows:"more flows",noRuns:"No run records",searchNodes:"Search nodes",noComponents:"No components available (check node library directory)",noMatch:"No matching nodes, adjust search terms",selectPipeline:"Select a pipeline from above to load components and canvas",validationWarnings:"Validation warnings (consistent with agentflow validate slot checks)",output:"Output",model:"Model",userDir:"User Directory",toggleRecentActivity:"Toggle recent opened or recent runs"},Qq={selectPipeline:"Please select a pipeline from the dropdown above",loadingProps:"Loading node properties...",pipelineId:"Pipeline ID",diskPath:"Disk Path",storageLocation:"Storage Location",introduction:"Introduction",introductionPlaceholder:"Briefly describe this pipeline (saved as flow.yaml ui.description)",metadata:"Metadata",nodeCount:"Node Count",nodesUnit:"nodes",loading:"Loading...",noRuns:"No run records (run records are generated in the workspace after terminal execution)"},Zq={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},eY={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},tY={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},nY={node:"Node",text:"Text",file:"File",bool:"Boolean"},rY={title:"Node Execution Context",resizeHandle:"Drag to resize node context width",apiConnectError:"Cannot connect to API (please open the page with agentflow ui, or configure /api proxy for Vite dev)",invalidJson:"Response is not valid JSON",requestTimeout:"Request timed out, please retry or check agentflow ui",executingNoArtifacts:"Executing, artifacts not yet written to workspace…",noData:"No data (this run has not reached this node or produced artifacts)",latest:"Latest",detectedContentType:"Detected content type",roundNoContent:"No content in this round",empty:"(empty)",imageTruncated:"Image truncated (exceeds size limit)",statusSuccess:"Success",statusFailed:"Failed",statusRunning:"Running",statusCacheMiss:"Cache miss",statusPending:"Pending"},sY={title:"Keyboard Shortcuts",general:"General",saveDesc:"Save; when node properties sidebar is open, submit node first then save flow",shortcutsLabel:"Keyboard Shortcuts",jumpToNode:"Jump to node by ID",openNodePalette:"Open node palette",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},iY={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},oY={title:"Start Building Your Flow",text:"Describe your workflow in the AI input box below, or drag nodes from the left panel to the canvas",composerHint:"Build AgentFlow with AI Composer",composerSub:"Drag nodes from the left panel, or describe your workflow in the <strong>input box below</strong>.<br/>Press <kbd>?</kbd> to view shortcuts."},aY={mainNav:"Main Navigation"},lY={flowWarningAriaLabel:"Flow validation warnings",reloadFromServer:"Reload flow from server and refresh validation",reloadFromServerShort:"Reload from server",closeBanner:"Close validation warning banner",nodePrefix:"Node",focusNodeAriaLabel:"Select and focus node {{nodeId}} on canvas",slotWarningCount:"Slot validation: {{count}} warnings (hidden)",show:"Show",shortcutHint:"Press ? to view keyboard shortcuts",shortcutHintLabel:"shortcuts",inputSlotNoEdge:' input slot "{{slotName}}" ({{handle}}) has no edge connection',outputSlotNoEdge:' output slot "{{slotName}}" ({{handle}}) has no edge connection'},cY={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
156
+ {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
157
+ Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},uY={currentPipeline:"Current Pipeline",backToEdit:"Back to edit",backToProjects:"Back to projects",executionLog:"Execution log",history:"History",pipelineSettings:"Pipeline settings",shortcutsLabel:"Shortcuts",shortcutsTitle:"Shortcuts (?)",deletePipeline:"Delete pipeline",resumeTitle:"Resume in same run directory (uuid={{uuid}})",resumeTitleNoUuid:"No apply-start received, will start a new run",rerunTitle:"Start a new run from scratch",runOptions:"Run options",runWithParams:"Run with params",runWithPreset:"Run with preset",editRun:"Edit run parameters",startRun:"Start run",stopRun:"Stop background run"},dY={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},fY={connectingApi:"Connecting to /api/flow/run…",connectingApiResume:"Connecting to /api/flow/run (resuming run uuid={{uuid}})…",connectedReceiving:"Connected to execution stream, receiving NDJSON output…",noBody:"Response has no body (cannot stream), please check browser and agentflow ui version",nodeStart:"▶ Starting: {{instanceId}}",nodeStartWithLabel:"▶ Starting: {{instanceId}} ({{label}})",nodeDone:"✓ Done: {{instanceId}}",nodeDoneWithElapsed:"✓ Done: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ Failed: {{instanceId}}",pipelineStart:"Pipeline started (uuid={{uuid}})",pipelineDone:"Pipeline completed",pipelineDoneWithElapsed:"Pipeline completed ({{elapsed}})",pipelinePaused:"Pipeline paused: waiting for user input ({{nodes}})",unknownError:"Unknown error",executionEnd:"Execution ended (exit code: {{exitCode}})",executionStopped:"Execution paused",pauseRun:"Pause run (can resume later)",pauseConfirm:"Pause the current run? You can resume from the interrupted node later.",pauseTitle:"Pause run",pauseConfirmOk:"Pause",backPromptTitle:"Back to projects",backPromptMessage:"Pipeline still running. Keep it in the background and exit, or stop it and return to edit mode?",backBackground:"Run in background & exit",backStopEdit:"Stop & enter edit",resizeConsole:"Drag to resize execution log height",closeLog:"Close log",userCheckContent:"Waiting for user to confirm content for node {{instanceId}}",userAskPrompt:"Waiting for user to choose branch for node {{instanceId}}"},pY={close:"Close",loading:"Loading…",placeholder:"File content",largeFileWarning:"Large file, editor performance may be affected",reset:"Reset",aiEdit:"AI Edit",aiRunning:"AI processing…",save:"Save",saving:"Saving…",saved:"Saved"},hY={title:"Pipeline Settings",subtitle:"Manage basic information, storage, node marketplace, scheduled runs, and metadata.",sectionNav:"Settings sections",basicInfo:"Basic Info",storageAndPath:"Storage & Path",nodeMarketplace:"Node Marketplace",overview:"Pipeline Overview",owner:"Owner",source:"Source",marketplaceNodes:"Marketplace nodes",marketNodesUnit:"market nodes",marketplaceHint:"Local marketplace nodes can be added to this pipeline; installed nodes can then be placed on the canvas.",marketplaceEmpty:"No local marketplace nodes are installed in this workspace yet. Publish one from the node properties panel.",addNodeFromMarket:"Back to canvas",quickActions:"Quick Actions",saveChanges:"Save changes",savingChanges:"Saving…",installNode:"Add to pipeline",installingNode:"Adding…",addInstalledNode:"Add to canvas",previewNode:"Preview",nodePreviewTitle:"Node preview",nodeStylePreview:"Node style preview",closePreview:"Close preview",nodeFunction:"Node purpose",nodePackageInfo:"Package info",definitionId:"Definition ID",version:"Version",packagePath:"Package path",packagedFiles:"Packaged files",marketplaceNoDescription:"No node purpose has been provided.",noInputs:"No inputs",noOutputs:"No outputs",backToCanvas:"Back to canvas",help:"Help",helpText:"Publish nodes from the node properties panel; installed collections sync into the local node marketplace.",archived:"Archived",archivedNote:"This pipeline is in the archive directory (_archived) and cannot be moved between user directory and workspace.",builtinNote:"Built-in templates are read-only; first save will write to workspace .workspace/agentflow/pipelines (pipelines), .workspace/agentflow/nodes (custom nodes), etc.",moveBusy:"Moving…",moveToWorkspace:"Move to workspace",moveToUserDir:"Move to user directory",globalSettings:"Global settings",currentPipeline:"Current pipeline:",builtin:"Built-in",rename:"Rename",renameBusy:"Renaming…",renameSuccess:"Renamed",copyPath:"Copy path",pathCopied:"Copied"},mY={title:"Scheduled Run",enabled:"Enable scheduled trigger",cron:"Cron expression",timezone:"Timezone",preset:"Run preset",defaultPreset:"Default inputs",overlapSkip:"Overlap policy: skip this trigger while the pipeline is running",nextRun:"Next estimated trigger: {{time}}",noNextRun:"No next trigger is configured",runtime:"Scheduler state",running:"Running",waiting:"Waiting",disabled:"Disabled",lastTriggeredAt:"Last triggered",lastSkippedAt:"Last skipped",lastRun:"Last run",lastExit:"Last exit code",lastFinishedAt:"Last finished",readonlyNote:"Built-in or archived pipelines cannot save schedule settings.",save:"Save schedule",saving:"Saving…",saved:"Schedule saved"},gY={title:"Execution History",summary:"Execution results summary",successCount:"{{count}} succeeded",failedCount:"{{count}} failed",stoppedCount:"{{count}} stopped",interruptedCount:"{{count}} interrupted",runningCount:"{{count}} running",success:"Success",failed:"Failed",stopped:"Stopped",interrupted:"Interrupted",running:"Running",unknown:"Unknown",runLabel:"Run #{{id}}",enterRunView:"Enter run view with canvas and log"},yY={invalidInstanceId:"Invalid Instance ID: only letters, numbers, underscores, and hyphens allowed, must not start with a number.",duplicateInstanceId:"This Instance ID already exists, please choose another.",loadFlowFailed:"Failed to load flow",loadNodesFailed:"Failed to load node library"},xY={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},wY={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},bY={title:"User Confirmation ({{instanceId}})",edit:"Edit",save:"Save",cancel:"Cancel",aiEditPlaceholder:"Enter AI edit instruction, e.g., remove item 2, merge first two items…",aiEditBtn:"AI Edit",aiEditStarted:"AI is modifying content…",aiEditDone:"AI modification complete",aiEditFailed:"AI modification failed",contentSaved:"Content saved",saveFailed:"Save failed",close:"Close",continue:"Continue Execution",hint:"Edit or use AI to modify, then save. Click 'Continue Execution' to resume the flow"},vY={title:"User Choice ({{instanceId}})",hint:"Pick an option below to continue the flow",submitting:"Submitting…",submitFailed:"Submit failed",close:"Close",noOptions:"No options configured on this node. Add items to the output slots in the editor first."},kY={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},SY={save:"Save",cancel:"Cancel"},NY={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},jY={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},CY={preset:"Preset",default:"Default",newPreset:"New preset",deletePreset:"Delete preset",presetNamePlaceholder:"Preset name",inputParams:"Input Parameters",noProvideNodes:"No provide nodes in this flow",filePathPlaceholder:"File path…",stringValuePlaceholder:"Value…",presetSaved:"Preset saved",presetDeleted:"Preset Deleted",savePreset:"Save current preset",expandInput:"Edit content"},EY={title:Vq,nodes:Wq,edges:Uq,properties:Kq,node:qq,nodeProps:Yq,actions:Gq,panel:Xq,palette:Jq,pipeline:Qq,status:Zq,roles:eY,phases:tY,types:nY,runContext:rY,shortcuts:sY,jumpPalette:iY,emptyCanvas:oY,sidebar:aY,validation:lY,composer:cY,topbar:uY,palette2:dY,run:fY,fileEdit:pY,settings:hY,schedule:mY,history:gY,nodePropsError:yY,placeholder:xY,time:wY,userCheck:bY,userAsk:vY,toolPrint:kY,provideEdit:SY,runParams:NY,runPreset:jY,runConfig:CY},_Y="Settings",PY={engine:"Engine Settings",preferences:"Global Preferences"},AY={title:"Workspace",currentPath:"Current Workspace Root",placeholder:"Loading...",copyPath:"Copy path",description:"Pipelines and node lists are resolved relative to this directory (passed when starting the UI)."},IY={title:"Cursor CLI",status:{cached:"Cached",notCached:"Not cached"},modelPreviewLabel:"Cursor model id list",modelList:{cached:"Model list cached",empty:"No model list",count:"{{count}} items",fetchedAt:"Updated {{time}}",never:"Never fetched",refresh:"Refresh List",fetching:"Fetching..."}},TY={modelPreviewLabel:"OpenCode model id list",title:"OpenCode CLI",status:{ready:"Ready",notFound:"Not found"},provider:"Plan / Provider ID",providerPlaceholder:"e.g., bailian-coding-plan",saving:"Saving and updating list...",description:"Corresponds to CLI opencode models <provider> parameter; written to user directory config and triggers model-lists.json refresh after typing stops."},RY={title:"Claude Code CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Claude Code model id list",description:"Built-in model list (Claude Code CLI has no models subcommand); refresh probes the claude binary in PATH. Run 'claude /login' first."},LY={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",saving:"Saving...",key:"Key",value:"Value",add:"Add",delete:"Delete {{key}}",invalidKey:"Env key must start with a letter or underscore, and only contain letters, numbers, and underscores.",newKey:"New env key",newValue:"Value (be careful with secrets)"},OY={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},MY={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},$Y={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},DY={title:"Onboarding Tour",description:"Restart the product tour to learn about AgentFlow's core features.",reset:"Reset Tour",resetSuccess:"Reset complete. Tour will start automatically on next visit."},FY={title:_Y,crumb:PY,workspace:AY,cursor:IY,opencode:TY,claudeCode:RY,env:LY,system:OY,shortcuts:MY,language:$Y,onboarding:DY},zY={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},BY={input:"Ask AI to help edit this node...",waiting:"Waiting for response...",selectedEmpty:"Select a node on the canvas, or use @ in the input to select instances or node types",textarea:"Describe your workflow or ask AI to help (⌘/Ctrl+Enter to send)"},HY={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},VY={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},WY={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},UY={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},KY={aiLabels:zY,placeholders:BY,actions:HY,labels:VY,tooltips:WY,rightPanel:UY},qY="Projects",YY="All",GY="Archived",XY="Nodes",JY="My Nodes",QY="My Flows",ZY="Skills",eG="Active Projects",tG="Archived Pipelines",nG="Global Nodes",rG="Manage node versions published to the current workspace marketplace, {{count}} total.",sG="Manage flow snippets published to the current workspace marketplace, {{count}} total.",iG="Global Skills",oG="Create New Project",aG="New Pipeline",lG="SEARCH PIPELINES...",cG="SEARCH NODES...",uG="SEARCH FLOW SNIPPETS...",dG="SEARCH SKILLS...",fG="Refresh Resources",pG="Loading pipelines...",hG="Loading global resources...",mG="Filter result: {{count}} items (matching title, description, path and tags)",gG="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",yG="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",xG="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",wG="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",bG="Executable building blocks for pipeline runtime",vG="Nodes define what can be placed on the canvas, which inputs and outputs exist, and whether runtime behavior is agent, control, provide, or marketplace logic.",kG="Published local node packages",SG="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",NG="Published flow snippets",jG="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",CG="Operating guides for Composer and agents",EG="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",_G="No archived projects.",PG="No active pipelines; archived items are in the Archived tab.",AG="No global nodes available.",IG="No marketplace nodes have been published.",TG="No flow snippets have been published. Select multiple canvas nodes and publish them first.",RG="No skills available.",LG="No description.",OG='No node matches "{{query}}".',MG='No flow snippet matches "{{query}}".',$G='No skill matches "{{query}}".',DG="{{inputs}} in / {{outputs}} out",FG="Flow Snippet",zG="{{nodes}} nodes / {{edges}} edges",BG="Skill",HG="Node detail",VG="Flow snippet detail",WG="Skill detail",UG="Type",KG="Source",qG="Package",YG="Version",GG="Path",XG="Editable",JG="Read only",QG="Editable",ZG="Schema",eX="Inputs",tX="Outputs",nX="Runtime",rX="Node Body",sX="Files",iX="Usage",oX="No runtime manifest.",aX="No node body or README.",lX="No previewable files.",cX="Select a file to preview.",uX="Binary file preview is not supported.",dX="Large file; showing the first 256KB only.",fX="No pipelines using this node were found.",pX="Node Management",hX="Delete Node Version",mX="Deleting...",gX="AgentFlow checks all flow references before deleting; installed or used versions are kept.",yX="Delete {{id}}@{{version}}? This cannot be undone.",xX="Deleted {{id}}@{{version}}.",wX="{{count}} flow(s) still use it.",bX="Flow Snippet Management",vX="Delete Flow Snippet",kX="Deleting...",SX="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",NX="Delete {{id}}@{{version}}? This cannot be undone.",jX="Deleted {{id}}@{{version}}.",CX="No slots",EX="Purpose",_X="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",PX="A flow snippet is a reusable part of a fixed workflow. Loading it copies its nodes, edges, and layout into the current canvas without replacing existing content.",AX="Scale",IX="Flow Preview",TX="Edges",RX="Snippet JSON",LX="{{count}} more edge(s)",OX="No previewable nodes.",MX="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",$X="SKILL.md Preview",DX="No preview content available.",FX="Select a resource to inspect details.",zX="Failed to load pipeline list.",BX="No pipelines in current workspace.",HX="Run {{code1}} in the repository root and ensure the workspace contains {{code2}} or pipelines in the user directory; or click New Pipeline to create one.",VX='No pipelines found matching "{{query}}". Try different keywords or clear the search.',WX="Recent Activity",UX="No recent activity",KX="No recent activity matching the keyword",qX="Recent Run",YX="Recent Open",GX={builtin:"Built-in",workspace:"Workspace",user:"User"},XX={flow:"Flow",global:"Global",marketplace:"Marketplace"},JX={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},QX={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},ZX="Open to edit this pipeline in the node canvas.",eJ={eyebrow:"AgentFlow Hub",title:"Browse community flows",desc:"Discover and install ready-made pipelines shared by the community.",cta:"Explore Hub",cliHint:"Or install via CLI: agentflow download <slug>"},tJ={title:"Create New Pipeline",lead:"Enter a pipeline name (English identifier); description is optional and will be saved in flow's ui.description.",nameLabel:"Name (required)",namePlaceholder:"e.g., my_feature_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",descLabel:"Description (optional)",descPlaceholder:"Briefly describe the purpose of this pipeline...",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",createFailed:"Creation failed",creating:"Creating...",createAndOpen:"Create and Open",cancel:"Cancel",close:"Close"},nJ={title:"Import Pipeline",lead:'File "{{filename}}" selected. Please confirm the pipeline name and save location; ZIP will preserve scripts and other files in the directory.',nameLabel:"Name (required)",namePlaceholder:"e.g., my_shared_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",changeFile:"Change File...",importFailed:"Import failed",importing:"Importing...",importAndOpen:"Import and Open",cancel:"Cancel",close:"Close"},rJ={title:"Delete Pipeline",lead:'This will permanently delete the pipeline directory from disk (including flow.yaml, scripts, etc.) and cannot be undone. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",deleteFailed:"Delete failed",deleteTimeout:"Delete request timed out, please retry (check UI service logs in terminal)",delete:"Delete",deleting:"Deleting...",confirmDelete:"Confirm Delete",cancel:"Cancel",close:"Close"},sJ={title:"Archive Pipeline",lead:'After archiving, the pipeline will be moved to the "Archived" list and can still be opened and edited from there. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",archiveFailed:"Archive failed",archive:"Archive",archiving:"Archiving...",confirmArchive:"Confirm Archive",cancel:"Cancel",close:"Close"},iJ={title:qY,all:YY,archived:GY,nodes:XY,myNodes:JY,myFlows:QY,skills:ZY,activeProjects:eG,archivedPipelines:tG,globalNodes:nG,myNodesHint:rG,myFlowsHint:sG,globalSkills:iG,createNew:oG,newPipeline:aG,searchPipelines:lG,searchNodes:cG,searchFlows:uG,searchSkills:dG,refreshResources:fG,loadingPipelines:pG,loadingResources:hG,filterResult:mG,archivedHint:gG,activeHint:yG,nodesHint:xG,skillsHint:wG,nodesPurposeTitle:bG,nodesPurposeDesc:vG,myNodesPurposeTitle:kG,myNodesPurposeDesc:SG,myFlowsPurposeTitle:NG,myFlowsPurposeDesc:jG,skillsPurposeTitle:CG,skillsPurposeDesc:EG,noArchived:_G,noActive:PG,noNodes:AG,noMyNodes:IG,noMyFlows:TG,noSkills:RG,noDescription:LG,noNodeMatch:OG,noFlowSnippetMatch:MG,noSkillMatch:$G,nodeSlots:DG,flowSnippet:FG,flowSnippetNodes:zG,skill:BG,nodeDetail:HG,flowDetail:VG,skillDetail:WG,detailType:UG,detailSource:KG,detailPackage:qG,detailVersion:YG,detailPath:GG,detailEditable:XG,readOnly:JG,editable:QG,nodeSchema:ZG,nodeInputs:eX,nodeOutputs:tX,nodeRuntime:nX,nodeBody:rX,nodeFiles:sX,nodeUsage:iX,noRuntimeManifest:oX,noNodeBody:aX,noNodeFiles:lX,selectNodeFile:cX,binaryFile:uX,fileTruncated:dX,noNodeUsage:fX,myNodeManagement:pX,deleteMyNode:hX,deletingMyNode:mX,deleteMyNodeHint:gX,deleteMyNodeConfirm:yX,deleteMyNodeSuccess:xX,deleteMyNodeUsedBy:wX,myFlowManagement:bX,deleteMyFlow:vX,deletingMyFlow:kX,deleteMyFlowHint:SX,deleteMyFlowConfirm:NX,deleteMyFlowSuccess:jX,noSlots:CX,resourceMeaning:EX,nodesMeaning:_X,myFlowsMeaning:PX,flowSnippetScale:AX,flowSnippetPreview:IX,flowSnippetEdges:TX,flowSnippetJson:RX,flowSnippetMoreEdges:LX,noFlowSnippetPreview:OX,skillsMeaning:MX,skillPreview:$X,skillPreviewEmpty:DX,selectResource:FX,loadFailed:zX,noPipelines:BX,emptyHint:HX,noMatch:VX,recentActivity:WX,noRecentActivity:UX,noMatchRecent:KX,recentRun:qX,recentOpen:YX,sourceBadge:GX,resourceSource:XX,resourceFilter:JX,nodeDetailTabs:QX,defaultCardDesc:ZX,hubCard:eJ,newPipelineModal:tJ,importModal:nJ,deleteModal:rJ,archiveModal:sJ},oJ="Back",aJ="Next",lJ="Skip",cJ="Done",uJ="Start Creating",dJ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
158
+
159
+ Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
160
+
161
+ Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},fJ={intro:`Now you're in the flow editor.
162
+
163
+ Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
164
+
165
+ The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
166
+
167
+ Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
168
+
169
+ The left node panel allows you to freely drag, delete, and adjust connections.`},pJ={guideTitle:"First-time Creation Guide",guideDesc:"After entering the name and description, AI will automatically generate the flow graph. You can freely adjust nodes and connections in the editor.",nameHintGuide:"e.g., MyFirstFlow (starts with a letter, supports numbers and underscores)",descPlaceholderGuide:"e.g., Implement user login functionality with registration, verification, and authorization",descHintGuide:"More detailed description leads to more accurate AI-generated flow",createGuide:"Create & Start Editing",typeNode:"Node reference type",typeStr:"String type",typeFile:"File path type",typeBool:"Boolean type"},hJ={back:oJ,next:aJ,skip:lJ,done:cJ,startCreate:uJ,projects:dJ,flow:fJ,newPipeline:pJ},mJ={name:"AgentFlow",tagline:"AI 工作流编排"},gJ={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},yJ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},xJ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},wJ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},bJ={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},vJ={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},kJ={app:mJ,nav:gJ,common:yJ,status:xJ,nodeTypes:wJ,engine:bJ,links:vJ},SJ="流程编辑器",NJ="节点",jJ="连线",CJ="属性",EJ={label:"节点标签",type:"节点类型",model:"模型",body:"内容",inputs:"输入",outputs:"输出",addInput:"添加输入",addOutput:"添加输出",remove:"删除节点",duplicate:"复制节点",nodeType:"节点类型",displayName:"显示名称",displayNameHint:"(字母、数字、下划线、短横线,勿以数字开头)",role:"角色",modelHint:"来自 ~/agentflow/model-lists.json;UI 服务启动时会后台执行 agentflow update-model-lists",defaultModel:"默认",userPrompt:"用户提示(USER PROMPT / body)",systemDescription:"系统说明(只读,来自节点定义)",directCommand:"直接执行命令",scriptHint:"(tool_nodejs:有 script 时跳过 AI,由流水线执行)",diskRunning:"磁盘记录为执行中",deleteNode:"删除节点",inputTooltip:"输入 {{name}} | 类型: {{type}}",outputTooltip:"输出 {{name}} | 类型: {{type}}",defaultSuffix:" | 默认: {{value}}",fallbackLabel:"节点",expandProvide:"编辑内容"},_J={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},PJ={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},AJ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},IJ={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},TJ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},RJ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},LJ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},OJ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},MJ={node:"节点",text:"文本",file:"文件",bool:"布尔"},$J={title:"节点执行上下文",resizeHandle:"拖动调整节点上下文宽度",apiConnectError:"无法连接 API(请使用 agentflow ui 打开页面,或为 Vite 开发配置 /api 代理)",invalidJson:"响应不是有效 JSON",requestTimeout:"请求超时,请稍后重试或检查 agentflow ui",executingNoArtifacts:"执行中,产物尚未写入工作区…",noData:"暂无数据(本 run 尚未执行到该节点或未产生产物)",latest:"最新",detectedContentType:"检测到的内容类型",roundNoContent:"该轮次暂无内容",empty:"(空)",imageTruncated:"图像已截断(超过大小上限)",statusSuccess:"成功",statusFailed:"失败",statusRunning:"运行中",statusCacheMiss:"缓存失效",statusPending:"等待"},DJ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},FJ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},zJ={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},BJ={mainNav:"主导航"},HJ={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},VJ={title:"AI 助手",placeholder:"让 AI 协助编辑此节点…",thinking:"思考",reply:"回复",result:"结果",error:"错误",waiting:"等待响应…",yourQuestion:"您的问题",send:"发送",expand:"展开对话",collapse:"收起",connecting:"连接中…",requestFailed:"请求失败",cannotReadStream:"无法读取响应流",connectTimeout:"连接超时(120s),请确认 UI 服务正在运行并重试。[CONNECT_TIMEOUT]",aborted:"已中止",executing:"执行中…",ready:"就绪",done:"完成",inputPlaceholder:"在此输入问题(⌘/Ctrl+Enter 发送)",inputAriaLabel:"问题输入",mentionAriaLabel:"提及:实例与节点类型",modelLabel:"模型",modelAriaLabel:"对话模型",modelDefault:"默认",modelNotInList:"(不在当前列表)",stopGeneration:"停止生成",conversationOutput:"对话与输出",collapseAriaLabel:"收起",closeSidebar:"关闭侧栏",endConversation:"结束对话(将停止生成)",closeConversation:"关闭对话",newConversation:"新建对话",switchConversation:"切换对话",selectedNodesAriaLabel:"已选节点列表",selectedNodesEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",removeFromInput:"从输入中移除 @{{id}}",deselectNode:"取消选中 {{id}}",taskPlan:`📋 任务规划({{count}} 步):
170
+ {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
171
+ 当前:{{current}}`,phaseComplete:"{{phaseName}}已完成。下一阶段:{{nextPhase}}",nextPhase:"下一阶段",continuePhase:"继续{{label}}",skipRemainingPhases:"请一次性完成剩余所有步骤(跳过分阶段确认)",phaseProgress:"分阶段进度",phaseReviewLabel:"分阶段选项",phaseReviewHint:"当前阶段完成,请在画布上检查结果,确认无误后进入「{{nextPhase}}」",phaseReviewContinue:"继续:{{label}}",phaseReviewSkip:"跳过,一次性完成剩余",stepsAriaLabel:"任务步骤进度",phasesAriaLabel:"生成阶段进度",phaseNumber:"第 {{index}} 阶段",stepRoleLabel:"角色:{{role}}",stepInstanceLabel:"实例:{{instanceId}}",pageRefreshReset:"页面刷新后重置",conversationLabel:"对话 {{n}}"},WJ={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},UJ={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},KJ={connectingApi:"正在连接 /api/flow/run…",connectingApiResume:"正在连接 /api/flow/run(恢复 run uuid={{uuid}})…",connectedReceiving:"已连接执行流,正在接收 NDJSON 输出…",noBody:"响应无 body(无法流式读取),请检查浏览器与 agentflow ui 版本",nodeStart:"▶ 开始执行: {{instanceId}}",nodeStartWithLabel:"▶ 开始执行: {{instanceId}} ({{label}})",nodeDone:"✓ 完成: {{instanceId}}",nodeDoneWithElapsed:"✓ 完成: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ 失败: {{instanceId}}",pipelineStart:"流水线开始执行 (uuid={{uuid}})",pipelineDone:"流水线执行完成",pipelineDoneWithElapsed:"流水线执行完成 ({{elapsed}})",pipelinePaused:"流水线暂停: 等待用户输入 ({{nodes}})",unknownError:"未知错误",executionEnd:"执行结束 (exit code: {{exitCode}})",executionStopped:"执行已暂停",pauseRun:"暂停运行(可稍后恢复)",pauseConfirm:"确认暂停当前 run?之后可从中断节点恢复。",pauseTitle:"暂停运行",pauseConfirmOk:"暂停",backPromptTitle:"返回项目列表",backPromptMessage:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。",backBackground:"后台运行并退出",backStopEdit:"停止并进入编辑",resizeConsole:"拖动调整执行日志高度",closeLog:"关闭日志",userCheckContent:"等待用户确认节点 {{instanceId}} 的内容",userAskPrompt:"等待用户选择节点 {{instanceId}} 的分支"},qJ={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},YJ={title:"流水线设置",subtitle:"管理流水线的基础信息、存储位置、节点市场、定时任务与元数据。",sectionNav:"设置分区",basicInfo:"基础信息",storageAndPath:"存储与路径",nodeMarketplace:"节点市场配置",overview:"流水线概览",owner:"所有者",source:"来源",marketplaceNodes:"市场节点",marketNodesUnit:"个市场节点",marketplaceHint:"本地市场中的节点可加入当前流水线;已加入后可直接添加到画布。",marketplaceEmpty:"当前工作区还没有安装本地市场节点。可在节点属性面板发布节点。",addNodeFromMarket:"返回画布添加节点",quickActions:"快捷操作",saveChanges:"保存更改",savingChanges:"保存中…",installNode:"加入流水线",installingNode:"加入中…",addInstalledNode:"添加到画布",previewNode:"预览",nodePreviewTitle:"节点预览",nodeStylePreview:"节点样式预览",closePreview:"关闭预览",nodeFunction:"节点用途",nodePackageInfo:"包信息",definitionId:"Definition ID",version:"版本",packagePath:"包路径",packagedFiles:"打包文件",marketplaceNoDescription:"暂无节点用途说明。",noInputs:"无输入",noOutputs:"无输出",backToCanvas:"返回画布",help:"帮助中心",helpText:"节点发布入口在节点属性面板;合集安装后会同步进入本地节点市场。",archived:"已归档",archivedNote:"此流水线位于归档目录(_archived),无法在用户目录与工作区之间移动。",builtinNote:"内置模板只读;首次保存将写入工作区 .workspace/agentflow/pipelines(流水线)、.workspace/agentflow/nodes(自定义节点)等;旧 .cursor/agentflow/ 下文件仍可读。",moveBusy:"移动中…",moveToWorkspace:"移动到工作区",moveToUserDir:"移动到用户目录",globalSettings:"全局设置",currentPipeline:"当前流水线:",builtin:"内置",rename:"重命名",renameBusy:"重命名中…",renameSuccess:"已重命名",copyPath:"复制路径",pathCopied:"已复制"},GJ={title:"定时执行",enabled:"启用定时触发",cron:"Cron 表达式",timezone:"时区",preset:"运行参数预设",defaultPreset:"默认参数",overlapSkip:"重叠策略:运行中则跳过本次触发",nextRun:"下一次预计触发:{{time}}",noNextRun:"未设置下一次触发时间",runtime:"调度状态",running:"运行中",waiting:"等待触发",disabled:"未启用",lastTriggeredAt:"最近触发",lastSkippedAt:"最近跳过",lastRun:"最近 Run",lastExit:"最近退出码",lastFinishedAt:"最近结束",readonlyNote:"内置或归档流水线不可保存定时配置。",save:"保存定时配置",saving:"保存中…",saved:"定时配置已保存"},XJ={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},JJ={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},QJ={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},ZJ={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},eQ={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},tQ={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},nQ={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},rQ={save:"保存",cancel:"取消"},sQ={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},iQ={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},oQ={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},aQ={title:SJ,nodes:NJ,edges:jJ,properties:CJ,node:EJ,nodeProps:_J,actions:PJ,panel:AJ,palette:IJ,pipeline:TJ,status:RJ,roles:LJ,phases:OJ,types:MJ,runContext:$J,shortcuts:DJ,jumpPalette:FJ,emptyCanvas:zJ,sidebar:BJ,validation:HJ,composer:VJ,topbar:WJ,palette2:UJ,run:KJ,fileEdit:qJ,settings:YJ,schedule:GJ,history:XJ,nodePropsError:JJ,placeholder:QJ,time:ZJ,userCheck:eQ,userAsk:tQ,toolPrint:nQ,provideEdit:rQ,runParams:sQ,runPreset:iQ,runConfig:oQ},lQ="设置",cQ={engine:"引擎设置",preferences:"全局首选项"},uQ={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},dQ={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},fQ={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},pQ={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},hQ={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",saving:"正在保存...",key:"键",value:"值",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},mQ={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},gQ={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},yQ={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},xQ={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},wQ={title:lQ,crumb:cQ,workspace:uQ,cursor:dQ,opencode:fQ,claudeCode:pQ,env:hQ,system:mQ,shortcuts:gQ,language:yQ,onboarding:xQ},bQ={thinking:"思考",result:"结果",reply:"回复",error:"错误"},vQ={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},kQ={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},SQ={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},NQ={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},jQ={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},CQ={aiLabels:bQ,placeholders:vQ,actions:kQ,labels:SQ,tooltips:NQ,rightPanel:jQ},EQ="项目",_Q="全部",PQ="已归档",AQ="Nodes",IQ="我的 Nodes",TQ="我的流程",RQ="Skills",LQ="活跃项目",OQ="已归档流水线",MQ="全局 Nodes",$Q="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",DQ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",FQ="全局 Skills",zQ="创建新项目",BQ="新建流水线",HQ="搜索流水线…",VQ="搜索 nodes…",WQ="搜索流程片段…",UQ="搜索 skills…",KQ="刷新资源",qQ="加载流水线列表…",YQ="加载全局资源…",GQ="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",XQ="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",JQ="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",QQ="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",ZQ="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",eZ="流程运行时的可执行积木",tZ="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",nZ="已发布的本地节点包",rZ="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",sZ="已发布的流程片段",iZ="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",oZ="Composer/Agent 的操作指南",aZ="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",lZ="暂无归档项目。",cZ="暂无未归档流水线;已归档项在 Archived 标签中查看。",uZ="暂无可用全局 nodes。",dZ="暂无已发布的 marketplace nodes。",fZ="暂无已发布的流程片段。可在画布中选中多个节点后发布。",pZ="暂无可用 skills。",hZ="暂无描述。",mZ="未找到与「{{query}}」匹配的 node。",gZ="未找到与「{{query}}」匹配的流程片段。",yZ="未找到与「{{query}}」匹配的 skill。",xZ="{{inputs}} in / {{outputs}} out",wZ="流程片段",bZ="{{nodes}} 节点 / {{edges}} 连线",vZ="Skill",kZ="Node 详情",SZ="流程片段详情",NZ="Skill 详情",jZ="类型",CZ="来源",EZ="包",_Z="版本",PZ="路径",AZ="可编辑",IZ="只读",TZ="可编辑",RZ="Schema",LZ="输入",OZ="输出",MZ="Runtime",$Z="节点内容",DZ="Files",FZ="Usage",zZ="暂无 runtime manifest。",BZ="暂无节点正文或 README。",HZ="暂无可预览文件。",VZ="请选择文件查看内容。",WZ="二进制文件暂不支持预览。",UZ="文件较大,仅显示前 256KB。",KZ="暂未发现使用此 node 的流水线。",qZ="节点管理",YZ="删除节点版本",GZ="删除中…",XZ="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",JZ="确定删除 {{id}}@{{version}}?此操作不可撤销。",QZ="已删除 {{id}}@{{version}}。",ZZ="仍有 {{count}} 个 Flow 使用它。",eee="流程片段管理",tee="删除流程片段",nee="删除中…",ree="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",see="确定删除 {{id}}@{{version}}?此操作不可撤销。",iee="已删除 {{id}}@{{version}}。",oee="无槽位",aee="作用",lee="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",cee="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",uee="规模",dee="流程预览",fee="连线",pee="片段 JSON",hee="还有 {{count}} 条连线",mee="暂无可预览节点。",gee="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",yee="SKILL.md 预览",xee="暂无可预览内容。",wee="请选择一个资源查看详情。",bee="未能加载流水线列表。",vee="当前工作区暂无流水线。",kee="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",See="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Nee="最近打开或最近运行",jee="暂无打开或运行记录",Cee="暂无与关键词匹配的最近记录",Eee="最近运行",_ee="最近打开",Pee={builtin:"内置",workspace:"工作区",user:"用户"},Aee={flow:"Flow",global:"Global",marketplace:"Marketplace"},Iee={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Tee={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Ree="打开以在节点画布中编辑此流水线。",Lee={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Oee={title:"新建空流水线",lead:"请先填写流水线名称(英文标识);介绍可选,将保存在 flow 的 ui.description。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_feature_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",descLabel:"介绍(可选)",descPlaceholder:"简要说明此流水线的用途…",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",createFailed:"创建失败",creating:"创建中…",createAndOpen:"创建并打开",cancel:"取消",close:"关闭"},Mee={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},$ee={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Dee={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Fee={title:EQ,all:_Q,archived:PQ,nodes:AQ,myNodes:IQ,myFlows:TQ,skills:RQ,activeProjects:LQ,archivedPipelines:OQ,globalNodes:MQ,myNodesHint:$Q,myFlowsHint:DQ,globalSkills:FQ,createNew:zQ,newPipeline:BQ,searchPipelines:HQ,searchNodes:VQ,searchFlows:WQ,searchSkills:UQ,refreshResources:KQ,loadingPipelines:qQ,loadingResources:YQ,filterResult:GQ,archivedHint:XQ,activeHint:JQ,nodesHint:QQ,skillsHint:ZQ,nodesPurposeTitle:eZ,nodesPurposeDesc:tZ,myNodesPurposeTitle:nZ,myNodesPurposeDesc:rZ,myFlowsPurposeTitle:sZ,myFlowsPurposeDesc:iZ,skillsPurposeTitle:oZ,skillsPurposeDesc:aZ,noArchived:lZ,noActive:cZ,noNodes:uZ,noMyNodes:dZ,noMyFlows:fZ,noSkills:pZ,noDescription:hZ,noNodeMatch:mZ,noFlowSnippetMatch:gZ,noSkillMatch:yZ,nodeSlots:xZ,flowSnippet:wZ,flowSnippetNodes:bZ,skill:vZ,nodeDetail:kZ,flowDetail:SZ,skillDetail:NZ,detailType:jZ,detailSource:CZ,detailPackage:EZ,detailVersion:_Z,detailPath:PZ,detailEditable:AZ,readOnly:IZ,editable:TZ,nodeSchema:RZ,nodeInputs:LZ,nodeOutputs:OZ,nodeRuntime:MZ,nodeBody:$Z,nodeFiles:DZ,nodeUsage:FZ,noRuntimeManifest:zZ,noNodeBody:BZ,noNodeFiles:HZ,selectNodeFile:VZ,binaryFile:WZ,fileTruncated:UZ,noNodeUsage:KZ,myNodeManagement:qZ,deleteMyNode:YZ,deletingMyNode:GZ,deleteMyNodeHint:XZ,deleteMyNodeConfirm:JZ,deleteMyNodeSuccess:QZ,deleteMyNodeUsedBy:ZZ,myFlowManagement:eee,deleteMyFlow:tee,deletingMyFlow:nee,deleteMyFlowHint:ree,deleteMyFlowConfirm:see,deleteMyFlowSuccess:iee,noSlots:oee,resourceMeaning:aee,nodesMeaning:lee,myFlowsMeaning:cee,flowSnippetScale:uee,flowSnippetPreview:dee,flowSnippetEdges:fee,flowSnippetJson:pee,flowSnippetMoreEdges:hee,noFlowSnippetPreview:mee,skillsMeaning:gee,skillPreview:yee,skillPreviewEmpty:xee,selectResource:wee,loadFailed:bee,noPipelines:vee,emptyHint:kee,noMatch:See,recentActivity:Nee,noRecentActivity:jee,noMatchRecent:Cee,recentRun:Eee,recentOpen:_ee,sourceBadge:Pee,resourceSource:Aee,resourceFilter:Iee,nodeDetailTabs:Tee,defaultCardDesc:Ree,hubCard:Lee,newPipelineModal:Oee,importModal:Mee,deleteModal:$ee,archiveModal:Dee},zee="返回",Bee="下一步",Hee="跳过",Vee="完成",Wee="开始创建",Uee={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
172
+
173
+ 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
174
+
175
+ 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Kee={intro:`现在进入流程编辑器。
176
+
177
+ 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
178
+
179
+ 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
180
+
181
+ 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
182
+
183
+ 左侧节点面板可以自由拖拽、删除和调整连接。`},qee={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Yee={back:zee,next:Bee,skip:Hee,done:Vee,startCreate:Wee,projects:Uee,flow:Kee,newPipeline:qee},Gee={en:{common:Hq,flow:EY,settings:FY,composer:KY,project:iJ,onboarding:hJ},zh:{common:kJ,flow:aQ,settings:wQ,composer:CQ,project:Fee,onboarding:Yee}};Nr.use(cT).use(vO).init({resources:Gee,fallbackLng:"en",debug:!1,ns:["common","flow","settings","composer","project","onboarding"],defaultNS:"common",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"agentflow-lang",caches:["localStorage"]}});const Xee=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Jee(e){return Nr.changeLanguage(e)}const Ow="agentflow-settings-opencode-plan-v1";function By(e){if(!e||typeof e!="object")return{cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null};const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null}}function uT(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Qee(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Hp(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=String(n.key??"").trim(),s=String(n.value??""),i=String(n.id??"").trim()||uT();!r&&!s||t.push({id:i,key:r,value:s})}return t}function Hj(){try{return localStorage.getItem(Ow)??""}catch{return""}}function Zee(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Vj(e,t="zh"){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return String(e);try{const r=t==="en"?"en-US":t==="ja"?"ja-JP":"zh-CN";return new Intl.DateTimeFormat(r,{dateStyle:"short",timeStyle:"medium"}).format(new Date(n))}catch{return String(e)}}function ete({authUser:e}){const{t,i18n:n}=pn(["common","settings"]),r=n.language||"zh",[s,i]=m.useState(""),[a,l]=m.useState(""),[c,d]=m.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[u,f]=m.useState(""),[p,h]=m.useState(!1),[g,v]=m.useState(!1),[k,y]=m.useState(""),[b,w]=m.useState([]),[S,C]=m.useState(""),[N,I]=m.useState(!1),[M,R]=m.useState(""),[F,O]=m.useState(""),[L,W]=m.useState(""),[D,$]=m.useState([]),[A,B]=m.useState(!1),[P,T]=m.useState(""),E=m.useRef(null),Y=m.useRef(!1),Q=m.useRef(!1),U=m.useRef(""),re=m.useCallback(async()=>{l("");try{const ee=await fetch("/api/ui-context");if(!ee.ok)throw new Error("HTTP "+ee.status);const De=await ee.json();i(typeof De.workspaceRoot=="string"?De.workspaceRoot:"")}catch(ee){l(String(ee.message||ee)),i("")}},[]),ue=m.useCallback(async()=>{f(""),h(!0);try{const ee=await fetch("/api/model-lists");if(!ee.ok)throw new Error("HTTP "+ee.status);const De=await ee.json();d(By(De))}catch(ee){f(String(ee.message||ee))}finally{h(!1)}},[]),ge=m.useCallback(async()=>{C("");try{const ee=await fetch("/api/user-env"),De=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof De.error=="string"?De.error:"HTTP "+ee.status);const tt=Hp(Array.isArray(De.env)?De.env:[]);U.current=JSON.stringify(tt),w(tt)}catch(ee){w([]),C(String(ee.message||ee))}finally{Q.current=!0}},[]),le=m.useCallback(async()=>{if(e!=null&&e.isAdmin){B(!0),T("");try{const ee=await fetch("/api/feedback"),De=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof De.error=="string"?De.error:"HTTP "+ee.status);$(Array.isArray(De.feedback)?De.feedback:[])}catch(ee){T(String(ee.message||ee))}finally{B(!1)}}},[e==null?void 0:e.isAdmin]),ce=m.useCallback(async ee=>{const De=Hp(ee);I(!0),C("");try{const tt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:De})}),Nt=await tt.json().catch(()=>({}));if(!tt.ok)throw new Error(typeof Nt.error=="string"?Nt.error:"HTTP "+tt.status);const en=Hp(Array.isArray(Nt.env)?Nt.env:[]);U.current=JSON.stringify(en),w(en)}catch(tt){C(String(tt.message||tt))}finally{I(!1)}},[]),de=m.useCallback(async()=>{f(""),h(!0);try{const ee=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:L.trim()})}),De=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof De.error=="string"?De.error:"HTTP "+ee.status);d(By(De.modelLists))}catch(ee){f(String(ee.message||ee))}finally{h(!1)}},[L]);m.useEffect(()=>{re(),ue(),ge(),e!=null&&e.isAdmin&&le(),(async()=>{try{const ee=await fetch("/api/agentflow-config");if(ee.ok){const De=await ee.json(),tt=typeof De.opencodeProvider=="string"?De.opencodeProvider:"";W(tt),E.current=tt;try{localStorage.setItem(Ow,tt)}catch{}}else{const De=Hj();W(De),E.current=De}}catch{const ee=Hj();W(ee),E.current=ee}finally{Y.current=!0}})()},[e==null?void 0:e.isAdmin,re,le,ue,ge]),m.useEffect(()=>{if(!Q.current||JSON.stringify(Hp(b))===U.current)return;const De=setTimeout(()=>{ce(b)},350);return()=>clearTimeout(De)},[b,ce]),m.useEffect(()=>{if(!Y.current)return;const ee=L.trim();if(ee===E.current)return;const De=setTimeout(()=>{(async()=>{v(!0),y("");try{const tt=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ee})}),Nt=await tt.json().catch(()=>({}));if(!tt.ok)throw new Error(typeof Nt.error=="string"?Nt.error:"HTTP "+tt.status);E.current=ee;try{localStorage.setItem(Ow,ee)}catch{}Nt.modelLists&&d(By(Nt.modelLists))}catch(tt){y(String(tt.message||tt))}finally{v(!1)}})()},450);return()=>clearTimeout(De)},[L]);const Ae=c.cursor.length>0,Ne=c.opencode.length>0,Pe=c.claudeCode.length>0,Ie=m.useCallback(()=>{var ee;s&&((ee=navigator.clipboard)==null||ee.writeText(s))},[s]),qe=m.useCallback(()=>{const ee=M.trim(),De=F;if(ee){if(!Qee(ee)){C(t("settings:env.invalidKey"));return}w(tt=>[...tt,{id:uT(),key:ee,value:De}]),R(""),O("")}},[M,F,t]),ct=m.useCallback(ee=>{w(De=>De.filter(tt=>tt.id!==ee))},[]),Ge=m.useCallback(ee=>{const De=ee.target.value;Jee(De)},[]),xt=ee=>{const De=Vj(ee,r);return De?t("settings:cursor.modelList.fetchedAt",{time:De}):t("settings:cursor.modelList.never")},Fe=ee=>Vj(ee,r)||String(ee||"");return o.jsxs("div",{className:"af-settings-page",children:[o.jsx("header",{className:"af-settings-top",children:o.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,u?o.jsx("p",{className:"af-err af-settings-api-hint",children:u}):null,S?o.jsx("p",{className:"af-err af-settings-api-hint",children:S}):null]}),o.jsxs("div",{className:"af-settings-layout",children:[o.jsxs("div",{className:"af-settings-bento",children:[o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[o.jsxs("div",{className:"af-set-card-inner",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),o.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Ie,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),o.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),o.jsx("span",{className:"af-set-badge"+(Ae?" af-set-badge--ok":" af-set-badge--muted"),children:t(Ae?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Ae?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(Ae?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Ae?t("settings:cursor.modelList.count",{count:c.cursor.length})+" · "+xt(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Ae?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:c.cursor.join(`
184
+ `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>de(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),o.jsx("span",{className:"af-set-badge"+(Ne?" af-set-badge--ok":" af-set-badge--err"),children:t(Ne?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),o.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:L,onChange:ee=>W(ee.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,k?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:k}):null]}),Ne?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+" · "+xt(c.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:c.opencode.join(`
185
+ `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>de(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(Pe?" af-set-badge--ok":" af-set-badge--err"),children:t(Pe?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Pe?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(Pe?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Pe?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+" · "+xt(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),Pe?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:c.claudeCode.join(`
186
+ `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>de(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),o.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:t(N?"settings:env.saving":"settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows",children:[b.map(ee=>o.jsxs("div",{className:"af-set-env-row",children:[o.jsxs("div",{className:"af-set-env-cell",children:[o.jsx("span",{className:"af-set-env-k",children:t("settings:env.key")}),o.jsx("code",{className:"af-set-code-key",children:ee.key||"—"})]}),o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow",children:[o.jsx("span",{className:"af-set-env-k",children:t("settings:env.value")}),o.jsx("code",{className:"af-set-code-val",children:Zee(ee.value)})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ee.key}),onClick:()=>ct(ee.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ee.id)),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft",children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-input af-set-input--dashed af-set-input--mono",placeholder:"KEY_NAME",value:M,onChange:ee=>R(ee.target.value),"aria-label":t("settings:env.newKey")})}),o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow",children:o.jsx("input",{className:"af-set-input af-set-input--dashed af-set-input--mono",type:"password",placeholder:t("settings:env.newValue"),value:F,onChange:ee=>O(ee.target.value),"aria-label":t("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:qe,disabled:!M.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]})]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),o.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void le(),disabled:A,children:A?"刷新中...":"刷新"})]}),P?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:P}):null,o.jsx("div",{className:"af-feedback-list",children:D.length>0?D.map(ee=>o.jsxs("article",{className:"af-feedback-item",children:[o.jsxs("header",{className:"af-feedback-item__head",children:[o.jsxs("div",{children:[o.jsx("h3",{children:ee.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:ee.username||ee.userId||"unknown"}),o.jsx("span",{children:Fe(ee.createdAt)})]})]}),ee.contact?o.jsx("span",{className:"af-feedback-item__contact",children:ee.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:ee.content}),ee.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:ee.pageUrl}):null]},ee.id)):o.jsx("div",{className:"af-feedback-empty",children:A?"正在加载反馈...":"暂无反馈"})})]}):null]}),o.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[o.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[o.jsxs("div",{className:"af-set-rail-inner",children:[o.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),o.jsxs("div",{className:"af-set-health-line",children:[o.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),o.jsx("span",{className:"af-set-health-label",children:t(!a&&!u?"settings:system.normal":"settings:system.abnormal")})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.cursorModels")}),o.jsx("span",{children:c.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.opencodeModels")}),o.jsx("span",{children:c.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.claudeCodeModels")}),o.jsx("span",{children:c.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]})]}),o.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),o.jsxs("div",{className:"af-set-rail-card",children:[o.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Ge,"aria-label":t("settings:language.description"),children:Xee.map(ee=>o.jsxs("option",{value:ee.code,children:[ee.flag," ",ee.name]},ee.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function tte(){const{navigate:e}=Ma(),[t,n]=m.useState(""),[r,s]=m.useState(""),[i,a]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),[f,p]=m.useState(!1),h=async g=>{if(g.preventDefault(),!l){c(!0),u("");try{const v=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,content:r,contact:i,pageUrl:window.location.href})}),k=await v.json().catch(()=>({}));if(!v.ok)throw new Error(k.error||"提交失败");p(!0),n(""),s(""),a("")}catch(v){u(String(v.message||v))}finally{c(!1)}}};return o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),f?o.jsxs("div",{className:"af-feedback-success",role:"status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsxs("div",{children:[o.jsx("strong",{children:"已提交"}),o.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,o.jsxs("form",{className:"af-feedback-form",onSubmit:h,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:t,onChange:g=>n(g.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:r,onChange:g=>s(g.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"联系方式"}),o.jsx("input",{value:i,onChange:g=>a(g.target.value),placeholder:"可选,方便后续沟通",maxLength:160})]}),d?o.jsx("p",{className:"af-err af-feedback-error",children:d}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:l||!t.trim()||!r.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:l?"hourglass_empty":"send"}),l?"提交中...":"提交反馈"]})})]})]})})}function dT(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Wj(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:dT(),key:r,value:String(s??""),private:n.has(r)}))}function Uj(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.key)||"").trim();r&&(t[r]=String((n==null?void 0:n.value)??""))}return t}function hh(e=null){const t=e!=null&&e.raw&&typeof e.raw=="object"?e.raw:{},n=Array.isArray(t.args)?t.args:Array.isArray(e==null?void 0:e.args)?e.args:[];return{originalName:String((e==null?void 0:e.name)||""),name:String((e==null?void 0:e.name)||""),type:e!=null&&e.url||t.url?"url":"command",url:String((e==null?void 0:e.url)||t.url||""),command:String((e==null?void 0:e.command)||t.command||""),argsText:n.map(String).join(`
187
+ `),description:String((e==null?void 0:e.description)||t.description||""),envRows:Wj(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:Wj(t.headers||(e==null?void 0:e.headers),e==null?void 0:e.privateHeaderKeys),extraJson:JSON.stringify(Object.fromEntries(Object.entries(t).filter(([r])=>!["url","command","args","env","headers","description","__agentflowPrivateKeys"].includes(r))),null,2)}}function Hy(){return hh({name:"",raw:{command:""}})}function nte(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const i=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);i.length&&(n.args=i)}const r=Uj(e.envRows),s=Uj(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(s).length&&(n.headers=s),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean)}}function Kj(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function qj(e){return e?e.ok?"ok":"error":"unknown"}function Yj({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,c)=>n(t.map(d=>d.id===a?{...d,[l]:c}:d));return o.jsxs("div",{className:"af-mcp-field",children:[o.jsxs("div",{className:"af-mcp-field-head",children:[o.jsx("span",{children:e}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:dT(),key:"",value:"",private:!0}]),children:"添加"})]}),o.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?o.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>o.jsxs("div",{className:"af-mcp-kv-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>i(a.id,"key",l.target.value)}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>i(a.id,"value",l.target.value)}),o.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[o.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>i(a.id,"private",l.target.checked)}),o.jsx("span",{children:"个人"})]}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function rte(){var L;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,i]=m.useState(Hy),[a,l]=m.useState(""),[c,d]=m.useState(!1),[u,f]=m.useState(!1),[p,h]=m.useState(!1),[g,v]=m.useState({}),[k,y]=m.useState(""),[b,w]=m.useState(""),S=m.useMemo(()=>n.find(W=>W.name===a)||null,[a,n]),C=S&&g[S.name]||null,N=m.useCallback(async()=>{d(!0),y("");try{const W=await fetch("/api/mcps"),D=await W.json().catch(()=>({}));if(!W.ok)throw new Error(D.error||"MCP HTTP "+W.status);const $=Array.isArray(D.servers)?D.servers:[];t(String(D.path||"")),r($),a&&$.some(A=>A.name===a)&&i(hh($.find(A=>A.name===a)))}catch(W){y(String(W.message||W))}finally{d(!1)}},[a]);m.useEffect(()=>{N()},[N]);const I=()=>{l(""),i(Hy()),w(""),y("")},M=W=>{l(W.name),i(hh(W)),w(""),y("")},R=async(W="")=>{h(!0),y(""),w("");try{const D=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W?{name:W}:{})}),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error($.error||"检测 MCP 失败");const A=Array.isArray($.results)?$.results:[];v(B=>{const P={...B};for(const T of A)T!=null&&T.name&&(P[T.name]=T);return P}),w(W?`已检测 ${W}。`:"已检测所有 MCP。")}catch(D){y(String(D.message||D))}finally{h(!1)}},F=async()=>{f(!0),y(""),w("");try{const W=nte(s);if(!W.nextName)throw new Error("请填写 MCP 名称");const D=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error($.error||"保存 MCP 失败");const A=Array.isArray($.servers)?$.servers:[];r(A),t(String($.path||e)),l(W.nextName),i(hh(A.find(B=>B.name===W.nextName)||null)),v(B=>{const P={...B};return s.originalName&&s.originalName!==W.nextName&&delete P[s.originalName],delete P[W.nextName],P}),w("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(W){y(String(W.message||W))}finally{f(!1)}},O=async W=>{if(W!=null&&W.name&&window.confirm(`删除 MCP "${W.name}"?`)){f(!0),y(""),w("");try{const D=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W.name})}),$=await D.json().catch(()=>({}));if(!D.ok)throw new Error($.error||"删除 MCP 失败");r(Array.isArray($.servers)?$.servers:[]),l(""),i(Hy()),v(A=>{const B={...A};return delete B[W.name],B}),w("已删除。")}catch(D){y(String(D.message||D))}finally{f(!1)}}};return o.jsxs("main",{className:"af-settings-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),o.jsxs("div",{className:"af-settings-top-right",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:c||u,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(),disabled:p||c||u||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:I,disabled:u,children:"新增 MCP"})]})]}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("section",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),o.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",o.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),o.jsxs("div",{className:"af-mcp-layout",children:[o.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2",children:"Servers"}),o.jsxs("div",{className:"af-mcp-list-head-actions",children:[o.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),o.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:I,disabled:u,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?o.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?o.jsxs("div",{className:"af-mcp-empty",children:[o.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:I,disabled:u,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(W=>o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===W.name?" af-mcp-server-item--active":""),onClick:()=>M(W),children:[o.jsx("span",{className:"material-symbols-outlined",children:W.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:W.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${qj(g[W.name])}`,children:Kj(g[W.name])})]}),o.jsx("em",{children:W.url||[W.command,...W.args||[]].filter(Boolean).join(" ")})]})]},W.name))})]}),o.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:S?"编辑 MCP":"新增 MCP"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),S?o.jsxs("div",{className:"af-mcp-editor-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(S.name),disabled:p||u,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>O(S),disabled:u,children:"删除"})]}):null]}),k?o.jsx("p",{className:"af-mcp-error",children:k}):null,b?o.jsx("p",{className:"af-mcp-status",children:b}):null,C?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${qj(C)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:Kj(C)}),o.jsxs("span",{children:[C.elapsedMs||0,"ms"]})]}),C.error?o.jsx("p",{children:C.error}):null,(L=C.tools)!=null&&L.length?o.jsx("div",{className:"af-mcp-tools-list",children:C.tools.map(W=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:W.name}),W.description?o.jsx("span",{children:W.description}):null]},W.name))}):null]}):null,o.jsxs("div",{className:"af-mcp-form",children:[o.jsxs("label",{className:"af-set-label",children:["MCP 名称",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:W=>i(D=>({...D,name:W.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:W=>i(D=>({...D,type:W.target.value})),children:[o.jsx("option",{value:"url",children:"URL / HTTP"}),o.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:W=>i(D=>({...D,url:W.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-set-label",children:["Command",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:W=>i(D=>({...D,command:W.target.value})),placeholder:"uvx"})]}),o.jsxs("label",{className:"af-set-label",children:["Args,每行一个",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:W=>i(D=>({...D,argsText:W.target.value})),placeholder:`mcp-server-example
188
+ --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:W=>i(D=>({...D,description:W.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(Yj,{title:"Headers",rows:s.headerRows,onChange:W=>i(D=>({...D,headerRows:W})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(Yj,{title:"Env",rows:s.envRows,onChange:W=>i(D=>({...D,envRows:W})),placeholderKey:"TOKEN",placeholderValue:"..."}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:W=>i(D=>({...D,extraJson:W.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:I,disabled:u,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:F,disabled:u,children:u?"保存中...":"保存 MCP"})]})]})]})]})})]})}function fT(e){return t=>typeof t===e}var ste=fT("function"),ite=e=>e===null,Gj=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",Xj=e=>!ote(e)&&!ite(e)&&(ste(e)||typeof e=="object"),ote=fT("undefined");function ate(e,t,n){return hte(n,e,t)?!0:(mte(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?lte(e,t,n):e instanceof Map&&t instanceof Map?dte(e,t,n):e instanceof Set&&t instanceof Set?pte(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?cte(e,t):Gj(e)&&Gj(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?ute(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():fte(e,t,n))}function Cf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!Xj(e)||!t||!Xj(t)?!1:ate(e,t,n)}function lte(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!Cf(e[s],t[s],n))return!1;return!0}function cte(e,t){if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer),r=new DataView(t.buffer);let s=e.byteLength;for(;s--;)if(n.getUint8(s)!==r.getUint8(s))return!1;return!0}function ute(e,t,n){return e.message===t.message&&e.name===t.name&&Cf(e.cause,t.cause,n)}function dte(e,t,n){if(e.size!==t.size)return!1;for(const r of e.entries())if(!t.has(r[0]))return!1;for(const r of e.entries())if(!Cf(r[1],t.get(r[0]),n))return!1;return!0}function fte(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=r.length;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[s]))return!1;for(let s=r.length;s--!==0;){const i=r[s];if(!(i==="_owner"&&e.$$typeof)&&!Cf(e[i],t[i],n))return!1}return!0}function pte(e,t){if(e.size!==t.size)return!1;for(const n of e.entries())if(!t.has(n[0]))return!1;return!0}function hte(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function mte(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function Cv(e,t){return Cf(e,t,new WeakMap)}function Vy(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function gte(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function yte(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function xte(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function wte(e,t){const n=xte();m.useEffect(()=>{if(!n)return e()},t)}function pT(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function bte(e,t){const n=m.useRef(t);return Cv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function vte(e){m.useEffect(()=>{e()},[])}function kte(e=0){const[t,n]=m.useState({height:Vy()?window.innerHeight:0,width:Vy()?window.innerWidth:0}),r=m.useRef(0),s=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!Vy())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),yte(window,"resize",i),()=>{gte(window,"resize",i)}},[]),t}var Ste=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Nte=["bigint","boolean","null","number","string","symbol","undefined"];function Ef(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(jte(t))return t}function Si(e){return t=>Ef(t)===e}function jte(e){return Ste.includes(e)}function su(e){return t=>typeof t===e}function Cte(e){return Nte.includes(e)}var Ete=["innerHTML","ownerDocument","style","attributes","nodeValue"],_f=e=>Array.isArray(e),_te=e=>Ef(e)==="AsyncGeneratorFunction",Pte=Si("AsyncFunction"),Ate=su("bigint"),Ite=e=>e===!0||e===!1,Tte=Si("Date"),Rte=Si("Error"),Aa=su("function"),Lte=Si("GeneratorFunction"),Ote=e=>typeof e=="number"&&Number.isInteger(e),Mw=Si("Map"),hT=e=>Number.isNaN(e),Ev=e=>e===null,mT=Si("Function"),Mte=Si("Promise"),$te=Si("RegExp"),$w=Si("Set"),Pf=su("string"),Dte=su("symbol"),_v=su("undefined"),Fte=Si("WeakMap"),zte=Si("WeakSet"),Pv=e=>Ev(e)||_v(e),gT=e=>!_v(e),Bte=e=>su("number")(e)&&!hT(e),Hte=e=>Pf(e)&&e.trim().length>0,Vte=e=>{if(!Pf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},rg=e=>!Pv(e)&&(Aa(e)||typeof e=="object"),yT=e=>{if(Ef(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Wte=e=>Ev(e)||Cte(typeof e),Ute=e=>Ef(e)==="URL",xT=e=>!Pv(e)&&Aa(e[Symbol.iterator]),Kte=e=>xT(e)&&Aa(e.next)&&Aa(e.throw),qte=e=>Aa(e)&&/^class\s/.test(e.toString()),Yte=(e,t)=>!_f(e)||!Aa(t)?!1:e.every(n=>t(n)),Gte=e=>rg(e)&&!yT(e)&&e.nodeType===1&&Pf(e.nodeName)&&Ete.every(t=>t in e),Xte=e=>Pf(e)&&e.length===0||_f(e)&&e.length===0||rg(e)&&!Mw(e)&&!$w(e)&&Object.keys(e).length===0||$w(e)&&e.size===0||Mw(e)&&e.size===0,Jte=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Qte=(e,t)=>_f(e)?e.indexOf(t)>-1:!1,Zte=(e,t,n)=>{if(!rg(e)||!t)return!1;const r=e[t];return Aa(n)?n(r):gT(r)};function vt(e){if(e===null)return"null";switch(typeof e){case"bigint":return"bigint";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"undefined":return"undefined"}if(_f(e))return"Array";if(mT(e))return"Function";const t=Ef(e);return t||"Object"}vt.array=_f;vt.arrayOf=Yte;vt.asyncGeneratorFunction=_te;vt.asyncFunction=Pte;vt.bigint=Ate;vt.boolean=Ite;vt.class=qte;vt.date=Tte;vt.defined=gT;vt.domElement=Gte;vt.empty=Xte;vt.error=Rte;vt.function=Aa;vt.generator=Kte;vt.generatorFunction=Lte;vt.instanceOf=Jte;vt.integer=Ote;vt.iterable=xT;vt.map=Mw;vt.nan=hT;vt.null=Ev;vt.nullOrUndefined=Pv;vt.nonEmptyString=Hte;vt.number=Bte;vt.numericString=Vte;vt.object=rg;vt.oneOf=Qte;vt.plainFunction=mT;vt.plainObject=yT;vt.primitive=Wte;vt.promise=Mte;vt.propertyOf=Zte;vt.regexp=$te;vt.set=$w;vt.string=Pf;vt.symbol=Dte;vt.undefined=_v;vt.url=Ute;vt.weakMap=Fte;vt.weakSet=zte;var Lr=vt;/* v8 ignore next -- @preserve */var ene=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},tne=function(e,t){return e+of(t)},of=function(e){return e===null||typeof e=="boolean"||typeof e>"u"?"":typeof e=="number"?e.toString():typeof e=="string"?e:Array.isArray(e)?e.reduce(tne,""):ene(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?of(e.props.children):""};of.default=of;var nne=of;const Wy=Ta(nne);var wT={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(i){return typeof i=="object"&&i!==null&&!(i instanceof RegExp)&&!(i instanceof Date)}}function r(s){function i(C){return C!=="constructor"&&C!=="prototype"&&C!=="__proto__"}function a(C){let N=0;const I=C.length,M=new Array(I);for(N;N<I;++N)M[N]=y(C[N]);return M}function l(C){const N={};if(p&&Object.getPrototypeOf(C)!==t)return p(C);const I=f(C);let M,R,F;for(M=0,R=I.length;M<R;++M)i(F=I[M])&&(N[F]=y(C[F]));return N}function c(C,N){const I=C.length,M=N.length;let R=0;const F=new Array(I+M);for(R;R<I;++R)F[R]=y(C[R]);for(R=0;R<M;++R)F[R+I]=y(N[R]);return F}const d=Object.prototype.propertyIsEnumerable;function u(C){const N=Object.keys(C),I=Object.getOwnPropertySymbols(C);for(let M=0,R=I.length;M<R;++M)d.call(C,I[M])&&N.push(I[M]);return N}const f=s!=null&&s.symbols?u:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),g=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(C){return typeof C!="object"||C===null}const k=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:w,getKeys:f,isMergeableObject:h}):c;function y(C){return h(C)?Array.isArray(C)?a(C):l(C):C}function b(C,N){const I={},M=f(C),R=f(N);let F,O,L;for(F=0,O=M.length;F<O;++F)i(L=M[F])&&R.indexOf(L)===-1&&(I[L]=y(C[L]));for(F=0,O=R.length;F<O;++F)if(i(L=R[F]))if(L in C)M.indexOf(L)!==-1&&(p&&h(N[L])&&Object.getPrototypeOf(N[L])!==t?I[L]=p(N[L]):I[L]=w(C[L],N[L]));else{if(g&&typeof N[L]>"u")continue;I[L]=y(N[L])}return I}function w(C,N){if(g&&typeof N>"u")return y(C);const I=Array.isArray(N),M=Array.isArray(C);return v(N)?N:h(C)?I&&M?k(C,N):I!==M?y(N):b(C,N):y(N)}function S(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return w(arguments[0],arguments[1])}let C;for(let N=0,I=arguments.length;N<I;++N)C=w(C,arguments[N]);return C}return s!=null&&s.all?S:w}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(wT);var rne=wT.exports;const sne=Ta(rne);var ine=new Error("Element already at target scroll position"),one=new Error("Scroll cancelled"),ane=Math.min,Jj=Date.now,lne={left:Qj("scrollLeft"),top:Qj("scrollTop")};function Qj(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=une);var a=Jj(),l=n[e],c=s.ease||cne,d=isNaN(s.duration)?350:+s.duration,u=!1;return l===r?i(ine,n[e]):requestAnimationFrame(p),f;function f(){u=!0}function p(h){if(u)return i(one,n[e]);var g=Jj(),v=ane(1,(g-a)/d),k=c(v);n[e]=k*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function cne(e){return .5*(1-Math.cos(Math.PI*e))}function une(){}const dne=Ta(lne);var bT={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(kd,function(){function t(r){var s=getComputedStyle(r,null).getPropertyValue("overflow");return s.indexOf("scroll")>-1||s.indexOf("auto")>-1}function n(r){if(r instanceof HTMLElement||r instanceof SVGElement){for(var s=r.parentNode;s.parentNode;){if(t(s))return s;s=s.parentNode}return document.scrollingElement||document.documentElement}}return n})})(bT);var fne=bT.exports;const vT=Ta(fne),pne=["top","right","bottom","left"],Zj=["start","end"],e1=pne.reduce((e,t)=>e.concat(t,t+"-"+Zj[0],t+"-"+Zj[1]),[]),Jc=Math.min,hl=Math.max,gm=Math.round,Vp=Math.floor,Qi=e=>({x:e,y:e}),hne={left:"right",right:"left",bottom:"top",top:"bottom"};function Dw(e,t,n){return hl(e,Jc(t,n))}function iu(e,t){return typeof e=="function"?e(t):e}function Oo(e){return e.split("-")[0]}function Zi(e){return e.split("-")[1]}function kT(e){return e==="x"?"y":"x"}function Av(e){return e==="y"?"height":"width"}function fa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Iv(e){return kT(fa(e))}function ST(e,t,n){n===void 0&&(n=!1);const r=Zi(e),s=Iv(e),i=Av(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=xm(a)),[a,xm(a)]}function mne(e){const t=xm(e);return[ym(e),t,ym(t)]}function ym(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const t1=["left","right"],n1=["right","left"],gne=["top","bottom"],yne=["bottom","top"];function xne(e,t,n){switch(e){case"top":case"bottom":return n?t?n1:t1:t?t1:n1;case"left":case"right":return t?gne:yne;default:return[]}}function wne(e,t,n,r){const s=Zi(e);let i=xne(Oo(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(ym)))),i}function xm(e){const t=Oo(e);return hne[t]+e.slice(t.length)}function bne(e){return{top:0,right:0,bottom:0,left:0,...e}}function NT(e){return typeof e!="number"?bne(e):{top:e,right:e,bottom:e,left:e}}function wm(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function r1(e,t,n){let{reference:r,floating:s}=e;const i=fa(t),a=Iv(t),l=Av(a),c=Oo(t),d=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Zi(t)){case"start":h[a]-=p*(n&&d?-1:1);break;case"end":h[a]+=p*(n&&d?-1:1);break}return h}async function vne(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=iu(t,e),g=NT(h),k=l[p?f==="floating"?"reference":"floating":f],y=wm(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(k)))==null||n?k:k.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),b=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},C=wm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:w,strategy:c}):b);return{top:(y.top-C.top+g.top)/S.y,bottom:(C.bottom-y.bottom+g.bottom)/S.y,left:(y.left-C.left+g.left)/S.x,right:(C.right-y.right+g.right)/S.x}}const kne=50,Sne=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:vne},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:f}=r1(d,r,c),p=r,h=0;const g={};for(let v=0;v<i.length;v++){const k=i[v];if(!k)continue;const{name:y,fn:b}=k,{x:w,y:S,data:C,reset:N}=await b({x:u,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});u=w??u,f=S??f,g[y]={...g[y],...C},N&&h<kne&&(h++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(d=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):N.rects),{x:u,y:f}=r1(d,p,c)),v=-1)}return{x:u,y:f,placement:p,strategy:s,middlewareData:g}},Nne=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:u=0}=iu(e,t)||{};if(d==null)return{};const f=NT(u),p={x:n,y:r},h=Iv(s),g=Av(h),v=await a.getDimensions(d),k=h==="y",y=k?"top":"left",b=k?"bottom":"right",w=k?"clientHeight":"clientWidth",S=i.reference[g]+i.reference[h]-p[h]-i.floating[g],C=p[h]-i.reference[h],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let I=N?N[w]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=l.floating[w]||i.floating[g]);const M=S/2-C/2,R=I/2-v[g]/2-1,F=Jc(f[y],R),O=Jc(f[b],R),L=F,W=I-v[g]-O,D=I/2-v[g]/2+M,$=Dw(L,D,W),A=!c.arrow&&Zi(s)!=null&&D!==$&&i.reference[g]/2-(D<L?F:O)-v[g]/2<0,B=A?D<L?D-L:D-W:0;return{[h]:p[h]+B,data:{[h]:$,centerOffset:D-$-B,...A&&{alignmentOffset:B}},reset:A}}});function jne(e,t,n){return(e?[...n.filter(s=>Zi(s)===e),...n.filter(s=>Zi(s)!==e)]:n.filter(s=>Oo(s)===s)).filter(s=>e?Zi(s)===e||(t?ym(s)!==s:!1):!0)}const Cne=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:i,middlewareData:a,placement:l,platform:c,elements:d}=t,{crossAxis:u=!1,alignment:f,allowedPlacements:p=e1,autoAlignment:h=!0,...g}=iu(e,t),v=f!==void 0||p===e1?jne(f||null,h,p):p,k=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,b=v[y];if(b==null)return{};const w=ST(b,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==b)return{reset:{placement:v[0]}};const S=[k[Oo(b)],k[w[0]],k[w[1]]],C=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:b,overflows:S}],N=v[y+1];if(N)return{data:{index:y+1,overflows:C},reset:{placement:N}};const I=C.map(F=>{const O=Zi(F.placement);return[F.placement,O&&u?F.overflows.slice(0,2).reduce((L,W)=>L+W,0):F.overflows[0],F.overflows]}).sort((F,O)=>F[1]-O[1]),R=((s=I.filter(F=>F[2].slice(0,Zi(F[0])?2:3).every(O=>O<=0))[0])==null?void 0:s[0])||I[0][0];return R!==l?{data:{index:y+1,overflows:C},reset:{placement:R}}:{}}}},Ene=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...k}=iu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Oo(s),b=fa(l),w=Oo(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(d.floating)),C=p||(w||!v?[xm(l)]:mne(l)),N=g!=="none";!p&&N&&C.push(...wne(l,v,g,S));const I=[l,...C],M=await c.detectOverflow(t,k),R=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&R.push(M[y]),f){const D=ST(s,a,S);R.push(M[D[0]],M[D[1]])}if(F=[...F,{placement:s,overflows:R}],!R.every(D=>D<=0)){var O,L;const D=(((O=i.flip)==null?void 0:O.index)||0)+1,$=I[D];if($&&(!(f==="alignment"?b!==fa($):!1)||F.every(P=>fa(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:D,overflows:F},reset:{placement:$}};let A=(L=F.filter(B=>B.overflows[0]<=0).sort((B,P)=>B.overflows[1]-P.overflows[1])[0])==null?void 0:L.placement;if(!A)switch(h){case"bestFit":{var W;const B=(W=F.filter(P=>{if(N){const T=fa(P.placement);return T===b||T==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(T=>T>0).reduce((T,E)=>T+E,0)]).sort((P,T)=>P[1]-T[1])[0])==null?void 0:W[0];B&&(A=B);break}case"initialPlacement":A=l;break}if(s!==A)return{reset:{placement:A}}}return{}}}},_ne=new Set(["left","top"]);async function Pne(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=Oo(n),l=Zi(n),c=fa(n)==="y",d=_ne.has(a)?-1:1,u=i&&c?-1:1,f=iu(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),c?{x:h*u,y:p*d}:{x:p*d,y:h*u}}const Ane=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=t,c=await Pne(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},Ine=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...d}=iu(e,t),u={x:n,y:r},f=await i.detectOverflow(t,d),p=fa(Oo(s)),h=kT(p);let g=u[h],v=u[p];if(a){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=g+f[y],S=g-f[b];g=Dw(w,g,S)}if(l){const y=p==="y"?"top":"left",b=p==="y"?"bottom":"right",w=v+f[y],S=v-f[b];v=Dw(w,v,S)}const k=c.fn({...t,[h]:g,[p]:v});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[h]:a,[p]:l}}}}}};function sg(){return typeof window<"u"}function ou(e){return jT(e)?(e.nodeName||"").toLowerCase():"#document"}function js(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ro(e){var t;return(t=(jT(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jT(e){return sg()?e instanceof Node||e instanceof js(e).Node:!1}function bi(e){return sg()?e instanceof Element||e instanceof js(e).Element:!1}function Do(e){return sg()?e instanceof HTMLElement||e instanceof js(e).HTMLElement:!1}function s1(e){return!sg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof js(e).ShadowRoot}function Af(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=vi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Tne(e){return/^(table|td|th)$/.test(ou(e))}function ig(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Rne=/transform|translate|scale|rotate|perspective|filter/,Lne=/paint|layout|strict|content/,el=e=>!!e&&e!=="none";let Uy;function Tv(e){const t=bi(e)?vi(e):e;return el(t.transform)||el(t.translate)||el(t.scale)||el(t.rotate)||el(t.perspective)||!Rv()&&(el(t.backdropFilter)||el(t.filter))||Rne.test(t.willChange||"")||Lne.test(t.contain||"")}function One(e){let t=Ia(e);for(;Do(t)&&!Qc(t);){if(Tv(t))return t;if(ig(t))return null;t=Ia(t)}return null}function Rv(){return Uy==null&&(Uy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Uy}function Qc(e){return/^(html|body|#document)$/.test(ou(e))}function vi(e){return js(e).getComputedStyle(e)}function og(e){return bi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ia(e){if(ou(e)==="html")return e;const t=e.assignedSlot||e.parentNode||s1(e)&&e.host||ro(e);return s1(t)?t.host:t}function CT(e){const t=Ia(e);return Qc(t)?e.ownerDocument?e.ownerDocument.body:e.body:Do(t)&&Af(t)?t:CT(t)}function af(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=CT(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=js(s);if(i){const l=Fw(a);return t.concat(a,a.visualViewport||[],Af(s)?s:[],l&&n?af(l):[])}else return t.concat(s,af(s,[],n))}function Fw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ET(e){const t=vi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Do(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=gm(n)!==i||gm(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Lv(e){return bi(e)?e:e.contextElement}function Ic(e){const t=Lv(e);if(!Do(t))return Qi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=ET(t);let a=(i?gm(n.width):n.width)/r,l=(i?gm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Mne=Qi(0);function _T(e){const t=js(e);return!Rv()||!t.visualViewport?Mne:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $ne(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==js(e)?!1:t}function jl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=Lv(e);let a=Qi(1);t&&(r?bi(r)&&(a=Ic(r)):a=Ic(e));const l=$ne(i,n,r)?_T(i):Qi(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,f=s.height/a.y;if(i){const p=js(i),h=r&&bi(r)?js(r):r;let g=p,v=Fw(g);for(;v&&r&&h!==g;){const k=Ic(v),y=v.getBoundingClientRect(),b=vi(v),w=y.left+(v.clientLeft+parseFloat(b.paddingLeft))*k.x,S=y.top+(v.clientTop+parseFloat(b.paddingTop))*k.y;c*=k.x,d*=k.y,u*=k.x,f*=k.y,c+=w,d+=S,g=js(v),v=Fw(g)}}return wm({width:u,height:f,x:c,y:d})}function ag(e,t){const n=og(e).scrollLeft;return t?t.left+n:jl(ro(e)).left+n}function PT(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ag(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Dne(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=ro(r),l=t?ig(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=Qi(1);const u=Qi(0),f=Do(r);if((f||!f&&!i)&&((ou(r)!=="body"||Af(a))&&(c=og(r)),f)){const h=jl(r);d=Ic(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const p=a&&!f&&!i?PT(a,c):Qi(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+p.x,y:n.y*d.y-c.scrollTop*d.y+u.y+p.y}}function Fne(e){return Array.from(e.getClientRects())}function zne(e){const t=ro(e),n=og(e),r=e.ownerDocument.body,s=hl(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=hl(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ag(e);const l=-n.scrollTop;return vi(r).direction==="rtl"&&(a+=hl(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const i1=25;function Bne(e,t){const n=js(e),r=ro(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const u=Rv();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=ag(r);if(d<=0){const u=r.ownerDocument,f=u.body,p=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-h);g<=i1&&(i-=g)}else d<=i1&&(i+=d);return{width:i,height:a,x:l,y:c}}function Hne(e,t){const n=jl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=Do(e)?Ic(e):Qi(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,d=r*i.y;return{width:a,height:l,x:c,y:d}}function o1(e,t,n){let r;if(t==="viewport")r=Bne(e,n);else if(t==="document")r=zne(ro(e));else if(bi(t))r=Hne(t,n);else{const s=_T(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return wm(r)}function AT(e,t){const n=Ia(e);return n===t||!bi(n)||Qc(n)?!1:vi(n).position==="fixed"||AT(n,t)}function Vne(e,t){const n=t.get(e);if(n)return n;let r=af(e,[],!1).filter(l=>bi(l)&&ou(l)!=="body"),s=null;const i=vi(e).position==="fixed";let a=i?Ia(e):e;for(;bi(a)&&!Qc(a);){const l=vi(a),c=Tv(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Af(a)&&!c&&AT(e,a))?r=r.filter(u=>u!==a):s=l,a=Ia(a)}return t.set(e,r),r}function Wne(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?ig(t)?[]:Vne(t,this._c):[].concat(n),r],l=o1(t,a[0],s);let c=l.top,d=l.right,u=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const h=o1(t,a[p],s);c=hl(h.top,c),d=Jc(h.right,d),u=Jc(h.bottom,u),f=hl(h.left,f)}return{width:d-f,height:u-c,x:f,y:c}}function Une(e){const{width:t,height:n}=ET(e);return{width:t,height:n}}function Kne(e,t,n){const r=Do(t),s=ro(t),i=n==="fixed",a=jl(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Qi(0);function d(){c.x=ag(s)}if(r||!r&&!i)if((ou(t)!=="body"||Af(s))&&(l=og(t)),r){const h=jl(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&d();i&&!r&&s&&d();const u=s&&!r&&!i?PT(s,l):Qi(0),f=a.left+l.scrollLeft-c.x-u.x,p=a.top+l.scrollTop-c.y-u.y;return{x:f,y:p,width:a.width,height:a.height}}function Ky(e){return vi(e).position==="static"}function a1(e,t){if(!Do(e)||vi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ro(e)===n&&(n=n.ownerDocument.body),n}function IT(e,t){const n=js(e);if(ig(e))return n;if(!Do(e)){let s=Ia(e);for(;s&&!Qc(s);){if(bi(s)&&!Ky(s))return s;s=Ia(s)}return n}let r=a1(e,t);for(;r&&Tne(r)&&Ky(r);)r=a1(r,t);return r&&Qc(r)&&Ky(r)&&!Tv(r)?n:r||One(e)||n}const qne=async function(e){const t=this.getOffsetParent||IT,n=this.getDimensions,r=await n(e.floating);return{reference:Kne(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yne(e){return vi(e).direction==="rtl"}const Gne={convertOffsetParentRelativeRectToViewportRelativeRect:Dne,getDocumentElement:ro,getClippingRect:Wne,getOffsetParent:IT,getElementRects:qne,getClientRects:Fne,getDimensions:Une,getScale:Ic,isElement:bi,isRTL:Yne};function TT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xne(e,t){let n=null,r;const s=ro(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const d=e.getBoundingClientRect(),{left:u,top:f,width:p,height:h}=d;if(l||t(),!p||!h)return;const g=Vp(f),v=Vp(s.clientWidth-(u+p)),k=Vp(s.clientHeight-(f+h)),y=Vp(u),w={rootMargin:-g+"px "+-v+"px "+-k+"px "+-y+"px",threshold:hl(0,Jc(1,c))||1};let S=!0;function C(N){const I=N[0].intersectionRatio;if(I!==c){if(!S)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!TT(d,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),i}function l1(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=Lv(e),u=s||i?[...d?af(d):[],...t?af(t):[]]:[];u.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const f=d&&l?Xne(d,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(y=>{let[b]=y;b&&b.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),d&&!c&&h.observe(d),t&&h.observe(t));let g,v=c?jl(e):null;c&&k();function k(){const y=jl(e);v&&!TT(v,y)&&n(),v=y,g=requestAnimationFrame(k)}return n(),()=>{var y;u.forEach(b=>{s&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const Jne=Ane,Qne=Cne,Zne=Ine,ere=Ene,c1=Nne,tre=(e,t,n)=>{const r=new Map,s={platform:Gne,...n},i={...s.platform,_c:r};return Sne(e,t,{...s,platform:i})};var nre=typeof document<"u",rre=function(){},mh=nre?m.useLayoutEffect:rre;function bm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!bm(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!bm(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function RT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function u1(e,t){const n=RT(e);return Math.round(t*n)/n}function qy(e){const t=m.useRef(e);return mh(()=>{t.current=e}),t}function d1(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);bm(p,r)||h(r);const[g,v]=m.useState(null),[k,y]=m.useState(null),b=m.useCallback(P=>{P!==N.current&&(N.current=P,v(P))},[]),w=m.useCallback(P=>{P!==I.current&&(I.current=P,y(P))},[]),S=i||g,C=a||k,N=m.useRef(null),I=m.useRef(null),M=m.useRef(u),R=c!=null,F=qy(c),O=qy(s),L=qy(d),W=m.useCallback(()=>{if(!N.current||!I.current)return;const P={placement:t,strategy:n,middleware:p};O.current&&(P.platform=O.current),tre(N.current,I.current,P).then(T=>{const E={...T,isPositioned:L.current!==!1};D.current&&!bm(M.current,E)&&(M.current=E,ts.flushSync(()=>{f(E)}))})},[p,t,n,O,L]);mh(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(P=>({...P,isPositioned:!1})))},[d]);const D=m.useRef(!1);mh(()=>(D.current=!0,()=>{D.current=!1}),[]),mh(()=>{if(S&&(N.current=S),C&&(I.current=C),S&&C){if(F.current)return F.current(S,C,W);W()}},[S,C,W,F,R]);const $=m.useMemo(()=>({reference:N,floating:I,setReference:b,setFloating:w}),[b,w]),A=m.useMemo(()=>({reference:S,floating:C}),[S,C]),B=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!A.floating)return P;const T=u1(A.floating,u.x),E=u1(A.floating,u.y);return l?{...P,transform:"translate("+T+"px, "+E+"px)",...RT(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:E}},[n,l,A.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:W,refs:$,elements:A,floatingStyles:B}),[u,W,$,A,B])}const sre=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?c1({element:r.current,padding:s}).fn(n):{}:r?c1({element:r,padding:s}).fn(n):{}}}},f1=(e,t)=>{const n=Jne(e);return{name:n.name,fn:n.fn,options:[e,t]}},ire=(e,t)=>{const n=Zne(e);return{name:n.name,fn:n.fn,options:[e,t]}},ore=(e,t)=>{const n=ere(e);return{name:n.name,fn:n.fn,options:[e,t]}},are=(e,t)=>{const n=Qne(e);return{name:n.name,fn:n.fn,options:[e,t]}},lre=(e,t)=>{const n=sre(e);return{name:n.name,fn:n.fn,options:[e,t]}},cre={arrowBase:32,arrowColor:"#ffffff",arrowSize:16,arrowSpacing:12,backgroundColor:"#ffffff",beaconSize:36,beaconTrigger:"click",beforeTimeout:5e3,blockTargetInteraction:!1,buttons:["back","close","primary"],closeButtonAction:"close",disableFocusTrap:!1,dismissKeyAction:"close",hideOverlay:!1,loaderDelay:300,offset:10,overlayClickAction:"close",overlayColor:"#00000080",primaryColor:"#000000",scrollDuration:300,scrollOffset:20,showProgress:!1,skipBeacon:!1,skipScroll:!1,spotlightPadding:10,spotlightRadius:4,targetWaitTimeout:1e3,textColor:"#000000",width:380,zIndex:100},ure={beaconOptions:{offset:-18}},LT={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},dre={isFixed:!1,locale:LT,placement:"bottom"},fre={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Tt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},lr={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Be={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Vi={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Et={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},pre="react-joyride-portal";function hre(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function bc(...e){return sne({all:!0,isMergeableObject:t=>!(!Lr.plainObject(t)||m.isValidElement(t))})(...e)}function OT(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function ko(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=Wy(e);if(i)(i.includes("{current}")||i.includes("{total}"))&&r&&s&&(i=i.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&OT(e.type)==="function")try{i=ko(e.type({}),t)}catch{i=Wy(n)}else i=Wy(n);return i}function ur(e,t,n,...r){if(!e)return;const s=new Date,i=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}.${String(s.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${i}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function mre(e,t){const n=hre(t);return{...e,...n}}function lf(){}function gre(e){return Object.keys(e)}function vm(e,...t){if(!Lr.plainObject(e))throw new TypeError("Expected an object");const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&(t.includes(r)||(n[r]=e[r]));return n}function p1(e,...t){if(!Lr.plainObject(e))throw new TypeError("Expected an object");if(!t.length)return e;const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&t.includes(r)&&(n[r]=e[r]);return n}function zw(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(OT(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Lr.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(i=>typeof i=="string"?r(i):zw(i,t,n))});if(Lr.function(e.type)&&!Object.values(e.props).length)try{return zw(e.type({}),t,n)}catch{return e}return e}function h1(e){return gre(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Ov(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function m1(e){let t=0,n=0,r=e;for(;r;)t+=r.offsetTop,n+=r.offsetLeft,r=r.offsetParent;return{left:n,top:t}}function Mv(e){return e?e.getBoundingClientRect():null}function yre(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((i,a)=>i-a),s=Math.floor(r.length/2);return r.length%2===0?(r[s-1]+r[s])/2:r[s]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function qs(e){if(!e)return null;if(typeof e=="function")try{return e()}catch{return null}if(typeof e=="object"&&"current"in e)return e.current;if(typeof e=="string")try{return document.querySelector(e)}catch{return null}return e}function xre(e,t,n){const r=Mv(e),s=au(e),i=s?!s.isSameNode(os()):!1,a=n??lu(e);let l=0,c=(r==null?void 0:r.top)??0;return i&&a?c=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!i&&!a&&(c+=l),s.isSameNode(os())||(c+=os().scrollTop)),Math.floor(c-t)}function au(e,t){if(!e)return os();const n=vT(e);if(n){if(n.isSameNode(os()))return t?document:os();if(!(n.scrollHeight>n.offsetHeight))return os()}return n}function wre(e){const t=e.getBoundingClientRect(),n=os(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function bre(e,t){if(!e)return 0;const n=vT(e)??os(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Mv(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(MT(e)||vre(e))){const u=e.getBoundingClientRect(),f=u.top-((s==null?void 0:s.top)??0),p=f+u.height,h=n.clientHeight,g=h*.2;f>=g&&p<=h-g?c=i:c=f+i}const d=Math.floor(c-t-r);return d<0?0:d}function vre(e){return e.offsetParent!==document.body}function MT(e){if(!e)return!1;const t=au(e);return t?!t.isSameNode(os()):!1}function lu(e,t="fixed"){if(!e||!(e instanceof Element))return!1;const{nodeName:n}=e;return n==="BODY"||n==="HTML"?!1:getComputedStyle(e).position===t?!0:e.parentNode?lu(e.parentNode,t):!1}function Wp(e){if(!e)return!1;let t=e;for(;t&&t!==document.body;){if(t instanceof HTMLElement){const{display:n,visibility:r}=getComputedStyle(t);if(n==="none"||r==="hidden")return!1}t=t.parentElement??null}return!0}function g1(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Be.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?au(s):os(),l=a?!a.isSameNode(os()):!1;return(r.isFixed||lu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function os(){return document.scrollingElement??document.documentElement}function y1(e,t){const{duration:n,element:r}=t;let s=()=>{};const i=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=dne.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function kre(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,i,a)=>s+s+i+i+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const $T={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Up={...$T,borderRadius:4,padding:8};function Sre(e,t){const{styles:n}=e,r=bc(n??{},t.styles??{});let{width:s}=t;Ov()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const i={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return bc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...$T,display:"inline-flex",borderRadius:"50%",position:"relative"},beacon:{height:t.beaconSize,width:t.beaconSize},beaconInner:{animation:"joyride-beacon-inner 1.2s infinite ease-in-out",backgroundColor:t.primaryColor,borderRadius:"50%",display:"block",height:"50%",left:"50%",opacity:.7,position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:"50%"},beaconOuter:{animation:"joyride-beacon-outer 1.2s infinite ease-in-out",backgroundColor:`rgba(${kre(t.primaryColor).join(",")}, 0.2)`,border:`2px solid ${t.primaryColor}`,borderRadius:"50%",boxSizing:"border-box",display:"block",height:"100%",left:0,opacity:.9,position:"absolute",top:0,transformOrigin:"center",width:"100%"},buttonBack:{...Up,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Up,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Up,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Up,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...i,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:s},tooltipContainer:{lineHeight:1.4,textAlign:"center"},tooltipTitle:{fontSize:18,margin:0},tooltipContent:{paddingBottom:12,paddingTop:12},tooltipFooter:{alignItems:"center",display:"flex",justifyContent:"flex-end"},tooltipFooterSpacer:{flex:1}},r)}const Nre=["after","arrowBase","arrowColor","arrowSize","arrowSpacing","backgroundColor","beaconSize","beaconTrigger","before","beforeTimeout","buttons","closeButtonAction","skipBeacon","dismissKeyAction","disableFocusTrap","hideOverlay","skipScroll","blockTargetInteraction","loaderDelay","offset","overlayClickAction","overlayColor","primaryColor","scrollDuration","scrollOffset","showProgress","spotlightPadding","spotlightRadius","targetWaitTimeout","textColor","width","zIndex"];function $v(e,t){if(!t)return null;const n=bc(dre,p1(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=bc(cre,e.options??{},p1(t,...Nre)),s=Sre(e,{...n,...r}),i=bc(ure,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:bc(LT,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:jre(r.spotlightPadding),styles:s}}function jre(e){return typeof e=="number"?{top:e,right:e,bottom:e,left:e}:{top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0,left:(e==null?void 0:e.left)??0}}function Cre(e,t,n){const{action:r}=t,s=n&&[Tt.PREV,Tt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function DT(e,t=!1){return Lr.plainObject(e)?e.target?!0:(ur(t,"tour","target is missing from the step"),!1):(ur(t,"tour","step must be an object"),!1)}function FT(e,t=!1){return Lr.array(e)?e.every(n=>DT(n,t)):(ur(t,"tour","steps must be an array"),!1)}var Ere=class{constructor(e){Rn(this,"beaconPosition",null);Rn(this,"debug");Rn(this,"eventListeners",new Map);Rn(this,"listeners",new Set);Rn(this,"props");Rn(this,"snapshot");Rn(this,"state");Rn(this,"steps");Rn(this,"tooltipPosition",null);Rn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Rn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Rn(this,"getServerSnapshot",()=>this.snapshot);Rn(this,"getSnapshot",()=>this.snapshot);Rn(this,"getEventState",()=>vm(this.snapshot,"positioned"));Rn(this,"getState",()=>vm(this.snapshot,"positioned"));Rn(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&ur(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Be.BEACON_BEFORE||this.state.lifecycle===Be.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(i=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:i.onPosition;n&&n(t)});Rn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Rn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Rn(this,"on",(e,t)=>{let n=this.eventListeners.get(e);return n||(n=new Set,this.eventListeners.set(e,n)),n.add(t),()=>{n.delete(t)}});Rn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Rn(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,i=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:i,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!Cv(s,l)){this.snapshot=Object.freeze({...l});for(const c of this.listeners)c(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},s=Lr.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Lr.number(t)&&ur(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Lr.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&ur(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Tt.INIT,controlled:s,index:i,lifecycle:Be.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Et.READY:Et.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Et.WAITING&&e.size>0?{...e,status:Et.RUNNING}:e}getStep(e){return $v(this.props,this.steps[e??this.state.index])}};function _re(e){return new Ere(e)}function x1(e,t){return Math.min(Math.max(e,0),t)}function Pre(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const i=()=>e.current.getSnapshot();return{close:(k=null)=>{const{index:y,status:b}=i();b===Et.RUNNING&&e.current.updateState({action:Tt.CLOSE,index:y+1,origin:k,lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:k=>{const{controlled:y,size:b,status:w}=i();if(y){ur(r.current,"tour","go() is not supported in controlled mode");return}w===Et.RUNNING&&e.current.updateState({action:Tt.GO,index:k,lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,status:k<b?w:Et.FINISHED,waiting:!1})},info:()=>vm(e.current.getSnapshot(),"positioned"),next:k=>{const{index:y,size:b,status:w}=i();w===Et.RUNNING&&e.current.updateState({action:Tt.NEXT,index:x1(y+1,b),lifecycle:Be.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:k}=i();k===Et.RUNNING&&e.current.updateState({action:Tt.UPDATE,lifecycle:Be.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:k=>{const{index:y,size:b,status:w}=i();w===Et.RUNNING&&e.current.updateState({action:Tt.PREV,index:x1(y-1,b),lifecycle:Be.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},reset:(k=!1)=>{const{controlled:y}=i();if(y){ur(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Tt.RESET,index:0,lifecycle:Be.INIT,positioned:!1,scrolling:!1,status:k?Et.RUNNING:Et.READY,waiting:!1})},skip:k=>{const{status:y}=i();y===Et.RUNNING&&e.current.updateState({action:Tt.SKIP,lifecycle:Be.COMPLETE,origin:k,positioned:!1,scrolling:!1,status:Et.SKIPPED,waiting:!1})},start:k=>{const{index:y,size:b}=i();s.current(),e.current.updateState({action:Tt.START,index:Lr.number(k)?k:y,lifecycle:Be.INIT,positioned:!1,scrolling:!1,status:b?Et.RUNNING:Et.WAITING,waiting:!1},!0)},stop:(k=!1)=>{const{index:y,status:b}=i();[Et.FINISHED,Et.SKIPPED].includes(b)||e.current.updateState({action:Tt.STOP,index:y+(k?1:0),lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,status:Et.PAUSED,waiting:!1})}}},[e])}const Are=new Set(["origin","positioned"]);function Ire(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return ur(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const i=n.current;if(n.current=s,!i)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==i[c]&&!Are.has(c)&&(a[c]={from:i[c],to:s[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||ur(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Tre(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.useCallback((i,a,l)=>{var d;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(d=r.current)==null||d.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function ia(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],i=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(i):s===r&&i!==r},previous:t}}function Rre(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:d,index:u,lifecycle:f,positioned:p,scrolling:h,size:g,status:v}=a,k=pT(l)??null,y=m.useRef(null),b=m.useRef(i),w=m.useRef(a),S=m.useRef(s),C=m.useRef(l),N=m.useRef(k),I=m.useRef(n),M=m.useRef(null),R=m.useRef(null),F=m.useRef(null);b.current=i,w.current=a,S.current=s,C.current=l,N.current=k,I.current=n;const O=()=>{M.current&&(clearInterval(M.current),M.current=null),R.current=null,F.current&&(F.current.cancel(),F.current=null)};m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:L}=ia(w.current,S.current);(L("action",[Tt.NEXT,Tt.PREV,Tt.SKIP,Tt.CLOSE])||y.current===Tt.CLOSE&&d===Tt.START)&&(y.current=d)},[d]),m.useEffect(()=>{if(!S.current)return()=>{O()};const{hasChanged:L}=ia(w.current,S.current),W=C.current;if(L("index")&&O(),v!==Et.RUNNING||!W||f!==Be.INIT)return()=>{O()};const{hasChangedTo:D}=ia(w.current,S.current);D("status",Et.RUNNING)&&[Et.IDLE,Et.READY,Et.PAUSED].includes(S.current.status)&&r(lr.TOUR_START,W),c.current.cleanupPositionData();const{debug:$}=b.current;if(W.before&&!F.current){ur($,`step:${u}`,"before()",W),F.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(lr.STEP_BEFORE_HOOK,W,{action:y.current??w.current.action});const A=()=>{F.current=null,c.current.updateState({action:y.current??w.current.action,waiting:!1,lifecycle:Be.READY})},B=new AbortController,P=W.beforeTimeout;F.current={cancel:()=>B.abort()};const T=P?setTimeout(()=>{B.signal.aborted||(ur($,`step:${u}`,"before()","timed out",`${P}ms`),B.abort(),t(W,"before_hook"),r(lr.ERROR,W,{error:new Error("Step before hook timed out")}),A())},P):null;W.before({...c.current.getState(),action:y.current??c.current.getState().action,step:W}).then(()=>{B.signal.aborted||(T&&clearTimeout(T),A())}).catch(E=>{B.signal.aborted||(T&&clearTimeout(T),t(W,"before_hook"),r(lr.ERROR,W,{error:E instanceof Error?E:new Error(String(E))}),A())})}else if(!F.current){M.current&&R.current!==W.target&&O();const A=qs(W.target);if(A&&Wp(A))O(),c.current.updateState({action:y.current??Tt.UPDATE,lifecycle:Be.READY,waiting:!1});else if(W.targetWaitTimeout===0)c.current.updateState({action:y.current??Tt.UPDATE,lifecycle:Be.READY,waiting:!1});else if(!M.current){const{targetWaitTimeout:B}=W,P=Date.now();R.current=W.target,ur($,`step:${u}`,"polling","started",`${B}ms`),c.current.updateState({waiting:!0}),M.current=setInterval(()=>{const T=qs(W.target),E=Date.now()-P,Y=E>=B;(T&&Wp(T)||Y)&&(ur($,`step:${u}`,"polling",T&&Wp(T)?"found":"timed out",`${E}ms`),O(),c.current.updateState({action:y.current??Tt.UPDATE,lifecycle:Be.READY,waiting:!1}))},100)}}return()=>{O()}},[t,r,u,f,v,c]),m.useEffect(()=>{if(!S.current)return;const{hasChanged:L,hasChangedTo:W,previous:D}=ia(w.current,S.current),$=C.current;if(!$)return;const A=qs($.target),B=!!A;if(B&&Wp(A)){if(W("lifecycle",Be.READY)&&D.lifecycle===Be.INIT&&r(lr.STEP_BEFORE,$,{action:y.current??w.current.action}),W("lifecycle",Be.READY)){const P=w.current,T=Cre($,P,b.current.continuous)?Be.TOOLTIP:Be.BEACON,E=qs($.scrollTarget??$.spotlightTarget??$.target),Y=g1({isFirstStep:P.index===0,scrollToFirstStep:b.current.scrollToFirstStep,step:$,target:E,targetLifecycle:T}),Q=T===Be.TOOLTIP?Be.TOOLTIP_BEFORE:Be.BEACON_BEFORE;ur(b.current.debug,`step:${u}`,"scroll",Y?"needed":"skipped"),c.current.updateState({action:Tt.UPDATE,lifecycle:Q,scrolling:Y})}}else if(w.current.status===Et.RUNNING&&f!==Be.INIT&&f!==Be.COMPLETE&&L("lifecycle")){ur(b.current.debug,`step:${u}`,B?"Target not visible":"Target not mounted",$),t($,"target_not_found"),r(lr.TARGET_NOT_FOUND,$);const P=w.current;P.controlled||c.current.updateState({action:Tt.UPDATE,index:P.index+(P.action===Tt.PREV?-1:1),lifecycle:Be.INIT})}},[t,r,u,f,c]),m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:L,previous:W}=ia(w.current,S.current),D=C.current,$=N.current;if(D&&L("lifecycle",Be.TOOLTIP_BEFORE)&&W.lifecycle===Be.BEACON){const P=qs(D.scrollTarget??D.spotlightTarget??D.target);if(g1({isFirstStep:w.current.index===0,scrollToFirstStep:b.current.scrollToFirstStep,step:D,target:P,targetLifecycle:Be.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const A=f===Be.BEACON_BEFORE||f===Be.TOOLTIP_BEFORE;if(D&&A&&!h){const P=f===Be.TOOLTIP_BEFORE?Be.TOOLTIP:Be.BEACON;c.current.updateState({action:Tt.UPDATE,lifecycle:P})}D&&L("lifecycle",Be.BEACON)&&r(lr.BEACON,D),D&&L("lifecycle",Be.TOOLTIP)&&r(lr.TOOLTIP,D);const B=w.current;if((B.status===Et.RUNNING||B.controlled&&B.status===Et.PAUSED&&D)&&$&&L("lifecycle",Be.COMPLETE)&&W.lifecycle===Be.TOOLTIP&&(r(lr.STEP_AFTER,$,{action:y.current??Tt.UPDATE,index:W.index??B.index,lifecycle:B.lifecycle}),$.after)){r(lr.STEP_AFTER_HOOK,$,{action:y.current??Tt.UPDATE,index:W.index??B.index,lifecycle:B.lifecycle});try{$.after({...c.current.getState(),action:y.current??Tt.UPDATE,index:W.index??B.index,lifecycle:B.lifecycle,step:$})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:L,previous:W}=ia(w.current,S.current),D=C.current,$=N.current;g&&!D&&f===Be.INIT&&c.current.updateState({action:Tt.UPDATE,lifecycle:Be.COMPLETE,status:Et.FINISHED}),!w.current.controlled&&v===Et.RUNNING&&L("lifecycle",Be.COMPLETE)&&u<g&&c.current.updateState({action:Tt.UPDATE,lifecycle:Be.INIT}),L("lifecycle",Be.COMPLETE)&&u>=g&&c.current.updateState({action:Tt.UPDATE,lifecycle:Be.COMPLETE,status:Et.FINISHED});const A=D??$??$v(b.current,b.current.steps[u-1]);if(A&&L("status",[Et.FINISHED,Et.SKIPPED])){let B;D?B=u:$?B=W.index??u:B=u-1,r(lr.TOUR_END,A,{index:B}),w.current.controlled||I.current.reset(),y.current=null}D&&L("action",Tt.STOP)&&(y.current=null,r(lr.TOUR_STATUS,D)),D&&L("action",Tt.RESET)&&(r(lr.TOUR_STATUS,D),y.current=null)},[d,r,u,f,g,v,c])}function Lre({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:d}=n,u=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=u.current;if(u.current=n,!h||n===h)return;const{hasChanged:g}=ia(n,h);if(Cv(h.steps,d)||(FT(d,i)?s.current.setSteps(d):(ur(i,"tour","Steps are not valid",d),t(lr.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&p.current.start(c??a):p.current.stop();else if(Lr.number(c)&&g("stepIndex")){const v=Lr.number(h.stepIndex)&&h.stepIndex<c?Tt.NEXT:Tt.PREV;[Et.FINISHED,Et.SKIPPED].includes(f.current.status)||s.current.updateState({action:v,index:c,lifecycle:Be.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,d,s])}function Ore(e,t){var l,c,d,u;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:i}=t;if(i.scrollTarget||i.spotlightTarget)return Math.max(0,e);let a=e-i.spotlightPadding.top;if(r===Be.BEACON_BEFORE&&(n!=null&&n.placement)){const f=Mre(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Be.TOOLTIP_BEFORE){const{placement:f}=i;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=i.floatingOptions)!=null&&c.hideArrow?0:i.arrowSize,g=i.offset+i.spotlightPadding.top+h;a-=p+g}else if(f==="left"||f==="right"){const p=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,h=((u=qs(i.target))==null?void 0:u.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+h/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Mre(e){var n;const t=(n=e.middlewareData)==null?void 0:n.offset;return t?["left","right"].some(r=>e.placement.startsWith(r))?t.x:t.y:0}function $re({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:c,scrolling:d,status:u}=r,f=m.useRef(null),p=m.useRef(r),h=m.useRef(t),g=m.useRef(n),v=m.useRef(s);p.current=r,h.current=t,g.current=n,v.current=s,m.useEffect(()=>()=>{var k;(k=f.current)==null||k.call(f)},[]),m.useEffect(()=>{var C;if(!h.current||!v.current)return;const{hasChangedTo:k}=ia(p.current,h.current),y=v.current,{debug:b}=g.current,{scrollDuration:w}=y,S=l===Be.BEACON_BEFORE||l===Be.TOOLTIP_BEFORE;if(u===Et.RUNNING&&S&&d&&k("positioned",!0)){const N=qs(y.scrollTarget??y.spotlightTarget??y.target),I=i.current.getPositionData("beacon"),M=au(N),R=M?!M.isSameNode(os()):!1;(C=f.current)==null||C.call(f),(async()=>{if(R&&!lu(M)){const B=os(),P=wre(M),T={initial:B.scrollTop,target:P,element:B,duration:w};e(lr.SCROLL_START,y,{scroll:T});const{cancel:E,promise:Y}=y1(P,{element:B,duration:w});f.current=E,await Y,e(lr.SCROLL_END,y,{scroll:T})}const O=Math.floor(bre(N,y.scrollOffset))||0,L=R?O:Ore(O,{beaconPosition:I,lifecycle:l,scrollOffset:y.scrollOffset,step:y});ur(b,`step:${a}`,"scroll",R?"custom":"document",`${O} → ${L}`);const W=M,D={initial:W.scrollTop,target:L,element:W,duration:w};e(lr.SCROLL_START,y,{scroll:D});const{cancel:$,promise:A}=y1(L,{element:W,duration:w});f.current=$,await A,e(lr.SCROLL_END,y,{scroll:D}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,d,u,i])}function Dre(e){const t=bte(()=>mre(fre,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=m.useRef(_re(t)),d=pP.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[u,f]=m.useState([]),p=m.useCallback((C,N)=>{f(I=>[...I,{reason:N,step:C}])},[]),h=m.useCallback(()=>{f([])},[]);Ire(c,n);const g=Pre(c,n,h),v=Tre(s,g,c),{index:k,size:y,status:b}=d,w=pT(d),S=m.useMemo(()=>$v(t,l[k]),[k,t,l]);return vte(()=>{i&&y&&FT(l,n)&&g.start(a??r)}),wte(()=>{i&&y&&b===Et.IDLE&&c.current.updateState({status:Et.READY})},[i,y,b]),Lre({controls:g,emitEvent:v,props:t,state:d,store:c}),Rre({addFailure:p,controls:g,emitEvent:v,previousState:w,props:t,state:d,step:S,store:c}),$re({emitEvent:v,previousState:w,props:t,state:d,step:S,store:c}),{controls:g,failures:u,mergedProps:t,state:d,step:S,store:c}}function Fre(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Lr.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=pre,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const zre={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Bre({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return lf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
189
+ @keyframes joyride-loader-spin {
190
+ to { transform: rotate(360deg); }
191
+ }
192
+ `)),document.head.appendChild(c),()=>{const d=document.getElementById("joyride-loader-animation");d!=null&&d.parentNode&&d.parentNode.removeChild(d)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const c=n;l=et.createElement(c,{step:t})}else l=et.createElement("div",{style:{...zre,height:s,width:i,borderTopColor:t.primaryColor}});return et.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Hre={height:0,isFixed:!1,left:0,top:0,width:0};function Uu(e,t){const n=qs(e);if(!n)return Hre;const r=Mv(n),s=lu(n),i=xre(n,t.top,s);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:s,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:i,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function Vre(e,t,n){const[r,s]=m.useState(()=>Uu(e,t)),i=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),d=m.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(f=>{const p=Uu(e,t);return f.top===p.top&&f.left===p.left&&f.width===p.width&&f.height===p.height&&f.isFixed===p.isFixed?f:p})},100)},[e,t]);m.useEffect(()=>{let f=null;const p=g=>{a.current=au(g,!0),a.current&&a.current.addEventListener("scroll",d,{passive:!0}),window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(d),c.current.observe(g)),s(Uu(e,t))},h=qs(e);return h?p(h):(f=new MutationObserver(()=>{const g=qs(e);g&&(f==null||f.disconnect(),f=null,p(g))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",d),window.removeEventListener("scroll",d),window.removeEventListener("resize",d),(g=c.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,d]),m.useEffect(()=>{l.current&&!n&&s(Uu(e,t)),l.current=n},[n,e,t]);let u=r;return l.current&&!n&&(u=Uu(e,t)),u}function Wre(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function w1(e,t,n,r,s){if(n<=0||r<=0)return"";const i=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+i} ${t}`;return a+=`H${e+n-i}`,a+=`A${i} ${i} 0 0 1 ${e+n} ${t+i}`,a+=`V${t+r-i}`,a+=`A${i} ${i} 0 0 1 ${e+n-i} ${t+r}`,a+=`H${e+i}`,a+=`A${i} ${i} 0 0 1 ${e} ${t+r-i}`,a+=`V${t+i}`,a+=`A${i} ${i} 0 0 1 ${e+i} ${t}Z`,a}const Ure=[Be.BEACON_BEFORE,Be.BEACON];function Kre(e){var A,B;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:d,spotlightPadding:u,spotlightRadius:f,spotlightTarget:p,styles:h,target:g,waiting:v}=e,k=kte(),y=Vre(p??g,u,d||v),b=m.useRef(null),w=(s===Be.TOOLTIP||s===Be.TOOLTIP_BEFORE)&&l!=="center",[S,C]=m.useState(!1),N=c?(A=b.current)==null?void 0:A.offsetParent:null,I=(N==null?void 0:N.clientWidth)??k.width,M=(N==null?void 0:N.clientHeight)??yre()??k.height,R=((B=h.overlay)==null?void 0:B.backgroundColor)??"rgba(0, 0, 0, 0.5)",F=m.useMemo(()=>{const{backgroundColor:P,mixBlendMode:T,...E}=h.overlay;return{height:M,pointerEvents:"none",...E}},[M,h.overlay]),O=w&&!d&&!v;m.useEffect(()=>{O?requestAnimationFrame(()=>C(!0)):C(!1)},[O]);const L=n&&Ure.includes(s),W=!n&&s!==Be.TOOLTIP;if(r||!v&&(L||W))return null;let D="";if(O)if(c&&N){const P=qs(p??g);if(P){const T=m1(P),E=m1(N);D=w1(T.left-E.left-u.left,T.top-E.top-u.top,P.offsetWidth+u.left+u.right,P.offsetHeight+u.top+u.bottom,f)}}else D=w1(y.left,y.top,y.width,y.height,f);const $=Wre(I,M,D);return et.createElement("div",{ref:b,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:F},et.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:M,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:I}},et.createElement("path",{d:$,fill:R,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),D&&et.createElement("path",{d:D,fill:R,style:{opacity:S?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),D&&Object.keys(h.spotlight).length>0&&et.createElement("path",{d:D,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function zT(e){const{children:t,element:n}=e;return n?ts.createPortal(t,n):null}const qre='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Yre(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return lf;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(qre)],{shiftKey:l}=i;if(!a.length)return;i.preventDefault();let c=document.activeElement?a.indexOf(document.activeElement):0;c===-1||!l&&c+1===a.length?c=0:l&&c===0?c=a.length-1:c+=l?-1:1,a[c].focus()};e.addEventListener("keydown",r,!1);let s;{const i=e.querySelector(t);i&&(s=setTimeout(()=>{i.focus({preventScroll:!0})},100))}return()=>{var i;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(i=n.current)==null||i.focus({preventScroll:!0})}},[e,t])}function Eo(e,t,n){const[r]=e.split("-");switch(r){case"top":case"bottom":return{width:t,height:n};case"left":case"right":return{width:n,height:t};default:return null}}function Gre(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Eo(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Eo(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Eo(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Eo(e,t,n)};default:return null}}function Xre(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Eo(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Eo(e,r,n)};case"left":return{right:-n,top:t.y??0,...Eo(e,r,n)};case"right":return{left:-n,top:t.y??0,...Eo(e,r,n)};default:return{}}}function Jre({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!Eo(r,n,i))return null;c=et.createElement("span",{style:{flexShrink:0}},et.createElement(l,{base:n,placement:r,size:i}))}else{const d=Gre(r,n,i);if(!d)return null;c=et.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},et.createElement("polygon",{fill:"currentColor",points:d.points}))}return et.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...Xre(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function Qre(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:d,step:u,styles:f}=e,p=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return lf;const k=document.createElement("style");k.id="joyride-beacon-animation",a&&k.setAttribute("nonce",a),k.appendChild(document.createTextNode(`
193
+ @keyframes joyride-beacon-inner {
194
+ 20% {
195
+ opacity: 0.9;
196
+ }
197
+
198
+ 90% {
199
+ opacity: 0.7;
200
+ }
201
+ }
202
+
203
+ @keyframes joyride-beacon-outer {
204
+ 0% {
205
+ transform: scale(1);
206
+ }
207
+
208
+ 45% {
209
+ opacity: 0.7;
210
+ transform: scale(0.75);
211
+ }
212
+
213
+ 100% {
214
+ opacity: 0.9;
215
+ transform: scale(1);
216
+ }
217
+ }
218
+ `)),document.head.appendChild(k);const y=setTimeout(()=>{Lr.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(y);const b=document.getElementById("joyride-beacon-animation");b!=null&&b.parentNode&&b.parentNode.removeChild(b)}},[h,a,c]);const g=ko(i.open);let v;if(t){const k=t;v=et.createElement(k,{continuous:n,index:r,isLastStep:s,size:d,step:u})}else v=et.createElement("span",{style:f.beacon},et.createElement("span",{style:f.beaconOuter}),et.createElement("span",{style:f.beaconInner}));return et.createElement("button",{ref:p,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:g,type:"button"},v)}function Zre({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return et.createElement("button",{style:i,type:"button",...t},et.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof s=="number"?`${s}px`:s,xmlns:"http://www.w3.org/2000/svg"},et.createElement("g",null,et.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function ese(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:d,content:u,styles:f,title:p}=l,h={};d.includes("primary")&&(h.primary=et.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...i})),d.includes("skip")&&!s&&(h.skip=et.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(h.back=et.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=d.includes("close")&&et.createElement(Zre,{"data-testid":"button-close",styles:f.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":ko(u),"aria-describedby":"joyride-tooltip-content"};return et.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...g},et.createElement("div",{style:f.tooltipContainer},p&&et.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),et.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},u)),d.some(v=>v==="back"||v==="primary"||v==="skip")&&et.createElement("div",{style:f.tooltipFooter},et.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function tse(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(Vi.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(Vi.BUTTON_CLOSE):n.close(Vi.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(Vi.BUTTON_PRIMARY);return}n.next(Vi.BUTTON_PRIMARY)},u=y=>{y.preventDefault(),n.skip(Vi.BUTTON_SKIP)},f=()=>{const{back:y,close:b,last:w,next:S,nextWithProgress:C,skip:N}=a.locale,I=ko(y),M=ko(b),R=ko(w),F=ko(S),O=ko(N);let L=b,W=M;if(t){if(L=S,W=F,a.showProgress&&!s){const D=ko(C,{step:r+1,steps:i});L=zw(C,r+1,i),W=D}s&&(L=w,W=R)}return{backProps:{"aria-label":I,children:y,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":M,children:b,"data-action":"close",onClick:c,role:"button",title:M},primaryProps:{"aria-label":W,children:L,"data-action":"primary",onClick:d,role:"button",title:W},skipProps:{"aria-label":O,children:N,"data-action":"skip",onClick:u,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:g,...v}=a;let k;if(g){const y=g;k=et.createElement(y,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:v})}else k=et.createElement(ese,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:v});return k}function nse(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function rse(e,t,n){var r,s;return e?[are()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[ore({crossAxis:!1,fallbackPlacements:nse(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function sse(e){var T,E,Y,Q,U;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:d,shouldScroll:u,size:f,step:p,target:h,updateState:g}=e,v=m.useRef(null),k=m.useRef({}),y=m.useRef({}),b=p.placement==="center",w=p.placement==="auto",S=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),C=m.useMemo(()=>MT(h)?au(h):void 0,[h]),N=m.useMemo(()=>lu(h),[h]),I=m.useMemo(()=>C?{boundary:C,rootBoundary:"viewport"}:{},[C]),M=b||w?"bottom":p.placement,R=b?"fixed":((T=p.floatingOptions)==null?void 0:T.strategy)??(p.isFixed||N?"fixed":"absolute"),F=m.useMemo(()=>{var re,ue,ge,le;return b?[{name:"center",fn:({rects:ce})=>({x:(window.innerWidth-ce.floating.width)/2,y:(window.innerHeight-ce.floating.height)/2})}]:[f1(({placement:ce})=>{var Ne;let de="right";ce.startsWith("top")?de="top":ce.startsWith("bottom")?de="bottom":ce.startsWith("left")&&(de="left");const Ae=p.spotlightTarget?0:p.spotlightPadding[de];return p.offset+Ae+((Ne=p.floatingOptions)!=null&&Ne.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(re=p.floatingOptions)==null?void 0:re.hideArrow]),...rse(w,p,M),ire({padding:10,...I,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(ge=p.floatingOptions)!=null&&ge.hideArrow?[]:[lre({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((le=p.floatingOptions)==null?void 0:le.middleware)??[]]},[b,p,w,M,I]),O=d1({...b?{elements:{reference:S}}:{},placement:M,strategy:R,middleware:F}),L=d1({strategy:R,placement:p.beaconPlacement??(w||b?"bottom":p.placement),middleware:m.useMemo(()=>{var re,ue;return[f1(((ue=(re=p.floatingOptions)==null?void 0:re.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Y=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Y.offset]),whileElementsMounted:l1});y.current=O.middlewareData,k.current=L.middlewareData,m.useEffect(()=>{var ge;const{floating:re,reference:ue}=O.elements;if(!(!ue||!re||s!==Be.TOOLTIP))return l1(ue,re,O.update,(ge=p.floatingOptions)==null?void 0:ge.autoUpdate)},[s,O.update,(Q=p.floatingOptions)==null?void 0:Q.autoUpdate,p.target,O.elements]),m.useEffect(()=>{!b&&h&&O.refs.setReference(h),h&&L.refs.setReference(h)},[L.refs,b,h,O.refs]),m.useEffect(()=>{O.isPositioned&&c("tooltip",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:y.current})},[c,O.isPositioned,O.placement,O.x,O.y]),m.useEffect(()=>{L.isPositioned&&c("beacon",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:k.current})},[c,L.isPositioned,L.placement,L.x,L.y]);const W=p.zIndex+100,D=m.useCallback(re=>{re.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Be.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),$=m.useCallback(re=>{re&&(O.refs.setFloating(re),d(re))},[O.refs,d]),{arrow:A,floater:B}=p.styles;let P=null;if(s===Be.TOOLTIP||s===Be.TOOLTIP_BEFORE){const re=h1({...B,...O.floatingStyles,zIndex:W,opacity:a&&O.isPositioned?1:0,...!a&&{transition:"none"}});P=et.createElement("div",{ref:$,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:re},et.createElement(tse,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!b&&!((U=p.floatingOptions)!=null&&U.hideArrow)&&et.createElement(Jre,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:p.arrowSize,styles:A}))}else(s===Be.BEACON||s===Be.BEACON_BEFORE)&&(P=et.createElement("div",{ref:L.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:h1({...L.floatingStyles,zIndex:W})},et.createElement(Qre,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:i,onInteract:D,shouldFocus:u,size:f,step:p,styles:p.styles})));return et.createElement(zT,{element:l},P)}function ise(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:d,step:u,updateState:f}=e,[p,h]=m.useState(null);Yre(u.disableFocusTrap?null:p,"[data-action=primary]");const g=qs(u.target),v=s===Be.TOOLTIP;return!DT(u)||!Lr.domElement(g)?null:et.createElement(sse,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:d,step:u,target:g,updateState:f})}function ose({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,u=Fre(c),{index:f,lifecycle:p,status:h}=n,g=h===Et.RUNNING,[v,k]=m.useState(!1),y=m.useRef(null),b=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?b===0?k(!0):y.current=setTimeout(()=>{k(!0)},b):k(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[b,n.waiting]),m.useEffect(()=>{if(!g)return;const C=N=>{!r||p!==Be.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Vi.KEYBOARD):e.close(Vi.KEYBOARD))};return document.body.addEventListener("keydown",C,{passive:!0}),()=>{document.body.removeEventListener("keydown",C)}},[e,g,p,r]);const w=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Vi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Vi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const S=n.action===Tt.START&&!r.skipBeacon&&r.placement!=="center";return et.createElement(et.Fragment,null,p!==Be.INIT&&et.createElement(ise,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:u,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||d),step:r,updateState:s.current.updateState}),et.createElement(zT,{element:u},et.createElement(et.Fragment,null,v&&et.createElement(Bre,{nonce:l,step:r}),!S&&et.createElement(Kre,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:c?u:null,scrolling:n.scrolling,waiting:n.waiting}))))}function ase(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=Dre(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>vm(s,"positioned"),[s]),step:i,Tour:Ov()?et.createElement(ose,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function lse(e){const{Tour:t}=ase(e);return t}function cse(e){return Ov()?et.createElement(lse,e):null}function use(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function dse(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function fse(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Yy="af:onboarding";function pse({page:e,hasNodes:t=!1}){const{t:n}=pn(),[r,s]=m.useState(!1),[i,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?use(n):t?dse(n):fse(n),[e,t,n]);return m.useEffect(()=>{const d=localStorage.getItem(Yy);console.log("[Onboarding] localStorage:",d);const u=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",u,"page:",e),u.completed||u[e]){console.log("[Onboarding] skipped - already done"),s(!1),a([]);return}console.log("[Onboarding] starting with steps:",c),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const d=u=>{var g;const f=u.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(g=f.textContent)==null?void 0:g.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(Yy)||"{}",k=JSON.parse(v);h===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(Yy,JSON.stringify(k)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const y=document.querySelector(".af-create-btn");y&&y.click()},500))}};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(cse,{ref:l,steps:i,run:r,continuous:!0,showSkipButton:!0,showProgress:i.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function hse(){const{navigate:e,path:t}=Ma(),[n,r]=m.useState([]),[s,i]=m.useState(!1);if(m.useEffect(()=>{let u=!1;const f=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const g=await h.json();if(u)return;const v=Array.isArray(g.runs)?g.runs:[];r(v.filter(k=>k&&k.status==="running"))}catch{}};f();const p=window.setInterval(f,3e3);return()=>{u=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=u=>{const f=new URLSearchParams({flowId:u.flowId,flowSource:u.flowSource||"workspace"});e(`/flow?${f.toString()}`),i(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,c=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(u=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(u.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(u),title:`${u.flowId} · ${u.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:u.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:u.runId.slice(0,12)})]},`${u.flowId}:${u.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):i(u=>!u),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}class mse extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,i;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((i=this.state.info)==null?void 0:i.componentStack)||"");return o.jsx("div",{className:"af-auth-screen",children:o.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"error"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow UI Error"}),o.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),o.jsx("pre",{children:t}),n?o.jsx("pre",{children:n}):null]})})}}function gse({authUser:e}){const{path:t}=Ma();return t==="/projects"||t==="/"?o.jsx(Yl,{authUser:e}):t==="/nodes"?o.jsx(Yl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Yl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Yl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Yl,{authUser:e,resourceKind:"skills"}):t==="/mcps"?o.jsx(rte,{}):t==="/flow"?o.jsx($7,{}):t==="/workspace"?o.jsx(qK,{}):t==="/settings"?o.jsx(ete,{authUser:e}):t==="/feedback"?o.jsx(tte,{}):o.jsx(Yl,{})}function yse({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[i,a]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),f=async()=>{try{const g=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!g.authenticated,user:g.user||null,setupRequired:!!g.setupRequired}),u(g.error?String(g.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),u(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),u("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),v=await g.json().catch(()=>({}));if(!g.ok)throw new Error(v.error||"登录失败");n({loading:!1,authenticated:!0,user:v.user||null,setupRequired:!1})}catch(g){u(String(g.message||g))}finally{c(!1)}};return t.loading?o.jsx("div",{className:"af-auth-screen",children:o.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):o.jsx("div",{className:"af-auth-screen",children:o.jsxs("form",{className:"af-auth-panel",onSubmit:p,children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow"}),o.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"用户名"}),o.jsx("input",{value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"密码"}),o.jsx("input",{type:"password",value:i,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?o.jsx("p",{className:"af-auth-error",children:d}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function xse({authUser:e,onLogout:t}){const{path:n}=Ma(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(pse,{page:r?"flow":"projects"}):null,r?null:o.jsx(_O,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(gse,{authUser:e})}),o.jsx(hse,{})]})}function wse(){return o.jsx(mse,{children:o.jsx(cO,{children:o.jsx(yse,{children:({user:e,onLogout:t})=>o.jsx(xse,{authUser:e,onLogout:t})})})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const b1=document.querySelector('link[rel="icon"]');b1&&(b1.href=ME);Gy.createRoot(document.getElementById("root")).render(o.jsx(et.StrictMode,{children:o.jsx(wse,{})}));