@fieldwangai/agentflow 0.1.87 → 0.1.89

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.
@@ -1,340 +0,0 @@
1
- var rR=Object.defineProperty;var sR=(e,t,n)=>t in e?rR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wn=(e,t,n)=>sR(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 ou=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s1={exports:{}},Zp={},i1={exports:{}},Nt={};/**
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 Ku=Symbol.for("react.element"),iR=Symbol.for("react.portal"),oR=Symbol.for("react.fragment"),aR=Symbol.for("react.strict_mode"),lR=Symbol.for("react.profiler"),cR=Symbol.for("react.provider"),uR=Symbol.for("react.context"),dR=Symbol.for("react.forward_ref"),fR=Symbol.for("react.suspense"),pR=Symbol.for("react.memo"),hR=Symbol.for("react.lazy"),av=Symbol.iterator;function mR(e){return e===null||typeof e!="object"?null:(e=av&&e[av]||e["@@iterator"],typeof e=="function"?e:null)}var o1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},a1=Object.assign,l1={};function Dl(e,t,n){this.props=e,this.context=t,this.refs=l1,this.updater=n||o1}Dl.prototype.isReactComponent={};Dl.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")};Dl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function c1(){}c1.prototype=Dl.prototype;function Ax(e,t,n){this.props=e,this.context=t,this.refs=l1,this.updater=n||o1}var Px=Ax.prototype=new c1;Px.constructor=Ax;a1(Px,Dl.prototype);Px.isPureReactComponent=!0;var lv=Array.isArray,u1=Object.prototype.hasOwnProperty,Ix={current:null},d1={key:!0,ref:!0,__self:!0,__source:!0};function f1(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)u1.call(t,r)&&!d1.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),u=0;u<l;u++)c[u]=arguments[u+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:Ku,type:e,key:i,ref:a,props:s,_owner:Ix.current}}function gR(e,t){return{$$typeof:Ku,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Tx(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ku}function yR(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var cv=/\/+/g;function um(e,t){return typeof e=="object"&&e!==null&&e.key!=null?yR(""+e.key):t.toString(36)}function Pf(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 Ku:case iR:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+um(a,0):r,lv(s)?(n="",e!=null&&(n=e.replace(cv,"$&/")+"/"),Pf(s,t,n,"",function(u){return u})):s!=null&&(Tx(s)&&(s=gR(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(cv,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",lv(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+um(i,l);a+=Pf(i,t,n,c,s)}else if(c=mR(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+um(i,l++),a+=Pf(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 Dd(e,t,n){if(e==null)return e;var r=[],s=0;return Pf(e,r,"","",function(i){return t.call(n,i,s++)}),r}function xR(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 dr={current:null},If={transition:null},wR={ReactCurrentDispatcher:dr,ReactCurrentBatchConfig:If,ReactCurrentOwner:Ix};function p1(){throw Error("act(...) is not supported in production builds of React.")}Nt.Children={map:Dd,forEach:function(e,t,n){Dd(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Dd(e,function(){t++}),t},toArray:function(e){return Dd(e,function(t){return t})||[]},only:function(e){if(!Tx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Nt.Component=Dl;Nt.Fragment=oR;Nt.Profiler=lR;Nt.PureComponent=Ax;Nt.StrictMode=aR;Nt.Suspense=fR;Nt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wR;Nt.act=p1;Nt.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=a1({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Ix.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)u1.call(t,c)&&!d1.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 u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:Ku,type:e.type,key:s,ref:i,props:r,_owner:a}};Nt.createContext=function(e){return e={$$typeof:uR,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:cR,_context:e},e.Consumer=e};Nt.createElement=f1;Nt.createFactory=function(e){var t=f1.bind(null,e);return t.type=e,t};Nt.createRef=function(){return{current:null}};Nt.forwardRef=function(e){return{$$typeof:dR,render:e}};Nt.isValidElement=Tx;Nt.lazy=function(e){return{$$typeof:hR,_payload:{_status:-1,_result:e},_init:xR}};Nt.memo=function(e,t){return{$$typeof:pR,type:e,compare:t===void 0?null:t}};Nt.startTransition=function(e){var t=If.transition;If.transition={};try{e()}finally{If.transition=t}};Nt.unstable_act=p1;Nt.useCallback=function(e,t){return dr.current.useCallback(e,t)};Nt.useContext=function(e){return dr.current.useContext(e)};Nt.useDebugValue=function(){};Nt.useDeferredValue=function(e){return dr.current.useDeferredValue(e)};Nt.useEffect=function(e,t){return dr.current.useEffect(e,t)};Nt.useId=function(){return dr.current.useId()};Nt.useImperativeHandle=function(e,t,n){return dr.current.useImperativeHandle(e,t,n)};Nt.useInsertionEffect=function(e,t){return dr.current.useInsertionEffect(e,t)};Nt.useLayoutEffect=function(e,t){return dr.current.useLayoutEffect(e,t)};Nt.useMemo=function(e,t){return dr.current.useMemo(e,t)};Nt.useReducer=function(e,t,n){return dr.current.useReducer(e,t,n)};Nt.useRef=function(e){return dr.current.useRef(e)};Nt.useState=function(e){return dr.current.useState(e)};Nt.useSyncExternalStore=function(e,t,n){return dr.current.useSyncExternalStore(e,t,n)};Nt.useTransition=function(){return dr.current.useTransition()};Nt.version="18.3.1";i1.exports=Nt;var m=i1.exports;const st=bo(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 bR=m,kR=Symbol.for("react.element"),vR=Symbol.for("react.fragment"),SR=Object.prototype.hasOwnProperty,NR=bR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,jR={key:!0,ref:!0,__self:!0,__source:!0};function h1(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)SR.call(t,r)&&!jR.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:kR,type:e,key:i,ref:a,props:s,_owner:NR.current}}Zp.Fragment=vR;Zp.jsx=h1;Zp.jsxs=h1;s1.exports=Zp;var o=s1.exports,Rg={},m1={exports:{}},Vr={},g1={exports:{}},y1={};/**
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(A,M){var _=A.length;A.push(M);e:for(;0<_;){var U=_-1>>>1,q=A[U];if(0<s(q,M))A[U]=M,A[_]=q,_=U;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var M=A[0],_=A.pop();if(_!==M){A[0]=_;e:for(var U=0,q=A.length,B=q>>>1;U<B;){var Q=2*(U+1)-1,se=A[Q],oe=Q+1,ve=A[oe];if(0>s(se,_))oe<q&&0>s(ve,se)?(A[U]=ve,A[oe]=_,U=oe):(A[U]=se,A[Q]=_,U=Q);else if(oe<q&&0>s(ve,_))A[U]=ve,A[oe]=_,U=oe;else break e}}return M}function s(A,M){var _=A.sortIndex-M.sortIndex;return _!==0?_:A.id-M.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=[],u=[],p=1,f=null,d=3,h=!1,g=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(A){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=A)r(u),M.sortIndex=M.expirationTime,t(c,M);else break;M=n(u)}}function S(A){if(b=!1,x(A),!g)if(n(c)!==null)g=!0,$(C);else{var M=n(u);M!==null&&O(S,M.startTime-A)}}function C(A,M){g=!1,b&&(b=!1,y(P),P=-1),h=!0;var _=d;try{for(x(M),f=n(c);f!==null&&(!(f.expirationTime>M)||A&&!z());){var U=f.callback;if(typeof U=="function"){f.callback=null,d=f.priorityLevel;var q=U(f.expirationTime<=M);M=e.unstable_now(),typeof q=="function"?f.callback=q:f===n(c)&&r(c),x(M)}else r(c);f=n(c)}if(f!==null)var B=!0;else{var Q=n(u);Q!==null&&O(S,Q.startTime-M),B=!1}return B}finally{f=null,d=_,h=!1}}var j=!1,E=null,P=-1,F=5,V=-1;function z(){return!(e.unstable_now()-V<F)}function D(){if(E!==null){var A=e.unstable_now();V=A;var M=!0;try{M=E(!0,A)}finally{M?R():(j=!1,E=null)}}else j=!1}var R;if(typeof w=="function")R=function(){w(D)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,L=T.port2;T.port1.onmessage=D,R=function(){L.postMessage(null)}}else R=function(){v(D,0)};function $(A){E=A,j||(j=!0,R())}function O(A,M){P=v(function(){A(e.unstable_now())},M)}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(A){A.callback=null},e.unstable_continueExecution=function(){g||h||(g=!0,$(C))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(d){case 1:case 2:case 3:var M=3;break;default:M=d}var _=d;d=M;try{return A()}finally{d=_}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,M){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var _=d;d=A;try{return M()}finally{d=_}},e.unstable_scheduleCallback=function(A,M,_){var U=e.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?U+_:U):_=U,A){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=_+q,A={id:p++,callback:M,priorityLevel:A,startTime:_,expirationTime:q,sortIndex:-1},_>U?(A.sortIndex=_,t(u,A),n(c)===null&&A===n(u)&&(b?(y(P),P=-1):b=!0,O(S,_-U))):(A.sortIndex=q,t(c,A),g||h||(g=!0,$(C))),A},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(A){var M=d;return function(){var _=d;d=M;try{return A.apply(this,arguments)}finally{d=_}}}})(y1);g1.exports=y1;var CR=g1.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 _R=m,Br=CR;function Ne(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 x1=new Set,au={};function ha(e,t){bl(e,t),bl(e+"Capture",t)}function bl(e,t){for(au[e]=t,e=0;e<t.length;e++)x1.add(t[e])}var vi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mg=Object.prototype.hasOwnProperty,ER=/^[: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]*$/,uv={},dv={};function AR(e){return Mg.call(dv,e)?!0:Mg.call(uv,e)?!1:ER.test(e)?dv[e]=!0:(uv[e]=!0,!1)}function PR(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 IR(e,t,n,r){if(t===null||typeof t>"u"||PR(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 fr(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 Yn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Yn[e]=new fr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Yn[t]=new fr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Yn[e]=new fr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Yn[e]=new fr(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){Yn[e]=new fr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Yn[e]=new fr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Yn[e]=new fr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Yn[e]=new fr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Yn[e]=new fr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Rx=/[\-:]([a-z])/g;function Mx(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(Rx,Mx);Yn[t]=new fr(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(Rx,Mx);Yn[t]=new fr(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(Rx,Mx);Yn[t]=new fr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Yn[e]=new fr(e,1,!1,e.toLowerCase(),null,!1,!1)});Yn.xlinkHref=new fr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Yn[e]=new fr(e,1,!1,e.toLowerCase(),null,!0,!0)});function $x(e,t,n,r){var s=Yn.hasOwnProperty(t)?Yn[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(IR(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 Ei=_R.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Fd=Symbol.for("react.element"),Ka=Symbol.for("react.portal"),Ua=Symbol.for("react.fragment"),Lx=Symbol.for("react.strict_mode"),$g=Symbol.for("react.profiler"),w1=Symbol.for("react.provider"),b1=Symbol.for("react.context"),Ox=Symbol.for("react.forward_ref"),Lg=Symbol.for("react.suspense"),Og=Symbol.for("react.suspense_list"),Dx=Symbol.for("react.memo"),qi=Symbol.for("react.lazy"),k1=Symbol.for("react.offscreen"),fv=Symbol.iterator;function fc(e){return e===null||typeof e!="object"?null:(e=fv&&e[fv]||e["@@iterator"],typeof e=="function"?e:null)}var xn=Object.assign,dm;function Ic(e){if(dm===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);dm=t&&t[1]||""}return`
34
- `+dm+e}var fm=!1;function pm(e,t){if(!e||fm)return"";fm=!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(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.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{fm=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ic(e):""}function TR(e){switch(e.tag){case 5:return Ic(e.type);case 16:return Ic("Lazy");case 13:return Ic("Suspense");case 19:return Ic("SuspenseList");case 0:case 2:case 15:return e=pm(e.type,!1),e;case 11:return e=pm(e.type.render,!1),e;case 1:return e=pm(e.type,!0),e;default:return""}}function Dg(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 Ua:return"Fragment";case Ka:return"Portal";case $g:return"Profiler";case Lx:return"StrictMode";case Lg:return"Suspense";case Og:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b1:return(e.displayName||"Context")+".Consumer";case w1:return(e._context.displayName||"Context")+".Provider";case Ox:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Dx:return t=e.displayName||null,t!==null?t:Dg(e.type)||"Memo";case qi:t=e._payload,e=e._init;try{return Dg(e(t))}catch{}}return null}function RR(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 Dg(t);case 8:return t===Lx?"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 mo(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function v1(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function MR(e){var t=v1(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 zd(e){e._valueTracker||(e._valueTracker=MR(e))}function S1(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=v1(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Zf(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 Fg(e,t){var n=t.checked;return xn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function pv(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=mo(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 N1(e,t){t=t.checked,t!=null&&$x(e,"checked",t,!1)}function zg(e,t){N1(e,t);var n=mo(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")?Hg(e,t.type,n):t.hasOwnProperty("defaultValue")&&Hg(e,t.type,mo(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function hv(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 Hg(e,t,n){(t!=="number"||Zf(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Tc=Array.isArray;function ll(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=""+mo(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 Bg(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ne(91));return xn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mv(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ne(92));if(Tc(n)){if(1<n.length)throw Error(Ne(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:mo(n)}}function j1(e,t){var n=mo(t.value),r=mo(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 gv(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function C1(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 Wg(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?C1(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Hd,_1=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(Hd=Hd||document.createElement("div"),Hd.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Hd.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lu(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Hc={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},$R=["Webkit","ms","Moz","O"];Object.keys(Hc).forEach(function(e){$R.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Hc[t]=Hc[e]})});function E1(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Hc.hasOwnProperty(e)&&Hc[e]?(""+t).trim():t+"px"}function A1(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=E1(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var LR=xn({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 Vg(e,t){if(t){if(LR[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ne(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ne(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ne(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ne(62))}}function Kg(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 Ug=null;function Fx(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var qg=null,cl=null,ul=null;function yv(e){if(e=Yu(e)){if(typeof qg!="function")throw Error(Ne(280));var t=e.stateNode;t&&(t=sh(t),qg(e.stateNode,e.type,t))}}function P1(e){cl?ul?ul.push(e):ul=[e]:cl=e}function I1(){if(cl){var e=cl,t=ul;if(ul=cl=null,yv(e),t)for(e=0;e<t.length;e++)yv(t[e])}}function T1(e,t){return e(t)}function R1(){}var hm=!1;function M1(e,t,n){if(hm)return e(t,n);hm=!0;try{return T1(e,t,n)}finally{hm=!1,(cl!==null||ul!==null)&&(R1(),I1())}}function cu(e,t){var n=e.stateNode;if(n===null)return null;var r=sh(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(Ne(231,t,typeof n));return n}var Yg=!1;if(vi)try{var pc={};Object.defineProperty(pc,"passive",{get:function(){Yg=!0}}),window.addEventListener("test",pc,pc),window.removeEventListener("test",pc,pc)}catch{Yg=!1}function OR(e,t,n,r,s,i,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Bc=!1,ep=null,tp=!1,Gg=null,DR={onError:function(e){Bc=!0,ep=e}};function FR(e,t,n,r,s,i,a,l,c){Bc=!1,ep=null,OR.apply(DR,arguments)}function zR(e,t,n,r,s,i,a,l,c){if(FR.apply(this,arguments),Bc){if(Bc){var u=ep;Bc=!1,ep=null}else throw Error(Ne(198));tp||(tp=!0,Gg=u)}}function ma(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 $1(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 xv(e){if(ma(e)!==e)throw Error(Ne(188))}function HR(e){var t=e.alternate;if(!t){if(t=ma(e),t===null)throw Error(Ne(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 xv(s),e;if(i===r)return xv(s),t;i=i.sibling}throw Error(Ne(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(Ne(189))}}if(n.alternate!==r)throw Error(Ne(190))}if(n.tag!==3)throw Error(Ne(188));return n.stateNode.current===n?e:t}function L1(e){return e=HR(e),e!==null?O1(e):null}function O1(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=O1(e);if(t!==null)return t;e=e.sibling}return null}var D1=Br.unstable_scheduleCallback,wv=Br.unstable_cancelCallback,BR=Br.unstable_shouldYield,WR=Br.unstable_requestPaint,Sn=Br.unstable_now,VR=Br.unstable_getCurrentPriorityLevel,zx=Br.unstable_ImmediatePriority,F1=Br.unstable_UserBlockingPriority,np=Br.unstable_NormalPriority,KR=Br.unstable_LowPriority,z1=Br.unstable_IdlePriority,eh=null,Ys=null;function UR(e){if(Ys&&typeof Ys.onCommitFiberRoot=="function")try{Ys.onCommitFiberRoot(eh,e,void 0,(e.current.flags&128)===128)}catch{}}var Cs=Math.clz32?Math.clz32:GR,qR=Math.log,YR=Math.LN2;function GR(e){return e>>>=0,e===0?32:31-(qR(e)/YR|0)|0}var Bd=64,Wd=4194304;function Rc(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 rp(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=Rc(l):(i&=a,i!==0&&(r=Rc(i)))}else a=n&~s,a!==0?r=Rc(a):i!==0&&(r=Rc(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-Cs(t),s=1<<n,r|=e[n],t&=~s;return r}function JR(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 XR(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Cs(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=JR(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function Jg(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function H1(){var e=Bd;return Bd<<=1,!(Bd&4194240)&&(Bd=64),e}function mm(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Uu(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Cs(t),e[t]=n}function QR(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-Cs(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Hx(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Cs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var Bt=0;function B1(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var W1,Bx,V1,K1,U1,Xg=!1,Vd=[],ro=null,so=null,io=null,uu=new Map,du=new Map,Ji=[],ZR="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 bv(e,t){switch(e){case"focusin":case"focusout":ro=null;break;case"dragenter":case"dragleave":so=null;break;case"mouseover":case"mouseout":io=null;break;case"pointerover":case"pointerout":uu.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":du.delete(t.pointerId)}}function hc(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=Yu(t),t!==null&&Bx(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function eM(e,t,n,r,s){switch(t){case"focusin":return ro=hc(ro,e,t,n,r,s),!0;case"dragenter":return so=hc(so,e,t,n,r,s),!0;case"mouseover":return io=hc(io,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return uu.set(i,hc(uu.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,du.set(i,hc(du.get(i)||null,e,t,n,r,s)),!0}return!1}function q1(e){var t=zo(e.target);if(t!==null){var n=ma(t);if(n!==null){if(t=n.tag,t===13){if(t=$1(n),t!==null){e.blockedOn=t,U1(e.priority,function(){V1(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 Tf(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Qg(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ug=r,n.target.dispatchEvent(r),Ug=null}else return t=Yu(n),t!==null&&Bx(t),e.blockedOn=n,!1;t.shift()}return!0}function kv(e,t,n){Tf(e)&&n.delete(t)}function tM(){Xg=!1,ro!==null&&Tf(ro)&&(ro=null),so!==null&&Tf(so)&&(so=null),io!==null&&Tf(io)&&(io=null),uu.forEach(kv),du.forEach(kv)}function mc(e,t){e.blockedOn===t&&(e.blockedOn=null,Xg||(Xg=!0,Br.unstable_scheduleCallback(Br.unstable_NormalPriority,tM)))}function fu(e){function t(s){return mc(s,e)}if(0<Vd.length){mc(Vd[0],e);for(var n=1;n<Vd.length;n++){var r=Vd[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ro!==null&&mc(ro,e),so!==null&&mc(so,e),io!==null&&mc(io,e),uu.forEach(t),du.forEach(t),n=0;n<Ji.length;n++)r=Ji[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ji.length&&(n=Ji[0],n.blockedOn===null);)q1(n),n.blockedOn===null&&Ji.shift()}var dl=Ei.ReactCurrentBatchConfig,sp=!0;function nM(e,t,n,r){var s=Bt,i=dl.transition;dl.transition=null;try{Bt=1,Wx(e,t,n,r)}finally{Bt=s,dl.transition=i}}function rM(e,t,n,r){var s=Bt,i=dl.transition;dl.transition=null;try{Bt=4,Wx(e,t,n,r)}finally{Bt=s,dl.transition=i}}function Wx(e,t,n,r){if(sp){var s=Qg(e,t,n,r);if(s===null)jm(e,t,r,ip,n),bv(e,r);else if(eM(s,e,t,n,r))r.stopPropagation();else if(bv(e,r),t&4&&-1<ZR.indexOf(e)){for(;s!==null;){var i=Yu(s);if(i!==null&&W1(i),i=Qg(e,t,n,r),i===null&&jm(e,t,r,ip,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else jm(e,t,r,null,n)}}var ip=null;function Qg(e,t,n,r){if(ip=null,e=Fx(r),e=zo(e),e!==null)if(t=ma(e),t===null)e=null;else if(n=t.tag,n===13){if(e=$1(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 ip=e,null}function Y1(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(VR()){case zx:return 1;case F1:return 4;case np:case KR:return 16;case z1:return 536870912;default:return 16}default:return 16}}var Zi=null,Vx=null,Rf=null;function G1(){if(Rf)return Rf;var e,t=Vx,n=t.length,r,s="value"in Zi?Zi.value:Zi.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 Rf=s.slice(e,1<r?1-r:void 0)}function Mf(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 Kd(){return!0}function vv(){return!1}function Kr(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)?Kd:vv,this.isPropagationStopped=vv,this}return xn(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=Kd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Kd)},persist:function(){},isPersistent:Kd}),t}var Fl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kx=Kr(Fl),qu=xn({},Fl,{view:0,detail:0}),sM=Kr(qu),gm,ym,gc,th=xn({},qu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ux,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!==gc&&(gc&&e.type==="mousemove"?(gm=e.screenX-gc.screenX,ym=e.screenY-gc.screenY):ym=gm=0,gc=e),gm)},movementY:function(e){return"movementY"in e?e.movementY:ym}}),Sv=Kr(th),iM=xn({},th,{dataTransfer:0}),oM=Kr(iM),aM=xn({},qu,{relatedTarget:0}),xm=Kr(aM),lM=xn({},Fl,{animationName:0,elapsedTime:0,pseudoElement:0}),cM=Kr(lM),uM=xn({},Fl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),dM=Kr(uM),fM=xn({},Fl,{data:0}),Nv=Kr(fM),pM={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hM={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"},mM={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gM(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=mM[e])?!!t[e]:!1}function Ux(){return gM}var yM=xn({},qu,{key:function(e){if(e.key){var t=pM[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Mf(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?hM[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ux,charCode:function(e){return e.type==="keypress"?Mf(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Mf(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),xM=Kr(yM),wM=xn({},th,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jv=Kr(wM),bM=xn({},qu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ux}),kM=Kr(bM),vM=xn({},Fl,{propertyName:0,elapsedTime:0,pseudoElement:0}),SM=Kr(vM),NM=xn({},th,{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}),jM=Kr(NM),CM=[9,13,27,32],qx=vi&&"CompositionEvent"in window,Wc=null;vi&&"documentMode"in document&&(Wc=document.documentMode);var _M=vi&&"TextEvent"in window&&!Wc,J1=vi&&(!qx||Wc&&8<Wc&&11>=Wc),Cv=" ",_v=!1;function X1(e,t){switch(e){case"keyup":return CM.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Q1(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qa=!1;function EM(e,t){switch(e){case"compositionend":return Q1(t);case"keypress":return t.which!==32?null:(_v=!0,Cv);case"textInput":return e=t.data,e===Cv&&_v?null:e;default:return null}}function AM(e,t){if(qa)return e==="compositionend"||!qx&&X1(e,t)?(e=G1(),Rf=Vx=Zi=null,qa=!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 J1&&t.locale!=="ko"?null:t.data;default:return null}}var PM={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 Ev(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!PM[e.type]:t==="textarea"}function Z1(e,t,n,r){P1(r),t=op(t,"onChange"),0<t.length&&(n=new Kx("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Vc=null,pu=null;function IM(e){uC(e,0)}function nh(e){var t=Ja(e);if(S1(t))return e}function TM(e,t){if(e==="change")return t}var eC=!1;if(vi){var wm;if(vi){var bm="oninput"in document;if(!bm){var Av=document.createElement("div");Av.setAttribute("oninput","return;"),bm=typeof Av.oninput=="function"}wm=bm}else wm=!1;eC=wm&&(!document.documentMode||9<document.documentMode)}function Pv(){Vc&&(Vc.detachEvent("onpropertychange",tC),pu=Vc=null)}function tC(e){if(e.propertyName==="value"&&nh(pu)){var t=[];Z1(t,pu,e,Fx(e)),M1(IM,t)}}function RM(e,t,n){e==="focusin"?(Pv(),Vc=t,pu=n,Vc.attachEvent("onpropertychange",tC)):e==="focusout"&&Pv()}function MM(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return nh(pu)}function $M(e,t){if(e==="click")return nh(t)}function LM(e,t){if(e==="input"||e==="change")return nh(t)}function OM(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var As=typeof Object.is=="function"?Object.is:OM;function hu(e,t){if(As(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(!Mg.call(t,s)||!As(e[s],t[s]))return!1}return!0}function Iv(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Tv(e,t){var n=Iv(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=Iv(n)}}function nC(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?nC(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function rC(){for(var e=window,t=Zf();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Zf(e.document)}return t}function Yx(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 DM(e){var t=rC(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&nC(n.ownerDocument.documentElement,n)){if(r!==null&&Yx(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=Tv(n,i);var a=Tv(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 FM=vi&&"documentMode"in document&&11>=document.documentMode,Ya=null,Zg=null,Kc=null,ey=!1;function Rv(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ey||Ya==null||Ya!==Zf(r)||(r=Ya,"selectionStart"in r&&Yx(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}),Kc&&hu(Kc,r)||(Kc=r,r=op(Zg,"onSelect"),0<r.length&&(t=new Kx("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Ya)))}function Ud(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Ga={animationend:Ud("Animation","AnimationEnd"),animationiteration:Ud("Animation","AnimationIteration"),animationstart:Ud("Animation","AnimationStart"),transitionend:Ud("Transition","TransitionEnd")},km={},sC={};vi&&(sC=document.createElement("div").style,"AnimationEvent"in window||(delete Ga.animationend.animation,delete Ga.animationiteration.animation,delete Ga.animationstart.animation),"TransitionEvent"in window||delete Ga.transitionend.transition);function rh(e){if(km[e])return km[e];if(!Ga[e])return e;var t=Ga[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in sC)return km[e]=t[n];return e}var iC=rh("animationend"),oC=rh("animationiteration"),aC=rh("animationstart"),lC=rh("transitionend"),cC=new Map,Mv="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 ko(e,t){cC.set(e,t),ha(t,[e])}for(var vm=0;vm<Mv.length;vm++){var Sm=Mv[vm],zM=Sm.toLowerCase(),HM=Sm[0].toUpperCase()+Sm.slice(1);ko(zM,"on"+HM)}ko(iC,"onAnimationEnd");ko(oC,"onAnimationIteration");ko(aC,"onAnimationStart");ko("dblclick","onDoubleClick");ko("focusin","onFocus");ko("focusout","onBlur");ko(lC,"onTransitionEnd");bl("onMouseEnter",["mouseout","mouseover"]);bl("onMouseLeave",["mouseout","mouseover"]);bl("onPointerEnter",["pointerout","pointerover"]);bl("onPointerLeave",["pointerout","pointerover"]);ha("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ha("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ha("onBeforeInput",["compositionend","keypress","textInput","paste"]);ha("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ha("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ha("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mc="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(" "),BM=new Set("cancel close invalid load scroll toggle".split(" ").concat(Mc));function $v(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,zR(r,t,void 0,e),e.currentTarget=null}function uC(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,u=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;$v(s,l,u),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;$v(s,l,u),i=c}}}if(tp)throw e=Gg,tp=!1,Gg=null,e}function on(e,t){var n=t[iy];n===void 0&&(n=t[iy]=new Set);var r=e+"__bubble";n.has(r)||(dC(t,e,2,!1),n.add(r))}function Nm(e,t,n){var r=0;t&&(r|=4),dC(n,e,r,t)}var qd="_reactListening"+Math.random().toString(36).slice(2);function mu(e){if(!e[qd]){e[qd]=!0,x1.forEach(function(n){n!=="selectionchange"&&(BM.has(n)||Nm(n,!1,e),Nm(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[qd]||(t[qd]=!0,Nm("selectionchange",!1,t))}}function dC(e,t,n,r){switch(Y1(t)){case 1:var s=nM;break;case 4:s=rM;break;default:s=Wx}n=s.bind(null,t,n,e),s=void 0,!Yg||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 jm(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=zo(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}M1(function(){var u=i,p=Fx(n),f=[];e:{var d=cC.get(e);if(d!==void 0){var h=Kx,g=e;switch(e){case"keypress":if(Mf(n)===0)break e;case"keydown":case"keyup":h=xM;break;case"focusin":g="focus",h=xm;break;case"focusout":g="blur",h=xm;break;case"beforeblur":case"afterblur":h=xm;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=Sv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=oM;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=kM;break;case iC:case oC:case aC:h=cM;break;case lC:h=SM;break;case"scroll":h=sM;break;case"wheel":h=jM;break;case"copy":case"cut":case"paste":h=dM;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=jv}var b=(t&4)!==0,v=!b&&e==="scroll",y=b?d!==null?d+"Capture":null:d;b=[];for(var w=u,x;w!==null;){x=w;var S=x.stateNode;if(x.tag===5&&S!==null&&(x=S,y!==null&&(S=cu(w,y),S!=null&&b.push(gu(w,S,x)))),v)break;w=w.return}0<b.length&&(d=new h(d,g,null,n,p),f.push({event:d,listeners:b}))}}if(!(t&7)){e:{if(d=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",d&&n!==Ug&&(g=n.relatedTarget||n.fromElement)&&(zo(g)||g[Si]))break e;if((h||d)&&(d=p.window===p?p:(d=p.ownerDocument)?d.defaultView||d.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=u,g=g?zo(g):null,g!==null&&(v=ma(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=u),h!==g)){if(b=Sv,S="onMouseLeave",y="onMouseEnter",w="mouse",(e==="pointerout"||e==="pointerover")&&(b=jv,S="onPointerLeave",y="onPointerEnter",w="pointer"),v=h==null?d:Ja(h),x=g==null?d:Ja(g),d=new b(S,w+"leave",h,n,p),d.target=v,d.relatedTarget=x,S=null,zo(p)===u&&(b=new b(y,w+"enter",g,n,p),b.target=x,b.relatedTarget=v,S=b),v=S,h&&g)t:{for(b=h,y=g,w=0,x=b;x;x=$a(x))w++;for(x=0,S=y;S;S=$a(S))x++;for(;0<w-x;)b=$a(b),w--;for(;0<x-w;)y=$a(y),x--;for(;w--;){if(b===y||y!==null&&b===y.alternate)break t;b=$a(b),y=$a(y)}b=null}else b=null;h!==null&&Lv(f,d,h,b,!1),g!==null&&v!==null&&Lv(f,v,g,b,!0)}}e:{if(d=u?Ja(u):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var C=TM;else if(Ev(d))if(eC)C=LM;else{C=MM;var j=RM}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(C=$M);if(C&&(C=C(e,u))){Z1(f,C,n,p);break e}j&&j(e,d,u),e==="focusout"&&(j=d._wrapperState)&&j.controlled&&d.type==="number"&&Hg(d,"number",d.value)}switch(j=u?Ja(u):window,e){case"focusin":(Ev(j)||j.contentEditable==="true")&&(Ya=j,Zg=u,Kc=null);break;case"focusout":Kc=Zg=Ya=null;break;case"mousedown":ey=!0;break;case"contextmenu":case"mouseup":case"dragend":ey=!1,Rv(f,n,p);break;case"selectionchange":if(FM)break;case"keydown":case"keyup":Rv(f,n,p)}var E;if(qx)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else qa?X1(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(J1&&n.locale!=="ko"&&(qa||P!=="onCompositionStart"?P==="onCompositionEnd"&&qa&&(E=G1()):(Zi=p,Vx="value"in Zi?Zi.value:Zi.textContent,qa=!0)),j=op(u,P),0<j.length&&(P=new Nv(P,e,null,n,p),f.push({event:P,listeners:j}),E?P.data=E:(E=Q1(n),E!==null&&(P.data=E)))),(E=_M?EM(e,n):AM(e,n))&&(u=op(u,"onBeforeInput"),0<u.length&&(p=new Nv("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=E))}uC(f,t)})}function gu(e,t,n){return{instance:e,listener:t,currentTarget:n}}function op(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=cu(e,n),i!=null&&r.unshift(gu(e,i,s)),i=cu(e,t),i!=null&&r.push(gu(e,i,s))),e=e.return}return r}function $a(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Lv(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,s?(c=cu(n,i),c!=null&&a.unshift(gu(n,c,l))):s||(c=cu(n,i),c!=null&&a.push(gu(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var WM=/\r\n?/g,VM=/\u0000|\uFFFD/g;function Ov(e){return(typeof e=="string"?e:""+e).replace(WM,`
38
- `).replace(VM,"")}function Yd(e,t,n){if(t=Ov(t),Ov(e)!==t&&n)throw Error(Ne(425))}function ap(){}var ty=null,ny=null;function ry(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 sy=typeof setTimeout=="function"?setTimeout:void 0,KM=typeof clearTimeout=="function"?clearTimeout:void 0,Dv=typeof Promise=="function"?Promise:void 0,UM=typeof queueMicrotask=="function"?queueMicrotask:typeof Dv<"u"?function(e){return Dv.resolve(null).then(e).catch(qM)}:sy;function qM(e){setTimeout(function(){throw e})}function Cm(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),fu(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);fu(t)}function oo(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 Fv(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 zl=Math.random().toString(36).slice(2),Ws="__reactFiber$"+zl,yu="__reactProps$"+zl,Si="__reactContainer$"+zl,iy="__reactEvents$"+zl,YM="__reactListeners$"+zl,GM="__reactHandles$"+zl;function zo(e){var t=e[Ws];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Si]||n[Ws]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Fv(e);e!==null;){if(n=e[Ws])return n;e=Fv(e)}return t}e=n,n=e.parentNode}return null}function Yu(e){return e=e[Ws]||e[Si],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ja(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ne(33))}function sh(e){return e[yu]||null}var oy=[],Xa=-1;function vo(e){return{current:e}}function ln(e){0>Xa||(e.current=oy[Xa],oy[Xa]=null,Xa--)}function nn(e,t){Xa++,oy[Xa]=e.current,e.current=t}var go={},tr=vo(go),Sr=vo(!1),Qo=go;function kl(e,t){var n=e.type.contextTypes;if(!n)return go;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 Nr(e){return e=e.childContextTypes,e!=null}function lp(){ln(Sr),ln(tr)}function zv(e,t,n){if(tr.current!==go)throw Error(Ne(168));nn(tr,t),nn(Sr,n)}function fC(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(Ne(108,RR(e)||"Unknown",s));return xn({},n,r)}function cp(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||go,Qo=tr.current,nn(tr,e),nn(Sr,Sr.current),!0}function Hv(e,t,n){var r=e.stateNode;if(!r)throw Error(Ne(169));n?(e=fC(e,t,Qo),r.__reactInternalMemoizedMergedChildContext=e,ln(Sr),ln(tr),nn(tr,e)):ln(Sr),nn(Sr,n)}var pi=null,ih=!1,_m=!1;function pC(e){pi===null?pi=[e]:pi.push(e)}function JM(e){ih=!0,pC(e)}function So(){if(!_m&&pi!==null){_m=!0;var e=0,t=Bt;try{var n=pi;for(Bt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}pi=null,ih=!1}catch(s){throw pi!==null&&(pi=pi.slice(e+1)),D1(zx,So),s}finally{Bt=t,_m=!1}}return null}var Qa=[],Za=0,up=null,dp=0,Jr=[],Xr=0,Zo=null,mi=1,gi="";function Ro(e,t){Qa[Za++]=dp,Qa[Za++]=up,up=e,dp=t}function hC(e,t,n){Jr[Xr++]=mi,Jr[Xr++]=gi,Jr[Xr++]=Zo,Zo=e;var r=mi;e=gi;var s=32-Cs(r)-1;r&=~(1<<s),n+=1;var i=32-Cs(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,mi=1<<32-Cs(t)+s|n<<s|r,gi=i+e}else mi=1<<i|n<<s|r,gi=e}function Gx(e){e.return!==null&&(Ro(e,1),hC(e,1,0))}function Jx(e){for(;e===up;)up=Qa[--Za],Qa[Za]=null,dp=Qa[--Za],Qa[Za]=null;for(;e===Zo;)Zo=Jr[--Xr],Jr[Xr]=null,gi=Jr[--Xr],Jr[Xr]=null,mi=Jr[--Xr],Jr[Xr]=null}var zr=null,Dr=null,dn=!1,ks=null;function mC(e,t){var n=es(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 Bv(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,zr=e,Dr=oo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,zr=e,Dr=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Zo!==null?{id:mi,overflow:gi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=es(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,zr=e,Dr=null,!0):!1;default:return!1}}function ay(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ly(e){if(dn){var t=Dr;if(t){var n=t;if(!Bv(e,t)){if(ay(e))throw Error(Ne(418));t=oo(n.nextSibling);var r=zr;t&&Bv(e,t)?mC(r,n):(e.flags=e.flags&-4097|2,dn=!1,zr=e)}}else{if(ay(e))throw Error(Ne(418));e.flags=e.flags&-4097|2,dn=!1,zr=e}}}function Wv(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;zr=e}function Gd(e){if(e!==zr)return!1;if(!dn)return Wv(e),dn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ry(e.type,e.memoizedProps)),t&&(t=Dr)){if(ay(e))throw gC(),Error(Ne(418));for(;t;)mC(e,t),t=oo(t.nextSibling)}if(Wv(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ne(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Dr=oo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Dr=null}}else Dr=zr?oo(e.stateNode.nextSibling):null;return!0}function gC(){for(var e=Dr;e;)e=oo(e.nextSibling)}function vl(){Dr=zr=null,dn=!1}function Xx(e){ks===null?ks=[e]:ks.push(e)}var XM=Ei.ReactCurrentBatchConfig;function yc(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(Ne(309));var r=n.stateNode}if(!r)throw Error(Ne(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(Ne(284));if(!n._owner)throw Error(Ne(290,e))}return e}function Jd(e,t){throw e=Object.prototype.toString.call(t),Error(Ne(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Vv(e){var t=e._init;return t(e._payload)}function yC(e){function t(y,w){if(e){var x=y.deletions;x===null?(y.deletions=[w],y.flags|=16):x.push(w)}}function n(y,w){if(!e)return null;for(;w!==null;)t(y,w),w=w.sibling;return null}function r(y,w){for(y=new Map;w!==null;)w.key!==null?y.set(w.key,w):y.set(w.index,w),w=w.sibling;return y}function s(y,w){return y=uo(y,w),y.index=0,y.sibling=null,y}function i(y,w,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<w?(y.flags|=2,w):x):(y.flags|=2,w)):(y.flags|=1048576,w)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,w,x,S){return w===null||w.tag!==6?(w=Mm(x,y.mode,S),w.return=y,w):(w=s(w,x),w.return=y,w)}function c(y,w,x,S){var C=x.type;return C===Ua?p(y,w,x.props.children,S,x.key):w!==null&&(w.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===qi&&Vv(C)===w.type)?(S=s(w,x.props),S.ref=yc(y,w,x),S.return=y,S):(S=Hf(x.type,x.key,x.props,null,y.mode,S),S.ref=yc(y,w,x),S.return=y,S)}function u(y,w,x,S){return w===null||w.tag!==4||w.stateNode.containerInfo!==x.containerInfo||w.stateNode.implementation!==x.implementation?(w=$m(x,y.mode,S),w.return=y,w):(w=s(w,x.children||[]),w.return=y,w)}function p(y,w,x,S,C){return w===null||w.tag!==7?(w=Uo(x,y.mode,S,C),w.return=y,w):(w=s(w,x),w.return=y,w)}function f(y,w,x){if(typeof w=="string"&&w!==""||typeof w=="number")return w=Mm(""+w,y.mode,x),w.return=y,w;if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Fd:return x=Hf(w.type,w.key,w.props,null,y.mode,x),x.ref=yc(y,null,w),x.return=y,x;case Ka:return w=$m(w,y.mode,x),w.return=y,w;case qi:var S=w._init;return f(y,S(w._payload),x)}if(Tc(w)||fc(w))return w=Uo(w,y.mode,x,null),w.return=y,w;Jd(y,w)}return null}function d(y,w,x,S){var C=w!==null?w.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return C!==null?null:l(y,w,""+x,S);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Fd:return x.key===C?c(y,w,x,S):null;case Ka:return x.key===C?u(y,w,x,S):null;case qi:return C=x._init,d(y,w,C(x._payload),S)}if(Tc(x)||fc(x))return C!==null?null:p(y,w,x,S,null);Jd(y,x)}return null}function h(y,w,x,S,C){if(typeof S=="string"&&S!==""||typeof S=="number")return y=y.get(x)||null,l(w,y,""+S,C);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case Fd:return y=y.get(S.key===null?x:S.key)||null,c(w,y,S,C);case Ka:return y=y.get(S.key===null?x:S.key)||null,u(w,y,S,C);case qi:var j=S._init;return h(y,w,x,j(S._payload),C)}if(Tc(S)||fc(S))return y=y.get(x)||null,p(w,y,S,C,null);Jd(w,S)}return null}function g(y,w,x,S){for(var C=null,j=null,E=w,P=w=0,F=null;E!==null&&P<x.length;P++){E.index>P?(F=E,E=null):F=E.sibling;var V=d(y,E,x[P],S);if(V===null){E===null&&(E=F);break}e&&E&&V.alternate===null&&t(y,E),w=i(V,w,P),j===null?C=V:j.sibling=V,j=V,E=F}if(P===x.length)return n(y,E),dn&&Ro(y,P),C;if(E===null){for(;P<x.length;P++)E=f(y,x[P],S),E!==null&&(w=i(E,w,P),j===null?C=E:j.sibling=E,j=E);return dn&&Ro(y,P),C}for(E=r(y,E);P<x.length;P++)F=h(E,y,P,x[P],S),F!==null&&(e&&F.alternate!==null&&E.delete(F.key===null?P:F.key),w=i(F,w,P),j===null?C=F:j.sibling=F,j=F);return e&&E.forEach(function(z){return t(y,z)}),dn&&Ro(y,P),C}function b(y,w,x,S){var C=fc(x);if(typeof C!="function")throw Error(Ne(150));if(x=C.call(x),x==null)throw Error(Ne(151));for(var j=C=null,E=w,P=w=0,F=null,V=x.next();E!==null&&!V.done;P++,V=x.next()){E.index>P?(F=E,E=null):F=E.sibling;var z=d(y,E,V.value,S);if(z===null){E===null&&(E=F);break}e&&E&&z.alternate===null&&t(y,E),w=i(z,w,P),j===null?C=z:j.sibling=z,j=z,E=F}if(V.done)return n(y,E),dn&&Ro(y,P),C;if(E===null){for(;!V.done;P++,V=x.next())V=f(y,V.value,S),V!==null&&(w=i(V,w,P),j===null?C=V:j.sibling=V,j=V);return dn&&Ro(y,P),C}for(E=r(y,E);!V.done;P++,V=x.next())V=h(E,y,P,V.value,S),V!==null&&(e&&V.alternate!==null&&E.delete(V.key===null?P:V.key),w=i(V,w,P),j===null?C=V:j.sibling=V,j=V);return e&&E.forEach(function(D){return t(y,D)}),dn&&Ro(y,P),C}function v(y,w,x,S){if(typeof x=="object"&&x!==null&&x.type===Ua&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Fd:e:{for(var C=x.key,j=w;j!==null;){if(j.key===C){if(C=x.type,C===Ua){if(j.tag===7){n(y,j.sibling),w=s(j,x.props.children),w.return=y,y=w;break e}}else if(j.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===qi&&Vv(C)===j.type){n(y,j.sibling),w=s(j,x.props),w.ref=yc(y,j,x),w.return=y,y=w;break e}n(y,j);break}else t(y,j);j=j.sibling}x.type===Ua?(w=Uo(x.props.children,y.mode,S,x.key),w.return=y,y=w):(S=Hf(x.type,x.key,x.props,null,y.mode,S),S.ref=yc(y,w,x),S.return=y,y=S)}return a(y);case Ka:e:{for(j=x.key;w!==null;){if(w.key===j)if(w.tag===4&&w.stateNode.containerInfo===x.containerInfo&&w.stateNode.implementation===x.implementation){n(y,w.sibling),w=s(w,x.children||[]),w.return=y,y=w;break e}else{n(y,w);break}else t(y,w);w=w.sibling}w=$m(x,y.mode,S),w.return=y,y=w}return a(y);case qi:return j=x._init,v(y,w,j(x._payload),S)}if(Tc(x))return g(y,w,x,S);if(fc(x))return b(y,w,x,S);Jd(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,w!==null&&w.tag===6?(n(y,w.sibling),w=s(w,x),w.return=y,y=w):(n(y,w),w=Mm(x,y.mode,S),w.return=y,y=w),a(y)):n(y,w)}return v}var Sl=yC(!0),xC=yC(!1),fp=vo(null),pp=null,el=null,Qx=null;function Zx(){Qx=el=pp=null}function ew(e){var t=fp.current;ln(fp),e._currentValue=t}function cy(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 fl(e,t){pp=e,Qx=el=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(br=!0),e.firstContext=null)}function ns(e){var t=e._currentValue;if(Qx!==e)if(e={context:e,memoizedValue:t,next:null},el===null){if(pp===null)throw Error(Ne(308));el=e,pp.dependencies={lanes:0,firstContext:e}}else el=el.next=e;return t}var Ho=null;function tw(e){Ho===null?Ho=[e]:Ho.push(e)}function wC(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,tw(t)):(n.next=s.next,s.next=n),t.interleaved=n,Ni(e,r)}function Ni(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 Yi=!1;function nw(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function bC(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 bi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ao(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Rt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Ni(e,n)}return s=r.interleaved,s===null?(t.next=t,tw(r)):(t.next=s.next,s.next=t),r.interleaved=t,Ni(e,n)}function $f(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,Hx(e,n)}}function Kv(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 hp(e,t,n,r){var s=e.updateQueue;Yi=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?i=u:a.next=u,a=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==a&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;a=0,p=u=c=null,l=i;do{var d=l.lane,h=l.eventTime;if((r&d)===d){p!==null&&(p=p.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,b=l;switch(d=t,h=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){f=g.call(h,f,d);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,d=typeof g=="function"?g.call(h,f,d):g,d==null)break e;f=xn({},f,d);break e;case 2:Yi=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=s.effects,d===null?s.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=h,c=f):p=p.next=h,a|=d;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;d=l,l=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(p===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=p,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);ta|=a,e.lanes=a,e.memoizedState=f}}function Uv(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(Ne(191,s));s.call(r)}}}var Gu={},Gs=vo(Gu),xu=vo(Gu),wu=vo(Gu);function Bo(e){if(e===Gu)throw Error(Ne(174));return e}function rw(e,t){switch(nn(wu,t),nn(xu,e),nn(Gs,Gu),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Wg(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Wg(t,e)}ln(Gs),nn(Gs,t)}function Nl(){ln(Gs),ln(xu),ln(wu)}function kC(e){Bo(wu.current);var t=Bo(Gs.current),n=Wg(t,e.type);t!==n&&(nn(xu,e),nn(Gs,n))}function sw(e){xu.current===e&&(ln(Gs),ln(xu))}var mn=vo(0);function mp(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 Em=[];function iw(){for(var e=0;e<Em.length;e++)Em[e]._workInProgressVersionPrimary=null;Em.length=0}var Lf=Ei.ReactCurrentDispatcher,Am=Ei.ReactCurrentBatchConfig,ea=0,yn=null,Mn=null,Bn=null,gp=!1,Uc=!1,bu=0,QM=0;function Jn(){throw Error(Ne(321))}function ow(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!As(e[n],t[n]))return!1;return!0}function aw(e,t,n,r,s,i){if(ea=i,yn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Lf.current=e===null||e.memoizedState===null?n2:r2,e=n(r,s),Uc){i=0;do{if(Uc=!1,bu=0,25<=i)throw Error(Ne(301));i+=1,Bn=Mn=null,t.updateQueue=null,Lf.current=s2,e=n(r,s)}while(Uc)}if(Lf.current=yp,t=Mn!==null&&Mn.next!==null,ea=0,Bn=Mn=yn=null,gp=!1,t)throw Error(Ne(300));return e}function lw(){var e=bu!==0;return bu=0,e}function Fs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?yn.memoizedState=Bn=e:Bn=Bn.next=e,Bn}function rs(){if(Mn===null){var e=yn.alternate;e=e!==null?e.memoizedState:null}else e=Mn.next;var t=Bn===null?yn.memoizedState:Bn.next;if(t!==null)Bn=t,Mn=e;else{if(e===null)throw Error(Ne(310));Mn=e,e={memoizedState:Mn.memoizedState,baseState:Mn.baseState,baseQueue:Mn.baseQueue,queue:Mn.queue,next:null},Bn===null?yn.memoizedState=Bn=e:Bn=Bn.next=e}return Bn}function ku(e,t){return typeof t=="function"?t(e):t}function Pm(e){var t=rs(),n=t.queue;if(n===null)throw Error(Ne(311));n.lastRenderedReducer=e;var r=Mn,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,u=i;do{var p=u.lane;if((ea&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,yn.lanes|=p,ta|=p}u=u.next}while(u!==null&&u!==i);c===null?a=r:c.next=l,As(r,t.memoizedState)||(br=!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,yn.lanes|=i,ta|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Im(e){var t=rs(),n=t.queue;if(n===null)throw Error(Ne(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);As(i,t.memoizedState)||(br=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function vC(){}function SC(e,t){var n=yn,r=rs(),s=t(),i=!As(r.memoizedState,s);if(i&&(r.memoizedState=s,br=!0),r=r.queue,cw(CC.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Bn!==null&&Bn.memoizedState.tag&1){if(n.flags|=2048,vu(9,jC.bind(null,n,r,s,t),void 0,null),Vn===null)throw Error(Ne(349));ea&30||NC(n,t,s)}return s}function NC(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=yn.updateQueue,t===null?(t={lastEffect:null,stores:null},yn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function jC(e,t,n,r){t.value=n,t.getSnapshot=r,_C(t)&&EC(e)}function CC(e,t,n){return n(function(){_C(t)&&EC(e)})}function _C(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!As(e,n)}catch{return!0}}function EC(e){var t=Ni(e,1);t!==null&&_s(t,e,1,-1)}function qv(e){var t=Fs();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ku,lastRenderedState:e},t.queue=e,e=e.dispatch=t2.bind(null,yn,e),[t.memoizedState,e]}function vu(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=yn.updateQueue,t===null?(t={lastEffect:null,stores:null},yn.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 AC(){return rs().memoizedState}function Of(e,t,n,r){var s=Fs();yn.flags|=e,s.memoizedState=vu(1|t,n,void 0,r===void 0?null:r)}function oh(e,t,n,r){var s=rs();r=r===void 0?null:r;var i=void 0;if(Mn!==null){var a=Mn.memoizedState;if(i=a.destroy,r!==null&&ow(r,a.deps)){s.memoizedState=vu(t,n,i,r);return}}yn.flags|=e,s.memoizedState=vu(1|t,n,i,r)}function Yv(e,t){return Of(8390656,8,e,t)}function cw(e,t){return oh(2048,8,e,t)}function PC(e,t){return oh(4,2,e,t)}function IC(e,t){return oh(4,4,e,t)}function TC(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 RC(e,t,n){return n=n!=null?n.concat([e]):null,oh(4,4,TC.bind(null,t,e),n)}function uw(){}function MC(e,t){var n=rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&ow(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function $C(e,t){var n=rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&ow(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function LC(e,t,n){return ea&21?(As(n,t)||(n=H1(),yn.lanes|=n,ta|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,br=!0),e.memoizedState=n)}function ZM(e,t){var n=Bt;Bt=n!==0&&4>n?n:4,e(!0);var r=Am.transition;Am.transition={};try{e(!1),t()}finally{Bt=n,Am.transition=r}}function OC(){return rs().memoizedState}function e2(e,t,n){var r=co(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},DC(e))FC(t,n);else if(n=wC(e,t,n,r),n!==null){var s=ur();_s(n,e,r,s),zC(n,t,r)}}function t2(e,t,n){var r=co(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(DC(e))FC(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,As(l,a)){var c=t.interleaved;c===null?(s.next=s,tw(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=wC(e,t,s,r),n!==null&&(s=ur(),_s(n,e,r,s),zC(n,t,r))}}function DC(e){var t=e.alternate;return e===yn||t!==null&&t===yn}function FC(e,t){Uc=gp=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zC(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Hx(e,n)}}var yp={readContext:ns,useCallback:Jn,useContext:Jn,useEffect:Jn,useImperativeHandle:Jn,useInsertionEffect:Jn,useLayoutEffect:Jn,useMemo:Jn,useReducer:Jn,useRef:Jn,useState:Jn,useDebugValue:Jn,useDeferredValue:Jn,useTransition:Jn,useMutableSource:Jn,useSyncExternalStore:Jn,useId:Jn,unstable_isNewReconciler:!1},n2={readContext:ns,useCallback:function(e,t){return Fs().memoizedState=[e,t===void 0?null:t],e},useContext:ns,useEffect:Yv,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Of(4194308,4,TC.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Of(4194308,4,e,t)},useInsertionEffect:function(e,t){return Of(4,2,e,t)},useMemo:function(e,t){var n=Fs();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Fs();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=e2.bind(null,yn,e),[r.memoizedState,e]},useRef:function(e){var t=Fs();return e={current:e},t.memoizedState=e},useState:qv,useDebugValue:uw,useDeferredValue:function(e){return Fs().memoizedState=e},useTransition:function(){var e=qv(!1),t=e[0];return e=ZM.bind(null,e[1]),Fs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=yn,s=Fs();if(dn){if(n===void 0)throw Error(Ne(407));n=n()}else{if(n=t(),Vn===null)throw Error(Ne(349));ea&30||NC(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Yv(CC.bind(null,r,i,e),[e]),r.flags|=2048,vu(9,jC.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Fs(),t=Vn.identifierPrefix;if(dn){var n=gi,r=mi;n=(r&~(1<<32-Cs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=bu++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=QM++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},r2={readContext:ns,useCallback:MC,useContext:ns,useEffect:cw,useImperativeHandle:RC,useInsertionEffect:PC,useLayoutEffect:IC,useMemo:$C,useReducer:Pm,useRef:AC,useState:function(){return Pm(ku)},useDebugValue:uw,useDeferredValue:function(e){var t=rs();return LC(t,Mn.memoizedState,e)},useTransition:function(){var e=Pm(ku)[0],t=rs().memoizedState;return[e,t]},useMutableSource:vC,useSyncExternalStore:SC,useId:OC,unstable_isNewReconciler:!1},s2={readContext:ns,useCallback:MC,useContext:ns,useEffect:cw,useImperativeHandle:RC,useInsertionEffect:PC,useLayoutEffect:IC,useMemo:$C,useReducer:Im,useRef:AC,useState:function(){return Im(ku)},useDebugValue:uw,useDeferredValue:function(e){var t=rs();return Mn===null?t.memoizedState=e:LC(t,Mn.memoizedState,e)},useTransition:function(){var e=Im(ku)[0],t=rs().memoizedState;return[e,t]},useMutableSource:vC,useSyncExternalStore:SC,useId:OC,unstable_isNewReconciler:!1};function xs(e,t){if(e&&e.defaultProps){t=xn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function uy(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:xn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ah={isMounted:function(e){return(e=e._reactInternals)?ma(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ur(),s=co(e),i=bi(r,s);i.payload=t,n!=null&&(i.callback=n),t=ao(e,i,s),t!==null&&(_s(t,e,s,r),$f(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ur(),s=co(e),i=bi(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ao(e,i,s),t!==null&&(_s(t,e,s,r),$f(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ur(),r=co(e),s=bi(n,r);s.tag=2,t!=null&&(s.callback=t),t=ao(e,s,r),t!==null&&(_s(t,e,r,n),$f(t,e,r))}};function Gv(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?!hu(n,r)||!hu(s,i):!0}function HC(e,t,n){var r=!1,s=go,i=t.contextType;return typeof i=="object"&&i!==null?i=ns(i):(s=Nr(t)?Qo:tr.current,r=t.contextTypes,i=(r=r!=null)?kl(e,s):go),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ah,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Jv(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&&ah.enqueueReplaceState(t,t.state,null)}function dy(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},nw(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=ns(i):(i=Nr(t)?Qo:tr.current,s.context=kl(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(uy(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&&ah.enqueueReplaceState(s,s.state,null),hp(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function jl(e,t){try{var n="",r=t;do n+=TR(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 Tm(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function fy(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var i2=typeof WeakMap=="function"?WeakMap:Map;function BC(e,t,n){n=bi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){wp||(wp=!0,vy=r),fy(e,t)},n}function WC(e,t,n){n=bi(-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(){fy(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){fy(e,t),typeof r!="function"&&(lo===null?lo=new Set([this]):lo.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Xv(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new i2;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=w2.bind(null,e,t,n),t.then(e,e))}function Qv(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 Zv(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=bi(-1,1),t.tag=2,ao(n,t,1))),n.lanes|=1),e)}var o2=Ei.ReactCurrentOwner,br=!1;function lr(e,t,n,r){t.child=e===null?xC(t,null,n,r):Sl(t,e.child,n,r)}function e0(e,t,n,r,s){n=n.render;var i=t.ref;return fl(t,s),r=aw(e,t,n,r,i,s),n=lw(),e!==null&&!br?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ji(e,t,s)):(dn&&n&&Gx(t),t.flags|=1,lr(e,t,r,s),t.child)}function t0(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!xw(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,VC(e,t,i,r,s)):(e=Hf(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:hu,n(a,r)&&e.ref===t.ref)return ji(e,t,s)}return t.flags|=1,e=uo(i,r),e.ref=t.ref,e.return=t,t.child=e}function VC(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(hu(i,r)&&e.ref===t.ref)if(br=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(br=!0);else return t.lanes=e.lanes,ji(e,t,s)}return py(e,t,n,r,s)}function KC(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},nn(nl,$r),$r|=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,nn(nl,$r),$r|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,nn(nl,$r),$r|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,nn(nl,$r),$r|=r;return lr(e,t,s,n),t.child}function UC(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function py(e,t,n,r,s){var i=Nr(n)?Qo:tr.current;return i=kl(t,i),fl(t,s),n=aw(e,t,n,r,i,s),r=lw(),e!==null&&!br?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ji(e,t,s)):(dn&&r&&Gx(t),t.flags|=1,lr(e,t,n,s),t.child)}function n0(e,t,n,r,s){if(Nr(n)){var i=!0;cp(t)}else i=!1;if(fl(t,s),t.stateNode===null)Df(e,t),HC(t,n,r),dy(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=ns(u):(u=Nr(n)?Qo:tr.current,u=kl(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Jv(t,a,r,u),Yi=!1;var d=t.memoizedState;a.state=d,hp(t,r,a,s),c=t.memoizedState,l!==r||d!==c||Sr.current||Yi?(typeof p=="function"&&(uy(t,n,p,r),c=t.memoizedState),(l=Yi||Gv(t,n,l,r,d,c,u))?(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=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,bC(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:xs(t.type,l),a.props=u,f=t.pendingProps,d=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=ns(c):(c=Nr(n)?Qo:tr.current,c=kl(t,c));var h=n.getDerivedStateFromProps;(p=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||d!==c)&&Jv(t,a,r,c),Yi=!1,d=t.memoizedState,a.state=d,hp(t,r,a,s);var g=t.memoizedState;l!==f||d!==g||Sr.current||Yi?(typeof h=="function"&&(uy(t,n,h,r),g=t.memoizedState),(u=Yi||Gv(t,n,u,r,d,g,c)||!1)?(p||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&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),a.props=r,a.state=g,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return hy(e,t,n,r,i,s)}function hy(e,t,n,r,s,i){UC(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Hv(t,n,!1),ji(e,t,i);r=t.stateNode,o2.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Sl(t,e.child,null,i),t.child=Sl(t,null,l,i)):lr(e,t,l,i),t.memoizedState=r.state,s&&Hv(t,n,!0),t.child}function qC(e){var t=e.stateNode;t.pendingContext?zv(e,t.pendingContext,t.pendingContext!==t.context):t.context&&zv(e,t.context,!1),rw(e,t.containerInfo)}function r0(e,t,n,r,s){return vl(),Xx(s),t.flags|=256,lr(e,t,n,r),t.child}var my={dehydrated:null,treeContext:null,retryLane:0};function gy(e){return{baseLanes:e,cachePool:null,transitions:null}}function YC(e,t,n){var r=t.pendingProps,s=mn.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),nn(mn,s&1),e===null)return ly(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=uh(a,r,0,null),e=Uo(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=gy(n),t.memoizedState=my,e):dw(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return a2(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=uo(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=uo(l,i):(i=Uo(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?gy(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=my,r}return i=e.child,e=i.sibling,r=uo(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 dw(e,t){return t=uh({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Xd(e,t,n,r){return r!==null&&Xx(r),Sl(t,e.child,null,n),e=dw(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function a2(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=Tm(Error(Ne(422))),Xd(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=uh({mode:"visible",children:r.children},s,0,null),i=Uo(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&Sl(t,e.child,null,a),t.child.memoizedState=gy(a),t.memoizedState=my,i);if(!(t.mode&1))return Xd(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(Ne(419)),r=Tm(i,r,void 0),Xd(e,t,a,r)}if(l=(a&e.childLanes)!==0,br||l){if(r=Vn,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,Ni(e,s),_s(r,e,s,-1))}return yw(),r=Tm(Error(Ne(421))),Xd(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=b2.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Dr=oo(s.nextSibling),zr=t,dn=!0,ks=null,e!==null&&(Jr[Xr++]=mi,Jr[Xr++]=gi,Jr[Xr++]=Zo,mi=e.id,gi=e.overflow,Zo=t),t=dw(t,r.children),t.flags|=4096,t)}function s0(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),cy(e.return,t,n)}function Rm(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 GC(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(lr(e,t,r.children,n),r=mn.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&&s0(e,n,t);else if(e.tag===19)s0(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(nn(mn,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&&mp(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Rm(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&&mp(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Rm(t,!0,n,null,i);break;case"together":Rm(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Df(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ji(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ta|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ne(153));if(t.child!==null){for(e=t.child,n=uo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=uo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function l2(e,t,n){switch(t.tag){case 3:qC(t),vl();break;case 5:kC(t);break;case 1:Nr(t.type)&&cp(t);break;case 4:rw(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;nn(fp,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(nn(mn,mn.current&1),t.flags|=128,null):n&t.child.childLanes?YC(e,t,n):(nn(mn,mn.current&1),e=ji(e,t,n),e!==null?e.sibling:null);nn(mn,mn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return GC(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),nn(mn,mn.current),r)break;return null;case 22:case 23:return t.lanes=0,KC(e,t,n)}return ji(e,t,n)}var JC,yy,XC,QC;JC=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}};yy=function(){};XC=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Bo(Gs.current);var i=null;switch(n){case"input":s=Fg(e,s),r=Fg(e,r),i=[];break;case"select":s=xn({},s,{value:void 0}),r=xn({},r,{value:void 0}),i=[];break;case"textarea":s=Bg(e,s),r=Bg(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ap)}Vg(n,r);var a;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(au.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(l=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="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(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(au.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&on("scroll",e),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};QC=function(e,t,n,r){n!==r&&(t.flags|=4)};function xc(e,t){if(!dn)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 Xn(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 c2(e,t,n){var r=t.pendingProps;switch(Jx(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xn(t),null;case 1:return Nr(t.type)&&lp(),Xn(t),null;case 3:return r=t.stateNode,Nl(),ln(Sr),ln(tr),iw(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Gd(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ks!==null&&(jy(ks),ks=null))),yy(e,t),Xn(t),null;case 5:sw(t);var s=Bo(wu.current);if(n=t.type,e!==null&&t.stateNode!=null)XC(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ne(166));return Xn(t),null}if(e=Bo(Gs.current),Gd(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ws]=t,r[yu]=i,e=(t.mode&1)!==0,n){case"dialog":on("cancel",r),on("close",r);break;case"iframe":case"object":case"embed":on("load",r);break;case"video":case"audio":for(s=0;s<Mc.length;s++)on(Mc[s],r);break;case"source":on("error",r);break;case"img":case"image":case"link":on("error",r),on("load",r);break;case"details":on("toggle",r);break;case"input":pv(r,i),on("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},on("invalid",r);break;case"textarea":mv(r,i),on("invalid",r)}Vg(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&&Yd(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Yd(r.textContent,l,e),s=["children",""+l]):au.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&on("scroll",r)}switch(n){case"input":zd(r),hv(r,i,!0);break;case"textarea":zd(r),gv(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=ap)}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=C1(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[Ws]=t,e[yu]=r,JC(e,t,!1,!1),t.stateNode=e;e:{switch(a=Kg(n,r),n){case"dialog":on("cancel",e),on("close",e),s=r;break;case"iframe":case"object":case"embed":on("load",e),s=r;break;case"video":case"audio":for(s=0;s<Mc.length;s++)on(Mc[s],e);s=r;break;case"source":on("error",e),s=r;break;case"img":case"image":case"link":on("error",e),on("load",e),s=r;break;case"details":on("toggle",e),s=r;break;case"input":pv(e,r),s=Fg(e,r),on("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=xn({},r,{value:void 0}),on("invalid",e);break;case"textarea":mv(e,r),s=Bg(e,r),on("invalid",e);break;default:s=r}Vg(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?A1(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&_1(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&lu(e,c):typeof c=="number"&&lu(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(au.hasOwnProperty(i)?c!=null&&i==="onScroll"&&on("scroll",e):c!=null&&$x(e,i,c,a))}switch(n){case"input":zd(e),hv(e,r,!1);break;case"textarea":zd(e),gv(e);break;case"option":r.value!=null&&e.setAttribute("value",""+mo(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ll(e,!!r.multiple,i,!1):r.defaultValue!=null&&ll(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=ap)}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 Xn(t),null;case 6:if(e&&t.stateNode!=null)QC(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ne(166));if(n=Bo(wu.current),Bo(Gs.current),Gd(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ws]=t,(i=r.nodeValue!==n)&&(e=zr,e!==null))switch(e.tag){case 3:Yd(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Yd(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ws]=t,t.stateNode=r}return Xn(t),null;case 13:if(ln(mn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(dn&&Dr!==null&&t.mode&1&&!(t.flags&128))gC(),vl(),t.flags|=98560,i=!1;else if(i=Gd(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(Ne(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ne(317));i[Ws]=t}else vl(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Xn(t),i=!1}else ks!==null&&(jy(ks),ks=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||mn.current&1?$n===0&&($n=3):yw())),t.updateQueue!==null&&(t.flags|=4),Xn(t),null);case 4:return Nl(),yy(e,t),e===null&&mu(t.stateNode.containerInfo),Xn(t),null;case 10:return ew(t.type._context),Xn(t),null;case 17:return Nr(t.type)&&lp(),Xn(t),null;case 19:if(ln(mn),i=t.memoizedState,i===null)return Xn(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)xc(i,!1);else{if($n!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=mp(e),a!==null){for(t.flags|=128,xc(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 nn(mn,mn.current&1|2),t.child}e=e.sibling}i.tail!==null&&Sn()>Cl&&(t.flags|=128,r=!0,xc(i,!1),t.lanes=4194304)}else{if(!r)if(e=mp(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),xc(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!dn)return Xn(t),null}else 2*Sn()-i.renderingStartTime>Cl&&n!==1073741824&&(t.flags|=128,r=!0,xc(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=Sn(),t.sibling=null,n=mn.current,nn(mn,r?n&1|2:n&1),t):(Xn(t),null);case 22:case 23:return gw(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?$r&1073741824&&(Xn(t),t.subtreeFlags&6&&(t.flags|=8192)):Xn(t),null;case 24:return null;case 25:return null}throw Error(Ne(156,t.tag))}function u2(e,t){switch(Jx(t),t.tag){case 1:return Nr(t.type)&&lp(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Nl(),ln(Sr),ln(tr),iw(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return sw(t),null;case 13:if(ln(mn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ne(340));vl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ln(mn),null;case 4:return Nl(),null;case 10:return ew(t.type._context),null;case 22:case 23:return gw(),null;case 24:return null;default:return null}}var Qd=!1,Qn=!1,d2=typeof WeakSet=="function"?WeakSet:Set,He=null;function tl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){bn(e,t,r)}else n.current=null}function xy(e,t,n){try{n()}catch(r){bn(e,t,r)}}var i0=!1;function f2(e,t){if(ty=sp,e=rC(),Yx(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,u=0,p=0,f=e,d=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;)d=f,f=h;for(;;){if(f===e)break t;if(d===n&&++u===s&&(l=a),d===i&&++p===r&&(c=a),(h=f.nextSibling)!==null)break;f=d,d=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(ny={focusedElem:e,selectionRange:n},sp=!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 b=g.memoizedProps,v=g.memoizedState,y=t.stateNode,w=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:xs(t.type,b),v);y.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ne(163))}}catch(S){bn(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,He=e;break}He=t.return}return g=i0,i0=!1,g}function qc(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&&xy(t,n,i)}s=s.next}while(s!==r)}}function lh(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 wy(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 ZC(e){var t=e.alternate;t!==null&&(e.alternate=null,ZC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ws],delete t[yu],delete t[iy],delete t[YM],delete t[GM])),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 e_(e){return e.tag===5||e.tag===3||e.tag===4}function o0(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||e_(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 by(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=ap));else if(r!==4&&(e=e.child,e!==null))for(by(e,t,n),e=e.sibling;e!==null;)by(e,t,n),e=e.sibling}function ky(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(ky(e,t,n),e=e.sibling;e!==null;)ky(e,t,n),e=e.sibling}var Un=null,ws=!1;function Hi(e,t,n){for(n=n.child;n!==null;)t_(e,t,n),n=n.sibling}function t_(e,t,n){if(Ys&&typeof Ys.onCommitFiberUnmount=="function")try{Ys.onCommitFiberUnmount(eh,n)}catch{}switch(n.tag){case 5:Qn||tl(n,t);case 6:var r=Un,s=ws;Un=null,Hi(e,t,n),Un=r,ws=s,Un!==null&&(ws?(e=Un,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Un.removeChild(n.stateNode));break;case 18:Un!==null&&(ws?(e=Un,n=n.stateNode,e.nodeType===8?Cm(e.parentNode,n):e.nodeType===1&&Cm(e,n),fu(e)):Cm(Un,n.stateNode));break;case 4:r=Un,s=ws,Un=n.stateNode.containerInfo,ws=!0,Hi(e,t,n),Un=r,ws=s;break;case 0:case 11:case 14:case 15:if(!Qn&&(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)&&xy(n,t,a),s=s.next}while(s!==r)}Hi(e,t,n);break;case 1:if(!Qn&&(tl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){bn(n,t,l)}Hi(e,t,n);break;case 21:Hi(e,t,n);break;case 22:n.mode&1?(Qn=(r=Qn)||n.memoizedState!==null,Hi(e,t,n),Qn=r):Hi(e,t,n);break;default:Hi(e,t,n)}}function a0(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new d2),t.forEach(function(r){var s=k2.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function hs(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:Un=l.stateNode,ws=!1;break e;case 3:Un=l.stateNode.containerInfo,ws=!0;break e;case 4:Un=l.stateNode.containerInfo,ws=!0;break e}l=l.return}if(Un===null)throw Error(Ne(160));t_(i,a,s),Un=null,ws=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){bn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)n_(t,e),t=t.sibling}function n_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(hs(t,e),Ls(e),r&4){try{qc(3,e,e.return),lh(3,e)}catch(b){bn(e,e.return,b)}try{qc(5,e,e.return)}catch(b){bn(e,e.return,b)}}break;case 1:hs(t,e),Ls(e),r&512&&n!==null&&tl(n,n.return);break;case 5:if(hs(t,e),Ls(e),r&512&&n!==null&&tl(n,n.return),e.flags&32){var s=e.stateNode;try{lu(s,"")}catch(b){bn(e,e.return,b)}}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&&N1(s,i),Kg(l,a);var u=Kg(l,i);for(a=0;a<c.length;a+=2){var p=c[a],f=c[a+1];p==="style"?A1(s,f):p==="dangerouslySetInnerHTML"?_1(s,f):p==="children"?lu(s,f):$x(s,p,f,u)}switch(l){case"input":zg(s,i);break;case"textarea":j1(s,i);break;case"select":var d=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?ll(s,!!i.multiple,h,!1):d!==!!i.multiple&&(i.defaultValue!=null?ll(s,!!i.multiple,i.defaultValue,!0):ll(s,!!i.multiple,i.multiple?[]:"",!1))}s[yu]=i}catch(b){bn(e,e.return,b)}}break;case 6:if(hs(t,e),Ls(e),r&4){if(e.stateNode===null)throw Error(Ne(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){bn(e,e.return,b)}}break;case 3:if(hs(t,e),Ls(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{fu(t.containerInfo)}catch(b){bn(e,e.return,b)}break;case 4:hs(t,e),Ls(e);break;case 13:hs(t,e),Ls(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(hw=Sn())),r&4&&a0(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Qn=(u=Qn)||p,hs(t,e),Qn=u):hs(t,e),Ls(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(He=e,p=e.child;p!==null;){for(f=He=p;He!==null;){switch(d=He,h=d.child,d.tag){case 0:case 11:case 14:case 15:qc(4,d,d.return);break;case 1:tl(d,d.return);var g=d.stateNode;if(typeof g.componentWillUnmount=="function"){r=d,n=d.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(b){bn(r,n,b)}}break;case 5:tl(d,d.return);break;case 22:if(d.memoizedState!==null){c0(f);continue}}h!==null?(h.return=d,He=h):c0(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{s=f.stateNode,u?(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=E1("display",a))}catch(b){bn(e,e.return,b)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(b){bn(e,e.return,b)}}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;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:hs(t,e),Ls(e),r&4&&a0(e);break;case 21:break;default:hs(t,e),Ls(e)}}function Ls(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(e_(n)){var r=n;break e}n=n.return}throw Error(Ne(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(lu(s,""),r.flags&=-33);var i=o0(e);ky(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=o0(e);by(e,l,a);break;default:throw Error(Ne(161))}}catch(c){bn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function p2(e,t,n){He=e,r_(e)}function r_(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||Qd;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Qn;l=Qd;var u=Qn;if(Qd=a,(Qn=c)&&!u)for(He=s;He!==null;)a=He,c=a.child,a.tag===22&&a.memoizedState!==null?u0(s):c!==null?(c.return=a,He=c):u0(s);for(;i!==null;)He=i,r_(i),i=i.sibling;He=s,Qd=l,Qn=u}l0(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,He=i):l0(e)}}function l0(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:Qn||lh(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Qn)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:xs(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Uv(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}Uv(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 u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&fu(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ne(163))}Qn||t.flags&512&&wy(t)}catch(d){bn(t,t.return,d)}}if(t===e){He=null;break}if(n=t.sibling,n!==null){n.return=t.return,He=n;break}He=t.return}}function c0(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 u0(e){for(;He!==null;){var t=He;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{lh(4,t)}catch(c){bn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){bn(t,s,c)}}var i=t.return;try{wy(t)}catch(c){bn(t,i,c)}break;case 5:var a=t.return;try{wy(t)}catch(c){bn(t,a,c)}}}catch(c){bn(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 h2=Math.ceil,xp=Ei.ReactCurrentDispatcher,fw=Ei.ReactCurrentOwner,ts=Ei.ReactCurrentBatchConfig,Rt=0,Vn=null,_n=null,qn=0,$r=0,nl=vo(0),$n=0,Su=null,ta=0,ch=0,pw=0,Yc=null,wr=null,hw=0,Cl=1/0,fi=null,wp=!1,vy=null,lo=null,Zd=!1,eo=null,bp=0,Gc=0,Sy=null,Ff=-1,zf=0;function ur(){return Rt&6?Sn():Ff!==-1?Ff:Ff=Sn()}function co(e){return e.mode&1?Rt&2&&qn!==0?qn&-qn:XM.transition!==null?(zf===0&&(zf=H1()),zf):(e=Bt,e!==0||(e=window.event,e=e===void 0?16:Y1(e.type)),e):1}function _s(e,t,n,r){if(50<Gc)throw Gc=0,Sy=null,Error(Ne(185));Uu(e,n,r),(!(Rt&2)||e!==Vn)&&(e===Vn&&(!(Rt&2)&&(ch|=n),$n===4&&Xi(e,qn)),jr(e,r),n===1&&Rt===0&&!(t.mode&1)&&(Cl=Sn()+500,ih&&So()))}function jr(e,t){var n=e.callbackNode;XR(e,t);var r=rp(e,e===Vn?qn:0);if(r===0)n!==null&&wv(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&wv(n),t===1)e.tag===0?JM(d0.bind(null,e)):pC(d0.bind(null,e)),UM(function(){!(Rt&6)&&So()}),n=null;else{switch(B1(r)){case 1:n=zx;break;case 4:n=F1;break;case 16:n=np;break;case 536870912:n=z1;break;default:n=np}n=d_(n,s_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function s_(e,t){if(Ff=-1,zf=0,Rt&6)throw Error(Ne(327));var n=e.callbackNode;if(pl()&&e.callbackNode!==n)return null;var r=rp(e,e===Vn?qn:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=kp(e,r);else{t=r;var s=Rt;Rt|=2;var i=o_();(Vn!==e||qn!==t)&&(fi=null,Cl=Sn()+500,Ko(e,t));do try{y2();break}catch(l){i_(e,l)}while(!0);Zx(),xp.current=i,Rt=s,_n!==null?t=0:(Vn=null,qn=0,t=$n)}if(t!==0){if(t===2&&(s=Jg(e),s!==0&&(r=s,t=Ny(e,s))),t===1)throw n=Su,Ko(e,0),Xi(e,r),jr(e,Sn()),n;if(t===6)Xi(e,r);else{if(s=e.current.alternate,!(r&30)&&!m2(s)&&(t=kp(e,r),t===2&&(i=Jg(e),i!==0&&(r=i,t=Ny(e,i))),t===1))throw n=Su,Ko(e,0),Xi(e,r),jr(e,Sn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ne(345));case 2:Mo(e,wr,fi);break;case 3:if(Xi(e,r),(r&130023424)===r&&(t=hw+500-Sn(),10<t)){if(rp(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){ur(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=sy(Mo.bind(null,e,wr,fi),t);break}Mo(e,wr,fi);break;case 4:if(Xi(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Cs(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=Sn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*h2(r/1960))-r,10<r){e.timeoutHandle=sy(Mo.bind(null,e,wr,fi),r);break}Mo(e,wr,fi);break;case 5:Mo(e,wr,fi);break;default:throw Error(Ne(329))}}}return jr(e,Sn()),e.callbackNode===n?s_.bind(null,e):null}function Ny(e,t){var n=Yc;return e.current.memoizedState.isDehydrated&&(Ko(e,t).flags|=256),e=kp(e,t),e!==2&&(t=wr,wr=n,t!==null&&jy(t)),e}function jy(e){wr===null?wr=e:wr.push.apply(wr,e)}function m2(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(!As(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 Xi(e,t){for(t&=~pw,t&=~ch,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Cs(t),r=1<<n;e[n]=-1,t&=~r}}function d0(e){if(Rt&6)throw Error(Ne(327));pl();var t=rp(e,0);if(!(t&1))return jr(e,Sn()),null;var n=kp(e,t);if(e.tag!==0&&n===2){var r=Jg(e);r!==0&&(t=r,n=Ny(e,r))}if(n===1)throw n=Su,Ko(e,0),Xi(e,t),jr(e,Sn()),n;if(n===6)throw Error(Ne(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Mo(e,wr,fi),jr(e,Sn()),null}function mw(e,t){var n=Rt;Rt|=1;try{return e(t)}finally{Rt=n,Rt===0&&(Cl=Sn()+500,ih&&So())}}function na(e){eo!==null&&eo.tag===0&&!(Rt&6)&&pl();var t=Rt;Rt|=1;var n=ts.transition,r=Bt;try{if(ts.transition=null,Bt=1,e)return e()}finally{Bt=r,ts.transition=n,Rt=t,!(Rt&6)&&So()}}function gw(){$r=nl.current,ln(nl)}function Ko(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,KM(n)),_n!==null)for(n=_n.return;n!==null;){var r=n;switch(Jx(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&lp();break;case 3:Nl(),ln(Sr),ln(tr),iw();break;case 5:sw(r);break;case 4:Nl();break;case 13:ln(mn);break;case 19:ln(mn);break;case 10:ew(r.type._context);break;case 22:case 23:gw()}n=n.return}if(Vn=e,_n=e=uo(e.current,null),qn=$r=t,$n=0,Su=null,pw=ch=ta=0,wr=Yc=null,Ho!==null){for(t=0;t<Ho.length;t++)if(n=Ho[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}Ho=null}return e}function i_(e,t){do{var n=_n;try{if(Zx(),Lf.current=yp,gp){for(var r=yn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}gp=!1}if(ea=0,Bn=Mn=yn=null,Uc=!1,bu=0,fw.current=null,n===null||n.return===null){$n=1,Su=t,_n=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=qn,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var d=p.alternate;d?(p.updateQueue=d.updateQueue,p.memoizedState=d.memoizedState,p.lanes=d.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=Qv(a);if(h!==null){h.flags&=-257,Zv(h,a,l,i,t),h.mode&1&&Xv(i,u,t),t=h,c=u;var g=t.updateQueue;if(g===null){var b=new Set;b.add(c),t.updateQueue=b}else g.add(c);break e}else{if(!(t&1)){Xv(i,u,t),yw();break e}c=Error(Ne(426))}}else if(dn&&l.mode&1){var v=Qv(a);if(v!==null){!(v.flags&65536)&&(v.flags|=256),Zv(v,a,l,i,t),Xx(jl(c,l));break e}}i=c=jl(c,l),$n!==4&&($n=2),Yc===null?Yc=[i]:Yc.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=BC(i,c,t);Kv(i,y);break e;case 1:l=c;var w=i.type,x=i.stateNode;if(!(i.flags&128)&&(typeof w.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(lo===null||!lo.has(x)))){i.flags|=65536,t&=-t,i.lanes|=t;var S=WC(i,l,t);Kv(i,S);break e}}i=i.return}while(i!==null)}l_(n)}catch(C){t=C,_n===n&&n!==null&&(_n=n=n.return);continue}break}while(!0)}function o_(){var e=xp.current;return xp.current=yp,e===null?yp:e}function yw(){($n===0||$n===3||$n===2)&&($n=4),Vn===null||!(ta&268435455)&&!(ch&268435455)||Xi(Vn,qn)}function kp(e,t){var n=Rt;Rt|=2;var r=o_();(Vn!==e||qn!==t)&&(fi=null,Ko(e,t));do try{g2();break}catch(s){i_(e,s)}while(!0);if(Zx(),Rt=n,xp.current=r,_n!==null)throw Error(Ne(261));return Vn=null,qn=0,$n}function g2(){for(;_n!==null;)a_(_n)}function y2(){for(;_n!==null&&!BR();)a_(_n)}function a_(e){var t=u_(e.alternate,e,$r);e.memoizedProps=e.pendingProps,t===null?l_(e):_n=t,fw.current=null}function l_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=u2(n,t),n!==null){n.flags&=32767,_n=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{$n=6,_n=null;return}}else if(n=c2(n,t,$r),n!==null){_n=n;return}if(t=t.sibling,t!==null){_n=t;return}_n=t=e}while(t!==null);$n===0&&($n=5)}function Mo(e,t,n){var r=Bt,s=ts.transition;try{ts.transition=null,Bt=1,x2(e,t,n,r)}finally{ts.transition=s,Bt=r}return null}function x2(e,t,n,r){do pl();while(eo!==null);if(Rt&6)throw Error(Ne(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(Ne(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(QR(e,i),e===Vn&&(_n=Vn=null,qn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Zd||(Zd=!0,d_(np,function(){return pl(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ts.transition,ts.transition=null;var a=Bt;Bt=1;var l=Rt;Rt|=4,fw.current=null,f2(e,n),n_(n,e),DM(ny),sp=!!ty,ny=ty=null,e.current=n,p2(n),WR(),Rt=l,Bt=a,ts.transition=i}else e.current=n;if(Zd&&(Zd=!1,eo=e,bp=s),i=e.pendingLanes,i===0&&(lo=null),UR(n.stateNode),jr(e,Sn()),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(wp)throw wp=!1,e=vy,vy=null,e;return bp&1&&e.tag!==0&&pl(),i=e.pendingLanes,i&1?e===Sy?Gc++:(Gc=0,Sy=e):Gc=0,So(),null}function pl(){if(eo!==null){var e=B1(bp),t=ts.transition,n=Bt;try{if(ts.transition=null,Bt=16>e?16:e,eo===null)var r=!1;else{if(e=eo,eo=null,bp=0,Rt&6)throw Error(Ne(331));var s=Rt;for(Rt|=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 u=l[c];for(He=u;He!==null;){var p=He;switch(p.tag){case 0:case 11:case 15:qc(8,p,i)}var f=p.child;if(f!==null)f.return=p,He=f;else for(;He!==null;){p=He;var d=p.sibling,h=p.return;if(ZC(p),p===u){He=null;break}if(d!==null){d.return=h,He=d;break}He=h}}}var g=i.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var v=b.sibling;b.sibling=null,b=v}while(b!==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:qc(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,He=y;break e}He=i.return}}var w=e.current;for(He=w;He!==null;){a=He;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,He=x;else e:for(a=w;He!==null;){if(l=He,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:lh(9,l)}}catch(C){bn(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(Rt=s,So(),Ys&&typeof Ys.onPostCommitFiberRoot=="function")try{Ys.onPostCommitFiberRoot(eh,e)}catch{}r=!0}return r}finally{Bt=n,ts.transition=t}}return!1}function f0(e,t,n){t=jl(n,t),t=BC(e,t,1),e=ao(e,t,1),t=ur(),e!==null&&(Uu(e,1,t),jr(e,t))}function bn(e,t,n){if(e.tag===3)f0(e,e,n);else for(;t!==null;){if(t.tag===3){f0(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(lo===null||!lo.has(r))){e=jl(n,e),e=WC(t,e,1),t=ao(t,e,1),e=ur(),t!==null&&(Uu(t,1,e),jr(t,e));break}}t=t.return}}function w2(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=ur(),e.pingedLanes|=e.suspendedLanes&n,Vn===e&&(qn&n)===n&&($n===4||$n===3&&(qn&130023424)===qn&&500>Sn()-hw?Ko(e,0):pw|=n),jr(e,t)}function c_(e,t){t===0&&(e.mode&1?(t=Wd,Wd<<=1,!(Wd&130023424)&&(Wd=4194304)):t=1);var n=ur();e=Ni(e,t),e!==null&&(Uu(e,t,n),jr(e,n))}function b2(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),c_(e,n)}function k2(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(Ne(314))}r!==null&&r.delete(t),c_(e,n)}var u_;u_=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Sr.current)br=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return br=!1,l2(e,t,n);br=!!(e.flags&131072)}else br=!1,dn&&t.flags&1048576&&hC(t,dp,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Df(e,t),e=t.pendingProps;var s=kl(t,tr.current);fl(t,n),s=aw(null,t,r,e,s,n);var i=lw();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,Nr(r)?(i=!0,cp(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,nw(t),s.updater=ah,t.stateNode=s,s._reactInternals=t,dy(t,r,e,n),t=hy(null,t,r,!0,i,n)):(t.tag=0,dn&&i&&Gx(t),lr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Df(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=S2(r),e=xs(r,e),s){case 0:t=py(null,t,r,e,n);break e;case 1:t=n0(null,t,r,e,n);break e;case 11:t=e0(null,t,r,e,n);break e;case 14:t=t0(null,t,r,xs(r.type,e),n);break e}throw Error(Ne(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xs(r,s),py(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xs(r,s),n0(e,t,r,s,n);case 3:e:{if(qC(t),e===null)throw Error(Ne(387));r=t.pendingProps,i=t.memoizedState,s=i.element,bC(e,t),hp(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=jl(Error(Ne(423)),t),t=r0(e,t,r,n,s);break e}else if(r!==s){s=jl(Error(Ne(424)),t),t=r0(e,t,r,n,s);break e}else for(Dr=oo(t.stateNode.containerInfo.firstChild),zr=t,dn=!0,ks=null,n=xC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(vl(),r===s){t=ji(e,t,n);break e}lr(e,t,r,n)}t=t.child}return t;case 5:return kC(t),e===null&&ly(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,ry(r,s)?a=null:i!==null&&ry(r,i)&&(t.flags|=32),UC(e,t),lr(e,t,a,n),t.child;case 6:return e===null&&ly(t),null;case 13:return YC(e,t,n);case 4:return rw(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Sl(t,null,r,n):lr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xs(r,s),e0(e,t,r,s,n);case 7:return lr(e,t,t.pendingProps,n),t.child;case 8:return lr(e,t,t.pendingProps.children,n),t.child;case 12:return lr(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,nn(fp,r._currentValue),r._currentValue=a,i!==null)if(As(i.value,a)){if(i.children===s.children&&!Sr.current){t=ji(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=bi(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),cy(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(Ne(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),cy(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}lr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,fl(t,n),s=ns(s),r=r(s),t.flags|=1,lr(e,t,r,n),t.child;case 14:return r=t.type,s=xs(r,t.pendingProps),s=xs(r.type,s),t0(e,t,r,s,n);case 15:return VC(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xs(r,s),Df(e,t),t.tag=1,Nr(r)?(e=!0,cp(t)):e=!1,fl(t,n),HC(t,r,s),dy(t,r,s,n),hy(null,t,r,!0,e,n);case 19:return GC(e,t,n);case 22:return KC(e,t,n)}throw Error(Ne(156,t.tag))};function d_(e,t){return D1(e,t)}function v2(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 es(e,t,n,r){return new v2(e,t,n,r)}function xw(e){return e=e.prototype,!(!e||!e.isReactComponent)}function S2(e){if(typeof e=="function")return xw(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ox)return 11;if(e===Dx)return 14}return 2}function uo(e,t){var n=e.alternate;return n===null?(n=es(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 Hf(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")xw(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ua:return Uo(n.children,s,i,t);case Lx:a=8,s|=8;break;case $g:return e=es(12,n,t,s|2),e.elementType=$g,e.lanes=i,e;case Lg:return e=es(13,n,t,s),e.elementType=Lg,e.lanes=i,e;case Og:return e=es(19,n,t,s),e.elementType=Og,e.lanes=i,e;case k1:return uh(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case w1:a=10;break e;case b1:a=9;break e;case Ox:a=11;break e;case Dx:a=14;break e;case qi:a=16,r=null;break e}throw Error(Ne(130,e==null?e:typeof e,""))}return t=es(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Uo(e,t,n,r){return e=es(7,e,r,t),e.lanes=n,e}function uh(e,t,n,r){return e=es(22,e,r,t),e.elementType=k1,e.lanes=n,e.stateNode={isHidden:!1},e}function Mm(e,t,n){return e=es(6,e,null,t),e.lanes=n,e}function $m(e,t,n){return t=es(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function N2(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=mm(0),this.expirationTimes=mm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mm(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ww(e,t,n,r,s,i,a,l,c){return e=new N2(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=es(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},nw(i),e}function j2(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ka,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function f_(e){if(!e)return go;e=e._reactInternals;e:{if(ma(e)!==e||e.tag!==1)throw Error(Ne(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Nr(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ne(171))}if(e.tag===1){var n=e.type;if(Nr(n))return fC(e,n,t)}return t}function p_(e,t,n,r,s,i,a,l,c){return e=ww(n,r,!0,e,s,i,a,l,c),e.context=f_(null),n=e.current,r=ur(),s=co(n),i=bi(r,s),i.callback=t??null,ao(n,i,s),e.current.lanes=s,Uu(e,s,r),jr(e,r),e}function dh(e,t,n,r){var s=t.current,i=ur(),a=co(s);return n=f_(n),t.context===null?t.context=n:t.pendingContext=n,t=bi(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ao(s,t,a),e!==null&&(_s(e,s,a,i),$f(e,s,a)),a}function vp(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 p0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function bw(e,t){p0(e,t),(e=e.alternate)&&p0(e,t)}function C2(){return null}var h_=typeof reportError=="function"?reportError:function(e){console.error(e)};function kw(e){this._internalRoot=e}fh.prototype.render=kw.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ne(409));dh(e,t,null,null)};fh.prototype.unmount=kw.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;na(function(){dh(null,e,null,null)}),t[Si]=null}};function fh(e){this._internalRoot=e}fh.prototype.unstable_scheduleHydration=function(e){if(e){var t=K1();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ji.length&&t!==0&&t<Ji[n].priority;n++);Ji.splice(n,0,e),n===0&&q1(e)}};function vw(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ph(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function h0(){}function _2(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=vp(a);i.call(u)}}var a=p_(t,r,e,0,null,!1,!1,"",h0);return e._reactRootContainer=a,e[Si]=a.current,mu(e.nodeType===8?e.parentNode:e),na(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=vp(c);l.call(u)}}var c=ww(e,0,!1,null,null,!1,!1,"",h0);return e._reactRootContainer=c,e[Si]=c.current,mu(e.nodeType===8?e.parentNode:e),na(function(){dh(t,c,n,r)}),c}function hh(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=vp(a);l.call(c)}}dh(t,a,e,s)}else a=_2(n,t,e,s,r);return vp(a)}W1=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Rc(t.pendingLanes);n!==0&&(Hx(t,n|1),jr(t,Sn()),!(Rt&6)&&(Cl=Sn()+500,So()))}break;case 13:na(function(){var r=Ni(e,1);if(r!==null){var s=ur();_s(r,e,1,s)}}),bw(e,1)}};Bx=function(e){if(e.tag===13){var t=Ni(e,134217728);if(t!==null){var n=ur();_s(t,e,134217728,n)}bw(e,134217728)}};V1=function(e){if(e.tag===13){var t=co(e),n=Ni(e,t);if(n!==null){var r=ur();_s(n,e,t,r)}bw(e,t)}};K1=function(){return Bt};U1=function(e,t){var n=Bt;try{return Bt=e,t()}finally{Bt=n}};qg=function(e,t,n){switch(t){case"input":if(zg(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=sh(r);if(!s)throw Error(Ne(90));S1(r),zg(r,s)}}}break;case"textarea":j1(e,n);break;case"select":t=n.value,t!=null&&ll(e,!!n.multiple,t,!1)}};T1=mw;R1=na;var E2={usingClientEntryPoint:!1,Events:[Yu,Ja,sh,P1,I1,mw]},wc={findFiberByHostInstance:zo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},A2={bundleType:wc.bundleType,version:wc.version,rendererPackageName:wc.rendererPackageName,rendererConfig:wc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ei.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=L1(e),e===null?null:e.stateNode},findFiberByHostInstance:wc.findFiberByHostInstance||C2,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 ef=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ef.isDisabled&&ef.supportsFiber)try{eh=ef.inject(A2),Ys=ef}catch{}}Vr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=E2;Vr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vw(t))throw Error(Ne(200));return j2(e,t,null,n)};Vr.createRoot=function(e,t){if(!vw(e))throw Error(Ne(299));var n=!1,r="",s=h_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ww(e,1,!1,null,null,n,!1,r,s),e[Si]=t.current,mu(e.nodeType===8?e.parentNode:e),new kw(t)};Vr.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(Ne(188)):(e=Object.keys(e).join(","),Error(Ne(268,e)));return e=L1(t),e=e===null?null:e.stateNode,e};Vr.flushSync=function(e){return na(e)};Vr.hydrate=function(e,t,n){if(!ph(t))throw Error(Ne(200));return hh(null,e,t,!0,n)};Vr.hydrateRoot=function(e,t,n){if(!vw(e))throw Error(Ne(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=h_;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=p_(t,null,e,1,n??null,s,!1,i,a),e[Si]=t.current,mu(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 fh(t)};Vr.render=function(e,t,n){if(!ph(t))throw Error(Ne(200));return hh(null,e,t,!1,n)};Vr.unmountComponentAtNode=function(e){if(!ph(e))throw Error(Ne(40));return e._reactRootContainer?(na(function(){hh(null,null,e,!1,function(){e._reactRootContainer=null,e[Si]=null})}),!0):!1};Vr.unstable_batchedUpdates=mw;Vr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ph(n))throw Error(Ne(200));if(e==null||e._reactInternals===void 0)throw Error(Ne(38));return hh(e,t,n,!1,r)};Vr.version="18.3.1-next-f1338f8080-20240426";function m_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(m_)}catch(e){console.error(e)}}m_(),m1.exports=Vr;var cr=m1.exports,m0=cr;Rg.createRoot=m0.createRoot,Rg.hydrateRoot=m0.hydrateRoot;const g_=m.createContext(null);function Cy(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function P2(){const e=Cy(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function I2({children:e}){const[t,n]=m.useState(P2);m.useEffect(()=>{const i=()=>n(Cy(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=Cy(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(g_.Provider,{value:s,children:e})}function ti(){const e=m.useContext(g_);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function T2(){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 g0={};function _y(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&g0[t[0]]||(typeof t[0]=="string"&&(g0[t[0]]=new Date),T2(...t))}const y_=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function y0(e,t,n){e.loadNamespaces(t,y_(e,n))}function x0(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,y_(e,r))}function R2(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 u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===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 M2(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(_y("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}}):R2(e,t,n)}const $2=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,L2={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},O2=e=>L2[e],D2=e=>e.replace($2,O2);let Ey={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:D2};function F2(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ey={...Ey,...e}}function z2(){return Ey}let x_;function H2(e){x_=e}function B2(){return x_}const W2={type:"3rdParty",init(e){F2(e.options.react),H2(e)}},V2=m.createContext();class K2{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const U2=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function pr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(V2)||{},i=n||r||B2();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new K2),!i){_y("You will need to pass in an i18next instance by using initReactI18next");const x=(C,j)=>typeof j=="string"?j:j&&typeof j=="object"&&typeof j.defaultValue=="string"?j.defaultValue:Array.isArray(C)?C[C.length-1]:C,S=[x,{},!1];return S.t=x,S.i18n={},S.ready=!1,S}i.options.react&&i.options.react.wait!==void 0&&_y("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...z2(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||s||i.options&&i.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(u);const p=(i.isInitialized||i.initializedStoreOnce)&&u.every(x=>M2(x,i,a));function f(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[d,h]=m.useState(f);let g=u.join();t.lng&&(g=`${t.lng}${g}`);const b=U2(g),v=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:S}=a;v.current=!0,!p&&!l&&(t.lng?x0(i,t.lng,u,()=>{v.current&&h(f)}):y0(i,u,()=>{v.current&&h(f)})),p&&b&&b!==g&&v.current&&h(f);function C(){v.current&&h(f)}return x&&i&&i.on(x,C),S&&i&&i.store.on(S,C),()=>{v.current=!1,x&&i&&x.split(" ").forEach(j=>i.off(j,C)),S&&i&&S.split(" ").forEach(j=>i.store.off(j,C))}},[i,g]);const y=m.useRef(!0);m.useEffect(()=>{v.current&&!y.current&&h(f),y.current=!1},[i,c]);const w=[d,i,p];if(w.t=d,w.i18n=i,w.ready=p,p||!p&&!l)return w;throw new Promise(x=>{t.lng?x0(i,t.lng,u,()=>x()):y0(i,u,()=>x())})}const w_="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",q2=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workspaces",label:"工作区",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{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:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],Y2=[{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 G2(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function J2({authUser:e,onLogout:t}){const{path:n,navigate:r}=ti(),{t:s}=pr(),[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:w_,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:q2.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(G2(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:l.label||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)||""}),e!=null&&e.isAdmin?o.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,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&&Y2.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 X2="agentflow.pipelineRecent",Q2=15;function Z2(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function e$(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(X2);return e?Z2(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 t$(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 w0(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,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const p=Math.floor(a/24);return p<7?t("flow:time.daysAgo",{n:p}):`${l.getMonth()+1}/${l.getDate()}`}function n$(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:t$(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,Q2)}var Lr=Uint8Array,rl=Uint16Array,r$=Int32Array,b_=new Lr([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]),k_=new Lr([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]),s$=new Lr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),v_=function(e,t){for(var n=new rl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new r$(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}},S_=v_(b_,2),N_=S_.b,i$=S_.r;N_[28]=258,i$[258]=28;var o$=v_(k_,0),a$=o$.b,Ay=new rl(32768);for(var an=0;an<32768;++an){var Bi=(an&43690)>>1|(an&21845)<<1;Bi=(Bi&52428)>>2|(Bi&13107)<<2,Bi=(Bi&61680)>>4|(Bi&3855)<<4,Ay[an]=((Bi&65280)>>8|(Bi&255)<<8)>>1}var Jc=function(e,t,n){for(var r=e.length,s=0,i=new rl(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new rl(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new rl(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],p=t-e[s],f=a[e[s]-1]++<<p,d=f|(1<<p)-1;f<=d;++f)l[Ay[f]>>c]=u}else for(l=new rl(r),s=0;s<r;++s)e[s]&&(l[s]=Ay[a[e[s]-1]++]>>15-e[s]);return l},Ju=new Lr(288);for(var an=0;an<144;++an)Ju[an]=8;for(var an=144;an<256;++an)Ju[an]=9;for(var an=256;an<280;++an)Ju[an]=7;for(var an=280;an<288;++an)Ju[an]=8;var j_=new Lr(32);for(var an=0;an<32;++an)j_[an]=5;var l$=Jc(Ju,9,1),c$=Jc(j_,5,1),Lm=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ms=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Om=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},u$=function(e){return(e+7)/8|0},Sw=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Lr(e.subarray(t,n))},d$=["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"],Gr=function(e,t,n){var r=new Error(t||d$[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Gr),!n)throw r;return r},f$=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new Lr(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new Lr(s*3));var u=function(ae){var pe=n.length;if(ae>pe){var be=new Lr(Math.max(pe*2,ae));be.set(n),n=be}},p=t.f||0,f=t.p||0,d=t.b||0,h=t.l,g=t.d,b=t.m,v=t.n,y=s*8;do{if(!h){p=ms(e,f,1);var w=ms(e,f+1,3);if(f+=3,w)if(w==1)h=l$,g=c$,b=9,v=5;else if(w==2){var j=ms(e,f,31)+257,E=ms(e,f+10,15)+4,P=j+ms(e,f+5,31)+1;f+=14;for(var F=new Lr(P),V=new Lr(19),z=0;z<E;++z)V[s$[z]]=ms(e,f+z*3,7);f+=E*3;for(var D=Lm(V),R=(1<<D)-1,T=Jc(V,D,1),z=0;z<P;){var L=T[ms(e,f,R)];f+=L&15;var x=L>>4;if(x<16)F[z++]=x;else{var $=0,O=0;for(x==16?(O=3+ms(e,f,3),f+=2,$=F[z-1]):x==17?(O=3+ms(e,f,7),f+=3):x==18&&(O=11+ms(e,f,127),f+=7);O--;)F[z++]=$}}var A=F.subarray(0,j),M=F.subarray(j);b=Lm(A),v=Lm(M),h=Jc(A,b,1),g=Jc(M,v,1)}else Gr(1);else{var x=u$(f)+4,S=e[x-4]|e[x-3]<<8,C=x+S;if(C>s){c&&Gr(0);break}l&&u(d+S),n.set(e.subarray(x,C),d),t.b=d+=S,t.p=f=C*8,t.f=p;continue}if(f>y){c&&Gr(0);break}}l&&u(d+131072);for(var _=(1<<b)-1,U=(1<<v)-1,q=f;;q=f){var $=h[Om(e,f)&_],B=$>>4;if(f+=$&15,f>y){c&&Gr(0);break}if($||Gr(2),B<256)n[d++]=B;else if(B==256){q=f,h=null;break}else{var Q=B-254;if(B>264){var z=B-257,se=b_[z];Q=ms(e,f,(1<<se)-1)+N_[z],f+=se}var oe=g[Om(e,f)&U],ve=oe>>4;oe||Gr(3),f+=oe&15;var M=a$[ve];if(ve>3){var se=k_[ve];M+=Om(e,f)&(1<<se)-1,f+=se}if(f>y){c&&Gr(0);break}l&&u(d+131072);var re=d+Q;if(d<M){var ue=i-M,te=Math.min(M,re);for(ue+d<0&&Gr(3);d<te;++d)n[d]=r[ue+d]}for(;d<re;++d)n[d]=n[d-M]}}t.l=h,t.p=q,t.b=d,t.f=p,h&&(p=1,t.m=b,t.d=g,t.n=v)}while(!p);return d!=n.length&&a?Sw(n,0,d):n.subarray(0,d)},p$=new Lr(0),Vs=function(e,t){return e[t]|e[t+1]<<8},vs=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Dm=function(e,t){return vs(e,t)+vs(e,t+4)*4294967296};function h$(e,t){return f$(e,{i:2},t&&t.out,t&&t.dictionary)}var Py=typeof TextDecoder<"u"&&new TextDecoder,m$=0;try{Py.decode(p$,{stream:!0}),m$=1}catch{}var g$=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:Sw(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 y$(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(Py)return Py.decode(e);var s=g$(e),i=s.s,n=s.r;return n.length&&Gr(8),i}}var x$=function(e,t){return t+30+Vs(e,t+26)+Vs(e,t+28)},w$=function(e,t,n){var r=Vs(e,t+28),s=y$(e.subarray(t+46,t+46+r),!(Vs(e,t+8)&2048)),i=t+46+r,a=vs(e,t+20),l=n&&a==4294967295?b$(e,i):[a,vs(e,t+24),vs(e,t+42)],c=l[0],u=l[1],p=l[2];return[Vs(e,t+10),c,u,s,i+Vs(e,t+30)+Vs(e,t+32),p]},b$=function(e,t){for(;Vs(e,t)!=1;t+=4+Vs(e,t+2));return[Dm(e,t+12),Dm(e,t+4),Dm(e,t+20)]};function k$(e,t){for(var n={},r=e.length-22;vs(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Gr(13);var s=Vs(e,r+8);if(!s)return{};var i=vs(e,r+16),a=i==4294967295||s==65535;if(a){var l=vs(e,r-12);a=vs(e,l)==101075792,a&&(s=vs(e,l+32),i=vs(e,l+48))}for(var c=0;c<s;++c){var u=w$(e,i,a),p=u[0],f=u[1],d=u[2],h=u[3],g=u[4],b=u[5],v=x$(e,b);i=g,p?p==8?n[h]=h$(e.subarray(v,v+f),{out:new Lr(d)}):Gr(14,"unknown compression type "+p):n[h]=Sw(e,v,v+f)}return n}const v$=8*1024*1024,S$=500;function N$(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 j$(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function C$(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 _$=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function E$(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=k$(t),r=new Map;let s=0,i=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const p=N$(c);if(!p||j$(p))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>v$||(i+=1,i>S$))return null;r.set(p,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=C$(c);u!==null&&a.add(u)}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 _$.test(l)?l:null}catch{return null}}const Fm=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function A$({file:e,onClose:t,onImported:n}){const{t:r}=pr(),s=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,p]=m.useState("user"),[f,d]=m.useState(!1),[h,g]=m.useState(""),[b,v]=m.useState(null),y=b??e;m.useEffect(()=>{const C=requestAnimationFrame(()=>{var j;return(j=i.current)==null?void 0:j.focus()});return()=>cancelAnimationFrame(C)},[]),m.useEffect(()=>{let C=!1;return(async()=>{const j=y.name||"",E=j.toLowerCase();let P="";if(E.endsWith(".zip")){if(P=await E$(y)||"",!P){const F=j.replace(/\.zip$/i,"");Fm.test(F)&&(P=F)}}else if(E.endsWith(".yaml")||E.endsWith(".yml")){const F=j.replace(/\.ya?ml$/i,"");Fm.test(F)&&(P=F)}C||c(P)})(),()=>{C=!0}},[y]);const w=l.trim(),x=w.length>0&&Fm.test(w);async function S(C){if(C.preventDefault(),!(!x||f)){d(!0),g("");try{const j=new FormData;j.set("flowId",w),j.set("targetSpace",u),j.set("file",y,y.name);const E=await fetch("/api/flows/import",{method:"POST",body:j}),P=await E.json().catch(()=>({}));if(!E.ok){g(typeof P.error=="string"?P.error:r("project:importModal.importFailed"));return}n({id:P.flowId,source:P.flowSource??"user"})}catch(j){g(String((j==null?void 0:j.message)||j))}finally{d(!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 E;const j=(E=C.target.files)==null?void 0:E[0];j&&v(j),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":w.length>0&&!x}),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:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const P$=/^[a-zA-Z][a-zA-Z0-9_-]*$/,b0="af:newPipelineGuide";function I$({open:e,onClose:t,onCreated:n}){const{t:r}=pr(),s=m.useId(),i=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("user"),[d,h]=m.useState(!1),[g,b]=m.useState(""),[v,y]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),b(""),h(!1),localStorage.getItem(b0)==="true"&&y(!0);const E=requestAnimationFrame(()=>{var P;return(P=i.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(E)},[e]);const w=()=>{localStorage.removeItem(b0),y(!1)};if(!e)return null;const x=a.trim(),S=x.length>0&&P$.test(x);async function C(j){if(j.preventDefault(),!(!S||d)){h(!0),b(""),w();try{const E=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:p})}),P=await E.json().catch(()=>({}));if(!E.ok){b(typeof P.error=="string"?P.error:r("project:newPipelineModal.createFailed"));return}n({id:P.flowId,source:P.flowSource??"user"})}catch(E){b(String((E==null?void 0:E.message)||E))}finally{h(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.currentTarget&&(w(),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:j=>j.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:()=>{w(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),v?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:w,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:j=>l(j.target.value),"aria-invalid":x.length>0&&!S}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(v?"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(v?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:j=>u(j.target.value)}),v?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:()=>{w(),t()},disabled:d,children:r("project:newPipelineModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!S||d,children:r(d?"project:newPipelineModal.creating":v?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const C_="agentflow.pipelineViewPreference";function __(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function E_(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(C_)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function T$(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(C_,JSON.stringify(e))}catch{}}function Nw(e){return e==="display"?"display":"workspace"}function R$(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function A_(e,t){const n=Nw(t);return n==="pipeline"&&R$(e==null?void 0:e.source)?"workspace":n}function M$(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function $$(e,t,n,r=!1){if(!e)return;const s=E_();s[__(e,t,r)]={view:Nw(n),at:Date.now()},T$(s)}function L$(e,t="workspace"){if(!(e!=null&&e.id))return Nw(t);const r=E_()[__(e.id,e.source??"user",!!e.archived)],s=A_(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!M$(e)?"workspace":s}function O$(e,t="workspace"){const n=A_(e,t);if(!(e!=null&&e.id))return n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function tf(e,t="workspace"){return O$(e,L$(e,t))}function D$(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 Iy(e){return String((e==null?void 0:e.version)||"").trim()}function F$(e){const t=Iy(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 z$({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,i]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("keyword"),[d,h]=m.useState([]),[g,b]=m.useState({}),[v,y]=m.useState(""),[w,x]=m.useState(""),[S,C]=m.useState(""),j=m.useCallback(async()=>{x("");try{const[D,R]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),T=await D.json().catch(()=>({}));D.ok&&r({available:!!T.available,version:typeof T.version=="string"?T.version:"",loggedIn:!!T.loggedIn,user:typeof T.user=="string"?T.user:"",error:typeof T.error=="string"?T.error:""});const L=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+R.status);i(Array.isArray(L.skills)?L.skills:[]),l(typeof L.skillsRoot=="string"?L.skillsRoot:""),b({})}catch(D){x(String(D.message||D))}},[]);m.useEffect(()=>{j()},[j]);const E=m.useCallback(async()=>{const D=c.trim();if(D){y("search"),x(""),C("");try{const R=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(p)}`),T=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+R.status);h(Array.isArray(T.items)?T.items:[])}catch(R){x(String(R.message||R))}finally{y("")}}},[c,p]),P=m.useCallback(async(D,R=!1)=>{if(!t)return;const T=D&&typeof D=="object"?D:null,L=String(T?T.slug||T.name||T.collection||T.skillId||T.id:D||"").trim();if(L){y(`install:${L}`),x(""),C("");try{const $=T?{slug:T.slug||"",skillId:T.skillId||"",collection:T.collection||"",collectionName:T.collection&&T.name||"",target:"agentflow",agent:"codex",force:R}:{slug:L,target:"agentflow",agent:"codex",force:R},O=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),A=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof A.error=="string"?A.error:"HTTP "+O.status);C(R?`已更新 ${L}`:`已安装 ${L}`),await j(),typeof e=="function"&&await e()}catch($){x(String($.message||$))}finally{y("")}}},[t,j,e]),F=m.useCallback(async()=>{if(t&&s.length!==0){y("check-updates"),x(""),C("");try{const D=await Promise.all(s.map(async L=>{const $=String(L.name||"").trim();if(!$)return null;try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent($)}&mode=keyword`),A=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof A.error=="string"?A.error:"HTTP "+O.status);const M=Array.isArray(A.items)?A.items:[],_=M.find(Q=>Q.slug===$||Q.name===$||Q.id===$)||M[0],U=Iy(L),q=String((_==null?void 0:_.version)||"").trim();let B="unknown";return _?U&&q?B=D$(U,q)<0?"update":"current":q&&(B="remote-only"):B="missing",[$,{state:B,latestVersion:q,installedVersion:U,summary:(_==null?void 0:_.summary)||""}]}catch(O){return[$,{state:"error",error:String(O.message||O),installedVersion:Iy(L)}]}})),R={};for(const L of D)L&&(R[L[0]]=L[1]);b(R);const T=Object.values(R).filter(L=>L.state==="update").length;C(T>0?`发现 ${T} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{y("")}}},[t,s]),V=m.useCallback(async D=>{if(!t)return;const R=String(D||"").trim();if(R){y(`uninstall:${R}`),x(""),C("");try{const T=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:R,target:"agentflow",agent:"codex"})}),L=await T.json().catch(()=>({}));if(!T.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+T.status);C(`已卸载 ${R}`),await j(),typeof e=="function"&&await e()}catch(T){x(String(T.message||T))}finally{y("")}}},[t,j,e]),z=m.useCallback(async()=>{if(t){y("update-cli"),x(""),C("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),R=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+D.status);C("SkillHub CLI 已更新"),await j()}catch(D){x(String(D.message||D))}finally{y("")}}},[t,j]);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:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",o.jsx("code",{children:a})]}):null]}),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:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:j,disabled:!!v,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:F,disabled:!t||!!v||s.length===0,children:v==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!v,children:v==="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:p,onChange:D=>{f(D.target.value),h([])},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:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&E()},placeholder:p==="collectionId"?"输入 collection id,例如 1":p==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>E(),disabled:!c.trim()||v==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),v==="search"?"搜索中…":"搜索"]})]}),w?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:w}):null,S?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:S}):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:s.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(D=>{const R=g[D.name],T=!R||R.state==="update"||R.state==="remote-only"||R.state==="unknown"||R.state==="error",L=v===`install:${D.name}`?"更新中…":(R==null?void 0:R.state)==="current"?"已最新":(R==null?void 0:R.state)==="update"&&R.latestVersion?`更新到 v${R.latestVersion}`:(R==null?void 0:R.state)==="remote-only"&&R.latestVersion?`安装 v${R.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:F$(D)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:R?R.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",R.installedVersion?`v${R.installedVersion} -> `:"","v",R.latestVersion]}):R.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",R.latestVersion||R.installedVersion]}):R.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",R.latestVersion,",本地版本未知"]}):R.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):R.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:()=>P(D.name,!0),disabled:!t||!!v||!T,children:L}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>V(D.name),disabled:!t||!!v,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.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(D=>{const R=D.slug||D.name,T=D.kind==="collection"||D.collection,L=!T&&s.some($=>$.name===R||$.name===D.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:D.name||R}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[T?`collection:${D.collection}`:R,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),o.jsx("button",{type:"button",className:L?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>P(D,L),disabled:!t||!!v,children:L?"更新":T?"安装合集":"安装"})]},D.id||R)})})]})]})]})}function qo(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 H$(e){return{version:1,collections:qo({collections:e})}}function B$(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function P_(e){const t=new Map,n=new Map;for(const r of Array.isArray(e)?e:[])r!=null&&r.key&&t.set(r.key,r.key),r!=null&&r.name&&(r!=null&&r.key)&&!n.has(r.name)&&n.set(r.name,r.key);return r=>{const s=String(r||"").trim();return s&&(t.get(s)||n.get(B$(s)))||""}}function ra(e,t){const n=P_(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function W$(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 V$(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function K$(e,t,n){const r=ra(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 U$(e,t,n){const r=String(e).trim().toLowerCase(),s=qo({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return ra(s,t)}function q$(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),i=String(t).trim().toLowerCase(),a=qo({collections:r}),l=U$(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const p=JSON.parse(u);if(Array.isArray(p)){const f=P_(n),d=Array.from(new Set(p.map(f).filter(Boolean)));if(s.length>0&&d.length===s.length)return c;const h=new Set(d),g=new Set(l),b=l.length>0&&l.every(y=>h.has(y)),v=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const w=ra(y,n);return w.length>0&&w.every(x=>h.has(x))});return l.length>0&&v&&!b?c:d}}}catch{}return c}function bc(e){return e==="builtin"?"af-proj-badge af-proj-badge--builtin":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 Y$(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function G$(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 Ty(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function I_(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 J$="project:defaultCardDesc";function T_(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(J$)}function X$(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vn({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(`(${X$(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 Q$(e,t,n){const r=[String(e.id),T_(e,n),I_(e),Ty(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function Z$(e,t,n){return t?Q$(e,t,n).includes(t):!0}function eL(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 zm(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function k0(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 v0(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const tL=["all","agent","control","provide","marketplace"],nL=["all","agent","control","provide"],R_="agentflow.projects.activityPanelOpen",Ry="agentflow.projects.activitySelected";function rL(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(R_);return e!=="0"}function S0(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function sL(){return typeof localStorage>"u"?"":localStorage.getItem(Ry)||""}function nf(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function un(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 iL(e,t){if((e==null?void 0:e.source)!=="marketplace")return!1;const n=String((e==null?void 0:e.ownerUserId)||(e==null?void 0:e.createdBy)||"").trim();return n?new Set([String((t==null?void 0:t.userId)||"").trim(),String((t==null?void 0:t.username)||"").trim()].filter(Boolean)).has(n):!0}function Wi(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function M_(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 $_(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 My(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 N0(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||My(e,t))}function oL(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function j0(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 aL(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 Hm(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function lL(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 cL(e,t){const n=e.map(p=>p.id),r=new Set(n),s=new Map(n.map(p=>[p,0])),i=new Map(n.map(p=>[p,[]]));t.forEach(p=>{var f;!r.has(p.sourceId)||!r.has(p.targetId)||(s.set(p.targetId,(s.get(p.targetId)||0)+1),(f=i.get(p.sourceId))==null||f.push(p.targetId))});const a=new Map,l=n.filter(p=>(s.get(p)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(p=>a.set(p,0));for(let p=0;p<l.length;p+=1){const f=l[p],d=(a.get(f)||0)+1;for(const h of i.get(f)||[])(!a.has(h)||d>a.get(h))&&(a.set(h,d),l.push(h))}n.forEach((p,f)=>{a.has(p)||a.set(p,f%3)});const c=new Map,u=new Map;return n.forEach(p=>{const f=a.get(p)||0,d=c.get(f)||0;c.set(f,d+1),u.set(p,{x:f*190,y:d*86})}),u}function uL(e){var b,v,y,w;const t=M_(e),n=$_(e),r=new Map(t.map((x,S)=>[My(x,S),N0(x,S)])),s=t.map((x,S)=>({id:My(x,S),title:N0(x,S),meta:oL(x)})),i=n.map((x,S)=>{const C=j0(x,"source"),j=j0(x,"target");return{key:(x==null?void 0:x.id)||`${C}-${j}-${S}`,sourceId:C,targetId:j,source:r.get(C)||C||"?",target:r.get(j)||j||"?",label:aL(x)}}),a=(v=(b=e==null?void 0:e.snippet)==null?void 0:b.ui)!=null&&v.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(w=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&w.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=cL(s,i),u=s.map(x=>{const S=lL(a[x.id])||c.get(x.id)||{x:0,y:0},C=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},j=Number(C.width),E=Number(C.height),P=Math.max(132,Math.min(210,Number.isFinite(j)?j*.62:150)),F=Math.max(48,Math.min(76,Number.isFinite(E)?E*.46:54));return{...x,x:S.x,y:S.y,width:P,height:F}}),p=new Map(u.map(x=>[x.id,x])),f=i.map(x=>{const S=p.get(x.sourceId),C=p.get(x.targetId);if(!S||!C)return null;const j=S.x+S.width,E=S.y+S.height/2,P=C.x,F=C.y+C.height/2,V=Math.max(48,Math.abs(P-j)*.45);return{...x,path:`M ${j} ${E} C ${j+V} ${E}, ${P-V} ${F}, ${P} ${F}`,labelX:(j+P)/2,labelY:(E+F)/2}}).filter(Boolean),d=u.reduce((x,S)=>({minX:Math.min(x.minX,S.x),minY:Math.min(x.minY,S.y),maxX:Math.max(x.maxX,S.x+S.width),maxY:Math.max(x.maxY,S.y+S.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,g=`${d.minX-h} ${d.minY-h} ${Math.max(360,d.maxX-d.minX+h*2)} ${Math.max(180,d.maxY-d.minY+h*2)}`;return{nodes:s,edges:i,diagram:{nodes:u,edges:f,viewBox:g}}}function La({resourceKind:e="",authUser:t=null}){var Ti,xa,wa,as,ls,Ri;const{t:n}=pr(),{navigate:r,path:s}=ti(),i=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[p,f]=m.useState([]),[d,h]=m.useState([]),[g,b]=m.useState([]),[v,y]=m.useState([]),[w,x]=m.useState(""),[S,C]=m.useState(!1),[j,E]=m.useState([]),[P,F]=m.useState(""),[V,z]=m.useState(""),[D,R]=m.useState(!1),[T,L]=m.useState(!1),[$,O]=m.useState(!1),[A,M]=m.useState(null),[_,U]=m.useState(!1),[q,B]=m.useState(""),[Q,se]=m.useState(rL),[oe,ve]=m.useState(sL),[re,ue]=m.useState("all"),[te,ae]=m.useState(""),[pe,be]=m.useState("overview"),[Fe,Ue]=m.useState({}),[Me,et]=m.useState(""),[ht,Ie]=m.useState({}),[tt,Wt]=m.useState(""),[$e,Vt]=m.useState(""),[Gt,nt]=m.useState({}),[ie,ke]=m.useState(""),[Oe,We]=m.useState(""),[Je,vt]=m.useState(""),[ee,ye]=m.useState(""),[Ve,Ce]=m.useState(""),[at,mt]=m.useState(!1),[Qt,hr]=m.useState(""),[Ln,On]=m.useState({hiddenBuiltins:[],promoted:[]}),Nn=m.useRef(0),Zt=m.useRef(0),Kn=m.useRef(0),pn=m.useCallback(async()=>{var de,Te;const W=++Zt.current;F("");try{const _e=await fetch("/api/flows");if(W!==Zt.current)return;if(!_e.ok)throw new Error("HTTP "+_e.status);const Qe=await _e.json();if(W!==Zt.current)return;u(Array.isArray(Qe)?Qe:[])}catch(_e){if(W!==Zt.current)return;u([]),F(String(_e.message||_e))}try{const _e=await fetch("/api/pipeline-recent-runs");if(W!==Zt.current)return;if(_e.ok){const Qe=await _e.json();if(W!==Zt.current)return;E(Array.isArray(Qe.runs)?Qe.runs:[])}else E([])}catch{if(W!==Zt.current)return;E([])}if(t!=null&&t.isAdmin)try{const _e=await fetch("/api/admin/builtin-flows");if(W!==Zt.current)return;const Qe=await _e.json().catch(()=>({}));_e.ok&&On({hiddenBuiltins:Array.isArray((de=Qe==null?void 0:Qe.config)==null?void 0:de.hiddenBuiltins)?Qe.config.hiddenBuiltins:[],promoted:Array.isArray((Te=Qe==null?void 0:Qe.config)==null?void 0:Te.promoted)?Qe.config.promoted:[]})}catch{if(W!==Zt.current)return;On({hiddenBuiltins:[],promoted:[]})}else On({hiddenBuiltins:[],promoted:[]});R(!0)},[t==null?void 0:t.isAdmin]),Pn=m.useCallback(async(W,de)=>{if(!(t!=null&&t.isAdmin)||!(W!=null&&W.id))return;const Te=`${de}:${W.source}:${W.id}`;hr(Te),F("");try{const _e=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:de,flowId:W.id,ownerUserId:W.ownerUserId||t.userId})}),Qe=await _e.json().catch(()=>({}));if(!_e.ok)throw new Error(Qe.error||"更新内置配置失败");await pn()}catch(_e){F(String(_e.message||_e))}finally{hr("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,pn]),jn=m.useCallback(async()=>{const W=++Kn.current;z(""),L(!1);const de="/api/nodes",Te=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),b([]),ae("");try{const[_e,Qe,Jt,_t]=await Promise.all([fetch(de),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(Te)]),Tn=await _e.json().catch(()=>({})),cs=await Qe.json().catch(()=>({})),Co=await Jt.json().catch(()=>({})),Mi=await _t.json().catch(()=>({}));if(!_e.ok)throw new Error(Tn.error||"Nodes HTTP "+_e.status);if(!Qe.ok)throw new Error(cs.error||"Skills HTTP "+Qe.status);if(!Jt.ok)throw new Error(Co.error||"Collections HTTP "+Jt.status);if(!_t.ok)throw new Error(Mi.error||"Flow snippets HTTP "+_t.status);if(W!==Kn.current)return;f(Array.isArray(Tn.nodes)?Tn.nodes:Array.isArray(Tn)?Tn:[]),h(Array.isArray(cs.skills)?cs.skills:[]),y(qo(Co)),b(Array.isArray(Mi.snippets)?Mi.snippets:[])}catch(_e){if(W!==Kn.current)return;f([]),h([]),b([]),y([]),z(String(_e.message||_e))}finally{if(W!==Kn.current)return;L(!0)}},[e]);m.useEffect(()=>{R(!1),pn(),jn()},[pn,jn]),m.useEffect(()=>{try{localStorage.setItem(R_,Q?"1":"0")}catch{}},[Q]),m.useEffect(()=>{try{oe?localStorage.setItem(Ry,oe):localStorage.removeItem(Ry)}catch{}},[oe]),m.useEffect(()=>{let W=!1;return fetch("/api/ui-context").then(de=>de.json()).then(de=>{W||mt(!!de.hideCommunityLinks)}).catch(()=>{}),()=>{W=!0}},[]);const Dn=m.useCallback(async W=>{if(!i)return;const de=qo({collections:W});C(!0),z("");try{const Te=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H$(de))}),_e=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(_e.error||"Collections HTTP "+Te.status);y(qo(_e))}catch(Te){z(String(Te.message||Te))}finally{C(!1)}},[i]),Er=m.useCallback(()=>{if(!i)return;const W=w.trim();if(!W)return;const de=W.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Te=new Set(v.map(_t=>_t.id));let _e=de,Qe=2;for(;Te.has(_e);)_e=`${de}-${Qe++}`;const Jt=Date.now();Dn([...v,{id:_e,name:W,skillKeys:[],createdAt:Jt,updatedAt:Jt}]),x(""),ue(`collection:${_e}`)},[i,w,Dn,v]),Fn=m.useCallback(W=>{if(!i)return;const de=v.find(_e=>_e.id===W);if(de!=null&&de.builtin)return;const Te=v.filter(_e=>_e.id!==W);re===`collection:${W}`&&ue("all"),Dn(Te)},[i,re,Dn,v]),si=m.useCallback((W,de,Te)=>{if(!i)return;const _e=String(de||"").trim();if(!_e)return;const Qe=Date.now(),Jt=v.map(_t=>{if(_t.id!==W)return _t;const Tn=new Set(_t.skillKeys||[]);return Te?Tn.add(_e):Tn.delete(_e),{..._t,skillKeys:Array.from(Tn),updatedAt:Qe}});Dn(Jt)},[i,Dn,v]),mr=m.useCallback(async W=>{const de=W==null?void 0:W.packageId,Te=W==null?void 0:W.version;if(!de||!Te||!window.confirm(n("project:deleteMyNodeConfirm",{id:de,version:Te})))return;const _e=un(W);We(_e),vt(""),z("");try{const Qe=new URLSearchParams({id:de,version:Te}),Jt=await fetch(`/api/marketplace/node?${Qe.toString()}`,{method:"DELETE"}),_t=await Jt.json().catch(()=>({}));if(!Jt.ok||(_t==null?void 0:_t.ok)===!1){const Tn=Array.isArray(_t==null?void 0:_t.usage)&&_t.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:_t.usage.length})}`:"";throw new Error(((_t==null?void 0:_t.error)||"Delete failed")+Tn)}vt(n("project:deleteMyNodeSuccess",{id:de,version:Te})),Ie(Tn=>{const cs={...Tn};return delete cs[_e],cs}),nt(Tn=>{const cs={};for(const[Co,Mi]of Object.entries(Tn))Co.startsWith(`${_e}:`)||(cs[Co]=Mi);return cs}),ae(""),await jn()}catch(Qe){vt(String(Qe.message||Qe))}finally{We("")}},[jn,n]),Ur=m.useCallback(async W=>{const de=W==null?void 0:W.id,Te=(W==null?void 0:W.version)||"1.0.0";if(!de||!Te||!window.confirm(n("project:deleteMyFlowConfirm",{id:de,version:Te})))return;const _e=Wi(W);ye(_e),Ce(""),z("");try{const Qe=new URLSearchParams({id:de,version:Te}),Jt=await fetch(`/api/marketplace/flow-snippet?${Qe.toString()}`,{method:"DELETE"}),_t=await Jt.json().catch(()=>({}));if(!Jt.ok||(_t==null?void 0:_t.ok)===!1)throw new Error((_t==null?void 0:_t.error)||"Delete failed");Ce(n("project:deleteMyFlowSuccess",{id:de,version:Te})),ae(""),await jn()}catch(Qe){Ce(String(Qe.message||Qe))}finally{ye("")}},[jn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ue("all"),ae(""),be("overview");return}l(W=>W==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const W=new URLSearchParams(window.location.search),de=W.get("tab");let Te=!1;if(de==="nodes"){r("/nodes");return}if(de==="my-nodes"){r("/my-nodes");return}if(de==="my-flows"){r("/my-flows");return}if(de==="skills"){r("/skills");return}if(de==="archived"?(l("archived"),W.delete("tab"),Te=!0):de&&(l("all"),W.delete("tab"),Te=!0),W.get("new")==="1"&&(O(!0),W.delete("new"),Te=!0),Te){const _e=W.toString();window.history.replaceState({},"",_e?`/projects?${_e}`:"/projects")}},[s,r]);const Ar=m.useMemo(()=>n$(j,e$(),c),[j,c,s]),ss=m.useMemo(()=>Ar.filter(W=>eL(q,W)),[Ar,q]),In=q.trim().toLowerCase(),gr=m.useMemo(()=>a==="archived"?c.filter(W=>W.archived):c.filter(W=>!W.archived),[c,a]),rr=m.useMemo(()=>gr.filter(W=>Z$(W,In,n)),[gr,In,n]),Ms=m.useMemo(()=>new Set((Ln.promoted||[]).map(W=>String((W==null?void 0:W.id)||"").trim()).filter(Boolean)),[Ln.promoted]),Pr=m.useMemo(()=>(Ln.hiddenBuiltins||[]).map(W=>String(W||"").trim()).filter(Boolean),[Ln.hiddenBuiltins]),zt=a==="nodes"||a==="my-nodes",ne=a==="my-nodes",we=a==="my-flows",Z=m.useMemo(()=>p.filter(W=>ne&&!iL(W,t)?!1:(re==="all"||(re==="marketplace"?W.source==="marketplace":W.type===re))&&zm(q,[W.id,W.label,W.displayName,W.description,W.type,W.source,W.packageId,W.version])),[t,p,ne,q,re]),ge=m.useMemo(()=>{const W=new Map;for(const de of v)W.set(de.id,new Set(de.skillKeys||[]));return W},[v]),Ae=m.useMemo(()=>[{id:"all",label:"全部"},...v.map(W=>({id:`collection:${W.id}`,label:W.name,count:W.skillKeys.length,collection:W})),{id:"ungrouped",label:"未分组"}],[v]),bt=m.useMemo(()=>d.filter(W=>{var _e;const de=un(W);let Te=re==="all";if(re.startsWith("collection:")){const Qe=re.slice(11);Te=!!((_e=ge.get(Qe))!=null&&_e.has(de))}else re==="ungrouped"&&(Te=!Array.from(ge.values()).some(Qe=>Qe.has(de)));return Te&&zm(q,[W.name,W.id,W.description,W.sourceLabel,W.source,W.path])}),[d,q,re,ge]),Ct=m.useMemo(()=>g.filter(W=>zm(q,[W.id,W.name,W.displayName,W.description,W.version,W.packageDir,Array.isArray(W.tags)?W.tags.join(" "):""])),[g,q]),Kt=zt||we||a==="skills",qe=m.useMemo(()=>Z.find(W=>un(W)===te)||Z[0]||null,[Z,te]),Ot=m.useMemo(()=>bt.find(W=>un(W)===te)||bt[0]||null,[bt,te]),Pe=m.useMemo(()=>Ct.find(W=>Wi(W)===te)||Ct[0]||null,[Ct,te]),Ut=Ot?Fe[un(Ot)]:null,Xe=qe?ht[un(qe)]:null,Ir=qe&&$e?Gt[`${un(qe)}:${$e}`]:null,is=n(zt?"project:searchNodes":we?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Ot)return;const W=un(Ot);if(Fe[W])return;let de=!1;return et(W),fetch(`/api/skills/detail?key=${encodeURIComponent(W)}`).then(Te=>Te.json().then(_e=>({ok:Te.ok,json:_e}))).then(({ok:Te,json:_e})=>{de||Te&&_e.skill&&Ue(Qe=>({...Qe,[W]:_e.skill}))}).catch(()=>{}).finally(()=>{de||et("")}),()=>{de=!0}},[a,Ot,Fe]),m.useEffect(()=>{if(!zt||!qe)return;const W=un(qe);if(ht[W])return;let de=!1;return Wt(W),fetch(`/api/nodes/detail?id=${encodeURIComponent(qe.id)}`).then(Te=>Te.json().then(_e=>({ok:Te.ok,json:_e}))).then(({ok:Te,json:_e})=>{de||Te&&Ie(Qe=>({...Qe,[W]:_e}))}).catch(()=>{}).finally(()=>{de||Wt("")}),()=>{de=!0}},[zt,qe,ht]),m.useEffect(()=>{if(!zt)return;const W=Array.isArray(Xe==null?void 0:Xe.files)?Xe.files:[];Vt(de=>{var Te;return de&&W.some(_e=>_e.path===de)?de:((Te=W[0])==null?void 0:Te.path)||""})},[zt,Xe]),m.useEffect(()=>{if(!zt||!qe||!$e)return;const W=`${un(qe)}:${$e}`;if(Gt[W])return;let de=!1;return ke(W),fetch(`/api/nodes/file?id=${encodeURIComponent(qe.id)}&path=${encodeURIComponent($e)}`).then(Te=>Te.json().then(_e=>({ok:Te.ok,json:_e}))).then(({ok:Te,json:_e})=>{de||Te&&nt(Qe=>({...Qe,[W]:_e}))}).catch(()=>{}).finally(()=>{de||ke("")}),()=>{de=!0}},[zt,qe,$e,Gt]),m.useEffect(()=>{vt("")},[te,a]);const os=W=>{r(tf(W,"workspace"))},jo=W=>{ve(S0(W)),r(tf({id:W.flowId,source:W.flowSource,archived:!!W.archived},"workspace"))},ya=m.useCallback(W=>{var de,Te;W.preventDefault(),W.stopPropagation(),(Te=(de=W.dataTransfer)==null?void 0:de.types)!=null&&Te.includes("Files")&&(Nn.current+=1,U(!0))},[]),Jl=m.useCallback(W=>{W.preventDefault(),W.stopPropagation(),Nn.current-=1,Nn.current<=0&&(Nn.current=0,U(!1))},[]),Se=m.useCallback(W=>{W.preventDefault(),W.stopPropagation()},[]),Xl=m.useCallback(W=>{var _e,Qe;W.preventDefault(),W.stopPropagation(),Nn.current=0,U(!1);const de=(Qe=(_e=W.dataTransfer)==null?void 0:_e.files)==null?void 0:Qe[0];if(!de)return;const Te=de.name.toLowerCase();!Te.endsWith(".yaml")&&!Te.endsWith(".yml")&&!Te.endsWith(".zip")||M(de)},[]);return o.jsxs("div",{className:"af-projects"+(_?" af-projects--drop-target":""),onDragEnter:ya,onDragLeave:Jl,onDragOver:Se,onDrop:Xl,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:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("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"+(q.trim()?" af-search--has-clear":""),type:"search",placeholder:is,"aria-label":is,autoComplete:"off",value:q,onChange:W=>B(W.target.value),onKeyDown:W=>{W.key==="Escape"&&(B(""),W.currentTarget.blur())}}),q.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>B(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Kt?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>jn(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(Q?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":Q,"aria-controls":"af-recent-activity-panel",onClick:()=>se(W=>!W),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>O(!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(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:In?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?Z.length:a==="my-flows"?Ct.length:a==="skills"?bt.length:rr.length}):a==="my-nodes"?n("project:myNodesHint",{count:Z.length}):a==="my-flows"?n("project:myFlowsHint",{count:Ct.length}):a==="nodes"?n("project:nodesHint",{count:p.length}):a==="skills"?n("project:skillsHint",{count:d.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),P?o.jsx("p",{className:"af-err af-projects-api-hint",children:P}):null,V&&Kt?o.jsx("p",{className:"af-err af-projects-api-hint",children:V}):null]}),Kt?o.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?o.jsx(z$,{onChanged:jn,canManage:!!(t!=null&&t.isAdmin)}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:we?"schema":zt?ne?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(we?"project:myFlowsPurposeTitle":ne?"project:myNodesPurposeTitle":zt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(we?"project:myFlowsPurposeDesc":ne?"project:myNodesPurposeDesc":zt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),we?null:o.jsxs(o.Fragment,{children:[zt?o.jsxs("div",{className:"af-resource-filter-row",children:[o.jsx("button",{type:"button",className:"af-resource-filter"+(ne?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ue("all"),ae("")},children:n("project:nodeScopeAll")}),o.jsx("button",{type:"button",className:"af-resource-filter"+(ne?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ue("all"),ae("")},children:n("project:nodeScopeMine")})]}):null,o.jsx("div",{className:"af-resource-filter-row",children:(zt?(ne?nL:tL).map(W=>({id:W,label:n(`project:resourceFilter.${W}`)})):Ae).map(W=>W.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(re===W.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ue(W.id),ae("")},children:[W.label,o.jsx("em",{children:W.count}),W.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),i&&!W.collection.builtin?o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:S,"aria-label":`删除 ${W.collection.name}`,onClick:()=>Fn(W.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},W.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(re===W.id?" af-resource-filter--active":""),onClick:()=>{ue(W.id),ae("")},children:W.label},W.id))})]}),a==="skills"&&i?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:w,onChange:W=>x(W.target.value),onKeyDown:W=>{W.key==="Enter"&&Er()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!w.trim()||S,onClick:()=>Er(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,zt?o.jsx("div",{className:"af-resource-grid",children:Z.length>0?Z.map(W=>o.jsxs("button",{type:"button",className:"af-resource-card"+(qe&&un(W)===un(qe)?" af-resource-card--active":""),onClick:()=>ae(un(W)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:bc(W.type==="control"?"secondary":W.type==="provide"?"primary":"muted"),children:o.jsx(vn,{query:q,children:W.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(vn,{query:q,children:k0(W.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(vn,{query:q,children:W.label||W.displayName||W.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(vn,{query:q,children:W.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(vn,{query:q,children:W.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(W.inputs||{}).length,outputs:Object.keys(W.outputs||{}).length})})]}),W.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(vn,{query:q,children:`${W.packageId}${W.version?` / ${W.version}`:""}`})})]}):null]},`${W.id}:${W.source||""}:${W.packageId||""}`)):T?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:In?n("project:noNodeMatch",{query:q.trim()}):n(ne?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):we?o.jsx("div",{className:"af-resource-grid",children:Ct.length>0?Ct.map(W=>{const de=M_(W),Te=$_(W),_e=Number.isFinite(Number(W.nodeCount))?Number(W.nodeCount):de.length,Qe=Number.isFinite(Number(W.edgeCount))?Number(W.edgeCount):Te.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(Pe&&Wi(W)===Wi(Pe)?" af-resource-card--active":""),onClick:()=>ae(Wi(W)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:bc("primary"),children:o.jsx(vn,{query:q,children:W.version?`v${W.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(vn,{query:q,children:W.displayName||W.name||W.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(vn,{query:q,children:W.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:_e,edges:Qe})}),o.jsx("span",{children:o.jsx(vn,{query:q,children:W.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(vn,{query:q,children:v0(W)})})]})]},Wi(W))}):T?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:In?n("project:noFlowSnippetMatch",{query:q.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?o.jsx("div",{className:"af-resource-grid",children:bt.length>0?bt.map(W=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Ot&&un(W)===un(Ot)?" af-resource-card--active":""),onClick:()=>ae(un(W)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:bc(W.source==="builtin"?"muted":"primary"),children:o.jsx(vn,{query:q,children:W.sourceLabel||W.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(vn,{query:q,children:W.name||W.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(vn,{query:q,children:W.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(vn,{query:q,children:W.path||W.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[v.filter(de=>de.skillKeys.includes(un(W))).slice(0,3).map(de=>o.jsx("span",{children:de.name},de.id)),v.filter(de=>de.skillKeys.includes(un(W))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},W.key||`${W.source}:${W.name}`)):T?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:In?n("project:noSkillMatch",{query:q.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&&a==="all"&&Pr.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:Pr.map(W=>{const de=Qt===`show-builtin:builtin:${W}`;return o.jsxs("button",{type:"button",disabled:de,onClick:()=>Pn({id:W,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:W}),o.jsx("em",{children:de?"恢复中":"恢复"})]},W)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[rr.length>0?rr.map(W=>{const de=(t==null?void 0:t.isAdmin)&&W.source==="user"&&!W.archived&&!Ms.has(W.id),Te=(t==null?void 0:t.isAdmin)&&W.source==="admin",_e=(t==null?void 0:t.isAdmin)&&W.source==="builtin",Qe=Qt.endsWith(`:${W.source}:${W.id}`);return o.jsx("div",{className:Y$(W.source),role:"button",tabIndex:0,onClick:()=>os(W),onKeyDown:Jt=>{(Jt.key==="Enter"||Jt.key===" ")&&(Jt.preventDefault(),os(W))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:bc(Ty(W.source,n).tone),children:o.jsx(vn,{query:q,children:Ty(W.source,n).label})}),W.archived?o.jsx("span",{className:bc("muted"),children:o.jsx(vn,{query:q,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(vn,{query:q,children:W.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(vn,{query:q,children:T_(W,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(vn,{query:q,children:I_(W)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Jt=>Jt.stopPropagation(),onKeyDown:Jt=>Jt.stopPropagation(),children:[de?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>Pn(W,"promote"),children:"设为内置"}):null,Te?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>Pn(W,"unpromote"),children:"取消内置"}):null,_e?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>Pn(W,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${W.id}:${W.source??"user"}:${W.archived?"a":""}`)}):D?gr.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n(P?"project:loadFailed":"project:noPipelines")}),!P&&c.length===0&&a==="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:q.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:()=>O(!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")})]}),at?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")})]})]})]})]}),Kt?o.jsx("aside",{className:"af-resource-detail","aria-label":n(zt?"project:nodeDetail":we?"project:flowDetail":"project:skillDetail"),children:zt&&qe?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:qe.label||qe.displayName||qe.id}),o.jsx("p",{children:qe.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(W=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(pe===W?" af-resource-detail-tab--active":""),onClick:()=>be(W),children:n(`project:nodeDetailTabs.${W}`)},W))}),tt===un(qe)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):pe==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:qe.description||((Ti=Xe==null?void 0:Xe.node)==null?void 0:Ti.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:qe.type||((xa=Xe==null?void 0:Xe.node)==null?void 0:xa.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:k0(qe.source,n)})]}),qe.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:qe.packageId})]}):null,qe.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:qe.version})]}):null,qe.packageDir||Xe!=null&&Xe.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:qe.packageDir||(Xe==null?void 0:Xe.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Xe==null?void 0:Xe.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),ne&&qe.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:Oe===un(qe),onClick:()=>mr(qe),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Oe===un(qe)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),Je?o.jsx("p",{className:"af-resource-action-message",children:Je}):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")})]})]}):pe==="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")}),nf(((wa=Xe==null?void 0:Xe.node)==null?void 0:wa.inputs)||qe.inputs).length>0?nf(((as=Xe==null?void 0:Xe.node)==null?void 0:as.inputs)||qe.inputs).map(W=>o.jsxs("code",{children:[W.name||W.key,W.type?`: ${W.type}`:""]},W.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),nf(((ls=Xe==null?void 0:Xe.node)==null?void 0:ls.outputs)||qe.outputs).length>0?nf(((Ri=Xe==null?void 0:Xe.node)==null?void 0:Ri.outputs)||qe.outputs).map(W=>o.jsxs("code",{children:[W.name||W.key,W.type?`: ${W.type}`:""]},W.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):pe==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),Xe!=null&&Xe.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Xe.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Xe!=null&&Xe.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:Xe.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):pe==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Xe==null?void 0:Xe.files)&&Xe.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Xe.files.map(W=>o.jsxs("button",{type:"button",className:"af-node-file-item"+($e===W.path?" af-node-file-item--active":""),onClick:()=>Vt(W.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:W.path})]},W.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[ie===`${un(qe)}:${$e}`?n("project:loadingResources"):Ir!=null&&Ir.binary?n("project:binaryFile"):(Ir==null?void 0:Ir.content)||n("project:selectNodeFile"),Ir!=null&&Ir.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(Xe==null?void 0:Xe.usage)&&Xe.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Xe.usage.map(W=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:W.flowId}),o.jsxs("span",{children:[W.flowSource,W.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:W.instances.map(de=>de.label||de.instanceId).join(", ")})]},`${W.flowSource}:${W.flowId}:${W.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):we&&Pe?(()=>{const W=uL(Pe);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:Pe.displayName||Pe.name||Pe.id}),o.jsx("p",{children:Pe.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Pe.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:Pe.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:v0(Pe)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Pe.nodeCount))?Number(Pe.nodeCount):W.nodes.length,edges:Number.isFinite(Number(Pe.edgeCount))?Number(Pe.edgeCount):W.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:ee===Wi(Pe),onClick:()=>Ur(Pe),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),ee===Wi(Pe)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),Ve?o.jsx("p",{className:"af-resource-action-message",children:Ve}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),W.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:W.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:W.diagram.edges.map(de=>o.jsxs("g",{children:[o.jsx("path",{d:de.path}),de.label?o.jsx("text",{x:de.labelX,y:de.labelY-5,textAnchor:"middle",children:Hm(de.label,18)}):null]},de.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:W.diagram.nodes.map((de,Te)=>o.jsxs("g",{transform:`translate(${de.x} ${de.y})`,children:[o.jsx("rect",{width:de.width,height:de.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:de.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:de.height/2+4,textAnchor:"middle",children:Te+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:de.height/2-3,children:Hm(de.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:de.height/2+16,children:Hm(de.meta||de.id,20)})]},de.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(Pe.snippet||{},null,2)})]})]})]})})():a==="skills"&&Ot?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:Ot.name||Ot.id}),o.jsx("p",{children:Ot.sourceLabel||Ot.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Ot.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:Ot.sourceLabel||Ot.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Ot.path||Ot.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(W=>{const de=un(Ot),Te=W.skillKeys.includes(de);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Te,disabled:S||!i,onChange:_e=>si(W.id,de,_e.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:W.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[W.skillKeys.length," skills"]})]})]},W.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:Me===un(Ot)?n("project:loadingResources"):(Ut==null?void 0:Ut.body)||(Ut==null?void 0:Ut.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"+(Q?"":" af-activity--hidden"),"aria-hidden":!Q,"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:ss.length===0?o.jsx("p",{className:"af-activity-empty",children:Ar.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):ss.map(W=>{const de=oe===S0(W);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(de?" af-activity-row--active":""),"aria-current":de?"page":void 0,onClick:()=>jo(W),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(vn,{query:q,children:W.flowId})}),o.jsx("span",{className:"af-activity-time",children:w0(W.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:G$(W.kind),children:W.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[W.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",w0(W.at,n)]})]})]},`${W.kind}-${W.flowId}-${W.flowSource}-${W.at}`)})})]})]}),o.jsx(I$,{open:$,onClose:()=>O(!1),onCreated:async W=>{O(!1),await pn();const de=W.source??"user";r(tf({id:W.id,source:de},"workspace"))}}),A?o.jsx(A$,{file:A,onClose:()=>M(null),onImported:async W=>{M(null),await pn();const de=W.source??"user";r(tf({id:W.id,source:de},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}function An(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=An(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var dL={value:()=>{}};function mh(){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 Bf(n)}function Bf(e){this._=e}function fL(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}})}Bf.prototype=mh.prototype={constructor:Bf,on:function(e,t){var n=this._,r=fL(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=pL(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]=C0(n[s],e.name,t);else if(t==null)for(s in n)n[s]=C0(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 Bf(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 pL(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function C0(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=dL,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var $y="http://www.w3.org/1999/xhtml";const _0={svg:"http://www.w3.org/2000/svg",xhtml:$y,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gh(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),_0.hasOwnProperty(t)?{space:_0[t],local:e}:e}function hL(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===$y&&t.documentElement.namespaceURI===$y?t.createElement(e):t.createElementNS(n,e)}}function mL(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function L_(e){var t=gh(e);return(t.local?mL:hL)(t)}function gL(){}function jw(e){return e==null?gL:function(){return this.querySelector(e)}}function yL(e){typeof e!="function"&&(e=jw(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,u,p=0;p<a;++p)(c=i[p])&&(u=e.call(c,c.__data__,p,i))&&("__data__"in c&&(u.__data__=c.__data__),l[p]=u);return new Wr(r,this._parents)}function xL(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function wL(){return[]}function O_(e){return e==null?wL:function(){return this.querySelectorAll(e)}}function bL(e){return function(){return xL(e.apply(this,arguments))}}function kL(e){typeof e=="function"?e=bL(e):e=O_(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,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),s.push(c));return new Wr(r,s)}function D_(e){return function(){return this.matches(e)}}function F_(e){return function(t){return t.matches(e)}}var vL=Array.prototype.find;function SL(e){return function(){return vL.call(this.children,e)}}function NL(){return this.firstElementChild}function jL(e){return this.select(e==null?NL:SL(typeof e=="function"?e:F_(e)))}var CL=Array.prototype.filter;function _L(){return Array.from(this.children)}function EL(e){return function(){return CL.call(this.children,e)}}function AL(e){return this.selectAll(e==null?_L:EL(typeof e=="function"?e:F_(e)))}function PL(e){typeof e!="function"&&(e=D_(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,u=0;u<a;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&l.push(c);return new Wr(r,this._parents)}function z_(e){return new Array(e.length)}function IL(){return new Wr(this._enter||this._groups.map(z_),this._parents)}function Sp(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Sp.prototype={constructor:Sp,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 TL(e){return function(){return e}}function RL(e,t,n,r,s,i){for(var a=0,l,c=t.length,u=i.length;a<u;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Sp(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function ML(e,t,n,r,s,i,a){var l,c,u=new Map,p=t.length,f=i.length,d=new Array(p),h;for(l=0;l<p;++l)(c=t[l])&&(d[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,i[l],l,i)+"",(c=u.get(h))?(r[l]=c,c.__data__=i[l],u.delete(h)):n[l]=new Sp(e,i[l]);for(l=0;l<p;++l)(c=t[l])&&u.get(d[l])===c&&(s[l]=c)}function $L(e){return e.__data__}function LL(e,t){if(!arguments.length)return Array.from(this,$L);var n=t?ML:RL,r=this._parents,s=this._groups;typeof e!="function"&&(e=TL(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),u=0;u<i;++u){var p=r[u],f=s[u],d=f.length,h=OL(e.call(p,p&&p.__data__,u,r)),g=h.length,b=l[u]=new Array(g),v=a[u]=new Array(g),y=c[u]=new Array(d);n(p,f,b,v,y,h,t);for(var w=0,x=0,S,C;w<g;++w)if(S=b[w]){for(w>=x&&(x=w+1);!(C=v[x])&&++x<g;);S._next=C||null}}return a=new Wr(a,r),a._enter=l,a._exit=c,a}function OL(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function DL(){return new Wr(this._exit||this._groups.map(z_),this._parents)}function FL(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 zL(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 u=n[c],p=r[c],f=u.length,d=l[c]=new Array(f),h,g=0;g<f;++g)(h=u[g]||p[g])&&(d[g]=h);for(;c<s;++c)l[c]=n[c];return new Wr(l,this._parents)}function HL(){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 BL(e){e||(e=WL);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}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),u,p=0;p<l;++p)(u=a[p])&&(c[p]=u);c.sort(t)}return new Wr(s,this._parents).order()}function WL(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function VL(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function KL(){return Array.from(this)}function UL(){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 qL(){let e=0;for(const t of this)++e;return e}function YL(){return!this.node()}function GL(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 JL(e){return function(){this.removeAttribute(e)}}function XL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function QL(e,t){return function(){this.setAttribute(e,t)}}function ZL(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eO(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tO(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 nO(e,t){var n=gh(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?XL:JL:typeof t=="function"?n.local?tO:eO:n.local?ZL:QL)(n,t))}function H_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rO(e){return function(){this.style.removeProperty(e)}}function sO(e,t,n){return function(){this.style.setProperty(e,t,n)}}function iO(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function oO(e,t,n){return arguments.length>1?this.each((t==null?rO:typeof t=="function"?iO:sO)(e,t,n??"")):_l(this.node(),e)}function _l(e,t){return e.style.getPropertyValue(t)||H_(e).getComputedStyle(e,null).getPropertyValue(t)}function aO(e){return function(){delete this[e]}}function lO(e,t){return function(){this[e]=t}}function cO(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function uO(e,t){return arguments.length>1?this.each((t==null?aO:typeof t=="function"?cO:lO)(e,t)):this.node()[e]}function B_(e){return e.trim().split(/^|\s+/)}function Cw(e){return e.classList||new W_(e)}function W_(e){this._node=e,this._names=B_(e.getAttribute("class")||"")}W_.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 V_(e,t){for(var n=Cw(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function K_(e,t){for(var n=Cw(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function dO(e){return function(){V_(this,e)}}function fO(e){return function(){K_(this,e)}}function pO(e,t){return function(){(t.apply(this,arguments)?V_:K_)(this,e)}}function hO(e,t){var n=B_(e+"");if(arguments.length<2){for(var r=Cw(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?pO:t?dO:fO)(n,t))}function mO(){this.textContent=""}function gO(e){return function(){this.textContent=e}}function yO(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function xO(e){return arguments.length?this.each(e==null?mO:(typeof e=="function"?yO:gO)(e)):this.node().textContent}function wO(){this.innerHTML=""}function bO(e){return function(){this.innerHTML=e}}function kO(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vO(e){return arguments.length?this.each(e==null?wO:(typeof e=="function"?kO:bO)(e)):this.node().innerHTML}function SO(){this.nextSibling&&this.parentNode.appendChild(this)}function NO(){return this.each(SO)}function jO(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function CO(){return this.each(jO)}function _O(e){var t=typeof e=="function"?e:L_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function EO(){return null}function AO(e,t){var n=typeof e=="function"?e:L_(e),r=t==null?EO:typeof t=="function"?t:jw(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function PO(){var e=this.parentNode;e&&e.removeChild(this)}function IO(){return this.each(PO)}function TO(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RO(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function MO(e){return this.select(e?RO:TO)}function $O(e){return arguments.length?this.property("__data__",e):this.node().__data__}function LO(e){return function(t){e.call(this,t,this.__data__)}}function OO(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 DO(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 FO(e,t,n){return function(){var r=this.__on,s,i=LO(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 zO(e,t,n){var r=OO(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,p;c<u;++c)for(s=0,p=l[c];s<i;++s)if((a=r[s]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?FO:DO,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function U_(e,t,n){var r=H_(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 HO(e,t){return function(){return U_(this,e,t)}}function BO(e,t){return function(){return U_(this,e,t.apply(this,arguments))}}function WO(e,t){return this.each((typeof t=="function"?BO:HO)(e,t))}function*VO(){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 q_=[null];function Wr(e,t){this._groups=e,this._parents=t}function Xu(){return new Wr([[document.documentElement]],q_)}function KO(){return this}Wr.prototype=Xu.prototype={constructor:Wr,select:yL,selectAll:kL,selectChild:jL,selectChildren:AL,filter:PL,data:LL,enter:IL,exit:DL,join:FL,merge:zL,selection:KO,order:HL,sort:BL,call:VL,nodes:KL,node:UL,size:qL,empty:YL,each:GL,attr:nO,style:oO,property:uO,classed:hO,text:xO,html:vO,raise:NO,lower:CO,append:_O,insert:AO,remove:IO,clone:MO,datum:$O,on:zO,dispatch:WO,[Symbol.iterator]:VO};function Or(e){return typeof e=="string"?new Wr([[document.querySelector(e)]],[document.documentElement]):new Wr([[e]],q_)}function UO(e){let t;for(;t=e.sourceEvent;)e=t;return e}function bs(e,t){if(e=UO(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 qO={passive:!1},Nu={capture:!0,passive:!1};function Bm(e){e.stopImmediatePropagation()}function hl(e){e.preventDefault(),e.stopImmediatePropagation()}function Y_(e){var t=e.document.documentElement,n=Or(e).on("dragstart.drag",hl,Nu);"onselectstart"in t?n.on("selectstart.drag",hl,Nu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function G_(e,t){var n=e.document.documentElement,r=Or(e).on("dragstart.drag",null);t&&(r.on("click.drag",hl,Nu),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 rf=e=>()=>e;function Ly(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:u,dispatch:p}){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:u,enumerable:!0,configurable:!0},_:{value:p}})}Ly.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function YO(e){return!e.ctrlKey&&!e.button}function GO(){return this.parentNode}function JO(e,t){return t??{x:e.x,y:e.y}}function XO(){return navigator.maxTouchPoints||"ontouchstart"in this}function J_(){var e=YO,t=GO,n=JO,r=XO,s={},i=mh("start","drag","end"),a=0,l,c,u,p,f=0;function d(S){S.on("mousedown.drag",h).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,qO).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(S,C){if(!(p||!e.call(this,S,C))){var j=x(this,t.call(this,S,C),S,C,"mouse");j&&(Or(S.view).on("mousemove.drag",g,Nu).on("mouseup.drag",b,Nu),Y_(S.view),Bm(S),u=!1,l=S.clientX,c=S.clientY,j("start",S))}}function g(S){if(hl(S),!u){var C=S.clientX-l,j=S.clientY-c;u=C*C+j*j>f}s.mouse("drag",S)}function b(S){Or(S.view).on("mousemove.drag mouseup.drag",null),G_(S.view,u),hl(S),s.mouse("end",S)}function v(S,C){if(e.call(this,S,C)){var j=S.changedTouches,E=t.call(this,S,C),P=j.length,F,V;for(F=0;F<P;++F)(V=x(this,E,S,C,j[F].identifier,j[F]))&&(Bm(S),V("start",S,j[F]))}}function y(S){var C=S.changedTouches,j=C.length,E,P;for(E=0;E<j;++E)(P=s[C[E].identifier])&&(hl(S),P("drag",S,C[E]))}function w(S){var C=S.changedTouches,j=C.length,E,P;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),E=0;E<j;++E)(P=s[C[E].identifier])&&(Bm(S),P("end",S,C[E]))}function x(S,C,j,E,P,F){var V=i.copy(),z=bs(F||j,C),D,R,T;if((T=n.call(S,new Ly("beforestart",{sourceEvent:j,target:d,identifier:P,active:a,x:z[0],y:z[1],dx:0,dy:0,dispatch:V}),E))!=null)return D=T.x-z[0]||0,R=T.y-z[1]||0,function L($,O,A){var M=z,_;switch($){case"start":s[P]=L,_=a++;break;case"end":delete s[P],--a;case"drag":z=bs(A||O,C),_=a;break}V.call($,S,new Ly($,{sourceEvent:O,subject:T,target:d,identifier:P,active:_,x:z[0]+D,y:z[1]+R,dx:z[0]-M[0],dy:z[1]-M[1],dispatch:V}),E)}}return d.filter=function(S){return arguments.length?(e=typeof S=="function"?S:rf(!!S),d):e},d.container=function(S){return arguments.length?(t=typeof S=="function"?S:rf(S),d):t},d.subject=function(S){return arguments.length?(n=typeof S=="function"?S:rf(S),d):n},d.touchable=function(S){return arguments.length?(r=typeof S=="function"?S:rf(!!S),d):r},d.on=function(){var S=i.on.apply(i,arguments);return S===i?d:S},d.clickDistance=function(S){return arguments.length?(f=(S=+S)*S,d):Math.sqrt(f)},d}function _w(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function X_(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Qu(){}var ju=.7,Np=1/ju,ml="\\s*([+-]?\\d+)\\s*",Cu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Js="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",QO=/^#([0-9a-f]{3,8})$/,ZO=new RegExp(`^rgb\\(${ml},${ml},${ml}\\)$`),eD=new RegExp(`^rgb\\(${Js},${Js},${Js}\\)$`),tD=new RegExp(`^rgba\\(${ml},${ml},${ml},${Cu}\\)$`),nD=new RegExp(`^rgba\\(${Js},${Js},${Js},${Cu}\\)$`),rD=new RegExp(`^hsl\\(${Cu},${Js},${Js}\\)$`),sD=new RegExp(`^hsla\\(${Cu},${Js},${Js},${Cu}\\)$`),E0={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};_w(Qu,sa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:A0,formatHex:A0,formatHex8:iD,formatHsl:oD,formatRgb:P0,toString:P0});function A0(){return this.rgb().formatHex()}function iD(){return this.rgb().formatHex8()}function oD(){return Q_(this).formatHsl()}function P0(){return this.rgb().formatRgb()}function sa(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=QO.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?I0(t):n===3?new kr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sf(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sf(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=ZO.exec(e))?new kr(t[1],t[2],t[3],1):(t=eD.exec(e))?new kr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=tD.exec(e))?sf(t[1],t[2],t[3],t[4]):(t=nD.exec(e))?sf(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rD.exec(e))?M0(t[1],t[2]/100,t[3]/100,1):(t=sD.exec(e))?M0(t[1],t[2]/100,t[3]/100,t[4]):E0.hasOwnProperty(e)?I0(E0[e]):e==="transparent"?new kr(NaN,NaN,NaN,0):null}function I0(e){return new kr(e>>16&255,e>>8&255,e&255,1)}function sf(e,t,n,r){return r<=0&&(e=t=n=NaN),new kr(e,t,n,r)}function aD(e){return e instanceof Qu||(e=sa(e)),e?(e=e.rgb(),new kr(e.r,e.g,e.b,e.opacity)):new kr}function Oy(e,t,n,r){return arguments.length===1?aD(e):new kr(e,t,n,r??1)}function kr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}_w(kr,Oy,X_(Qu,{brighter(e){return e=e==null?Np:Math.pow(Np,e),new kr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ju:Math.pow(ju,e),new kr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new kr(Yo(this.r),Yo(this.g),Yo(this.b),jp(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:T0,formatHex:T0,formatHex8:lD,formatRgb:R0,toString:R0}));function T0(){return`#${Wo(this.r)}${Wo(this.g)}${Wo(this.b)}`}function lD(){return`#${Wo(this.r)}${Wo(this.g)}${Wo(this.b)}${Wo((isNaN(this.opacity)?1:this.opacity)*255)}`}function R0(){const e=jp(this.opacity);return`${e===1?"rgb(":"rgba("}${Yo(this.r)}, ${Yo(this.g)}, ${Yo(this.b)}${e===1?")":`, ${e})`}`}function jp(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Yo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wo(e){return e=Yo(e),(e<16?"0":"")+e.toString(16)}function M0(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ss(e,t,n,r)}function Q_(e){if(e instanceof Ss)return new Ss(e.h,e.s,e.l,e.opacity);if(e instanceof Qu||(e=sa(e)),!e)return new Ss;if(e instanceof Ss)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 Ss(a,l,c,e.opacity)}function cD(e,t,n,r){return arguments.length===1?Q_(e):new Ss(e,t,n,r??1)}function Ss(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}_w(Ss,cD,X_(Qu,{brighter(e){return e=e==null?Np:Math.pow(Np,e),new Ss(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ju:Math.pow(ju,e),new Ss(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 kr(Wm(e>=240?e-240:e+120,s,r),Wm(e,s,r),Wm(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ss($0(this.h),of(this.s),of(this.l),jp(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=jp(this.opacity);return`${e===1?"hsl(":"hsla("}${$0(this.h)}, ${of(this.s)*100}%, ${of(this.l)*100}%${e===1?")":`, ${e})`}`}}));function $0(e){return e=(e||0)%360,e<0?e+360:e}function of(e){return Math.max(0,Math.min(1,e||0))}function Wm(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 Ew=e=>()=>e;function uD(e,t){return function(n){return e+n*t}}function dD(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 fD(e){return(e=+e)==1?Z_:function(t,n){return n-t?dD(t,n,e):Ew(isNaN(t)?n:t)}}function Z_(e,t){var n=t-e;return n?uD(e,n):Ew(isNaN(e)?t:e)}const Cp=function e(t){var n=fD(t);function r(s,i){var a=n((s=Oy(s)).r,(i=Oy(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),u=Z_(s.opacity,i.opacity);return function(p){return s.r=a(p),s.g=l(p),s.b=c(p),s.opacity=u(p),s+""}}return r.gamma=e,r}(1);function pD(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 hD(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function mD(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]=Xc(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 gD(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Hs(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function yD(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]=Xc(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Dy=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Vm=new RegExp(Dy.source,"g");function xD(e){return function(){return e}}function wD(e){return function(t){return e(t)+""}}function eE(e,t){var n=Dy.lastIndex=Vm.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Dy.exec(e))&&(s=Vm.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:Hs(r,s)})),n=Vm.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?wD(c[0].x):xD(t):(t=c.length,function(u){for(var p=0,f;p<t;++p)l[(f=c[p]).i]=f.x(u);return l.join("")})}function Xc(e,t){var n=typeof t,r;return t==null||n==="boolean"?Ew(t):(n==="number"?Hs:n==="string"?(r=sa(t))?(t=r,Cp):eE:t instanceof sa?Cp:t instanceof Date?gD:hD(t)?pD:Array.isArray(t)?mD:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?yD:Hs)(e,t)}var L0=180/Math.PI,Fy={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function tE(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)*L0,skewX:Math.atan(c)*L0,scaleX:a,scaleY:l}}var af;function bD(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fy:tE(t.a,t.b,t.c,t.d,t.e,t.f)}function kD(e){return e==null||(af||(af=document.createElementNS("http://www.w3.org/2000/svg","g")),af.setAttribute("transform",e),!(e=af.transform.baseVal.consolidate()))?Fy:(e=e.matrix,tE(e.a,e.b,e.c,e.d,e.e,e.f))}function nE(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function i(u,p,f,d,h,g){if(u!==f||p!==d){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:Hs(u,f)},{i:b-2,x:Hs(p,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function a(u,p,f,d){u!==p?(u-p>180?p+=360:p-u>180&&(u+=360),d.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Hs(u,p)})):p&&f.push(s(f)+"rotate("+p+r)}function l(u,p,f,d){u!==p?d.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Hs(u,p)}):p&&f.push(s(f)+"skewX("+p+r)}function c(u,p,f,d,h,g){if(u!==f||p!==d){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:Hs(u,f)},{i:b-2,x:Hs(p,d)})}else(f!==1||d!==1)&&h.push(s(h)+"scale("+f+","+d+")")}return function(u,p){var f=[],d=[];return u=e(u),p=e(p),i(u.translateX,u.translateY,p.translateX,p.translateY,f,d),a(u.rotate,p.rotate,f,d),l(u.skewX,p.skewX,f,d),c(u.scaleX,u.scaleY,p.scaleX,p.scaleY,f,d),u=p=null,function(h){for(var g=-1,b=d.length,v;++g<b;)f[(v=d[g]).i]=v.x(h);return f.join("")}}}var vD=nE(bD,"px, ","px)","deg)"),SD=nE(kD,", ",")",")"),ND=1e-12;function O0(e){return((e=Math.exp(e))+1/e)/2}function jD(e){return((e=Math.exp(e))-1/e)/2}function CD(e){return((e=Math.exp(2*e))-1)/(e+1)}const Wf=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],u=i[2],p=a[0],f=a[1],d=a[2],h=p-l,g=f-c,b=h*h+g*g,v,y;if(b<ND)y=Math.log(d/u)/t,v=function(E){return[l+E*h,c+E*g,u*Math.exp(t*E*y)]};else{var w=Math.sqrt(b),x=(d*d-u*u+r*b)/(2*u*n*w),S=(d*d-u*u-r*b)/(2*d*n*w),C=Math.log(Math.sqrt(x*x+1)-x),j=Math.log(Math.sqrt(S*S+1)-S);y=(j-C)/t,v=function(E){var P=E*y,F=O0(C),V=u/(n*w)*(F*CD(t*P+C)-jD(C));return[l+V*h,c+V*g,u*F/O0(t*P+C)]}}return v.duration=y*1e3*t/Math.SQRT2,v}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 El=0,$c=0,kc=0,rE=1e3,_p,Lc,Ep=0,ia=0,yh=0,_u=typeof performance=="object"&&performance.now?performance:Date,sE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Aw(){return ia||(sE(_D),ia=_u.now()+yh)}function _D(){ia=0}function Ap(){this._call=this._time=this._next=null}Ap.prototype=iE.prototype={constructor:Ap,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Aw():+n)+(t==null?0:+t),!this._next&&Lc!==this&&(Lc?Lc._next=this:_p=this,Lc=this),this._call=e,this._time=n,zy()},stop:function(){this._call&&(this._call=null,this._time=1/0,zy())}};function iE(e,t,n){var r=new Ap;return r.restart(e,t,n),r}function ED(){Aw(),++El;for(var e=_p,t;e;)(t=ia-e._time)>=0&&e._call.call(void 0,t),e=e._next;--El}function D0(){ia=(Ep=_u.now())+yh,El=$c=0;try{ED()}finally{El=0,PD(),ia=0}}function AD(){var e=_u.now(),t=e-Ep;t>rE&&(yh-=t,Ep=e)}function PD(){for(var e,t=_p,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:_p=n);Lc=e,zy(r)}function zy(e){if(!El){$c&&($c=clearTimeout($c));var t=e-ia;t>24?(e<1/0&&($c=setTimeout(D0,e-_u.now()-yh)),kc&&(kc=clearInterval(kc))):(kc||(Ep=_u.now(),kc=setInterval(AD,rE)),El=1,sE(D0))}}function F0(e,t,n){var r=new Ap;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var ID=mh("start","end","cancel","interrupt"),TD=[],oE=0,z0=1,Hy=2,Vf=3,H0=4,By=5,Kf=6;function xh(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;RD(e,n,{name:t,index:r,group:s,on:ID,tween:TD,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:oE})}function Pw(e,t){var n=Ts(e,t);if(n.state>oE)throw new Error("too late; already scheduled");return n}function ni(e,t){var n=Ts(e,t);if(n.state>Vf)throw new Error("too late; already running");return n}function Ts(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function RD(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=iE(i,0,n.time);function i(u){n.state=z0,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var p,f,d,h;if(n.state!==z0)return c();for(p in r)if(h=r[p],h.name===n.name){if(h.state===Vf)return F0(a);h.state===H0?(h.state=Kf,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[p]):+p<t&&(h.state=Kf,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[p])}if(F0(function(){n.state===Vf&&(n.state=H0,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Hy,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Hy){for(n.state=Vf,s=new Array(d=n.tween.length),p=0,f=-1;p<d;++p)(h=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var p=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=By,1),f=-1,d=s.length;++f<d;)s[f].call(e,p);n.state===By&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Kf,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Uf(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>Hy&&r.state<By,r.state=Kf,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function MD(e){return this.each(function(){Uf(this,e)})}function $D(e,t){var n,r;return function(){var s=ni(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 LD(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=ni(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}i.tween=s}}function OD(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ts(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?$D:LD)(n,e,t))}function Iw(e,t,n){var r=e._id;return e.each(function(){var s=ni(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ts(s,r).value[t]}}function aE(e,t){var n;return(typeof t=="number"?Hs:t instanceof sa?Cp:(n=sa(t))?(t=n,Cp):eE)(e,t)}function DD(e){return function(){this.removeAttribute(e)}}function FD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zD(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 HD(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 BD(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 WD(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 VD(e,t){var n=gh(e),r=n==="transform"?SD:aE;return this.attrTween(e,typeof t=="function"?(n.local?WD:BD)(n,r,Iw(this,"attr."+e,t)):t==null?(n.local?FD:DD)(n):(n.local?HD:zD)(n,r,t))}function KD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function UD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qD(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&UD(e,i)),n}return s._value=t,s}function YD(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&KD(e,i)),n}return s._value=t,s}function GD(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=gh(e);return this.tween(n,(r.local?qD:YD)(r,t))}function JD(e,t){return function(){Pw(this,e).delay=+t.apply(this,arguments)}}function XD(e,t){return t=+t,function(){Pw(this,e).delay=t}}function QD(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?JD:XD)(t,e)):Ts(this.node(),t).delay}function ZD(e,t){return function(){ni(this,e).duration=+t.apply(this,arguments)}}function eF(e,t){return t=+t,function(){ni(this,e).duration=t}}function tF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ZD:eF)(t,e)):Ts(this.node(),t).duration}function nF(e,t){if(typeof t!="function")throw new Error;return function(){ni(this,e).ease=t}}function rF(e){var t=this._id;return arguments.length?this.each(nF(t,e)):Ts(this.node(),t).ease}function sF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ni(this,e).ease=n}}function iF(e){if(typeof e!="function")throw new Error;return this.each(sF(this._id,e))}function oF(e){typeof e!="function"&&(e=D_(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,u=0;u<a;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&l.push(c);return new Ci(r,this._parents,this._name,this._id)}function aF(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],u=n[l],p=c.length,f=a[l]=new Array(p),d,h=0;h<p;++h)(d=c[h]||u[h])&&(f[h]=d);for(;l<r;++l)a[l]=t[l];return new Ci(a,this._parents,this._name,this._id)}function lF(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 cF(e,t,n){var r,s,i=lF(t)?Pw:ni;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function uF(e,t){var n=this._id;return arguments.length<2?Ts(this.node(),n).on.on(e):this.each(cF(n,e,t))}function dF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function fF(){return this.on("end.remove",dF(this._id))}function pF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=jw(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,u=i[a]=new Array(c),p,f,d=0;d<c;++d)(p=l[d])&&(f=e.call(p,p.__data__,d,l))&&("__data__"in p&&(f.__data__=p.__data__),u[d]=f,xh(u[d],t,n,d,u,Ts(p,n)));return new Ci(i,this._parents,t,n)}function hF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=O_(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,p,f=0;f<u;++f)if(p=c[f]){for(var d=e.call(p,p.__data__,f,c),h,g=Ts(p,n),b=0,v=d.length;b<v;++b)(h=d[b])&&xh(h,t,n,b,d,g);i.push(d),a.push(p)}return new Ci(i,a,t,n)}var mF=Xu.prototype.constructor;function gF(){return new mF(this._groups,this._parents)}function yF(e,t){var n,r,s;return function(){var i=_l(this,e),a=(this.style.removeProperty(e),_l(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function lE(e){return function(){this.style.removeProperty(e)}}function xF(e,t,n){var r,s=n+"",i;return function(){var a=_l(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function wF(e,t,n){var r,s,i;return function(){var a=_l(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),_l(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function bF(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=ni(this,e),u=c.on,p=c.value[i]==null?l||(l=lE(t)):void 0;(u!==n||s!==p)&&(r=(n=u).copy()).on(a,s=p),c.on=r}}function kF(e,t,n){var r=(e+="")=="transform"?vD:aE;return t==null?this.styleTween(e,yF(e,r)).on("end.style."+e,lE(e)):typeof t=="function"?this.styleTween(e,wF(e,r,Iw(this,"style."+e,t))).each(bF(this._id,e)):this.styleTween(e,xF(e,r,t),n).on("end.style."+e,null)}function vF(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function SF(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&vF(e,a,n)),r}return i._value=t,i}function NF(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,SF(e,t,n??""))}function jF(e){return function(){this.textContent=e}}function CF(e){return function(){var t=e(this);this.textContent=t??""}}function _F(e){return this.tween("text",typeof e=="function"?CF(Iw(this,"text",e)):jF(e==null?"":e+""))}function EF(e){return function(t){this.textContent=e.call(this,t)}}function AF(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&EF(s)),t}return r._value=e,r}function PF(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,AF(e))}function IF(){for(var e=this._name,t=this._id,n=cE(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var p=Ts(c,t);xh(c,e,n,u,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Ci(r,this._parents,e,n)}function TF(){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 u=ni(this,r),p=u.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&i()})}var RF=0;function Ci(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function cE(){return++RF}var ui=Xu.prototype;Ci.prototype={constructor:Ci,select:pF,selectAll:hF,selectChild:ui.selectChild,selectChildren:ui.selectChildren,filter:oF,merge:aF,selection:gF,transition:IF,call:ui.call,nodes:ui.nodes,node:ui.node,size:ui.size,empty:ui.empty,each:ui.each,on:uF,attr:VD,attrTween:GD,style:kF,styleTween:NF,text:_F,textTween:PF,remove:fF,tween:OD,delay:QD,duration:tF,ease:rF,easeVarying:iF,end:TF,[Symbol.iterator]:ui[Symbol.iterator]};function MF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $F={time:null,delay:0,duration:250,ease:MF};function LF(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 OF(e){var t,n;e instanceof Ci?(t=e._id,e=e._name):(t=cE(),(n=$F).time=Aw(),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,u=0;u<l;++u)(c=a[u])&&xh(c,e,t,u,a,n||LF(c,t));return new Ci(r,this._parents,e,t)}Xu.prototype.interrupt=MD;Xu.prototype.transition=OF;const lf=e=>()=>e;function DF(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 yi(e,t,n){this.k=e,this.x=t,this.y=n}yi.prototype={constructor:yi,scale:function(e){return e===1?this:new yi(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new yi(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 wh=new yi(1,0,0);uE.prototype=yi.prototype;function uE(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wh;return e.__zoom}function Km(e){e.stopImmediatePropagation()}function vc(e){e.preventDefault(),e.stopImmediatePropagation()}function FF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function zF(){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 B0(){return this.__zoom||wh}function HF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function BF(){return navigator.maxTouchPoints||"ontouchstart"in this}function WF(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 dE(){var e=FF,t=zF,n=WF,r=HF,s=BF,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Wf,u=mh("start","zoom","end"),p,f,d,h=500,g=150,b=0,v=10;function y(T){T.property("__zoom",B0).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",V).filter(s).on("touchstart.zoom",z).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(T,L,$,O){var A=T.selection?T.selection():T;A.property("__zoom",B0),T!==A?C(T,L,$,O):A.interrupt().each(function(){j(this,arguments).event(O).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},y.scaleBy=function(T,L,$,O){y.scaleTo(T,function(){var A=this.__zoom.k,M=typeof L=="function"?L.apply(this,arguments):L;return A*M},$,O)},y.scaleTo=function(T,L,$,O){y.transform(T,function(){var A=t.apply(this,arguments),M=this.__zoom,_=$==null?S(A):typeof $=="function"?$.apply(this,arguments):$,U=M.invert(_),q=typeof L=="function"?L.apply(this,arguments):L;return n(x(w(M,q),_,U),A,a)},$,O)},y.translateBy=function(T,L,$,O){y.transform(T,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),a)},null,O)},y.translateTo=function(T,L,$,O,A){y.transform(T,function(){var M=t.apply(this,arguments),_=this.__zoom,U=O==null?S(M):typeof O=="function"?O.apply(this,arguments):O;return n(wh.translate(U[0],U[1]).scale(_.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof $=="function"?-$.apply(this,arguments):-$),M,a)},O,A)};function w(T,L){return L=Math.max(i[0],Math.min(i[1],L)),L===T.k?T:new yi(L,T.x,T.y)}function x(T,L,$){var O=L[0]-$[0]*T.k,A=L[1]-$[1]*T.k;return O===T.x&&A===T.y?T:new yi(T.k,O,A)}function S(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function C(T,L,$,O){T.on("start.zoom",function(){j(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(O).end()}).tween("zoom",function(){var A=this,M=arguments,_=j(A,M).event(O),U=t.apply(A,M),q=$==null?S(U):typeof $=="function"?$.apply(A,M):$,B=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),Q=A.__zoom,se=typeof L=="function"?L.apply(A,M):L,oe=c(Q.invert(q).concat(B/Q.k),se.invert(q).concat(B/se.k));return function(ve){if(ve===1)ve=se;else{var re=oe(ve),ue=B/re[2];ve=new yi(ue,q[0]-re[0]*ue,q[1]-re[1]*ue)}_.zoom(null,ve)}})}function j(T,L,$){return!$&&T.__zooming||new E(T,L)}function E(T,L){this.that=T,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,L),this.taps=0}E.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,L){return this.mouse&&T!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var L=Or(this.that).datum();u.call(T,this.that,new DF(T,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),L)}};function P(T,...L){if(!e.apply(this,arguments))return;var $=j(this,L).event(T),O=this.__zoom,A=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,r.apply(this,arguments)))),M=bs(T);if($.wheel)($.mouse[0][0]!==M[0]||$.mouse[0][1]!==M[1])&&($.mouse[1]=O.invert($.mouse[0]=M)),clearTimeout($.wheel);else{if(O.k===A)return;$.mouse=[M,O.invert(M)],Uf(this),$.start()}vc(T),$.wheel=setTimeout(_,g),$.zoom("mouse",n(x(w(O,A),$.mouse[0],$.mouse[1]),$.extent,a));function _(){$.wheel=null,$.end()}}function F(T,...L){if(d||!e.apply(this,arguments))return;var $=T.currentTarget,O=j(this,L,!0).event(T),A=Or(T.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",B,!0),M=bs(T,$),_=T.clientX,U=T.clientY;Y_(T.view),Km(T),O.mouse=[M,this.__zoom.invert(M)],Uf(this),O.start();function q(Q){if(vc(Q),!O.moved){var se=Q.clientX-_,oe=Q.clientY-U;O.moved=se*se+oe*oe>b}O.event(Q).zoom("mouse",n(x(O.that.__zoom,O.mouse[0]=bs(Q,$),O.mouse[1]),O.extent,a))}function B(Q){A.on("mousemove.zoom mouseup.zoom",null),G_(Q.view,O.moved),vc(Q),O.event(Q).end()}}function V(T,...L){if(e.apply(this,arguments)){var $=this.__zoom,O=bs(T.changedTouches?T.changedTouches[0]:T,this),A=$.invert(O),M=$.k*(T.shiftKey?.5:2),_=n(x(w($,M),O,A),t.apply(this,L),a);vc(T),l>0?Or(this).transition().duration(l).call(C,_,O,T):Or(this).call(y.transform,_,O,T)}}function z(T,...L){if(e.apply(this,arguments)){var $=T.touches,O=$.length,A=j(this,L,T.changedTouches.length===O).event(T),M,_,U,q;for(Km(T),_=0;_<O;++_)U=$[_],q=bs(U,this),q=[q,this.__zoom.invert(q),U.identifier],A.touch0?!A.touch1&&A.touch0[2]!==q[2]&&(A.touch1=q,A.taps=0):(A.touch0=q,M=!0,A.taps=1+!!p);p&&(p=clearTimeout(p)),M&&(A.taps<2&&(f=q[0],p=setTimeout(function(){p=null},h)),Uf(this),A.start())}}function D(T,...L){if(this.__zooming){var $=j(this,L).event(T),O=T.changedTouches,A=O.length,M,_,U,q;for(vc(T),M=0;M<A;++M)_=O[M],U=bs(_,this),$.touch0&&$.touch0[2]===_.identifier?$.touch0[0]=U:$.touch1&&$.touch1[2]===_.identifier&&($.touch1[0]=U);if(_=$.that.__zoom,$.touch1){var B=$.touch0[0],Q=$.touch0[1],se=$.touch1[0],oe=$.touch1[1],ve=(ve=se[0]-B[0])*ve+(ve=se[1]-B[1])*ve,re=(re=oe[0]-Q[0])*re+(re=oe[1]-Q[1])*re;_=w(_,Math.sqrt(ve/re)),U=[(B[0]+se[0])/2,(B[1]+se[1])/2],q=[(Q[0]+oe[0])/2,(Q[1]+oe[1])/2]}else if($.touch0)U=$.touch0[0],q=$.touch0[1];else return;$.zoom("touch",n(x(_,U,q),$.extent,a))}}function R(T,...L){if(this.__zooming){var $=j(this,L).event(T),O=T.changedTouches,A=O.length,M,_;for(Km(T),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),M=0;M<A;++M)_=O[M],$.touch0&&$.touch0[2]===_.identifier?delete $.touch0:$.touch1&&$.touch1[2]===_.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(_=bs(_,this),Math.hypot(f[0]-_[0],f[1]-_[1])<v)){var U=Or(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return y.wheelDelta=function(T){return arguments.length?(r=typeof T=="function"?T:lf(+T),y):r},y.filter=function(T){return arguments.length?(e=typeof T=="function"?T:lf(!!T),y):e},y.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:lf(!!T),y):s},y.extent=function(T){return arguments.length?(t=typeof T=="function"?T:lf([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),y):t},y.scaleExtent=function(T){return arguments.length?(i[0]=+T[0],i[1]=+T[1],y):[i[0],i[1]]},y.translateExtent=function(T){return arguments.length?(a[0][0]=+T[0][0],a[1][0]=+T[1][0],a[0][1]=+T[0][1],a[1][1]=+T[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(T){return arguments.length?(n=T,y):n},y.duration=function(T){return arguments.length?(l=+T,y):l},y.interpolate=function(T){return arguments.length?(c=T,y):c},y.on=function(){var T=u.on.apply(u,arguments);return T===u?y:T},y.clickDistance=function(T){return arguments.length?(b=(T=+T)*T,y):Math.sqrt(b)},y.tapDistance=function(T){return arguments.length?(v=+T,y):v},y}const Zs={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."},Eu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],fE=["Enter"," ","Escape"],pE={"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 Al;(function(e){e.Strict="strict",e.Loose="loose"})(Al||(Al={}));var Go;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Go||(Go={}));var Au;(function(e){e.Partial="partial",e.Full="full"})(Au||(Au={}));const hE={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Qi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Qi||(Qi={}));var Ks;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ks||(Ks={}));var Le;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Le||(Le={}));const W0={[Le.Left]:Le.Right,[Le.Right]:Le.Left,[Le.Top]:Le.Bottom,[Le.Bottom]:Le.Top};function mE(e){return e===null?null:e?"valid":"invalid"}const gE=e=>"id"in e&&"source"in e&&"target"in e,VF=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tw=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Zu=(e,t=[0,0])=>{const{width:n,height:r}=Ai(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},KF=(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):Tw(s)?s:t.nodeLookup.get(s.id));const l=a?Pp(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return bh(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return kh(n)},ed=(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=bh(n,Pp(s)),r=!0)}),r?kh(n):{x:0,y:0,width:0,height:0}},Rw=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...nd(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:p,selectable:f=!0,hidden:d=!1}=u;if(a&&!f||d)continue;const h=p.width??u.width??u.initialWidth??null,g=p.height??u.height??u.initialHeight??null,b=Pu(l,Il(u)),v=(h??0)*(g??0),y=i&&b>0;(!u.internals.handleBounds||y||b>=v||u.dragging)&&c.push(u)}return c},UF=(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 qF(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 YF({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=qF(e,a),c=ed(l),u=Mw(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(u,{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 yE({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:u}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Zs.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(f=[[c,u],[c+h,u+g]])}else l&&Tl(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const d=Tl(f)?oa(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Zs.error015())),{position:{x:d.x-c+(a.measured.width??0)*p[0],y:d.y-u+(a.measured.height??0)*p[1]},positionAbsolute:d}}async function GF({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&a.find(b=>b.id===d.parentId);(h||g)&&a.push(d)}const l=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),p=UF(a,c);for(const d of c)l.has(d.id)&&!p.find(g=>g.id===d.id)&&p.push(d);if(!s)return{edges:p,nodes:a};const f=await s({nodes:a,edges:p});return typeof f=="boolean"?f?{edges:p,nodes:a}:{edges:[],nodes:[]}:f}const Pl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),oa=(e={x:0,y:0},t,n)=>({x:Pl(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Pl(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function xE(e,t,n){const{width:r,height:s}=Ai(n),{x:i,y:a}=n.internals.positionAbsolute;return oa(e,[[i,a],[i+r,a+s]],t)}const V0=(e,t,n)=>e<t?Pl(Math.abs(e-t),1,t)/t:e>n?-Pl(Math.abs(e-n),1,t)/t:0,wE=(e,t,n=15,r=40)=>{const s=V0(e.x,r,t.width-r)*n,i=V0(e.y,r,t.height-r)*n;return[s,i]},bh=(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)}),Wy=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),kh=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Il=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Tw(e)?e.internals.positionAbsolute:Zu(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}},Pp=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Tw(e)?e.internals.positionAbsolute:Zu(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)}},bE=(e,t)=>kh(bh(Wy(e),Wy(t))),Pu=(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)},K0=e=>Ns(e.width)&&Ns(e.height)&&Ns(e.x)&&Ns(e.y),Ns=e=>!isNaN(e)&&isFinite(e),JF=(e,t)=>{},td=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),nd=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?td(l,a):l},Ip=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Oa(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 XF(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Oa(e,n),s=Oa(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Oa(e.top??e.y??0,n),s=Oa(e.bottom??e.y??0,n),i=Oa(e.left??e.x??0,t),a=Oa(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 QF(e,t,n,r,s,i){const{x:a,y:l}=Ip(e,[t,n,r]),{x:c,y:u}=Ip({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=s-c,f=i-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(f)}}const Mw=(e,t,n,r,s,i)=>{const a=XF(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),p=Pl(u,r,s),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*p,g=n/2-d*p,b=QF(e,h,g,p,t,n),v={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:h-v.left+v.right,y:g-v.top+v.bottom,zoom:p}},Iu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Tl(e){return e!=null&&e!=="parent"}function Ai(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 kE(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 vE(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 U0(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ZF(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function ez(e){return{...pE,...e||{}}}function Qc(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=js(e),l=nd({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?td(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const $w=e=>({width:e.offsetWidth,height:e.offsetHeight}),SE=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},tz=["INPUT","SELECT","TEXTAREA"];function NE(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:tz.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const jE=e=>"clientX"in e,js=(e,t)=>{var i,a;const n=jE(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)}},q0=(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,...$w(a)}})};function CE({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,u=t*.125+i*.375+l*.375+r*.125,p=Math.abs(c-e),f=Math.abs(u-t);return[c,u,p,f]}function cf(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Y0({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Le.Left:return[t-cf(t-r,i),n];case Le.Right:return[t+cf(r-t,i),n];case Le.Top:return[t,n-cf(n-s,i)];case Le.Bottom:return[t,n+cf(s-n,i)]}}function _E({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:i=Le.Top,curvature:a=.25}){const[l,c]=Y0({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,p]=Y0({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,d,h,g]=CE({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:p});return[`M${e},${t} C${l},${c} ${u},${p} ${r},${s}`,f,d,h,g]}function EE({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 nz({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 rz({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=bh(Pp(e),Pp(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 Pu(a,kh(i))>0}const sz=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,iz=(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)),qf=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||sz;let s;return gE(e)?s={...e}:s={...e,id:r(e)},iz(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function AE({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=EE({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const G0={[Le.Left]:{x:-1,y:0},[Le.Right]:{x:1,y:0},[Le.Top]:{x:0,y:-1},[Le.Bottom]:{x:0,y:1}},oz=({source:e,sourcePosition:t=Le.Bottom,target:n})=>t===Le.Left||t===Le.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},J0=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function az({source:e,sourcePosition:t=Le.Bottom,target:n,targetPosition:r=Le.Top,center:s,offset:i,stepPosition:a}){const l=G0[t],c=G0[r],u={x:e.x+l.x*i,y:e.y+l.y*i},p={x:n.x+c.x*i,y:n.y+c.y*i},f=oz({source:u,sourcePosition:t,target:p}),d=f.x!==0?"x":"y",h=f[d];let g=[],b,v;const y={x:0,y:0},w={x:0,y:0},[,,x,S]=EE({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*c[d]===-1){d==="x"?(b=s.x??u.x+(p.x-u.x)*a,v=s.y??(u.y+p.y)/2):(b=s.x??(u.x+p.x)/2,v=s.y??u.y+(p.y-u.y)*a);const P=[{x:b,y:u.y},{x:b,y:p.y}],F=[{x:u.x,y:v},{x:p.x,y:v}];l[d]===h?g=d==="x"?P:F:g=d==="x"?F:P}else{const P=[{x:u.x,y:p.y}],F=[{x:p.x,y:u.y}];if(d==="x"?g=l.x===h?F:P:g=l.y===h?P:F,t===r){const T=Math.abs(e[d]-n[d]);if(T<=i){const L=Math.min(i-1,i-T);l[d]===h?y[d]=(u[d]>e[d]?-1:1)*L:w[d]=(p[d]>n[d]?-1:1)*L}}if(t!==r){const T=d==="x"?"y":"x",L=l[d]===c[T],$=u[T]>p[T],O=u[T]<p[T];(l[d]===1&&(!L&&$||L&&O)||l[d]!==1&&(!L&&O||L&&$))&&(g=d==="x"?P:F)}const V={x:u.x+y.x,y:u.y+y.y},z={x:p.x+w.x,y:p.y+w.y},D=Math.max(Math.abs(V.x-g[0].x),Math.abs(z.x-g[0].x)),R=Math.max(Math.abs(V.y-g[0].y),Math.abs(z.y-g[0].y));D>=R?(b=(V.x+z.x)/2,v=g[0].y):(b=g[0].x,v=(V.y+z.y)/2)}const C={x:u.x+y.x,y:u.y+y.y},j={x:p.x+w.x,y:p.y+w.y};return[[e,...C.x!==g[0].x||C.y!==g[0].y?[C]:[],...g,...j.x!==g[g.length-1].x||j.y!==g[g.length-1].y?[j]:[],n],b,v,x,S]}function lz(e,t,n,r){const s=Math.min(J0(e,t)/2,J0(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 u=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${i+s*u},${a}Q ${i},${a} ${i},${a+s*p}`}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 Vy({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:i=Le.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:p=.5}){const[f,d,h,g,b]=az({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:u,stepPosition:p});let v=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)v+=lz(f[y-1],f[y],f[y+1],a);return v+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[v,d,h,g,b]}function X0(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function cz(e){var f;const{sourceNode:t,targetNode:n}=e;if(!X0(t)||!X0(n))return null;const r=t.internals.handleBounds||Q0(t.handles),s=n.internals.handleBounds||Q0(n.handles),i=Z0((r==null?void 0:r.source)??[],e.sourceHandle),a=Z0(e.connectionMode===Al.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",Zs.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Le.Bottom,c=(a==null?void 0:a.position)||Le.Top,u=aa(t,i,l),p=aa(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:c}}function Q0(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 aa(e,t,n=Le.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??Ai(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Le.Top:return{x:s+a/2,y:i};case Le.Right:return{x:s+a,y:i+l/2};case Le.Bottom:return{x:s+a/2,y:i+l};case Le.Left:return{x:s,y:i+l/2}}}function Z0(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ky(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function uz(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 u=Ky(c,t);i.has(u)||(a.push({id:u,color:c.color||n,...c}),i.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const PE=1e3,dz=10,Lw={nodeOrigin:[0,0],nodeExtent:Eu,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},fz={...Lw,checkEquality:!0};function Ow(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function pz(e,t,n){const r=Ow(Lw,n);for(const s of e.values())if(s.parentId)Fw(s,e,t,r);else{const i=Zu(s,r.nodeOrigin),a=Tl(s.extent)?s.extent:r.nodeExtent,l=oa(i,a,Ai(s));s.internals.positionAbsolute=l}}function hz(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 Dw(e){return e==="manual"}function Uy(e,t,n,r={}){var p,f;const s=Ow(fz,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Dw(s.zIndexMode)?PE:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let h=a.get(d.id);if(s.checkEquality&&d===(h==null?void 0:h.internals.userNode))t.set(d.id,h);else{const g=Zu(d,s.nodeOrigin),b=Tl(d.extent)?d.extent:s.nodeExtent,v=oa(g,b,Ai(d));h={...s.defaults,...d,measured:{width:(p=d.measured)==null?void 0:p.width,height:(f=d.measured)==null?void 0:f.height},internals:{positionAbsolute:v,handleBounds:hz(d,h),z:IE(d,l,s.zIndexMode),userNode:d}},t.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),d.parentId&&Fw(h,t,n,r,i),u||(u=d.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function mz(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 Fw(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Ow(Lw,r),u=e.parentId,p=t.get(u);if(!p){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mz(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&c==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*dz),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const f=i&&!Dw(c)?PE:0,{x:d,y:h,z:g}=gz(e,p,a,l,f,c),{positionAbsolute:b}=e.internals,v=d!==b.x||h!==b.y;(v||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:d,y:h}:b,z:g}})}function IE(e,t,n){const r=Ns(e.zIndex)?e.zIndex:0;return Dw(n)?r:r+(e.selected?t:0)}function gz(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=Ai(e),u=Zu(e,n),p=Tl(e.extent)?oa(u,e.extent,c):u;let f=oa({x:a+p.x,y:l+p.y},r,c);e.extent==="parent"&&(f=xE(f,c,t));const d=IE(e,s,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function zw(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 u=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??Il(c),p=bE(u,l.rect);i.set(l.parentId,{expandedRect:p,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},u)=>{var x;const p=c.internals.positionAbsolute,f=Ai(c),d=c.origin??r,h=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,g=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,b=Math.max(f.width,Math.round(l.width)),v=Math.max(f.height,Math.round(l.height)),y=(b-f.width)*d[0],w=(v-f.height)*d[1];(h>0||g>0||y||w)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+w}}),(x=n.get(u))==null||x.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:u,type:"dimensions",setAttributes:!0,dimensions:{width:b+(h?d[0]*h-y:0),height:v+(g?d[1]*g-w:0)}})}),s}function yz(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 u=[],p=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(p.transform),d=[];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 b=$w(h.nodeElement),v=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!g.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),x=Tl(g.extent)?g.extent:i;let{positionAbsolute:S}=g.internals;g.parentId&&g.extent==="parent"?S=xE(S,b,t.get(g.parentId)):x&&(S=oa(S,x,b));const C={...g,measured:b,internals:{...g.internals,positionAbsolute:S,handleBounds:{source:q0("source",h.nodeElement,w,f,g.id),target:q0("target",h.nodeElement,w,f,g.id)}}};t.set(g.id,C),g.parentId&&Fw(C,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,v&&(u.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Il(C,s)}))}}if(d.length>0){const h=zw(d,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function xz({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 eS(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 u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function TE(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},u=`${s}-${a}--${i}-${l}`,p=`${i}-${l}--${s}-${a}`;eS("source",c,p,e,s,a),eS("target",c,u,e,i,l),t.set(r.id,r)}}function RE(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:RE(n,t):!1}function tS(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 wz(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!RE(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 Um({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,p]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:p.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 bz({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=td(i,t);return{x:a.x-i.x,y:a.y-i.y}}function kz({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},p=null,f=!1,d=null,h=!1,g=!1,b=null;function v({noDragClassName:w,handleSelector:x,domNode:S,isSelectable:C,nodeId:j,nodeClickDistance:E=0}){d=Or(S);function P({x:D,y:R}){const{nodeLookup:T,nodeExtent:L,snapGrid:$,snapToGrid:O,nodeOrigin:A,onNodeDrag:M,onSelectionDrag:_,onError:U,updateNodePositions:q}=t();i={x:D,y:R};let B=!1;const Q=l.size>1,se=Q&&L?Wy(ed(l)):null,oe=Q&&O?bz({dragItems:l,snapGrid:$,x:D,y:R}):null;for(const[ve,re]of l){if(!T.has(ve))continue;let ue={x:D-re.distance.x,y:R-re.distance.y};O&&(ue=oe?{x:Math.round(ue.x+oe.x),y:Math.round(ue.y+oe.y)}:td(ue,$));let te=null;if(Q&&L&&!re.extent&&se){const{positionAbsolute:be}=re.internals,Fe=be.x-se.x+L[0][0],Ue=be.x+re.measured.width-se.x2+L[1][0],Me=be.y-se.y+L[0][1],et=be.y+re.measured.height-se.y2+L[1][1];te=[[Fe,Me],[Ue,et]]}const{position:ae,positionAbsolute:pe}=yE({nodeId:ve,nextPosition:ue,nodeLookup:T,nodeExtent:te||L,nodeOrigin:A,onError:U});B=B||re.position.x!==ae.x||re.position.y!==ae.y,re.position=ae,re.internals.positionAbsolute=pe}if(g=g||B,!!B&&(q(l,!0),b&&(r||M||!j&&_))){const[ve,re]=Um({nodeId:j,dragItems:l,nodeLookup:T});r==null||r(b,l,ve,re),M==null||M(b,ve,re),j||_==null||_(b,re)}}async function F(){if(!p)return;const{transform:D,panBy:R,autoPanSpeed:T,autoPanOnNodeDrag:L}=t();if(!L){c=!1,cancelAnimationFrame(a);return}const[$,O]=wE(u,p,T);($!==0||O!==0)&&(i.x=(i.x??0)-$/D[2],i.y=(i.y??0)-O/D[2],await R({x:$,y:O})&&P(i)),a=requestAnimationFrame(F)}function V(D){var Q;const{nodeLookup:R,multiSelectionActive:T,nodesDraggable:L,transform:$,snapGrid:O,snapToGrid:A,selectNodesOnDrag:M,onNodeDragStart:_,onSelectionDragStart:U,unselectNodesAndEdges:q}=t();f=!0,(!M||!C)&&!T&&j&&((Q=R.get(j))!=null&&Q.selected||q()),C&&M&&j&&(e==null||e(j));const B=Qc(D.sourceEvent,{transform:$,snapGrid:O,snapToGrid:A,containerBounds:p});if(i=B,l=wz(R,L,B,j),l.size>0&&(n||_||!j&&U)){const[se,oe]=Um({nodeId:j,dragItems:l,nodeLookup:R});n==null||n(D.sourceEvent,l,se,oe),_==null||_(D.sourceEvent,se,oe),j||U==null||U(D.sourceEvent,oe)}}const z=J_().clickDistance(E).on("start",D=>{const{domNode:R,nodeDragThreshold:T,transform:L,snapGrid:$,snapToGrid:O}=t();p=(R==null?void 0:R.getBoundingClientRect())||null,h=!1,g=!1,b=D.sourceEvent,T===0&&V(D),i=Qc(D.sourceEvent,{transform:L,snapGrid:$,snapToGrid:O,containerBounds:p}),u=js(D.sourceEvent,p)}).on("drag",D=>{const{autoPanOnNodeDrag:R,transform:T,snapGrid:L,snapToGrid:$,nodeDragThreshold:O,nodeLookup:A}=t(),M=Qc(D.sourceEvent,{transform:T,snapGrid:L,snapToGrid:$,containerBounds:p});if(b=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||j&&!A.has(j))&&(h=!0),!h){if(!c&&R&&f&&(c=!0,F()),!f){const _=js(D.sourceEvent,p),U=_.x-u.x,q=_.y-u.y;Math.sqrt(U*U+q*q)>O&&V(D)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&l&&f&&(u=js(D.sourceEvent,p),P(M))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:R,updateNodePositions:T,onNodeDragStop:L,onSelectionDragStop:$}=t();if(g&&(T(l,!1),g=!1),s||L||!j&&$){const[O,A]=Um({nodeId:j,dragItems:l,nodeLookup:R,dragging:!1});s==null||s(D.sourceEvent,l,O,A),L==null||L(D.sourceEvent,O,A),j||$==null||$(D.sourceEvent,A)}}}).filter(D=>{const R=D.target;return!D.button&&(!w||!tS(R,`.${w}`,S))&&(!x||tS(R,x,S))});d.call(z)}function y(){d==null||d.on(".drag",null)}return{update:v,destroy:y}}function vz(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())Pu(s,Il(i))>0&&r.push(i);return r}const Sz=250;function Nz(e,t,n,r){var l,c;let s=[],i=1/0;const a=vz(e,n,t+Sz);for(const u of a){const p=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of p){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:d,y:h}=aa(u,f,f.position,!0),g=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(s=[{...f,x:d,y:h}],i=g):g===i&&s.push({...f,x:d,y:h}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(p=>p.type===u)??s[0]}return s[0]}function ME(e,t,n,r,s,i=!1){var u,p,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...aa(a,c,c.position,!0)}:c}function $E(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function jz(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const LE=()=>!0;function Cz(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:p,flowId:f,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:v,isValidConnection:y=LE,onReconnectEnd:w,updateConnection:x,getTransform:S,getFromHandle:C,autoPanSpeed:j,dragThreshold:E=1,handleDomNode:P}){const F=SE(e.target);let V=0,z;const{x:D,y:R}=js(e),T=$E(i,P),L=l==null?void 0:l.getBoundingClientRect();let $=!1;if(!L||!T)return;const O=ME(s,T,r,c,t);if(!O)return;let A=js(e,L),M=!1,_=null,U=!1,q=null;function B(){if(!p||!L)return;const[ae,pe]=wE(A,L,j);d({x:ae,y:pe}),V=requestAnimationFrame(B)}const Q={...O,nodeId:s,type:T,position:O.position},se=c.get(s);let ve={inProgress:!0,isValid:null,from:aa(se,Q,Le.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:se,to:A,toHandle:null,toPosition:W0[Q.position],toNode:null,pointer:A};function re(){$=!0,x(ve),g==null||g(e,{nodeId:s,handleId:r,handleType:T})}E===0&&re();function ue(ae){if(!$){const{x:et,y:ht}=js(ae),Ie=et-D,tt=ht-R;if(!(Ie*Ie+tt*tt>E*E))return;re()}if(!C()||!Q){te(ae);return}const pe=S();A=js(ae,L),z=Nz(nd(A,pe,!1,[1,1]),n,c,Q),M||(B(),M=!0);const be=OE(ae,{handle:z,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:F,lib:u,flowId:f,nodeLookup:c});q=be.handleDomNode,_=be.connection,U=jz(!!z,be.isValid);const Fe=c.get(s),Ue=Fe?aa(Fe,Q,Le.Left,!0):ve.from,Me={...ve,from:Ue,isValid:U,to:be.toHandle&&U?Ip({x:be.toHandle.x,y:be.toHandle.y},pe):A,toHandle:be.toHandle,toPosition:U&&be.toHandle?be.toHandle.position:W0[Q.position],toNode:be.toHandle?c.get(be.toHandle.nodeId):null,pointer:A};x(Me),ve=Me}function te(ae){if(!("touches"in ae&&ae.touches.length>0)){if($){(z||q)&&_&&U&&(b==null||b(_));const{inProgress:pe,...be}=ve,Fe={...be,toPosition:ve.toHandle?ve.toPosition:null};v==null||v(ae,Fe),i&&(w==null||w(ae,Fe))}h(),cancelAnimationFrame(V),M=!1,U=!1,_=null,q=null,F.removeEventListener("mousemove",ue),F.removeEventListener("mouseup",te),F.removeEventListener("touchmove",ue),F.removeEventListener("touchend",te)}}F.addEventListener("mousemove",ue),F.addEventListener("mouseup",te),F.addEventListener("touchmove",ue),F.addEventListener("touchend",te)}function OE(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:u=LE,nodeLookup:p}){const f=i==="target",d=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}=js(e),b=a.elementFromPoint(h,g),v=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:d,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const w=$E(void 0,v),x=v.getAttribute("data-nodeid"),S=v.getAttribute("data-handleid"),C=v.classList.contains("connectable"),j=v.classList.contains("connectableend");if(!x||!w)return y;const E={source:f?x:r,sourceHandle:f?S:s,target:f?r:x,targetHandle:f?s:S};y.connection=E;const F=C&&j&&(n===Al.Strict?f&&w==="source"||!f&&w==="target":x!==r||S!==s);y.isValid=F&&u(E),y.toHandle=ME(x,w,S,p,n,!0)}return y}const qy={onPointerDown:Cz,isValid:OE};function _z({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Or(e);function i({translateExtent:l,width:c,height:u,zoomStep:p=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const S=n(),C=x.sourceEvent.ctrlKey&&Iu()?10:1,j=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*p,E=S[2]*Math.pow(2,j*C);t.scaleTo(E)};let b=[0,0];const v=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(b=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},y=x=>{const S=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const C=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],j=[C[0]-b[0],C[1]-b[1]];b=C;const E=r()*Math.max(S[2],Math.log(S[2]))*(h?-1:1),P={x:S[0]-j[0]*E,y:S[1]-j[1]*E},F=[[0,0],[c,u]];t.setViewportConstrained({x:P.x,y:P.y,zoom:S[2]},F,l)},w=dE().on("start",v).on("zoom",f?y:null).on("zoom.wheel",d?g:null);s.call(w,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:bs}}const vh=e=>({x:e.x,y:e.y,zoom:e.k}),qm=({x:e,y:t,zoom:n})=>wh.translate(e,t).scale(n),sl=(e,t)=>e.target.closest(`.${t}`),DE=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ez=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ym=(e,t=0,n=Ez,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},FE=e=>{const t=e.ctrlKey&&Iu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Az({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return p=>{if(sl(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(p.ctrlKey&&a){const v=bs(p),y=FE(p),w=f*Math.pow(2,y);r.scaleTo(n,w,v,p);return}const d=p.deltaMode===1?20:1;let h=s===Go.Vertical?0:p.deltaX*d,g=s===Go.Horizontal?0:p.deltaY*d;!Iu()&&p.shiftKey&&s!==Go.Vertical&&(h=p.deltaY*d,g=0),r.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const b=vh(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(p,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(p,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,b))}}function Pz({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=sl(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function Iz({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=vh(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 Tz({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&DE(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,vh(i.transform)))}}function Rz({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&&DE(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=vh(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function Mz({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:p}){return f=>{var v;const d=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(sl(f,`${u}-flow__node`)||sl(f,`${u}-flow__edge`)))return!0;if(!r&&!d&&!s&&!i&&!n||a||p&&!g||sl(f,l)&&g||sl(f,c)&&(!g||s&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((v=f.touches)==null?void 0:v.length)>1)return f.preventDefault(),!1;if(!d&&!s&&!h&&g||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function $z({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),f=dE().scaleExtent([t,n]).translateExtent(r),d=Or(e).call(f);w({x:s.x,y:s.y,zoom:Pl(s.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=d.on("wheel.zoom"),g=d.on("dblclick.zoom");f.wheelDelta(FE);function b(z,D){return d?new Promise(R=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Xc:Wf).transform(Ym(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>R(!0)),z)}):Promise.resolve(!1)}function v({noWheelClassName:z,noPanClassName:D,onPaneContextMenu:R,userSelectionActive:T,panOnScroll:L,panOnDrag:$,panOnScrollMode:O,panOnScrollSpeed:A,preventScrolling:M,zoomOnPinch:_,zoomOnScroll:U,zoomOnDoubleClick:q,zoomActivationKeyPressed:B,lib:Q,onTransformChange:se,connectionInProgress:oe,paneClickDistance:ve,selectionOnDrag:re}){T&&!u.isZoomingOrPanning&&y();const ue=L&&!B&&!T;f.clickDistance(re?1/0:!Ns(ve)||ve<0?0:ve);const te=ue?Az({zoomPanValues:u,noWheelClassName:z,d3Selection:d,d3Zoom:f,panOnScrollMode:O,panOnScrollSpeed:A,zoomOnPinch:_,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):Pz({noWheelClassName:z,preventScrolling:M,d3ZoomHandler:h});if(d.on("wheel.zoom",te,{passive:!1}),!T){const pe=Iz({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",pe);const be=Tz({zoomPanValues:u,panOnDrag:$,onPaneContextMenu:!!R,onPanZoom:i,onTransformChange:se});f.on("zoom",be);const Fe=Rz({zoomPanValues:u,panOnDrag:$,panOnScroll:L,onPaneContextMenu:R,onPanZoomEnd:l,onDraggingChange:c});f.on("end",Fe)}const ae=Mz({zoomActivationKeyPressed:B,panOnDrag:$,zoomOnScroll:U,panOnScroll:L,zoomOnDoubleClick:q,zoomOnPinch:_,userSelectionActive:T,noPanClassName:D,noWheelClassName:z,lib:Q,connectionInProgress:oe});f.filter(ae),q?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function w(z,D,R){const T=qm(z),L=f==null?void 0:f.constrain()(T,D,R);return L&&await b(L),new Promise($=>$(L))}async function x(z,D){const R=qm(z);return await b(R,D),new Promise(T=>T(R))}function S(z){if(d){const D=qm(z),R=d.property("__zoom");(R.k!==z.zoom||R.x!==z.x||R.y!==z.y)&&(f==null||f.transform(d,D,null,{sync:!0}))}}function C(){const z=d?uE(d.node()):{x:0,y:0,k:1};return{x:z.x,y:z.y,zoom:z.k}}function j(z,D){return d?new Promise(R=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Xc:Wf).scaleTo(Ym(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>R(!0)),z)}):Promise.resolve(!1)}function E(z,D){return d?new Promise(R=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Xc:Wf).scaleBy(Ym(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>R(!0)),z)}):Promise.resolve(!1)}function P(z){f==null||f.scaleExtent(z)}function F(z){f==null||f.translateExtent(z)}function V(z){const D=!Ns(z)||z<0?0:z;f==null||f.clickDistance(D)}return{update:v,destroy:y,setViewport:x,setViewportConstrained:w,getViewport:C,scaleTo:j,scaleBy:E,setScaleExtent:P,setTranslateExtent:F,syncViewport:S,setClickDistance:V}}var Rl;(function(e){e.Line="line",e.Handle="handle"})(Rl||(Rl={}));function Lz({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 nS(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 Vi(e,t){return Math.max(0,t-e)}function Ki(e,t){return Math.max(0,e-t)}function uf(e,t,n){return Math.max(0,t-e,e-n)}function rS(e,t){return e?!t:t}function Oz(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:p,isVertical:f}=t,d=p&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:v,minHeight:y,maxHeight:w}=r,{x,y:S,width:C,height:j,aspectRatio:E}=e;let P=Math.floor(p?h-e.pointerX:0),F=Math.floor(f?g-e.pointerY:0);const V=C+(c?-P:P),z=j+(u?-F:F),D=-i[0]*C,R=-i[1]*j;let T=uf(V,b,v),L=uf(z,y,w);if(a){let A=0,M=0;c&&P<0?A=Vi(x+P+D,a[0][0]):!c&&P>0&&(A=Ki(x+V+D,a[1][0])),u&&F<0?M=Vi(S+F+R,a[0][1]):!u&&F>0&&(M=Ki(S+z+R,a[1][1])),T=Math.max(T,A),L=Math.max(L,M)}if(l){let A=0,M=0;c&&P>0?A=Ki(x+P,l[0][0]):!c&&P<0&&(A=Vi(x+V,l[1][0])),u&&F>0?M=Ki(S+F,l[0][1]):!u&&F<0&&(M=Vi(S+z,l[1][1])),T=Math.max(T,A),L=Math.max(L,M)}if(s){if(p){const A=uf(V/E,y,w)*E;if(T=Math.max(T,A),a){let M=0;!c&&!u||c&&!u&&d?M=Ki(S+R+V/E,a[1][1])*E:M=Vi(S+R+(c?P:-P)/E,a[0][1])*E,T=Math.max(T,M)}if(l){let M=0;!c&&!u||c&&!u&&d?M=Vi(S+V/E,l[1][1])*E:M=Ki(S+(c?P:-P)/E,l[0][1])*E,T=Math.max(T,M)}}if(f){const A=uf(z*E,b,v)/E;if(L=Math.max(L,A),a){let M=0;!c&&!u||u&&!c&&d?M=Ki(x+z*E+D,a[1][0])/E:M=Vi(x+(u?F:-F)*E+D,a[0][0])/E,L=Math.max(L,M)}if(l){let M=0;!c&&!u||u&&!c&&d?M=Vi(x+z*E,l[1][0])/E:M=Ki(x+(u?F:-F)*E,l[0][0])/E,L=Math.max(L,M)}}}F=F+(F<0?L:-L),P=P+(P<0?T:-T),s&&(d?V>z*E?F=(rS(c,u)?-P:P)/E:P=(rS(c,u)?-F:F)*E:p?(F=P/E,u=c):(P=F*E,c=u));const $=c?x+P:x,O=u?S+F:S;return{width:C+(c?-P:P),height:j+(u?-F:F),x:i[0]*P*(c?-1:1)+$,y:i[1]*F*(u?-1:1)+O}}const zE={width:0,height:0,x:0,y:0},Dz={...zE,pointerX:0,pointerY:0,aspectRatio:1};function Fz(e){return[[0,0],[e.measured.width,e.measured.height]]}function zz(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 Hz({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Or(e);let a={controlDirection:nS("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:p,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:v}){let y={...zE},w={...Dz};a={boundaries:p,resizeDirection:d,keepAspectRatio:f,controlDirection:nS(u)};let x,S=null,C=[],j,E,P,F=!1;const V=J_().on("start",z=>{const{nodeLookup:D,transform:R,snapGrid:T,snapToGrid:L,nodeOrigin:$,paneDomNode:O}=n();if(x=D.get(t),!x)return;S=(O==null?void 0:O.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:M}=Qc(z.sourceEvent,{transform:R,snapGrid:T,snapToGrid:L,containerBounds:S});y={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},w={...y,pointerX:A,pointerY:M,aspectRatio:y.width/y.height},j=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(j=D.get(x.parentId),E=j&&x.extent==="parent"?Fz(j):void 0),C=[],P=void 0;for(const[_,U]of D)if(U.parentId===t&&(C.push({id:_,position:{...U.position},extent:U.extent}),U.extent==="parent"||U.expandParent)){const q=zz(U,x,U.origin??$);P?P=[[Math.min(q[0][0],P[0][0]),Math.min(q[0][1],P[0][1])],[Math.max(q[1][0],P[1][0]),Math.max(q[1][1],P[1][1])]]:P=q}h==null||h(z,{...y})}).on("drag",z=>{const{transform:D,snapGrid:R,snapToGrid:T,nodeOrigin:L}=n(),$=Qc(z.sourceEvent,{transform:D,snapGrid:R,snapToGrid:T,containerBounds:S}),O=[];if(!x)return;const{x:A,y:M,width:_,height:U}=y,q={},B=x.origin??L,{width:Q,height:se,x:oe,y:ve}=Oz(w,a.controlDirection,$,a.boundaries,a.keepAspectRatio,B,E,P),re=Q!==_,ue=se!==U,te=oe!==A&&re,ae=ve!==M&&ue;if(!te&&!ae&&!re&&!ue)return;if((te||ae||B[0]===1||B[1]===1)&&(q.x=te?oe:y.x,q.y=ae?ve:y.y,y.x=q.x,y.y=q.y,C.length>0)){const Ue=oe-A,Me=ve-M;for(const et of C)et.position={x:et.position.x-Ue+B[0]*(Q-_),y:et.position.y-Me+B[1]*(se-U)},O.push(et)}if((re||ue)&&(q.width=re&&(!a.resizeDirection||a.resizeDirection==="horizontal")?Q:y.width,q.height=ue&&(!a.resizeDirection||a.resizeDirection==="vertical")?se:y.height,y.width=q.width,y.height=q.height),j&&x.expandParent){const Ue=B[0]*(q.width??0);q.x&&q.x<Ue&&(y.x=Ue,w.x=w.x-(q.x-Ue));const Me=B[1]*(q.height??0);q.y&&q.y<Me&&(y.y=Me,w.y=w.y-(q.y-Me))}const pe=Lz({width:y.width,prevWidth:_,height:y.height,prevHeight:U,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),be={...y,direction:pe};(v==null?void 0:v(z,be))!==!1&&(F=!0,g==null||g(z,be),r(q,O))}).on("end",z=>{F&&(b==null||b(z,{...y}),s==null||s({...y}),F=!1)});i.call(V)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var HE={exports:{}},BE={},WE={exports:{}},VE={};/**
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 Ml=m;function Bz(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Wz=typeof Object.is=="function"?Object.is:Bz,Vz=Ml.useState,Kz=Ml.useEffect,Uz=Ml.useLayoutEffect,qz=Ml.useDebugValue;function Yz(e,t){var n=t(),r=Vz({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return Uz(function(){s.value=n,s.getSnapshot=t,Gm(s)&&i({inst:s})},[e,n,t]),Kz(function(){return Gm(s)&&i({inst:s}),e(function(){Gm(s)&&i({inst:s})})},[e]),qz(n),n}function Gm(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Wz(e,n)}catch{return!0}}function Gz(e,t){return t()}var Jz=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Gz:Yz;VE.useSyncExternalStore=Ml.useSyncExternalStore!==void 0?Ml.useSyncExternalStore:Jz;WE.exports=VE;var KE=WE.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 Sh=m,Xz=KE;function Qz(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Zz=typeof Object.is=="function"?Object.is:Qz,e3=Xz.useSyncExternalStore,t3=Sh.useRef,n3=Sh.useEffect,r3=Sh.useMemo,s3=Sh.useDebugValue;BE.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=t3(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=r3(function(){function c(h){if(!u){if(u=!0,p=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,Zz(p,h))return g;var b=r(h);return s!==void 0&&s(g,b)?(p=h,g):(p=h,f=b)}var u=!1,p,f,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,s]);var l=e3(e,i[0],i[1]);return n3(function(){a.hasValue=!0,a.value=l},[l]),s3(l),l};HE.exports=BE;var i3=HE.exports;const o3=bo(i3),a3={},sS=e=>{let t;const n=new Set,r=(p,f)=>{const d=typeof p=="function"?p(t):p;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(a3?"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()}},u=t=e(r,s,c);return c},l3=e=>e?sS(e):sS,{useDebugValue:c3}=st,{useSyncExternalStoreWithSelector:u3}=o3,d3=e=>e;function UE(e,t=d3,n){const r=u3(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return c3(r),r}const iS=(e,t)=>{const n=l3(e),r=(s,i=t)=>UE(n,s,i);return Object.assign(r,n),r},f3=(e,t)=>e?iS(e,t):iS;function fn(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 Nh=m.createContext(null),p3=Nh.Provider,qE=Zs.error001();function Pt(e,t){const n=m.useContext(Nh);if(n===null)throw new Error(qE);return UE(n,e,t)}function cn(){const e=m.useContext(Nh);if(e===null)throw new Error(qE);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const oS={display:"none"},h3={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},YE="react-flow__node-desc",GE="react-flow__edge-desc",m3="react-flow__aria-live",g3=e=>e.ariaLiveMessage,y3=e=>e.ariaLabelConfig;function x3({rfId:e}){const t=Pt(g3);return o.jsx("div",{id:`${m3}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:h3,children:t})}function w3({rfId:e,disableKeyboardA11y:t}){const n=Pt(y3);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${YE}-${e}`,style:oS,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${GE}-${e}`,style:oS,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(x3,{rfId:e})]})}const jh=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:An(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});jh.displayName="Panel";function b3({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(jh,{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 k3=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}},df=e=>e.id;function v3(e,t){return fn(e.selectedNodes.map(df),t.selectedNodes.map(df))&&fn(e.selectedEdges.map(df),t.selectedEdges.map(df))}function S3({onSelectionChange:e}){const t=cn(),{selectedNodes:n,selectedEdges:r}=Pt(k3,v3);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 N3=e=>!!e.onSelectionChangeHandlers;function j3({onSelectionChange:e}){const t=Pt(N3);return e||t?o.jsx(S3,{onSelectionChange:e}):null}const Yy=typeof window<"u"?m.useLayoutEffect:m.useEffect,JE=[0,0],C3={x:0,y:0,zoom:1},_3=["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"],aS=[..._3,"rfId"],E3=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}),lS={translateExtent:Eu,nodeOrigin:JE,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function A3(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Pt(E3,fn),u=cn();Yy(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=lS,l()}),[]);const p=m.useRef(lS);return Yy(()=>{for(const f of aS){const d=e[f],h=p.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?r(d):f==="maxZoom"?s(d):f==="translateExtent"?i(d):f==="nodeExtent"?a(d):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:ez(d)}):f==="fitView"?u.setState({fitViewQueued:d}):f==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[f]:d})))}p.current=e},aS.map(f=>e[f])),null}function cS(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function P3(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=cS(),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=cS())!=null&&r.matches?"dark":"light"}const uS=typeof document<"u"?document:null;function Tu(e=null,t={target:uS,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 u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),p=u.reduce((f,d)=>f.concat(...d),[]);return[u,p]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??uS,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=h=>{var v,y;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&NE(h))return!1;const b=fS(h.code,l);if(i.current.add(h[b]),dS(a,i.current,!1)){const w=((y=(v=h.composedPath)==null?void 0:v.call(h))==null?void 0:y[0])||h.target,x=(w==null?void 0:w.nodeName)==="BUTTON"||(w==null?void 0:w.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const g=fS(h.code,l);dS(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),s.current=!1},d=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",p),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",p),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function dS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function fS(e,t){return t.includes(e)?"code":"key"}const I3=()=>{const e=cn();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=Mw(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(),u={x:t.x-l,y:t.y-c},p=n.snapGrid??s,f=n.snapToGrid??i;return nd(u,r,f,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=Ip(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function XE(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)T3(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 T3(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 Tp(e,t){return XE(e,t)}function Hw(e,t){return XE(e,t)}function $o(e,t){return{id:e,type:"select",selected:t}}function il(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($o(i.id,a)))}return r}function pS({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 hS(e){return{id:e.id,type:"remove"}}const mS=e=>VF(e),R3=e=>gE(e);function QE(e){return m.forwardRef(e)}function gS(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>M3(()=>n(s=>s+BigInt(1))));return Yy(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function M3(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const ZE=m.createContext(null);function $3({children:e}){const t=cn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:p,onNodesChange:f,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let v=pS({items:b,lookup:d});for(const y of g.values())v=y(v);p&&u(b),v.length>0?f==null||f(v):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:x}=t.getState();y&&x(w)})},[]),r=gS(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:p,onEdgesChange:f,edgeLookup:d}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;p?u(h):f&&f(pS({items:h,lookup:d}))},[]),i=gS(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(ZE.Provider,{value:a,children:e})}function L3(){const e=m.useContext(ZE);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const O3=e=>!!e.panZoom;function Hl(){const e=I3(),t=cn(),n=L3(),r=Pt(O3),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,w;const{nodeLookup:d,nodeOrigin:h}=t.getState(),g=mS(f)?f:d.get(f.id),b=g.parentId?vE(g.position,g.measured,g.parentId,d,h):g.position,v={...g,position:b,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((w=g.measured)==null?void 0:w.height)??g.height};return Il(v)},u=(f,d,h={replace:!1})=>{a(g=>g.map(b=>{if(b.id===f){const v=typeof d=="function"?d(b):d;return h.replace&&mS(v)?v:{...b,...v}}return b}))},p=(f,d,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===f){const v=typeof d=="function"?d(b):d;return h.replace&&R3(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var d;return(d=i(f))==null?void 0:d.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:h}=t.getState(),[g,b,v]=h;return{nodes:f.map(y=>({...y})),edges:d.map(y=>({...y})),viewport:{x:g,y:b,zoom:v}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:w,onDelete:x,onBeforeDelete:S}=t.getState(),{nodes:C,edges:j}=await GF({nodesToRemove:f,edgesToRemove:d,nodes:h,edges:g,onBeforeDelete:S}),E=j.length>0,P=C.length>0;if(E){const F=j.map(hS);v==null||v(j),w(F)}if(P){const F=C.map(hS);b==null||b(C),y(F)}return(P||E)&&(x==null||x({nodes:C,edges:j})),{deletedNodes:C,deletedEdges:j}},getIntersectingNodes:(f,d=!0,h)=>{const g=K0(f),b=g?f:c(f),v=h!==void 0;return b?(h||t.getState().nodes).filter(y=>{const w=t.getState().nodeLookup.get(y.id);if(w&&!g&&(y.id===f.id||!w.internals.positionAbsolute))return!1;const x=Il(v?y:w),S=Pu(x,b);return d&&S>0||S>=x.width*x.height||S>=b.width*b.height}):[]},isNodeIntersecting:(f,d,h=!0)=>{const b=K0(f)?f:c(f);if(!b)return!1;const v=Pu(b,d);return h&&v>0||v>=d.width*d.height||v>=b.width*b.height},updateNode:u,updateNodeData:(f,d,h={replace:!1})=>{u(f,g=>{const b=typeof d=="function"?d(g):d;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:p,updateEdgeData:(f,d,h={replace:!1})=>{p(f,g=>{const b=typeof d=="function"?d(g):d;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return KF(f,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:f,id:d,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${f}${d?`-${d}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:f,handleId:d,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${f?d?`-${f}-${d}`:`-${f}`:""}`))==null?void 0:g.values())??[])},fitView:async f=>{const d=t.getState().fitViewResolver??ZF();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const yS=e=>e.selected,D3=typeof window<"u"?window:void 0;function F3({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=cn(),{deleteElements:r}=Hl(),s=Tu(e,{actInsideInputWithModifier:!1}),i=Tu(t,{target:D3});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(yS),edges:a.filter(yS)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function z3(e){const t=cn();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=$w(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Zs.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 Ch={position:"absolute",width:"100%",height:"100%",top:0,left:0},H3=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function B3({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Go.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:p,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:v,onViewportChange:y,isControlledViewport:w,paneClickDistance:x,selectionOnDrag:S}){const C=cn(),j=m.useRef(null),{userSelectionActive:E,lib:P,connectionInProgress:F}=Pt(H3,fn),V=Tu(d),z=m.useRef();z3(j);const D=m.useCallback(R=>{y==null||y({x:R[0],y:R[1],zoom:R[2]}),w||C.setState({transform:R})},[y,w]);return m.useEffect(()=>{if(j.current){z.current=$z({domNode:j.current,minZoom:p,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:$=>C.setState(O=>O.paneDragging===$?O:{paneDragging:$}),onPanZoomStart:($,O)=>{const{onViewportChangeStart:A,onMoveStart:M}=C.getState();M==null||M($,O),A==null||A(O)},onPanZoom:($,O)=>{const{onViewportChange:A,onMove:M}=C.getState();M==null||M($,O),A==null||A(O)},onPanZoomEnd:($,O)=>{const{onViewportChangeEnd:A,onMoveEnd:M}=C.getState();M==null||M($,O),A==null||A(O)}});const{x:R,y:T,zoom:L}=z.current.getViewport();return C.setState({panZoom:z.current,transform:[R,T,L],domNode:j.current.closest(".react-flow")}),()=>{var $;($=z.current)==null||$.destroy()}}},[]),m.useEffect(()=>{var R;(R=z.current)==null||R.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:V,preventScrolling:h,noPanClassName:v,userSelectionActive:E,noWheelClassName:b,lib:P,onTransformChange:D,connectionInProgress:F,selectionOnDrag:S,paneClickDistance:x})},[e,t,n,r,s,i,a,l,V,h,v,E,b,P,D,F,S,x]),o.jsx("div",{className:"react-flow__renderer",ref:j,style:Ch,children:g})}const W3=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function V3(){const{userSelectionActive:e,userSelectionRect:t}=Pt(W3,fn);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 Jm=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},K3=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function U3({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Au.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:p,onPaneMouseEnter:f,onPaneMouseMove:d,onPaneMouseLeave:h,children:g}){const b=cn(),{userSelectionActive:v,elementsSelectable:y,dragging:w,connectionInProgress:x}=Pt(K3,fn),S=y&&(e||v),C=m.useRef(null),j=m.useRef(),E=m.useRef(new Set),P=m.useRef(new Set),F=m.useRef(!1),V=A=>{if(F.current||x){F.current=!1;return}c==null||c(A),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},z=A=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){A.preventDefault();return}u==null||u(A)},D=p?A=>p(A):void 0,R=A=>{F.current&&(A.stopPropagation(),F.current=!1)},T=A=>{var se,oe;const{domNode:M}=b.getState();if(j.current=M==null?void 0:M.getBoundingClientRect(),!j.current)return;const _=A.target===C.current;if(!_&&!!A.target.closest(".nokey")||!e||!(i&&_||t)||A.button!==0||!A.isPrimary)return;(oe=(se=A.target)==null?void 0:se.setPointerCapture)==null||oe.call(se,A.pointerId),F.current=!1;const{x:B,y:Q}=js(A.nativeEvent,j.current);b.setState({userSelectionRect:{width:0,height:0,startX:B,startY:Q,x:B,y:Q}}),_||(A.stopPropagation(),A.preventDefault())},L=A=>{const{userSelectionRect:M,transform:_,nodeLookup:U,edgeLookup:q,connectionLookup:B,triggerNodeChanges:Q,triggerEdgeChanges:se,defaultEdgeOptions:oe,resetSelectedElements:ve}=b.getState();if(!j.current||!M)return;const{x:re,y:ue}=js(A.nativeEvent,j.current),{startX:te,startY:ae}=M;if(!F.current){const Me=t?0:s;if(Math.hypot(re-te,ue-ae)<=Me)return;ve(),a==null||a(A)}F.current=!0;const pe={startX:te,startY:ae,x:re<te?re:te,y:ue<ae?ue:ae,width:Math.abs(re-te),height:Math.abs(ue-ae)},be=E.current,Fe=P.current;E.current=new Set(Rw(U,pe,_,n===Au.Partial,!0).map(Me=>Me.id)),P.current=new Set;const Ue=(oe==null?void 0:oe.selectable)??!0;for(const Me of E.current){const et=B.get(Me);if(et)for(const{edgeId:ht}of et.values()){const Ie=q.get(ht);Ie&&(Ie.selectable??Ue)&&P.current.add(ht)}}if(!U0(be,E.current)){const Me=il(U,E.current,!0);Q(Me)}if(!U0(Fe,P.current)){const Me=il(q,P.current);se(Me)}b.setState({userSelectionRect:pe,userSelectionActive:!0,nodesSelectionActive:!1})},$=A=>{var M,_;A.button===0&&((_=(M=A.target)==null?void 0:M.releasePointerCapture)==null||_.call(M,A.pointerId),!v&&A.target===C.current&&b.getState().userSelectionRect&&(V==null||V(A)),b.setState({userSelectionActive:!1,userSelectionRect:null}),F.current&&(l==null||l(A),b.setState({nodesSelectionActive:E.current.size>0})))},O=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:An(["react-flow__pane",{draggable:O,dragging:w,selection:e}]),onClick:S?void 0:Jm(V,C),onContextMenu:Jm(z,C),onWheel:Jm(D,C),onPointerEnter:S?void 0:f,onPointerMove:S?L:d,onPointerUp:S?$:void 0,onPointerDownCapture:S?T:void 0,onClickCapture:S?R:void 0,onPointerLeave:h,ref:C,style:Ch,children:[g,o.jsx(V3,{})]})}function Gy({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Zs.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):s([e])}function eA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=cn(),[c,u]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=kz({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Gy({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=p.current)==null||f.destroy()}},[n,r,t,i,e,s,a]),c}const q3=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function tA(){const e=cn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:p}=e.getState(),f=new Map,d=q3(a),h=s?i[0]:5,g=s?i[1]:5,b=n.direction.x*h*n.factor,v=n.direction.y*g*n.factor;for(const[,y]of u){if(!d(y))continue;let w={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+v};s&&(w=td(w,i));const{position:x,positionAbsolute:S}=yE({nodeId:y.id,nextPosition:w,nodeLookup:u,nodeExtent:r,nodeOrigin:p,onError:l});y.position=x,y.internals.positionAbsolute=S,f.set(y.id,y)}c(f)},[])}const Bw=m.createContext(null),Y3=Bw.Provider;Bw.Consumer;const nA=()=>m.useContext(Bw),G3=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),J3=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,p=(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:p,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Al.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:p&&u}};function X3({type:e="source",position:t=Le.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:p,onTouchStart:f,...d},h){var L,$;const g=a||null,b=e==="target",v=cn(),y=nA(),{connectOnClick:w,noPanClassName:x,rfId:S}=Pt(G3,fn),{connectingFrom:C,connectingTo:j,clickConnecting:E,isPossibleEndHandle:P,connectionInProcess:F,clickConnectionInProcess:V,valid:z}=Pt(J3(y,g,e),fn);y||($=(L=v.getState()).onError)==null||$.call(L,"010",Zs.error010());const D=O=>{const{defaultEdgeOptions:A,onConnect:M,hasDefaultEdges:_}=v.getState(),U={...A,...O};if(_){const{edges:q,setEdges:B}=v.getState();B(qf(U,q))}M==null||M(U),l==null||l(U)},R=O=>{if(!y)return;const A=jE(O.nativeEvent);if(s&&(A&&O.button===0||!A)){const M=v.getState();qy.onPointerDown(O.nativeEvent,{handleDomNode:O.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:b,handleId:g,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(..._)=>{var U,q;return(q=(U=v.getState()).onConnectEnd)==null?void 0:q.call(U,..._)},updateConnection:M.updateConnection,onConnect:D,isValidConnection:n||((..._)=>{var U,q;return((q=(U=v.getState()).isValidConnection)==null?void 0:q.call(U,..._))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}A?p==null||p(O):f==null||f(O)},T=O=>{const{onClickConnectStart:A,onClickConnectEnd:M,connectionClickStartHandle:_,connectionMode:U,isValidConnection:q,lib:B,rfId:Q,nodeLookup:se,connection:oe}=v.getState();if(!y||!_&&!s)return;if(!_){A==null||A(O.nativeEvent,{nodeId:y,handleId:g,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const ve=SE(O.target),re=n||q,{connection:ue,isValid:te}=qy.isValid(O.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:U,fromNodeId:_.nodeId,fromHandleId:_.id||null,fromType:_.type,isValidConnection:re,flowId:Q,doc:ve,lib:B,nodeLookup:se});te&&ue&&D(ue);const ae=structuredClone(oe);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,M==null||M(O,ae),v.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${S}-${y}-${g}-${e}`,className:An(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:E,connectingfrom:C,connectingto:j,valid:z,connectionindicator:r&&(!F||P)&&(F||V?i:s)}]),onMouseDown:R,onTouchStart:R,onClick:w?T:void 0,ref:h,...d,children:c})}const En=m.memo(QE(X3));function Q3({data:e,isConnectable:t,sourcePosition:n=Le.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(En,{type:"source",position:n,isConnectable:t})]})}function Z3({data:e,isConnectable:t,targetPosition:n=Le.Top,sourcePosition:r=Le.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(En,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(En,{type:"source",position:r,isConnectable:t})]})}function e4(){return null}function t4({data:e,isConnectable:t,targetPosition:n=Le.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(En,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Rp={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},xS={input:Q3,default:Z3,output:t4,group:e4};function n4(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 r4=e=>{const{width:t,height:n,x:r,y:s}=ed(e.nodeLookup,{filter:i=>!!i.selected});return{width:Ns(t)?t:null,height:Ns(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 s4({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=cn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Pt(r4,fn),c=tA(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const p=!l&&s!==null&&i!==null;if(eA({nodeRef:u,disabled:!p}),!p)return null;const f=e?h=>{const g=r.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(Rp,h.key)&&(h.preventDefault(),c({direction:Rp[h.key],factor:h.shiftKey?4:1}))};return o.jsx("div",{className:An(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:s,height:i}})})}const wS=typeof window<"u"?window:void 0,i4=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function rA({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:p,selectionMode:f,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:S,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:E,panOnDrag:P,defaultViewport:F,translateExtent:V,minZoom:z,maxZoom:D,preventScrolling:R,onSelectionContextMenu:T,noWheelClassName:L,noPanClassName:$,disableKeyboardA11y:O,onViewportChange:A,isControlledViewport:M}){const{nodesSelectionActive:_,userSelectionActive:U}=Pt(i4,fn),q=Tu(u,{target:wS}),B=Tu(b,{target:wS}),Q=B||P,se=B||S,oe=p&&Q!==!0,ve=q||U||oe;return F3({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(B3,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:se,panOnScrollSpeed:C,panOnScrollMode:j,zoomOnDoubleClick:E,panOnDrag:!q&&Q,defaultViewport:F,translateExtent:V,minZoom:z,maxZoom:D,zoomActivationKeyCode:v,preventScrolling:R,noWheelClassName:L,noPanClassName:$,onViewportChange:A,isControlledViewport:M,paneClickDistance:l,selectionOnDrag:oe,children:o.jsxs(U3,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:Q,isSelecting:!!ve,selectionMode:f,selectionKeyPressed:q,paneClickDistance:l,selectionOnDrag:oe,children:[e,_&&o.jsx(s4,{onSelectionContextMenu:T,noPanClassName:$,disableKeyboardA11y:O})]})})}rA.displayName="FlowRenderer";const o4=m.memo(rA),a4=e=>t=>e?Rw(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 l4(e){return Pt(m.useCallback(a4(e),[e]),fn)}const c4=e=>e.updateNodeInternals;function u4(){const e=Pt(c4),[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 d4({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=cn(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!p||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const f=u.current!==t,d=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||d||h)&&(u.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 f4({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:p,resizeObserver:f,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:v,nodeClickDistance:y,onError:w}){const{node:x,internals:S,isParent:C}=Pt(re=>{const ue=re.nodeLookup.get(e),te=re.parentLookup.has(e);return{node:ue,internals:ue.internals,isParent:te}},fn);let j=x.type||"default",E=(v==null?void 0:v[j])||xS[j];E===void 0&&(w==null||w("003",Zs.error003(j)),j="default",E=(v==null?void 0:v.default)||xS.default);const P=!!(x.draggable||l&&typeof x.draggable>"u"),F=!!(x.selectable||c&&typeof x.selectable>"u"),V=!!(x.connectable||u&&typeof x.connectable>"u"),z=!!(x.focusable||p&&typeof x.focusable>"u"),D=cn(),R=kE(x),T=d4({node:x,nodeType:j,hasDimensions:R,resizeObserver:f}),L=eA({nodeRef:T,disabled:x.hidden||!P,noDragClassName:d,handleSelector:x.dragHandle,nodeId:e,isSelectable:F,nodeClickDistance:y}),$=tA();if(x.hidden)return null;const O=Ai(x),A=n4(x),M=F||P||t||n||r||s,_=n?re=>n(re,{...S.userNode}):void 0,U=r?re=>r(re,{...S.userNode}):void 0,q=s?re=>s(re,{...S.userNode}):void 0,B=i?re=>i(re,{...S.userNode}):void 0,Q=a?re=>a(re,{...S.userNode}):void 0,se=re=>{const{selectNodesOnDrag:ue,nodeDragThreshold:te}=D.getState();F&&(!ue||!P||te>0)&&Gy({id:e,store:D,nodeRef:T}),t&&t(re,{...S.userNode})},oe=re=>{if(!(NE(re.nativeEvent)||g)){if(fE.includes(re.key)&&F){const ue=re.key==="Escape";Gy({id:e,store:D,unselect:ue,nodeRef:T})}else if(P&&x.selected&&Object.prototype.hasOwnProperty.call(Rp,re.key)){re.preventDefault();const{ariaLabelConfig:ue}=D.getState();D.setState({ariaLiveMessage:ue["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~S.positionAbsolute.x,y:~~S.positionAbsolute.y})}),$({direction:Rp[re.key],factor:re.shiftKey?4:1})}}},ve=()=>{var Fe;if(g||!((Fe=T.current)!=null&&Fe.matches(":focus-visible")))return;const{transform:re,width:ue,height:te,autoPanOnNodeFocus:ae,setCenter:pe}=D.getState();if(!ae)return;Rw(new Map([[e,x]]),{x:0,y:0,width:ue,height:te},re,!0).length>0||pe(x.position.x+O.width/2,x.position.y+O.height/2,{zoom:re[2]})};return o.jsx("div",{className:An(["react-flow__node",`react-flow__node-${j}`,{[h]:P},x.className,{selected:x.selected,selectable:F,parent:C,draggable:P,dragging:L}]),ref:T,style:{zIndex:S.z,transform:`translate(${S.positionAbsolute.x}px,${S.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:R?"visible":"hidden",...x.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:_,onMouseMove:U,onMouseLeave:q,onContextMenu:B,onClick:se,onDoubleClick:Q,onKeyDown:z?oe:void 0,tabIndex:z?0:void 0,onFocus:z?ve:void 0,role:x.ariaRole??(z?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${YE}-${b}`,"aria-label":x.ariaLabel,...x.domAttributes,children:o.jsx(Y3,{value:e,children:o.jsx(E,{id:e,data:x.data,type:j,positionAbsoluteX:S.positionAbsolute.x,positionAbsoluteY:S.positionAbsolute.y,selected:x.selected??!1,selectable:F,draggable:P,deletable:x.deletable??!0,isConnectable:V,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:L,dragHandle:x.dragHandle,zIndex:S.z,parentId:x.parentId,...O})})})}var p4=m.memo(f4);const h4=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function sA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Pt(h4,fn),a=l4(e.onlyRenderVisibleElements),l=u4();return o.jsx("div",{className:"react-flow__nodes",style:Ch,children:a.map(c=>o.jsx(p4,{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))})}sA.displayName="NodeRenderer";const m4=m.memo(sA);function g4(e){return Pt(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&&rz({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),fn)}const y4=({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"})},x4=({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"})},bS={[Ks.Arrow]:y4,[Ks.ArrowClosed]:x4};function w4(e){const t=cn();return m.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(bS,e)?bS[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Zs.error009(e)),null)},[e])}const b4=({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=w4(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},iA=({defaultColor:e,rfId:t})=>{const n=Pt(i=>i.edges),r=Pt(i=>i.defaultEdgeOptions),s=m.useMemo(()=>uz(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(b4,{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};iA.displayName="MarkerDefinitions";var k4=m.memo(iA);function oA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...p}){const[f,d]=m.useState({x:1,y:0,width:0,height:0}),h=An(["react-flow__edge-textwrapper",u]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const b=g.current.getBBox();d({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...p,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}oA.displayName="EdgeText";const v4=m.memo(oA);function _h({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...p}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...p,d:e,fill:"none",className:An(["react-flow__edge-path",p.className])}),u?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&Ns(t)&&Ns(n)?o.jsx(v4,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function kS({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Le.Left||e===Le.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function aA({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:i=Le.Top}){const[a,l]=kS({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=kS({pos:i,x1:r,y1:s,x2:e,y2:t}),[p,f,d,h]=CE({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,p,f,d,h]}function lA(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:v,interactionWidth:y})=>{const[w,x,S]=aA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),C=e.isInternal?void 0:t;return o.jsx(_h,{id:C,path:w,labelX:x,labelY:S,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:v,interactionWidth:y})})}const S4=lA({isInternal:!1}),cA=lA({isInternal:!0});S4.displayName="SimpleBezierEdge";cA.displayName="SimpleBezierEdgeInternal";function uA(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,sourcePosition:h=Le.Bottom,targetPosition:g=Le.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:w})=>{const[x,S,C]=Vy({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}),j=e.isInternal?void 0:t;return o.jsx(_h,{id:j,path:x,labelX:S,labelY:C,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:b,markerStart:v,interactionWidth:w})})}const dA=uA({isInternal:!1}),fA=uA({isInternal:!0});dA.displayName="SmoothStepEdge";fA.displayName="SmoothStepEdgeInternal";function pA(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(dA,{...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 N4=pA({isInternal:!1}),hA=pA({isInternal:!0});N4.displayName="StepEdge";hA.displayName="StepEdgeInternal";function mA(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[v,y,w]=AE({sourceX:n,sourceY:r,targetX:s,targetY:i}),x=e.isInternal?void 0:t;return o.jsx(_h,{id:x,path:v,labelX:y,labelY:w,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:g,interactionWidth:b})})}const j4=mA({isInternal:!1}),gA=mA({isInternal:!0});j4.displayName="StraightEdge";gA.displayName="StraightEdgeInternal";function yA(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Le.Bottom,targetPosition:l=Le.Top,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:w})=>{const[x,S,C]=_E({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),j=e.isInternal?void 0:t;return o.jsx(_h,{id:j,path:x,labelX:S,labelY:C,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:v,interactionWidth:w})})}const C4=yA({isInternal:!1}),xA=yA({isInternal:!0});C4.displayName="BezierEdge";xA.displayName="BezierEdgeInternal";const vS={default:xA,straight:gA,step:hA,smoothstep:fA,simplebezier:cA},SS={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},_4=(e,t,n)=>n===Le.Left?e-t:n===Le.Right?e+t:e,E4=(e,t,n)=>n===Le.Top?e-t:n===Le.Bottom?e+t:e,NS="react-flow__edgeupdater";function jS({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:An([NS,`${NS}-${l}`]),cx:_4(t,r,e),cy:E4(n,r,e),r,stroke:"transparent",fill:"transparent"})}function A4({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,setReconnecting:d,setUpdateHover:h}){const g=cn(),b=(S,C)=>{if(S.button!==0)return;const{autoPanOnConnect:j,domNode:E,connectionMode:P,connectionRadius:F,lib:V,onConnectStart:z,cancelConnection:D,nodeLookup:R,rfId:T,panBy:L,updateConnection:$}=g.getState(),O=C.type==="target",A=(U,q)=>{d(!1),f==null||f(U,n,C.type,q)},M=U=>u==null?void 0:u(n,U),_=(U,q)=>{d(!0),p==null||p(S,n,C.type),z==null||z(U,q)};qy.onPointerDown(S.nativeEvent,{autoPanOnConnect:j,connectionMode:P,connectionRadius:F,domNode:E,handleId:C.id,nodeId:C.nodeId,nodeLookup:R,isTarget:O,edgeUpdaterType:C.type,lib:V,flowId:T,cancelConnection:D,panBy:L,isValidConnection:(...U)=>{var q,B;return((B=(q=g.getState()).isValidConnection)==null?void 0:B.call(q,...U))??!0},onConnect:M,onConnectStart:_,onConnectEnd:(...U)=>{var q,B;return(B=(q=g.getState()).onConnectEnd)==null?void 0:B.call(q,...U)},onReconnectEnd:A,updateConnection:$,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:S.currentTarget})},v=S=>b(S,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=S=>b(S,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>h(!0),x=()=>h(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(jS,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&o.jsx(jS,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:w,onMouseOut:x,type:"target"})]})}function P4({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:v,onError:y,disableKeyboardA11y:w}){let x=Pt(pe=>pe.edgeLookup.get(e));const S=Pt(pe=>pe.defaultEdgeOptions);x=S?{...S,...x}:x;let C=x.type||"default",j=(b==null?void 0:b[C])||vS[C];j===void 0&&(y==null||y("011",Zs.error011(C)),C="default",j=(b==null?void 0:b.default)||vS.default);const E=!!(x.focusable||t&&typeof x.focusable>"u"),P=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),F=!!(x.selectable||r&&typeof x.selectable>"u"),V=m.useRef(null),[z,D]=m.useState(!1),[R,T]=m.useState(!1),L=cn(),{zIndex:$,sourceX:O,sourceY:A,targetX:M,targetY:_,sourcePosition:U,targetPosition:q}=Pt(m.useCallback(pe=>{const be=pe.nodeLookup.get(x.source),Fe=pe.nodeLookup.get(x.target);if(!be||!Fe)return{zIndex:x.zIndex,...SS};const Ue=cz({id:e,sourceNode:be,targetNode:Fe,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:pe.connectionMode,onError:y});return{zIndex:nz({selected:x.selected,zIndex:x.zIndex,sourceNode:be,targetNode:Fe,elevateOnSelect:pe.elevateEdgesOnSelect,zIndexMode:pe.zIndexMode}),...Ue||SS}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),fn),B=m.useMemo(()=>x.markerStart?`url('#${Ky(x.markerStart,g)}')`:void 0,[x.markerStart,g]),Q=m.useMemo(()=>x.markerEnd?`url('#${Ky(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||O===null||A===null||M===null||_===null)return null;const se=pe=>{var Me;const{addSelectedEdges:be,unselectNodesAndEdges:Fe,multiSelectionActive:Ue}=L.getState();F&&(L.setState({nodesSelectionActive:!1}),x.selected&&Ue?(Fe({nodes:[],edges:[x]}),(Me=V.current)==null||Me.blur()):be([e])),s&&s(pe,x)},oe=i?pe=>{i(pe,{...x})}:void 0,ve=a?pe=>{a(pe,{...x})}:void 0,re=l?pe=>{l(pe,{...x})}:void 0,ue=c?pe=>{c(pe,{...x})}:void 0,te=u?pe=>{u(pe,{...x})}:void 0,ae=pe=>{var be;if(!w&&fE.includes(pe.key)&&F){const{unselectNodesAndEdges:Fe,addSelectedEdges:Ue}=L.getState();pe.key==="Escape"?((be=V.current)==null||be.blur(),Fe({edges:[x]})):Ue([e])}};return o.jsx("svg",{style:{zIndex:$},children:o.jsxs("g",{className:An(["react-flow__edge",`react-flow__edge-${C}`,x.className,v,{selected:x.selected,animated:x.animated,inactive:!F&&!s,updating:z,selectable:F}]),onClick:se,onDoubleClick:oe,onContextMenu:ve,onMouseEnter:re,onMouseMove:ue,onMouseLeave:te,onKeyDown:E?ae:void 0,tabIndex:E?0:void 0,role:x.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":E?`${GE}-${g}`:void 0,ref:V,...x.domAttributes,children:[!R&&o.jsx(j,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:F,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:O,sourceY:A,targetX:M,targetY:_,sourcePosition:U,targetPosition:q,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:B,markerEnd:Q,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),P&&o.jsx(A4,{edge:x,isReconnectable:P,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,sourceX:O,sourceY:A,targetX:M,targetY:_,sourcePosition:U,targetPosition:q,setUpdateHover:D,setReconnecting:T})]})})}var I4=m.memo(P4);const T4=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function wA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:p,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:w,onError:x}=Pt(T4,fn),S=g4(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(k4,{defaultColor:e,rfId:n}),S.map(C=>o.jsx(I4,{id:C,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:w,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:p,reconnectRadius:f,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:b},C))]})}wA.displayName="EdgeRenderer";const R4=m.memo(wA),M4=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function $4({children:e}){const t=Pt(M4);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function L4(e){const t=Hl(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const O4=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function D4(e){const t=Pt(O4),n=cn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function F4(e){return e.connection.inProgress?{...e.connection,to:nd(e.connection.to,e.transform)}:{...e.connection}}function z4(e){return F4}function H4(e){const t=z4();return Pt(t,fn)}const B4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function W4({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Pt(B4,fn);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:An(["react-flow__connection",mE(l)]),children:o.jsx(bA,{style:t,type:n,CustomComponent:r,isValid:l})})})}const bA=({style:e,type:t=Qi.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:p,toHandle:f,toPosition:d,pointer:h}=H4();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:d,connectionStatus:mE(r),toNode:p,toHandle:f,pointer:h});let g="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Qi.Bezier:[g]=_E(b);break;case Qi.SimpleBezier:[g]=aA(b);break;case Qi.Step:[g]=Vy({...b,borderRadius:0});break;case Qi.SmoothStep:[g]=Vy(b);break;default:[g]=AE(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};bA.displayName="ConnectionLine";const V4={};function CS(e=V4){m.useRef(e),cn(),m.useEffect(()=>{},[e])}function K4(){cn(),m.useRef(!1),m.useEffect(()=>{},[])}function kA({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:w,selectionOnDrag:x,selectionMode:S,multiSelectionKeyCode:C,panActivationKeyCode:j,zoomActivationKeyCode:E,deleteKeyCode:P,onlyRenderVisibleElements:F,elementsSelectable:V,defaultViewport:z,translateExtent:D,minZoom:R,maxZoom:T,preventScrolling:L,defaultMarkerColor:$,zoomOnScroll:O,zoomOnPinch:A,panOnScroll:M,panOnScrollSpeed:_,panOnScrollMode:U,zoomOnDoubleClick:q,panOnDrag:B,onPaneClick:Q,onPaneMouseEnter:se,onPaneMouseMove:oe,onPaneMouseLeave:ve,onPaneScroll:re,onPaneContextMenu:ue,paneClickDistance:te,nodeClickDistance:ae,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:Fe,onEdgeMouseLeave:Ue,reconnectRadius:Me,onReconnect:et,onReconnectStart:ht,onReconnectEnd:Ie,noDragClassName:tt,noWheelClassName:Wt,noPanClassName:$e,disableKeyboardA11y:Vt,nodeExtent:Gt,rfId:nt,viewport:ie,onViewportChange:ke}){return CS(e),CS(t),K4(),L4(n),D4(ie),o.jsx(o4,{onPaneClick:Q,onPaneMouseEnter:se,onPaneMouseMove:oe,onPaneMouseLeave:ve,onPaneContextMenu:ue,onPaneScroll:re,paneClickDistance:te,deleteKeyCode:P,selectionKeyCode:w,selectionOnDrag:x,selectionMode:S,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:C,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:V,zoomOnScroll:O,zoomOnPinch:A,zoomOnDoubleClick:q,panOnScroll:M,panOnScrollSpeed:_,panOnScrollMode:U,panOnDrag:B,defaultViewport:z,translateExtent:D,minZoom:R,maxZoom:T,onSelectionContextMenu:f,preventScrolling:L,noDragClassName:tt,noWheelClassName:Wt,noPanClassName:$e,disableKeyboardA11y:Vt,onViewportChange:ke,isControlledViewport:!!ie,children:o.jsxs($4,{children:[o.jsx(R4,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:et,onReconnectStart:ht,onReconnectEnd:Ie,onlyRenderVisibleElements:F,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:Fe,onEdgeMouseLeave:Ue,reconnectRadius:Me,defaultMarkerColor:$,noPanClassName:$e,disableKeyboardA11y:Vt,rfId:nt}),o.jsx(W4,{style:b,type:g,component:v,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(m4,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,nodeClickDistance:ae,onlyRenderVisibleElements:F,noPanClassName:$e,noDragClassName:tt,disableKeyboardA11y:Vt,nodeExtent:Gt,rfId:nt}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}kA.displayName="GraphView";const U4=m.memo(kA),_S=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:p,nodeExtent:f,zIndexMode:d="basic"}={})=>{const h=new Map,g=new Map,b=new Map,v=new Map,y=r??t??[],w=n??e??[],x=p??[0,0],S=f??Eu;TE(b,v,y);const{nodesInitialized:C}=Uy(w,h,g,{nodeOrigin:x,nodeExtent:S,zIndexMode:d});let j=[0,0,1];if(a&&s&&i){const E=ed(h,{filter:z=>!!((z.width||z.initialWidth)&&(z.height||z.initialHeight))}),{x:P,y:F,zoom:V}=Mw(E,s,i,c,u,(l==null?void 0:l.padding)??.1);j=[P,F,V]}return{rfId:"1",width:s??0,height:i??0,transform:j,nodes:w,nodesInitialized:C,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:Eu,nodeExtent:S,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Al.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,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:{...hE},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JF,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:pE,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},q4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d})=>f3((h,g)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:w,fitViewResolver:x,width:S,height:C,minZoom:j,maxZoom:E}=g();y&&(await YF({nodes:v,width:S,height:C,panZoom:y,minZoom:j,maxZoom:E},w),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{..._S({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:v=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:x,elevateNodesOnSelect:S,fitViewQueued:C,zIndexMode:j,nodesSelectionActive:E}=g(),{nodesInitialized:P,hasSelectedNodes:F}=Uy(v,y,w,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:S,checkEquality:!0,zIndexMode:j}),V=E&&F;C&&P?(b(),h({nodes:v,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:V})):h({nodes:v,nodesInitialized:P,nodesSelectionActive:V})},setEdges:v=>{const{connectionLookup:y,edgeLookup:w}=g();TE(y,w,v),h({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:w}=g();w(v),h({hasDefaultNodes:!0})}if(y){const{setEdges:w}=g();w(y),h({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:x,domNode:S,nodeOrigin:C,nodeExtent:j,debug:E,fitViewQueued:P,zIndexMode:F}=g(),{changes:V,updatedInternals:z}=yz(v,w,x,S,C,j,F);z&&(pz(w,x,{nodeOrigin:C,nodeExtent:j,zIndexMode:F}),P?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(V==null?void 0:V.length)>0&&(E&&console.log("React Flow: trigger node changes",V),y==null||y(V)))},updateNodePositions:(v,y=!1)=>{const w=[];let x=[];const{nodeLookup:S,triggerNodeChanges:C,connection:j,updateConnection:E,onNodesChangeMiddlewareMap:P}=g();for(const[F,V]of v){const z=S.get(F),D=!!(z!=null&&z.expandParent&&(z!=null&&z.parentId)&&(V!=null&&V.position)),R={id:F,type:"position",position:D?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:y};if(z&&j.inProgress&&j.fromNode.id===z.id){const T=aa(z,j.fromHandle,Le.Left,!0);E({...j,from:T})}D&&z.parentId&&w.push({id:F,parentId:z.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),x.push(R)}if(w.length>0){const{parentLookup:F,nodeOrigin:V}=g(),z=zw(w,S,F,V);x.push(...z)}for(const F of P.values())x=F(x);C(x)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:w,nodes:x,hasDefaultNodes:S,debug:C}=g();if(v!=null&&v.length){if(S){const j=Tp(v,x);w(j)}C&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:w,edges:x,hasDefaultEdges:S,debug:C}=g();if(v!=null&&v.length){if(S){const j=Hw(v,x);w(j)}C&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:x,triggerNodeChanges:S,triggerEdgeChanges:C}=g();if(y){const j=v.map(E=>$o(E,!0));S(j);return}S(il(x,new Set([...v]),!0)),C(il(w))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:x,triggerNodeChanges:S,triggerEdgeChanges:C}=g();if(y){const j=v.map(E=>$o(E,!0));C(j);return}C(il(w,new Set([...v]))),S(il(x,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:w,nodes:x,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:j}=g(),E=v||x,P=y||w,F=[];for(const z of E){if(!z.selected)continue;const D=S.get(z.id);D&&(D.selected=!1),F.push($o(z.id,!1))}const V=[];for(const z of P)z.selected&&V.push($o(z.id,!1));C(F),j(V)},setMinZoom:v=>{const{panZoom:y,maxZoom:w}=g();y==null||y.setScaleExtent([v,w]),h({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:w}=g();y==null||y.setScaleExtent([w,v]),h({maxZoom:v})},setTranslateExtent:v=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(v),h({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:x,elementsSelectable:S}=g();if(!S)return;const C=y.reduce((E,P)=>P.selected?[...E,$o(P.id,!1)]:E,[]),j=v.reduce((E,P)=>P.selected?[...E,$o(P.id,!1)]:E,[]);w(C),x(j)},setNodeExtent:v=>{const{nodes:y,nodeLookup:w,parentLookup:x,nodeOrigin:S,elevateNodesOnSelect:C,nodeExtent:j,zIndexMode:E}=g();v[0][0]===j[0][0]&&v[0][1]===j[0][1]&&v[1][0]===j[1][0]&&v[1][1]===j[1][1]||(Uy(y,w,x,{nodeOrigin:S,nodeExtent:v,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:E}),h({nodeExtent:v}))},panBy:v=>{const{transform:y,width:w,height:x,panZoom:S,translateExtent:C}=g();return xz({delta:v,panZoom:S,transform:y,translateExtent:C,width:w,height:x})},setCenter:async(v,y,w)=>{const{width:x,height:S,maxZoom:C,panZoom:j}=g();if(!j)return Promise.resolve(!1);const E=typeof(w==null?void 0:w.zoom)<"u"?w.zoom:C;return await j.setViewport({x:x/2-v*E,y:S/2-y*E,zoom:E},{duration:w==null?void 0:w.duration,ease:w==null?void 0:w.ease,interpolate:w==null?void 0:w.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...hE}})},updateConnection:v=>{h({connection:v})},reset:()=>h({..._S()})}},Object.is);function Ww({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d,children:h}){const[g]=m.useState(()=>q4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:p,nodeExtent:f,zIndexMode:d}));return o.jsx(p3,{value:g,children:o.jsx($3,{children:h})})}function Y4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h}){return m.useContext(Nh)?o.jsx(o.Fragment,{children:e}):o.jsx(Ww,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h,children:e})}const G4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function J4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:p,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:w,onNodeMouseMove:x,onNodeMouseLeave:S,onNodeContextMenu:C,onNodeDoubleClick:j,onNodeDragStart:E,onNodeDrag:P,onNodeDragStop:F,onNodesDelete:V,onEdgesDelete:z,onDelete:D,onSelectionChange:R,onSelectionDragStart:T,onSelectionDrag:L,onSelectionDragStop:$,onSelectionContextMenu:O,onSelectionStart:A,onSelectionEnd:M,onBeforeDelete:_,connectionMode:U,connectionLineType:q=Qi.Bezier,connectionLineStyle:B,connectionLineComponent:Q,connectionLineContainerStyle:se,deleteKeyCode:oe="Backspace",selectionKeyCode:ve="Shift",selectionOnDrag:re=!1,selectionMode:ue=Au.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:ae=Iu()?"Meta":"Control",zoomActivationKeyCode:pe=Iu()?"Meta":"Control",snapToGrid:be,snapGrid:Fe,onlyRenderVisibleElements:Ue=!1,selectNodesOnDrag:Me,nodesDraggable:et,autoPanOnNodeFocus:ht,nodesConnectable:Ie,nodesFocusable:tt,nodeOrigin:Wt=JE,edgesFocusable:$e,edgesReconnectable:Vt,elementsSelectable:Gt=!0,defaultViewport:nt=C3,minZoom:ie=.5,maxZoom:ke=2,translateExtent:Oe=Eu,preventScrolling:We=!0,nodeExtent:Je,defaultMarkerColor:vt="#b1b1b7",zoomOnScroll:ee=!0,zoomOnPinch:ye=!0,panOnScroll:Ve=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:at=Go.Free,zoomOnDoubleClick:mt=!0,panOnDrag:Qt=!0,onPaneClick:hr,onPaneMouseEnter:Ln,onPaneMouseMove:On,onPaneMouseLeave:Nn,onPaneScroll:Zt,onPaneContextMenu:Kn,paneClickDistance:pn=1,nodeClickDistance:Pn=0,children:jn,onReconnect:Dn,onReconnectStart:Er,onReconnectEnd:Fn,onEdgeContextMenu:si,onEdgeDoubleClick:mr,onEdgeMouseEnter:Ur,onEdgeMouseMove:Ar,onEdgeMouseLeave:ss,reconnectRadius:In=10,onNodesChange:gr,onEdgesChange:rr,noDragClassName:Ms="nodrag",noWheelClassName:Pr="nowheel",noPanClassName:zt="nopan",fitView:ne,fitViewOptions:we,connectOnClick:Z,attributionPosition:ge,proOptions:Ae,defaultEdgeOptions:bt,elevateNodesOnSelect:Ct=!0,elevateEdgesOnSelect:Kt=!1,disableKeyboardA11y:qe=!1,autoPanOnConnect:Ot,autoPanOnNodeDrag:Pe,autoPanSpeed:Ut,connectionRadius:Xe,isValidConnection:Ir,onError:is,style:os,id:jo,nodeDragThreshold:ya,connectionDragThreshold:Jl,viewport:Se,onViewportChange:Xl,width:Ti,height:xa,colorMode:wa="light",debug:as,onScroll:ls,ariaLabelConfig:Ri,zIndexMode:W="basic",...de},Te){const _e=jo||"1",Qe=P3(wa),Jt=m.useCallback(_t=>{_t.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ls==null||ls(_t)},[ls]);return o.jsx("div",{"data-testid":"rf__wrapper",...de,onScroll:Jt,style:{...os,...G4},ref:Te,className:An(["react-flow",s,Qe]),id:jo,role:"application",children:o.jsxs(Y4,{nodes:e,edges:t,width:Ti,height:xa,fitView:ne,fitViewOptions:we,minZoom:ie,maxZoom:ke,nodeOrigin:Wt,nodeExtent:Je,zIndexMode:W,children:[o.jsx(A3,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:et,autoPanOnNodeFocus:ht,nodesConnectable:Ie,nodesFocusable:tt,edgesFocusable:$e,edgesReconnectable:Vt,elementsSelectable:Gt,elevateNodesOnSelect:Ct,elevateEdgesOnSelect:Kt,minZoom:ie,maxZoom:ke,nodeExtent:Je,onNodesChange:gr,onEdgesChange:rr,snapToGrid:be,snapGrid:Fe,connectionMode:U,translateExtent:Oe,connectOnClick:Z,defaultEdgeOptions:bt,fitView:ne,fitViewOptions:we,onNodesDelete:V,onEdgesDelete:z,onDelete:D,onNodeDragStart:E,onNodeDrag:P,onNodeDragStop:F,onSelectionDrag:L,onSelectionDragStart:T,onSelectionDragStop:$,onMove:p,onMoveStart:f,onMoveEnd:d,noPanClassName:zt,nodeOrigin:Wt,rfId:_e,autoPanOnConnect:Ot,autoPanOnNodeDrag:Pe,autoPanSpeed:Ut,onError:is,connectionRadius:Xe,isValidConnection:Ir,selectNodesOnDrag:Me,nodeDragThreshold:ya,connectionDragThreshold:Jl,onBeforeDelete:_,debug:as,ariaLabelConfig:Ri,zIndexMode:W}),o.jsx(U4,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:x,onNodeMouseLeave:S,onNodeContextMenu:C,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:a,connectionLineType:q,connectionLineStyle:B,connectionLineComponent:Q,connectionLineContainerStyle:se,selectionKeyCode:ve,selectionOnDrag:re,selectionMode:ue,deleteKeyCode:oe,multiSelectionKeyCode:ae,panActivationKeyCode:te,zoomActivationKeyCode:pe,onlyRenderVisibleElements:Ue,defaultViewport:nt,translateExtent:Oe,minZoom:ie,maxZoom:ke,preventScrolling:We,zoomOnScroll:ee,zoomOnPinch:ye,zoomOnDoubleClick:mt,panOnScroll:Ve,panOnScrollSpeed:Ce,panOnScrollMode:at,panOnDrag:Qt,onPaneClick:hr,onPaneMouseEnter:Ln,onPaneMouseMove:On,onPaneMouseLeave:Nn,onPaneScroll:Zt,onPaneContextMenu:Kn,paneClickDistance:pn,nodeClickDistance:Pn,onSelectionContextMenu:O,onSelectionStart:A,onSelectionEnd:M,onReconnect:Dn,onReconnectStart:Er,onReconnectEnd:Fn,onEdgeContextMenu:si,onEdgeDoubleClick:mr,onEdgeMouseEnter:Ur,onEdgeMouseMove:Ar,onEdgeMouseLeave:ss,reconnectRadius:In,defaultMarkerColor:vt,noDragClassName:Ms,noWheelClassName:Pr,noPanClassName:zt,rfId:_e,disableKeyboardA11y:qe,nodeExtent:Je,viewport:Se,onViewportChange:Xl}),o.jsx(j3,{onSelectionChange:R}),jn,o.jsx(b3,{proOptions:Ae,position:ge}),o.jsx(w3,{rfId:_e,disableKeyboardA11y:qe})]})})}var vA=QE(J4);function X4(){const e=cn();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 Q4(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Tp(s,i)),[]);return[t,n,r]}function Z4(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Hw(s,i)),[]);return[t,n,r]}function e5({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:An(["react-flow__background-pattern",n,r])})}function t5({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:An(["react-flow__background-pattern","dots",t])})}var fo;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(fo||(fo={}));const n5={[fo.Dots]:1,[fo.Lines]:1,[fo.Cross]:6},r5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function SA({id:e,variant:t=fo.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:u,patternClassName:p}){const f=m.useRef(null),{transform:d,patternId:h}=Pt(r5,fn),g=r||n5[t],b=t===fo.Dots,v=t===fo.Cross,y=Array.isArray(n)?n:[n,n],w=[y[0]*d[2]||1,y[1]*d[2]||1],x=g*d[2],S=Array.isArray(i)?i:[i,i],C=v?[x,x]:w,j=[S[0]*d[2]||1+C[0]/2,S[1]*d[2]||1+C[1]/2],E=`${h}${e||""}`;return o.jsxs("svg",{className:An(["react-flow__background",u]),style:{...c,...Ch,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[o.jsx("pattern",{id:E,x:d[0]%w[0],y:d[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:b?o.jsx(t5,{radius:x/2,className:p}):o.jsx(e5,{dimensions:C,lineWidth:s,variant:t,className:p})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}SA.displayName="Background";const NA=m.memo(SA);function s5(){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 i5(){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 o5(){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 a5(){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 l5(){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 ff({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:An(["react-flow__controls-button",t]),...n,children:e})}const c5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function jA({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:p,position:f="bottom-left",orientation:d="vertical","aria-label":h}){const g=cn(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:w}=Pt(c5,fn),{zoomIn:x,zoomOut:S,fitView:C}=Hl(),j=()=>{x(),i==null||i()},E=()=>{S(),a==null||a()},P=()=>{C(s),l==null||l()},F=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},V=d==="horizontal"?"horizontal":"vertical";return o.jsxs(jh,{className:An(["react-flow__controls",V,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??w["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(ff,{onClick:j,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(s5,{})}),o.jsx(ff,{onClick:E,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:v,children:o.jsx(i5,{})})]}),n&&o.jsx(ff,{className:"react-flow__controls-fitview",onClick:P,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:o.jsx(o5,{})}),r&&o.jsx(ff,{className:"react-flow__controls-interactive",onClick:F,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:b?o.jsx(l5,{}):o.jsx(a5,{})}),p]})}jA.displayName="Controls";m.memo(jA);function u5({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:p,shapeRendering:f,selected:d,onClick:h}){const{background:g,backgroundColor:b}=i||{},v=a||g||b;return o.jsx("rect",{className:An(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:p,ry:p,width:r,height:s,style:{fill:v,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?y=>h(y,e):void 0})}const d5=m.memo(u5),f5=e=>e.nodes.map(t=>t.id),Xm=e=>e instanceof Function?e:()=>e;function p5({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=d5,onClick:a}){const l=Pt(f5,fn),c=Xm(t),u=Xm(e),p=Xm(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(d=>o.jsx(m5,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:f},d))})}function h5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:p,y:f,width:d,height:h}=Pt(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:y,y:w}=b.internals.positionAbsolute,{width:x,height:S}=Ai(v);return{node:v,x:y,y:w,width:x,height:S}},fn);return!u||u.hidden||!kE(u)?null:o.jsx(l,{x:p,y:f,width:d,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:a,onClick:c,id:u.id})}const m5=m.memo(h5);var g5=m.memo(p5);const y5=200,x5=150,w5=e=>!e.hidden,b5=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?bE(ed(e.nodeLookup,{filter:w5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},k5="react-flow__minimap-desc";function CA({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:p,maskStrokeWidth:f,position:d="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:v=!1,ariaLabel:y,inversePan:w,zoomStep:x=1,offsetScale:S=5}){const C=cn(),j=m.useRef(null),{boundingRect:E,viewBB:P,rfId:F,panZoom:V,translateExtent:z,flowWidth:D,flowHeight:R,ariaLabelConfig:T}=Pt(b5,fn),L=(e==null?void 0:e.width)??y5,$=(e==null?void 0:e.height)??x5,O=E.width/L,A=E.height/$,M=Math.max(O,A),_=M*L,U=M*$,q=S*M,B=E.x-(_-E.width)/2-q,Q=E.y-(U-E.height)/2-q,se=_+q*2,oe=U+q*2,ve=`${k5}-${F}`,re=m.useRef(0),ue=m.useRef();re.current=M,m.useEffect(()=>{if(j.current&&V)return ue.current=_z({domNode:j.current,panZoom:V,getTransform:()=>C.getState().transform,getViewScale:()=>re.current}),()=>{var be;(be=ue.current)==null||be.destroy()}},[V]),m.useEffect(()=>{var be;(be=ue.current)==null||be.update({translateExtent:z,width:D,height:R,inversePan:w,pannable:b,zoomStep:x,zoomable:v})},[b,v,w,x,z,D,R]);const te=h?be=>{var Me;const[Fe,Ue]=((Me=ue.current)==null?void 0:Me.pointer(be))||[0,0];h(be,{x:Fe,y:Ue})}:void 0,ae=g?m.useCallback((be,Fe)=>{const Ue=C.getState().nodeLookup.get(Fe).internals.userNode;g(be,Ue)},[]):void 0,pe=y??T["minimap.ariaLabel"];return o.jsx(jh,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*M: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:An(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:L,height:$,viewBox:`${B} ${Q} ${se} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ve,ref:j,onClick:te,children:[pe&&o.jsx("title",{id:ve,children:pe}),o.jsx(g5,{onClick:ae,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-q},${Q-q}h${se+q*2}v${oe+q*2}h${-se-q*2}z
66
- M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}CA.displayName="MiniMap";m.memo(CA);const v5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,S5={[Rl.Line]:"right",[Rl.Handle]:"bottom-right"};function N5({nodeId:e,position:t,variant:n=Rl.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:v,onResizeEnd:y}){const w=nA(),x=typeof e=="string"?e:w,S=cn(),C=m.useRef(null),j=n===Rl.Handle,E=Pt(m.useCallback(v5(j&&h),[j,h]),fn),P=m.useRef(null),F=t??S5[n];m.useEffect(()=>{if(!(!C.current||!x))return P.current||(P.current=Hz({domNode:C.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:z,transform:D,snapGrid:R,snapToGrid:T,nodeOrigin:L,domNode:$}=S.getState();return{nodeLookup:z,transform:D,snapGrid:R,snapToGrid:T,nodeOrigin:L,paneDomNode:$}},onChange:(z,D)=>{const{triggerNodeChanges:R,nodeLookup:T,parentLookup:L,nodeOrigin:$}=S.getState(),O=[],A={x:z.x,y:z.y},M=T.get(x);if(M&&M.expandParent&&M.parentId){const _=M.origin??$,U=z.width??M.measured.width??0,q=z.height??M.measured.height??0,B={id:M.id,parentId:M.parentId,rect:{width:U,height:q,...vE({x:z.x??M.position.x,y:z.y??M.position.y},{width:U,height:q},M.parentId,T,_)}},Q=zw([B],T,L,$);O.push(...Q),A.x=z.x?Math.max(_[0]*U,z.x):void 0,A.y=z.y?Math.max(_[1]*q,z.y):void 0}if(A.x!==void 0&&A.y!==void 0){const _={id:x,type:"position",position:{...A}};O.push(_)}if(z.width!==void 0&&z.height!==void 0){const U={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:z.width,height:z.height}};O.push(U)}for(const _ of D){const U={..._,type:"position"};O.push(U)}R(O)},onEnd:({width:z,height:D})=>{const R={id:x,type:"dimensions",resizing:!1,dimensions:{width:z,height:D}};S.getState().triggerNodeChanges([R])}})),P.current.update({controlPosition:F,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:p},keepAspectRatio:f,resizeDirection:d,onResizeStart:b,onResize:v,onResizeEnd:y,shouldResize:g}),()=>{var z;(z=P.current)==null||z.destroy()}},[F,l,c,u,p,f,b,v,y,g]);const V=F.split("-");return o.jsx("div",{className:An(["react-flow__resize-control","nodrag",...V,n,r]),ref:C,style:{...s,scale:E,...a&&{[j?"backgroundColor":"borderColor"]:a}},children:i})}const Vw=m.memo(N5),j5="modulepreload",C5=function(e){return"/"+e},ES={},_5=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=C5(c),c in ES)return;ES[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":j5,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),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)})};function E5(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const A5=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,P5=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,I5={};function AS(e,t){return(I5.jsx?P5:A5).test(e)}const T5=/[ \t\n\f\r]/g;function R5(e){return typeof e=="object"?e.type==="text"?PS(e.value):!1:PS(e)}function PS(e){return e.replace(T5,"")===""}class rd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}rd.prototype.normal={};rd.prototype.property={};rd.prototype.space=void 0;function _A(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new rd(n,r,t)}function Jy(e){return e.toLowerCase()}class _r{constructor(t,n){this.attribute=n,this.property=t}}_r.prototype.attribute="";_r.prototype.booleanish=!1;_r.prototype.boolean=!1;_r.prototype.commaOrSpaceSeparated=!1;_r.prototype.commaSeparated=!1;_r.prototype.defined=!1;_r.prototype.mustUseProperty=!1;_r.prototype.number=!1;_r.prototype.overloadedBoolean=!1;_r.prototype.property="";_r.prototype.spaceSeparated=!1;_r.prototype.space=void 0;let M5=0;const yt=ga(),Cn=ga(),Xy=ga(),je=ga(),tn=ga(),gl=ga(),Mr=ga();function ga(){return 2**++M5}const Qy=Object.freeze(Object.defineProperty({__proto__:null,boolean:yt,booleanish:Cn,commaOrSpaceSeparated:Mr,commaSeparated:gl,number:je,overloadedBoolean:Xy,spaceSeparated:tn},Symbol.toStringTag,{value:"Module"})),Qm=Object.keys(Qy);class Kw extends _r{constructor(t,n,r,s){let i=-1;if(super(t,n),IS(this,"space",s),typeof r=="number")for(;++i<Qm.length;){const a=Qm[i];IS(this,Qm[i],(r&Qy[a])===Qy[a])}}}Kw.prototype.defined=!0;function IS(e,t,n){n&&(e[t]=n)}function Bl(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Kw(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Jy(r)]=r,n[Jy(i.attribute)]=r}return new rd(t,n,e.space)}const EA=Bl({properties:{ariaActiveDescendant:null,ariaAtomic:Cn,ariaAutoComplete:null,ariaBusy:Cn,ariaChecked:Cn,ariaColCount:je,ariaColIndex:je,ariaColSpan:je,ariaControls:tn,ariaCurrent:null,ariaDescribedBy:tn,ariaDetails:null,ariaDisabled:Cn,ariaDropEffect:tn,ariaErrorMessage:null,ariaExpanded:Cn,ariaFlowTo:tn,ariaGrabbed:Cn,ariaHasPopup:null,ariaHidden:Cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:tn,ariaLevel:je,ariaLive:null,ariaModal:Cn,ariaMultiLine:Cn,ariaMultiSelectable:Cn,ariaOrientation:null,ariaOwns:tn,ariaPlaceholder:null,ariaPosInSet:je,ariaPressed:Cn,ariaReadOnly:Cn,ariaRelevant:null,ariaRequired:Cn,ariaRoleDescription:tn,ariaRowCount:je,ariaRowIndex:je,ariaRowSpan:je,ariaSelected:Cn,ariaSetSize:je,ariaSort:null,ariaValueMax:je,ariaValueMin:je,ariaValueNow:je,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function AA(e,t){return t in e?e[t]:t}function PA(e,t){return AA(e,t.toLowerCase())}const $5=Bl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gl,acceptCharset:tn,accessKey:tn,action:null,allow:null,allowFullScreen:yt,allowPaymentRequest:yt,allowUserMedia:yt,alt:null,as:null,async:yt,autoCapitalize:null,autoComplete:tn,autoFocus:yt,autoPlay:yt,blocking:tn,capture:null,charSet:null,checked:yt,cite:null,className:tn,cols:je,colSpan:null,content:null,contentEditable:Cn,controls:yt,controlsList:tn,coords:je|gl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yt,defer:yt,dir:null,dirName:null,disabled:yt,download:Xy,draggable:Cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yt,formTarget:null,headers:tn,height:je,hidden:Xy,high:je,href:null,hrefLang:null,htmlFor:tn,httpEquiv:tn,id:null,imageSizes:null,imageSrcSet:null,inert:yt,inputMode:null,integrity:null,is:null,isMap:yt,itemId:null,itemProp:tn,itemRef:tn,itemScope:yt,itemType:tn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yt,low:je,manifest:null,max:null,maxLength:je,media:null,method:null,min:null,minLength:je,multiple:yt,muted:yt,name:null,nonce:null,noModule:yt,noValidate:yt,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:yt,optimum:je,pattern:null,ping:tn,placeholder:null,playsInline:yt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yt,referrerPolicy:null,rel:tn,required:yt,reversed:yt,rows:je,rowSpan:je,sandbox:tn,scope:null,scoped:yt,seamless:yt,selected:yt,shadowRootClonable:yt,shadowRootDelegatesFocus:yt,shadowRootMode:null,shape:null,size:je,sizes:null,slot:null,span:je,spellCheck:Cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:je,step:null,style:null,tabIndex:je,target:null,title:null,translate:null,type:null,typeMustMatch:yt,useMap:null,value:Cn,width:je,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:tn,axis:null,background:null,bgColor:null,border:je,borderColor:null,bottomMargin:je,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:yt,declare:yt,event:null,face:null,frame:null,frameBorder:null,hSpace:je,leftMargin:je,link:null,longDesc:null,lowSrc:null,marginHeight:je,marginWidth:je,noResize:yt,noHref:yt,noShade:yt,noWrap:yt,object:null,profile:null,prompt:null,rev:null,rightMargin:je,rules:null,scheme:null,scrolling:Cn,standby:null,summary:null,text:null,topMargin:je,valueType:null,version:null,vAlign:null,vLink:null,vSpace:je,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:yt,disableRemotePlayback:yt,prefix:null,property:null,results:je,security:null,unselectable:null},space:"html",transform:PA}),L5=Bl({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:Mr,accentHeight:je,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:je,amplitude:je,arabicForm:null,ascent:je,attributeName:null,attributeType:null,azimuth:je,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:je,by:null,calcMode:null,capHeight:je,className:tn,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:je,diffuseConstant:je,direction:null,display:null,dur:null,divisor:je,dominantBaseline:null,download:yt,dx:null,dy:null,edgeMode:null,editable:null,elevation:je,enableBackground:null,end:null,event:null,exponent:je,externalResourcesRequired:null,fill:null,fillOpacity:je,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:gl,g2:gl,glyphName:gl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:je,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:je,horizOriginX:je,horizOriginY:je,id:null,ideographic:je,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:je,k:je,k1:je,k2:je,k3:je,k4:je,kernelMatrix:Mr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:je,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:je,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:je,overlineThickness:je,paintOrder:null,panose1:null,path:null,pathLength:je,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:tn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:je,pointsAtY:je,pointsAtZ:je,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Mr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Mr,rev:Mr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Mr,requiredFeatures:Mr,requiredFonts:Mr,requiredFormats:Mr,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:je,specularExponent:je,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:je,strikethroughThickness:je,string:null,stroke:null,strokeDashArray:Mr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:je,strokeOpacity:je,strokeWidth:null,style:null,surfaceScale:je,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Mr,tabIndex:je,tableValues:null,target:null,targetX:je,targetY:je,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Mr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:je,underlineThickness:je,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:je,values:null,vAlphabetic:je,vMathematical:je,vectorEffect:null,vHanging:je,vIdeographic:je,version:null,vertAdvY:je,vertOriginX:je,vertOriginY:je,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:je,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:AA}),IA=Bl({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()}}),TA=Bl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:PA}),RA=Bl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),O5={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"},D5=/[A-Z]/g,TS=/-[a-z]/g,F5=/^data[-\w.:]+$/i;function z5(e,t){const n=Jy(t);let r=t,s=_r;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&F5.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(TS,B5);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!TS.test(i)){let a=i.replace(D5,H5);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Kw}return new s(r,t)}function H5(e){return"-"+e.toLowerCase()}function B5(e){return e.charAt(1).toUpperCase()}const W5=_A([EA,$5,IA,TA,RA],"html"),Uw=_A([EA,L5,IA,TA,RA],"svg");function V5(e){return e.join(" ").trim()}var qw={},RS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,K5=/\n/g,U5=/^\s*/,q5=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Y5=/^:\s*/,G5=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,J5=/^[;\s]*/,X5=/^\s+|\s+$/g,Q5=`
67
- `,MS="/",$S="*",Oo="",Z5="comment",eH="declaration";function tH(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 b=g.match(K5);b&&(n+=b.length);var v=g.lastIndexOf(Q5);r=~v?g.length-v:r+g.length}function i(){var g={line:n,column:r};return function(b){return b.position=new a(g),u(),b}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var v=b[0];return s(v),e=e.slice(v.length),b}}function u(){c(U5)}function p(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=i();if(!(MS!=e.charAt(0)||$S!=e.charAt(1))){for(var b=2;Oo!=e.charAt(b)&&($S!=e.charAt(b)||MS!=e.charAt(b+1));)++b;if(b+=2,Oo===e.charAt(b-1))return l("End of comment missing");var v=e.slice(2,b-2);return r+=2,s(v),e=e.slice(b),r+=2,g({type:Z5,comment:v})}}function d(){var g=i(),b=c(q5);if(b){if(f(),!c(Y5))return l("property missing ':'");var v=c(G5),y=g({type:eH,property:LS(b[0].replace(RS,Oo)),value:v?LS(v[0].replace(RS,Oo)):Oo});return c(J5),y}}function h(){var g=[];p(g);for(var b;b=d();)b!==!1&&(g.push(b),p(g));return g}return u(),h()}function LS(e){return e?e.replace(X5,Oo):Oo}var nH=tH,rH=ou&&ou.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qw,"__esModule",{value:!0});qw.default=iH;const sH=rH(nH);function iH(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,sH.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 Eh={};Object.defineProperty(Eh,"__esModule",{value:!0});Eh.camelCase=void 0;var oH=/^--[a-zA-Z0-9_-]+$/,aH=/-([a-z])/g,lH=/^[^-]+$/,cH=/^-(webkit|moz|ms|o|khtml)-/,uH=/^-(ms)-/,dH=function(e){return!e||lH.test(e)||oH.test(e)},fH=function(e,t){return t.toUpperCase()},OS=function(e,t){return"".concat(t,"-")},pH=function(e,t){return t===void 0&&(t={}),dH(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(uH,OS):e=e.replace(cH,OS),e.replace(aH,fH))};Eh.camelCase=pH;var hH=ou&&ou.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},mH=hH(qw),gH=Eh;function Zy(e,t){var n={};return!e||typeof e!="string"||(0,mH.default)(e,function(r,s){r&&s&&(n[(0,gH.camelCase)(r,t)]=s)}),n}Zy.default=Zy;var yH=Zy;const xH=bo(yH),MA=$A("end"),Yw=$A("start");function $A(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 wH(e){const t=Yw(e),n=MA(e);if(t&&n)return{start:t,end:n}}function Zc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?DS(e.position):"start"in e||"end"in e?DS(e):"line"in e||"column"in e?ex(e):""}function ex(e){return FS(e&&e.line)+":"+FS(e&&e.column)}function DS(e){return ex(e&&e.start)+"-"+ex(e&&e.end)}function FS(e){return e&&typeof e=="number"?e:1}class nr 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=Zc(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}}nr.prototype.file="";nr.prototype.name="";nr.prototype.reason="";nr.prototype.message="";nr.prototype.stack="";nr.prototype.column=void 0;nr.prototype.line=void 0;nr.prototype.ancestors=void 0;nr.prototype.cause=void 0;nr.prototype.fatal=void 0;nr.prototype.place=void 0;nr.prototype.ruleId=void 0;nr.prototype.source=void 0;const Gw={}.hasOwnProperty,bH=new Map,kH=/[A-Z]/g,vH=new Set(["table","tbody","thead","tfoot","tr"]),SH=new Set(["td","th"]),LA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function NH(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=TH(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=IH(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"?Uw:W5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=OA(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function OA(e,t,n){if(t.type==="element")return jH(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return CH(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return EH(e,t,n);if(t.type==="mdxjsEsm")return _H(e,t);if(t.type==="root")return AH(e,t,n);if(t.type==="text")return PH(e,t)}function jH(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Uw,e.schema=s),e.ancestors.push(t);const i=FA(e,t.tagName,!1),a=RH(e,t);let l=Xw(e,t);return vH.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!R5(c):!0})),DA(e,a,i,t),Jw(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function CH(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)}Ru(e,t.position)}function _H(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ru(e,t.position)}function EH(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Uw,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:FA(e,t.name,!0),a=MH(e,t),l=Xw(e,t);return DA(e,a,i,t),Jw(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function AH(e,t,n){const r={};return Jw(r,Xw(e,t)),e.create(t,e.Fragment,r,n)}function PH(e,t){return t.value}function DA(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Jw(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function IH(e,t,n){return r;function r(s,i,a,l){const u=Array.isArray(a.children)?n:t;return l?u(i,a,l):u(i,a)}}function TH(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=Yw(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 RH(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Gw.call(t.properties,s)){const i=$H(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&SH.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 MH(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 Ru(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 Ru(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Xw(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:bH;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 u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const l=OA(e,i,a);l!==void 0&&n.push(l)}return n}function $H(e,t,n){const r=z5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?E5(n):V5(n)),r.property==="style"){let s=typeof n=="object"?n:LH(e,String(n));return e.stylePropertyNameCase==="css"&&(s=OH(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?O5[r.property]||r.property:r.attribute,n]}}function LH(e,t){try{return xH(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new nr("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 FA(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=AS(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=AS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Gw.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ru(e)}function Ru(e,t){const n=new nr("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 OH(e){const t={};let n;for(n in e)Gw.call(e,n)&&(t[DH(n)]=e[n]);return t}function DH(e){let t=e.replace(kH,FH);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function FH(e){return"-"+e.toLowerCase()}const Zm={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"]},zH={};function HH(e,t){const n=zH,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zA(e,r,s)}function zA(e,t,n){if(BH(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 zS(e.children,t,n)}return Array.isArray(e)?zS(e,t,n):""}function zS(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=zA(e[s],t,n);return r.join("")}function BH(e){return!!(e&&typeof e=="object")}const HS=document.createElement("i");function Qw(e){const t="&"+e+";";HS.innerHTML=t;const n=HS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ei(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 Qr(e,t){return e.length>0?(ei(e,e.length,0,t),e):t}const BS={}.hasOwnProperty;function WH(e){const t={};let n=-1;for(;++n<e.length;)VH(t,e[n]);return t}function VH(e,t){let n;for(n in t){const s=(BS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){BS.call(s,a)||(s[a]=[]);const l=i[a];KH(s[a],Array.isArray(l)?l:l?[l]:[])}}}function KH(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ei(e,0,0,r)}function HA(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 yl(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Us=No(/[A-Za-z]/),Fr=No(/[\dA-Za-z]/),UH=No(/[#-'*+\--9=?A-Z^-~]/);function tx(e){return e!==null&&(e<32||e===127)}const nx=No(/\d/),qH=No(/[\dA-Fa-f]/),YH=No(/[!-/:-@[-`{-~]/);function ct(e){return e!==null&&e<-2}function Cr(e){return e!==null&&(e<0||e===32)}function Lt(e){return e===-2||e===-1||e===32}const GH=No(new RegExp("\\p{P}|\\p{S}","u")),JH=No(/\s/);function No(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Wl(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Fr(e.charCodeAt(n+1))&&Fr(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 rn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return Lt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Lt(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const XH={tokenize:QH};function QH(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"),rn(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 ct(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const ZH={tokenize:eB},WS={tokenize:tB};function eB(e){const t=this,n=[];let r=0,s,i,a;return l;function l(x){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&w();const S=t.events.length;let C=S,j;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){j=t.events[C][1].end;break}y(r);let E=S;for(;E<t.events.length;)t.events[E][1].end={...j},E++;return ei(t.events,C+1,0,t.events.slice(S)),t.events.length=E,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return d(x);if(s.currentConstruct&&s.currentConstruct.concrete)return g(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(WS,p,f)(x)}function p(x){return s&&w(),y(r),d(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(x)}function d(x){return t.containerState={},e.attempt(WS,h,g)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),d(x)}function g(x){if(x===null){s&&w(),y(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(x)}function b(x){if(x===null){v(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return ct(x)?(e.consume(x),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),b)}function v(x,S){const C=t.sliceStream(x);if(S&&C.push(null),x.previous=i,i&&(i.next=x),i=x,s.defineSkip(x.start),s.write(C),t.parser.lazy[x.start.line]){let j=s.events.length;for(;j--;)if(s.events[j][1].start.offset<a&&(!s.events[j][1].end||s.events[j][1].end.offset>a))return;const E=t.events.length;let P=E,F,V;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(F){V=t.events[P][1].end;break}F=!0}for(y(r),j=E;j<t.events.length;)t.events[j][1].end={...V},j++;ei(t.events,P+1,0,t.events.slice(E)),t.events.length=j}}function y(x){let S=n.length;for(;S-- >x;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=x}function w(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function tB(e,t,n){return rn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function VS(e){if(e===null||Cr(e)||JH(e))return 1;if(GH(e))return 2}function Zw(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 rx={name:"attention",resolveAll:nB,tokenize:rB};function nB(e,t){let n=-1,r,s,i,a,l,c,u,p;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},d={...e[n][1].start};KS(f,-c),KS(d,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:d},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},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Qr(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Qr(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),u=Qr(u,Zw(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Qr(u,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,u=Qr(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,ei(e,r-1,n-r+3,u),n=r+u.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function rB(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=VS(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 u=e.exit("attentionSequence"),p=VS(c),f=!p||p===2&&s||n.includes(c),d=!s||s===2&&p||n.includes(r);return u._open=!!(i===42?f:f&&(s||!d)),u._close=!!(i===42?d:d&&(p||!f)),t(c)}}function KS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const sB={name:"autolink",tokenize:iB};function iB(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 Us(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||Fr(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||Fr(h))&&r++<32?(e.consume(h),l):(r=0,u(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||tx(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),p):UH(h)?(e.consume(h),u):n(h)}function p(h){return Fr(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,p):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):d(h)}function d(h){if((h===45||Fr(h))&&r++<63){const g=h===45?d:f;return e.consume(h),g}return n(h)}}const Ah={partial:!0,tokenize:oB};function oB(e,t,n){return r;function r(i){return Lt(i)?rn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||ct(i)?t(i):n(i)}}const BA={continuation:{tokenize:lB},exit:cB,name:"blockQuote",tokenize:aB};function aB(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 Lt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function lB(e,t,n){const r=this;return s;function s(a){return Lt(a)?rn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(BA,t,n)(a)}}function cB(e){e.exit("blockQuote")}const WA={name:"characterEscape",tokenize:uB};function uB(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 YH(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const VA={name:"characterReference",tokenize:dB};function dB(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"),u):(e.enter("characterReferenceValue"),i=31,a=Fr,p(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=qH,p):(e.enter("characterReferenceValue"),i=7,a=nx,p(f))}function p(f){if(f===59&&s){const d=e.exit("characterReferenceValue");return a===Fr&&!Qw(r.sliceSerialize(d))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<i?(e.consume(f),p):n(f)}}const US={partial:!0,tokenize:pB},qS={concrete:!0,name:"codeFenced",tokenize:fB};function fB(e,t,n){const r=this,s={partial:!0,tokenize:C};let i=0,a=0,l;return c;function c(j){return u(j)}function u(j){const E=r.events[r.events.length-1];return i=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,l=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(j)}function p(j){return j===l?(a++,e.consume(j),p):a<3?n(j):(e.exit("codeFencedFenceSequence"),Lt(j)?rn(e,f,"whitespace")(j):f(j))}function f(j){return j===null||ct(j)?(e.exit("codeFencedFence"),r.interrupt?t(j):e.check(US,b,S)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(j))}function d(j){return j===null||ct(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(j)):Lt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),rn(e,h,"whitespace")(j)):j===96&&j===l?n(j):(e.consume(j),d)}function h(j){return j===null||ct(j)?f(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(j))}function g(j){return j===null||ct(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(j)):j===96&&j===l?n(j):(e.consume(j),g)}function b(j){return e.attempt(s,S,v)(j)}function v(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),y}function y(j){return i>0&&Lt(j)?rn(e,w,"linePrefix",i+1)(j):w(j)}function w(j){return j===null||ct(j)?e.check(US,b,S)(j):(e.enter("codeFlowValue"),x(j))}function x(j){return j===null||ct(j)?(e.exit("codeFlowValue"),w(j)):(e.consume(j),x)}function S(j){return e.exit("codeFenced"),t(j)}function C(j,E,P){let F=0;return V;function V(L){return j.enter("lineEnding"),j.consume(L),j.exit("lineEnding"),z}function z(L){return j.enter("codeFencedFence"),Lt(L)?rn(j,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):D(L)}function D(L){return L===l?(j.enter("codeFencedFenceSequence"),R(L)):P(L)}function R(L){return L===l?(F++,j.consume(L),R):F>=a?(j.exit("codeFencedFenceSequence"),Lt(L)?rn(j,T,"whitespace")(L):T(L)):P(L)}function T(L){return L===null||ct(L)?(j.exit("codeFencedFence"),E(L)):P(L)}}}function pB(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 eg={name:"codeIndented",tokenize:mB},hB={partial:!0,tokenize:gB};function mB(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),rn(e,i,"linePrefix",5)(u)}function i(u){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):ct(u)?e.attempt(hB,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||ct(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function gB(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):ct(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):rn(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):ct(a)?s(a):n(a)}}const yB={name:"codeText",previous:wB,resolve:xB,tokenize:bB};function xB(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 wB(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function bB(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,p(f)):ct(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||ct(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function p(f){return f===96?(e.consume(f),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(i.type="codeTextData",u(f))}}class kB{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&&Sc(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),Sc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Sc(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);Sc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Sc(this.left,n.reverse())}}}function Sc(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 KA(e){const t={};let n=-1,r,s,i,a,l,c,u;const p=new kB(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.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,vB(p,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=p.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(p.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={...p.get(s)[1].start},l=p.slice(s,n),l.unshift(r),p.splice(s,n-s+1,l))}}return ei(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!u}function vB(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=[],u={};let p,f,d=-1,h=n,g=0,b=0;const v=[b];for(;h;){for(;e.get(++s)[1]!==h;);i.push(s),h._tokenizer||(p=r.sliceStream(h),h.next||p.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(b=d+1,v.push(b),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):v.pop(),d=v.length;d--;){const y=l.slice(v[d],v[d+1]),w=i.pop();c.push([w,w+y.length-1]),e.splice(w,2,y)}for(c.reverse(),d=-1;++d<c.length;)u[g+c[d][0]]=g+c[d][1],g+=c[d][1]-c[d][0]-1;return u}const SB={resolve:jB,tokenize:CB},NB={partial:!0,tokenize:_B};function jB(e){return KA(e),e}function CB(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):ct(l)?e.check(NB,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 _B(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),rn(e,i,"linePrefix")}function i(a){if(a===null||ct(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 UA(e,t,n,r,s,i,a,l,c){const u=c||Number.POSITIVE_INFINITY;let p=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),d):y===null||y===32||y===41||tx(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(y))}function d(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),d(y)):y===null||y===60||ct(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 b(y){return!p&&(y===null||y===41||Cr(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):p<u&&y===40?(e.consume(y),p++,b):y===41?(e.consume(y),p--,b):y===null||y===32||y===40||tx(y)?n(y):(e.consume(y),y===92?v:b)}function v(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function qA(e,t,n,r,s,i){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(i),p}function p(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):ct(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||ct(h)||l++>999?(e.exit("chunkString"),p(h)):(e.consume(h),c||(c=!Lt(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function YA(e,t,n,r,s,i){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(s),e.consume(d),e.exit(s),a=d===40?41:d,c):n(d)}function c(d){return d===a?(e.enter(s),e.consume(d),e.exit(s),e.exit(r),t):(e.enter(i),u(d))}function u(d){return d===a?(e.exit(i),c(a)):d===null?n(d):ct(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),rn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===a||d===null||ct(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?f:p)}function f(d){return d===a||d===92?(e.consume(d),p):p(d)}}function eu(e,t){let n;return r;function r(s){return ct(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Lt(s)?rn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const EB={name:"definition",tokenize:PB},AB={partial:!0,tokenize:IB};function PB(e,t,n){const r=this;let s;return i;function i(h){return e.enter("definition"),a(h)}function a(h){return qA.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=yl(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 Cr(h)?eu(e,u)(h):u(h)}function u(h){return UA(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function p(h){return e.attempt(AB,f,f)(h)}function f(h){return Lt(h)?rn(e,d,"whitespace")(h):d(h)}function d(h){return h===null||ct(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function IB(e,t,n){return r;function r(l){return Cr(l)?eu(e,s)(l):n(l)}function s(l){return YA(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Lt(l)?rn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||ct(l)?t(l):n(l)}}const TB={name:"hardBreakEscape",tokenize:RB};function RB(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return ct(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const MB={name:"headingAtx",resolve:$B,tokenize:LB};function $B(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"},ei(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function LB(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),i(p)}function i(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||Cr(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),c(p)):p===null||ct(p)?(e.exit("atxHeading"),t(p)):Lt(p)?rn(e,l,"whitespace")(p):(e.enter("atxHeadingText"),u(p))}function c(p){return p===35?(e.consume(p),c):(e.exit("atxHeadingSequence"),l(p))}function u(p){return p===null||p===35||Cr(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),u)}}const OB=["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"],YS=["pre","script","style","textarea"],DB={concrete:!0,name:"htmlFlow",resolveTo:HB,tokenize:BB},FB={partial:!0,tokenize:VB},zB={partial:!0,tokenize:WB};function HB(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 BB(e,t,n){const r=this;let s,i,a,l,c;return u;function u(B){return p(B)}function p(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),d):B===47?(e.consume(B),i=!0,b):B===63?(e.consume(B),s=3,r.interrupt?t:_):Us(B)?(e.consume(B),a=String.fromCharCode(B),v):n(B)}function d(B){return B===45?(e.consume(B),s=2,h):B===91?(e.consume(B),s=5,l=0,g):Us(B)?(e.consume(B),s=4,r.interrupt?t:_):n(B)}function h(B){return B===45?(e.consume(B),r.interrupt?t:_):n(B)}function g(B){const Q="CDATA[";return B===Q.charCodeAt(l++)?(e.consume(B),l===Q.length?r.interrupt?t:D:g):n(B)}function b(B){return Us(B)?(e.consume(B),a=String.fromCharCode(B),v):n(B)}function v(B){if(B===null||B===47||B===62||Cr(B)){const Q=B===47,se=a.toLowerCase();return!Q&&!i&&YS.includes(se)?(s=1,r.interrupt?t(B):D(B)):OB.includes(a.toLowerCase())?(s=6,Q?(e.consume(B),y):r.interrupt?t(B):D(B)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?w(B):x(B))}return B===45||Fr(B)?(e.consume(B),a+=String.fromCharCode(B),v):n(B)}function y(B){return B===62?(e.consume(B),r.interrupt?t:D):n(B)}function w(B){return Lt(B)?(e.consume(B),w):V(B)}function x(B){return B===47?(e.consume(B),V):B===58||B===95||Us(B)?(e.consume(B),S):Lt(B)?(e.consume(B),x):V(B)}function S(B){return B===45||B===46||B===58||B===95||Fr(B)?(e.consume(B),S):C(B)}function C(B){return B===61?(e.consume(B),j):Lt(B)?(e.consume(B),C):x(B)}function j(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,E):Lt(B)?(e.consume(B),j):P(B)}function E(B){return B===c?(e.consume(B),c=null,F):B===null||ct(B)?n(B):(e.consume(B),E)}function P(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Cr(B)?C(B):(e.consume(B),P)}function F(B){return B===47||B===62||Lt(B)?x(B):n(B)}function V(B){return B===62?(e.consume(B),z):n(B)}function z(B){return B===null||ct(B)?D(B):Lt(B)?(e.consume(B),z):n(B)}function D(B){return B===45&&s===2?(e.consume(B),$):B===60&&s===1?(e.consume(B),O):B===62&&s===4?(e.consume(B),U):B===63&&s===3?(e.consume(B),_):B===93&&s===5?(e.consume(B),M):ct(B)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(FB,q,R)(B)):B===null||ct(B)?(e.exit("htmlFlowData"),R(B)):(e.consume(B),D)}function R(B){return e.check(zB,T,q)(B)}function T(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),L}function L(B){return B===null||ct(B)?R(B):(e.enter("htmlFlowData"),D(B))}function $(B){return B===45?(e.consume(B),_):D(B)}function O(B){return B===47?(e.consume(B),a="",A):D(B)}function A(B){if(B===62){const Q=a.toLowerCase();return YS.includes(Q)?(e.consume(B),U):D(B)}return Us(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),A):D(B)}function M(B){return B===93?(e.consume(B),_):D(B)}function _(B){return B===62?(e.consume(B),U):B===45&&s===2?(e.consume(B),_):D(B)}function U(B){return B===null||ct(B)?(e.exit("htmlFlowData"),q(B)):(e.consume(B),U)}function q(B){return e.exit("htmlFlow"),t(B)}}function WB(e,t,n){const r=this;return s;function s(a){return ct(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 VB(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Ah,t,n)}}const KB={name:"htmlText",tokenize:UB};function UB(e,t,n){const r=this;let s,i,a;return l;function l(_){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(_),c}function c(_){return _===33?(e.consume(_),u):_===47?(e.consume(_),C):_===63?(e.consume(_),x):Us(_)?(e.consume(_),P):n(_)}function u(_){return _===45?(e.consume(_),p):_===91?(e.consume(_),i=0,g):Us(_)?(e.consume(_),w):n(_)}function p(_){return _===45?(e.consume(_),h):n(_)}function f(_){return _===null?n(_):_===45?(e.consume(_),d):ct(_)?(a=f,O(_)):(e.consume(_),f)}function d(_){return _===45?(e.consume(_),h):f(_)}function h(_){return _===62?$(_):_===45?d(_):f(_)}function g(_){const U="CDATA[";return _===U.charCodeAt(i++)?(e.consume(_),i===U.length?b:g):n(_)}function b(_){return _===null?n(_):_===93?(e.consume(_),v):ct(_)?(a=b,O(_)):(e.consume(_),b)}function v(_){return _===93?(e.consume(_),y):b(_)}function y(_){return _===62?$(_):_===93?(e.consume(_),y):b(_)}function w(_){return _===null||_===62?$(_):ct(_)?(a=w,O(_)):(e.consume(_),w)}function x(_){return _===null?n(_):_===63?(e.consume(_),S):ct(_)?(a=x,O(_)):(e.consume(_),x)}function S(_){return _===62?$(_):x(_)}function C(_){return Us(_)?(e.consume(_),j):n(_)}function j(_){return _===45||Fr(_)?(e.consume(_),j):E(_)}function E(_){return ct(_)?(a=E,O(_)):Lt(_)?(e.consume(_),E):$(_)}function P(_){return _===45||Fr(_)?(e.consume(_),P):_===47||_===62||Cr(_)?F(_):n(_)}function F(_){return _===47?(e.consume(_),$):_===58||_===95||Us(_)?(e.consume(_),V):ct(_)?(a=F,O(_)):Lt(_)?(e.consume(_),F):$(_)}function V(_){return _===45||_===46||_===58||_===95||Fr(_)?(e.consume(_),V):z(_)}function z(_){return _===61?(e.consume(_),D):ct(_)?(a=z,O(_)):Lt(_)?(e.consume(_),z):F(_)}function D(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),s=_,R):ct(_)?(a=D,O(_)):Lt(_)?(e.consume(_),D):(e.consume(_),T)}function R(_){return _===s?(e.consume(_),s=void 0,L):_===null?n(_):ct(_)?(a=R,O(_)):(e.consume(_),R)}function T(_){return _===null||_===34||_===39||_===60||_===61||_===96?n(_):_===47||_===62||Cr(_)?F(_):(e.consume(_),T)}function L(_){return _===47||_===62||Cr(_)?F(_):n(_)}function $(_){return _===62?(e.consume(_),e.exit("htmlTextData"),e.exit("htmlText"),t):n(_)}function O(_){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),A}function A(_){return Lt(_)?rn(e,M,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):M(_)}function M(_){return e.enter("htmlTextData"),a(_)}}const eb={name:"labelEnd",resolveAll:JB,resolveTo:XB,tokenize:QB},qB={tokenize:ZB},YB={tokenize:e6},GB={tokenize:t6};function JB(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&&ei(e,0,e.length,n),e}function XB(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}},u={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Qr(l,e.slice(i+1,i+r+3)),l=Qr(l,[["enter",p,t]]),l=Qr(l,Zw(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Qr(l,[["exit",p,t],e[a-2],e[a-1],["exit",u,t]]),l=Qr(l,e.slice(a+1)),l=Qr(l,[["exit",c,t]]),ei(e,i,e.length,l),e}function QB(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(d){return i?i._inactive?f(d):(a=r.parser.defined.includes(yl(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),c):n(d)}function c(d){return d===40?e.attempt(qB,p,a?p:f)(d):d===91?e.attempt(YB,p,a?u:f)(d):a?p(d):f(d)}function u(d){return e.attempt(GB,p,f)(d)}function p(d){return t(d)}function f(d){return i._balanced=!0,n(d)}}function ZB(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 Cr(f)?eu(e,i)(f):i(f)}function i(f){return f===41?p(f):UA(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Cr(f)?eu(e,c)(f):p(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?YA(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):p(f)}function u(f){return Cr(f)?eu(e,p)(f):p(f)}function p(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function e6(e,t,n){const r=this;return s;function s(l){return qA.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(yl(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function t6(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 n6={name:"labelStartImage",resolveAll:eb.resolveAll,tokenize:r6};function r6(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:eb.resolveAll,tokenize:i6};function i6(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 tg={name:"lineEnding",tokenize:o6};function o6(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),rn(e,t,"linePrefix")}}const Yf={name:"thematicBreak",tokenize:a6};function a6(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||ct(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Lt(u)?rn(e,l,"whitespace")(u):l(u))}}const xr={continuation:{tokenize:d6},exit:p6,name:"list",tokenize:u6},l6={partial:!0,tokenize:h6},c6={partial:!0,tokenize:f6};function u6(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:nx(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(Yf,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return nx(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"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Ah,r.interrupt?n:p,e.attempt(l6,d,f))}function p(h){return r.containerState.initialBlankLine=!0,i++,d(h)}function f(h){return Lt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function d6(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Ah,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,rn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Lt(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(c6,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,rn(e,e.attempt(xr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function f6(e,t,n){const r=this;return rn(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 p6(e){e.exit(this.containerState.type)}function h6(e,t,n){const r=this;return rn(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!Lt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const GS={name:"setextUnderline",resolveTo:m6,tokenize:g6};function m6(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 g6(e,t,n){const r=this;let s;return i;function i(u){let p=r.events.length,f;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){f=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Lt(u)?rn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||ct(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const y6={tokenize:x6};function x6(e){const t=this,n=e.attempt(Ah,r,e.attempt(this.parser.constructs.flowInitial,s,rn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(SB,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 w6={resolveAll:JA()},b6=GA("string"),k6=GA("text");function GA(e){return{resolveAll:JA(e==="text"?v6: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(p){return u(p)?i(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),c}function c(p){return u(p)?(n.exit("data"),i(p)):(n.consume(p),c)}function u(p){if(p===null)return!0;const f=s[p];let d=-1;if(f)for(;++d<f.length;){const h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function JA(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 v6(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 u=s[i];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={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={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const S6={42:xr,43:xr,45:xr,48:xr,49:xr,50:xr,51:xr,52:xr,53:xr,54:xr,55:xr,56:xr,57:xr,62:BA},N6={91:EB},j6={[-2]:eg,[-1]:eg,32:eg},C6={35:MB,42:Yf,45:[GS,Yf],60:DB,61:GS,95:Yf,96:qS,126:qS},_6={38:VA,92:WA},E6={[-5]:tg,[-4]:tg,[-3]:tg,33:n6,38:VA,42:rx,60:[sB,KB],91:s6,92:[TB,WA],93:eb,95:rx,96:yB},A6={null:[rx,w6]},P6={null:[42,95]},I6={null:[]},T6=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:P6,contentInitial:N6,disable:I6,document:S6,flow:C6,flowInitial:j6,insideSpan:A6,string:_6,text:E6},Symbol.toStringTag,{value:"Module"}));function R6(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:E(C),check:E(j),consume:w,enter:x,exit:S,interrupt:E(j,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:f};let p=t.tokenize.call(u,c);return t.resolveAll&&i.push(t),u;function f(z){return a=Qr(a,z),v(),a[a.length-1]!==null?[]:(P(t,0),u.events=Zw(i,u.events,u),u.events)}function d(z,D){return $6(h(z),D)}function h(z){return M6(a,z)}function g(){const{_bufferIndex:z,_index:D,line:R,column:T,offset:L}=r;return{_bufferIndex:z,_index:D,line:R,column:T,offset:L}}function b(z){s[z.line]=z.column,V()}function v(){let z;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<D.length;)y(D.charCodeAt(r._bufferIndex));else y(D)}}function y(z){p=p(z)}function w(z){ct(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,V()):z!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=z}function x(z,D){const R=D||{};return R.type=z,R.start=g(),u.events.push(["enter",R,u]),l.push(R),R}function S(z){const D=l.pop();return D.end=g(),u.events.push(["exit",D,u]),D}function C(z,D){P(z,D.from)}function j(z,D){D.restore()}function E(z,D){return R;function R(T,L,$){let O,A,M,_;return Array.isArray(T)?q(T):"tokenize"in T?q([T]):U(T);function U(oe){return ve;function ve(re){const ue=re!==null&&oe[re],te=re!==null&&oe.null,ae=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(te)?te:te?[te]:[]];return q(ae)(re)}}function q(oe){return O=oe,A=0,oe.length===0?$:B(oe[A])}function B(oe){return ve;function ve(re){return _=F(),M=oe,oe.partial||(u.currentConstruct=oe),oe.name&&u.parser.constructs.disable.null.includes(oe.name)?se():oe.tokenize.call(D?Object.assign(Object.create(u),D):u,c,Q,se)(re)}}function Q(oe){return z(M,_),L}function se(oe){return _.restore(),++A<O.length?B(O[A]):$}}}function P(z,D){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&ei(u.events,D,u.events.length-D,z.resolve(u.events.slice(D),u)),z.resolveTo&&(u.events=z.resolveTo(u.events,u))}function F(){const z=g(),D=u.previous,R=u.currentConstruct,T=u.events.length,L=Array.from(l);return{from:T,restore:$};function $(){r=z,u.previous=D,u.currentConstruct=R,u.events.length=T,l=L,V()}}function V(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function M6(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 $6(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 L6(e){const r={constructs:WH([T6,...(e||{}).extensions||[]]),content:s(XH),defined:[],document:s(ZH),flow:s(y6),lazy:{},string:s(b6),text:s(k6)};return r;function s(i){return a;function a(l){return R6(r,i,l)}}}function O6(e){for(;!KA(e););return e}const JS=/[\0\t\n\r]/g;function D6(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let u,p,f,d,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(JS.lastIndex=f,u=JS.exec(i),d=u&&u.index!==void 0?u.index:i.length,h=i.charCodeAt(d),!u){t=i.slice(f);break}if(h===10&&f===d&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<d&&(c.push(i.slice(f,d)),e+=d-f),h){case 0:{c.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,c.push(-2);e++<p;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=d+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const F6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function z6(e){return e.replace(F6,H6)}function H6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return HA(n.slice(i?2:1),i?16:10)}return Qw(n)||e}const XA={}.hasOwnProperty;function B6(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),W6(n)(O6(L6(n).document().write(D6()(e,t,!0))))}function W6(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ie),autolinkProtocol:F,autolinkEmail:F,atxHeading:i(Ue),blockQuote:i(te),characterEscape:F,characterReference:F,codeFenced:i(ae),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(ae,a),codeText:i(pe,a),codeTextData:F,data:F,codeFlowValue:F,definition:i(be),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Fe),hardBreakEscape:i(Me),hardBreakTrailing:i(Me),htmlFlow:i(et,a),htmlFlowData:F,htmlText:i(et,a),htmlTextData:F,image:i(ht),label:a,link:i(Ie),listItem:i(Wt),listItemValue:d,listOrdered:i(tt,f),listUnordered:i(tt),paragraph:i($e),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Ue),strong:i(Vt),thematicBreak:i(nt)},exit:{atxHeading:c(),atxHeadingSequence:C,autolink:c(),autolinkEmail:ue,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:V,characterReferenceMarkerHexadecimal:se,characterReferenceMarkerNumeric:se,characterReferenceValue:oe,characterReference:ve,codeFenced:c(v),codeFencedFence:b,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:V,codeIndented:c(y),codeText:c(L),codeTextData:V,data:V,definition:c(),definitionDestinationString:S,definitionLabelString:w,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(R),htmlFlowData:V,htmlText:c(T),htmlTextData:V,image:c(O),label:M,labelText:A,lineEnding:z,link:c($),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Q,resourceDestinationString:_,resourceTitleString:U,resource:q,setextHeading:c(P),setextHeadingLineSequence:E,setextHeadingText:j,strong:c(),thematicBreak:c()}};QA(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let ke={type:"root",children:[]};const Oe={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:p,data:n},We=[];let Je=-1;for(;++Je<ie.length;)if(ie[Je][1].type==="listOrdered"||ie[Je][1].type==="listUnordered")if(ie[Je][0]==="enter")We.push(Je);else{const vt=We.pop();Je=s(ie,vt,Je)}for(Je=-1;++Je<ie.length;){const vt=t[ie[Je][0]];XA.call(vt,ie[Je][1].type)&&vt[ie[Je][1].type].call(Object.assign({sliceSerialize:ie[Je][2].sliceSerialize},Oe),ie[Je][1])}if(Oe.tokenStack.length>0){const vt=Oe.tokenStack[Oe.tokenStack.length-1];(vt[1]||XS).call(Oe,void 0,vt[0])}for(ke.position={start:Ui(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ui(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},Je=-1;++Je<t.transforms.length;)ke=t.transforms[Je](ke)||ke;return ke}function s(ie,ke,Oe){let We=ke-1,Je=-1,vt=!1,ee,ye,Ve,Ce;for(;++We<=Oe;){const at=ie[We];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?Je++:Je--,Ce=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(ee&&!Ce&&!Je&&!Ve&&(Ve=We),Ce=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ce=void 0}if(!Je&&at[0]==="enter"&&at[1].type==="listItemPrefix"||Je===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(ee){let mt=We;for(ye=void 0;mt--;){const Qt=ie[mt];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;ye&&(ie[ye][1].type="lineEndingBlank",vt=!0),Qt[1].type="lineEnding",ye=mt}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}Ve&&(!ye||Ve<ye)&&(ee._spread=!0),ee.end=Object.assign({},ye?ie[ye][1].start:at[1].end),ie.splice(ye||We,0,["exit",ee,at[2]]),We++,Oe++}if(at[1].type==="listItemPrefix"){const mt={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};ee=mt,ie.splice(We,0,["enter",mt,at[2]]),We++,Oe++,Ve=void 0,Ce=!0}}}return ie[ke][1]._spread=vt,Oe}function i(ie,ke){return Oe;function Oe(We){l.call(this,ie(We),We),ke&&ke.call(this,We)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ie,ke,Oe){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([ke,Oe||void 0]),ie.position={start:Ui(ke.start),end:void 0}}function c(ie){return ke;function ke(Oe){ie&&ie.call(this,Oe),u.call(this,Oe)}}function u(ie,ke){const Oe=this.stack.pop(),We=this.tokenStack.pop();if(We)We[0].type!==ie.type&&(ke?ke.call(this,ie,We[0]):(We[1]||XS).call(this,ie,We[0]));else throw new Error("Cannot close `"+ie.type+"` ("+Zc({start:ie.start,end:ie.end})+"): it’s not open");Oe.position.end=Ui(ie.end)}function p(){return HH(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(ie){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ie}function g(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ie}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/(\r?\n|\r)$/g,"")}function w(ie){const ke=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=ke,Oe.identifier=yl(this.sliceSerialize(ie)).toLowerCase()}function x(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function S(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function C(ie){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Oe=this.sliceSerialize(ie).length;ke.depth=Oe}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function E(ie){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function F(ie){const Oe=this.stack[this.stack.length-1].children;let We=Oe[Oe.length-1];(!We||We.type!=="text")&&(We=Gt(),We.position={start:Ui(ie.start),end:void 0},Oe.push(We)),this.stack.push(We)}function V(ie){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ie),ke.position.end=Ui(ie.end)}function z(ie){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Oe=ke.children[ke.children.length-1];Oe.position.end=Ui(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(F.call(this,ie),V.call(this,ie))}function D(){this.data.atHardBreak=!0}function R(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function T(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function L(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function $(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function O(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function A(ie){const ke=this.sliceSerialize(ie),Oe=this.stack[this.stack.length-2];Oe.label=z6(ke),Oe.identifier=yl(ke).toLowerCase()}function M(){const ie=this.stack[this.stack.length-1],ke=this.resume(),Oe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Oe.type==="link"){const We=ie.children;Oe.children=We}else Oe.alt=ke}function _(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function U(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function q(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function Q(ie){const ke=this.resume(),Oe=this.stack[this.stack.length-1];Oe.label=ke,Oe.identifier=yl(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function se(ie){this.data.characterReferenceType=ie.type}function oe(ie){const ke=this.sliceSerialize(ie),Oe=this.data.characterReferenceType;let We;Oe?(We=HA(ke,Oe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):We=Qw(ke);const Je=this.stack[this.stack.length-1];Je.value+=We}function ve(ie){const ke=this.stack.pop();ke.position.end=Ui(ie.end)}function re(ie){V.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ie)}function ue(ie){V.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ie)}function te(){return{type:"blockquote",children:[]}}function ae(){return{type:"code",lang:null,meta:null,value:""}}function pe(){return{type:"inlineCode",value:""}}function be(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Fe(){return{type:"emphasis",children:[]}}function Ue(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function et(){return{type:"html",value:""}}function ht(){return{type:"image",title:null,url:"",alt:null}}function Ie(){return{type:"link",title:null,url:"",children:[]}}function tt(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function Wt(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function $e(){return{type:"paragraph",children:[]}}function Vt(){return{type:"strong",children:[]}}function Gt(){return{type:"text",value:""}}function nt(){return{type:"thematicBreak"}}}function Ui(e){return{line:e.line,column:e.column,offset:e.offset}}function QA(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?QA(e,r):V6(e,r)}}function V6(e,t){let n;for(n in t)if(XA.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 XS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Zc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Zc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Zc({start:t.start,end:t.end})+") is still open")}function K6(e){const t=this;t.parser=n;function n(r){return B6(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function U6(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 q6(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function Y6(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 G6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function J6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function X6(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Wl(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 u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function Q6(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 Z6(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function ZA(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 eW(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZA(e,t);const s={src:Wl(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 tW(e,t){const n={src:Wl(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 nW(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 rW(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ZA(e,t);const s={href:Wl(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 sW(e,t){const n={href:Wl(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 iW(e,t,n){const r=e.all(t),s=n?oW(n):eP(t),i={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let f;p&&p.type==="element"&&p.tagName==="p"?f=p:(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 p=r[l];(s||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),p.type==="element"&&p.tagName==="p"&&!s?a.push(...p.children):a.push(p)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const u={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,u),e.applyData(t,u)}function oW(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=eP(n[r])}return t}function eP(e){const t=e.spread;return t??e.children.length>1}function aW(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 lW(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cW(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function uW(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dW(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=Yw(t.children[1]),c=MA(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 fW(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 u=[];for(;++c<l;){const f=t.children[c],d={},h=a?a[c]:void 0;h&&(d.align=h);let g={type:"element",tagName:i,properties:d,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),u.push(g)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,p),e.applyData(t,p)}function pW(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const QS=9,ZS=32;function hW(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(eN(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(eN(t.slice(s),s>0,!1)),i.join("")}function eN(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===QS||i===ZS;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===QS||i===ZS;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function mW(e,t){const n={type:"text",value:hW(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function gW(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const yW={blockquote:U6,break:q6,code:Y6,delete:G6,emphasis:J6,footnoteReference:X6,heading:Q6,html:Z6,imageReference:eW,image:tW,inlineCode:nW,linkReference:rW,link:sW,listItem:iW,list:aW,paragraph:lW,root:cW,strong:uW,table:dW,tableCell:pW,tableRow:fW,text:mW,thematicBreak:gW,toml:pf,yaml:pf,definition:pf,footnoteDefinition:pf};function pf(){}const tP=-1,Ph=0,tu=1,Mp=2,tb=3,nb=4,rb=5,sb=6,nP=7,rP=8,tN=typeof self=="object"?self:globalThis,xW=(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 Ph:case tP:return n(a,s);case tu:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Mp:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case tb:return n(new Date(a),s);case nb:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case rb:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case sb:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case nP:{const{name:l,message:c}=a;return n(new tN[l](c),s)}case rP: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 tN[i](a),s)};return r},nN=e=>xW(new Map,e)(0),Da="",{toString:wW}={},{keys:bW}=Object,Nc=e=>{const t=typeof e;if(t!=="object"||!e)return[Ph,t];const n=wW.call(e).slice(8,-1);switch(n){case"Array":return[tu,Da];case"Object":return[Mp,Da];case"Date":return[tb,Da];case"RegExp":return[nb,Da];case"Map":return[rb,Da];case"Set":return[sb,Da];case"DataView":return[tu,n]}return n.includes("Array")?[tu,n]:n.includes("Error")?[nP,n]:[Mp,n]},hf=([e,t])=>e===Ph&&(t==="function"||t==="symbol"),kW=(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]=Nc(a);switch(l){case Ph:{let p=a;switch(c){case"bigint":l=rP,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);p=null;break;case"undefined":return s([tP],a)}return s([l,p],a)}case tu:{if(c){let d=a;return c==="DataView"?d=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(d=new Uint8Array(a)),s([c,[...d]],a)}const p=[],f=s([l,p],a);for(const d of a)p.push(i(d));return f}case Mp:{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 p=[],f=s([l,p],a);for(const d of bW(a))(e||!hf(Nc(a[d])))&&p.push([i(d),i(a[d])]);return f}case tb:return s([l,a.toISOString()],a);case nb:{const{source:p,flags:f}=a;return s([l,{source:p,flags:f}],a)}case rb:{const p=[],f=s([l,p],a);for(const[d,h]of a)(e||!(hf(Nc(d))||hf(Nc(h))))&&p.push([i(d),i(h)]);return f}case sb:{const p=[],f=s([l,p],a);for(const d of a)(e||!hf(Nc(d)))&&p.push(i(d));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return i},rN=(e,{json:t,lossy:n}={})=>{const r=[];return kW(!(t||n),!!t,new Map,r)(e),r},$p=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?nN(rN(e,t)):structuredClone(e):(e,t)=>nN(rN(e,t));function vW(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 SW(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function NW(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||vW,r=e.options.footnoteBackLabel||SW,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 u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const p=e.all(u),f=String(u.identifier).toUpperCase(),d=Wl(f.toLowerCase());let h=0;const g=[],b=e.footnoteCounts.get(f);for(;b!==void 0&&++h<=b;){g.length>0&&g.push({type:"text",value:" "});let w=typeof n=="string"?n:n(c,h);typeof w=="string"&&(w={type:"text",value:w}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(w)?w:[w]})}const v=p[p.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const w=v.children[v.children.length-1];w&&w.type==="text"?w.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...g)}else p.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(p,!0)};e.patch(u,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...$p(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 sP=function(e){if(e==null)return EW;if(typeof e=="function")return Ih(e);if(typeof e=="object")return Array.isArray(e)?jW(e):CW(e);if(typeof e=="string")return _W(e);throw new Error("Expected function, string, or object as test")};function jW(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=sP(e[n]);return Ih(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function CW(e){const t=e;return Ih(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function _W(e){return Ih(t);function t(n){return n&&n.type===e}}function Ih(e){return t;function t(n,r,s){return!!(AW(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function EW(){return!0}function AW(e){return e!==null&&typeof e=="object"&&"type"in e}const iP=[],PW=!0,sN=!1,IW="skip";function TW(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=sP(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,p){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(d,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=iP,g,b,v;if((!t||i(c,u,p[p.length-1]||void 0))&&(h=RW(n(c,p)),h[0]===sN))return h;if("children"in c&&c.children){const y=c;if(y.children&&h[0]!==IW)for(b=(r?y.children.length:-1)+a,v=p.concat(y);b>-1&&b<y.children.length;){const w=y.children[b];if(g=l(w,b,v)(),g[0]===sN)return g;b=typeof g[1]=="number"?g[1]:b+a}}return h}}}function RW(e){return Array.isArray(e)?e:typeof e=="number"?[PW,e]:e==null?iP:[e]}function oP(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),TW(e,i,l,s);function l(c,u){const p=u[u.length-1],f=p?p.children.indexOf(c):void 0;return a(c,f,p)}}const sx={}.hasOwnProperty,MW={};function $W(e,t){const n=t||MW,r=new Map,s=new Map,i=new Map,a={...yW,...n.handlers},l={all:u,applyData:OW,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:LW,wrap:FW};return oP(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const f=p.type==="definition"?r:s,d=String(p.identifier).toUpperCase();f.has(d)||f.set(d,p)}}),l;function c(p,f){const d=p.type,h=l.handlers[d];if(sx.call(l.handlers,d)&&h)return h(l,p,f);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in p){const{children:b,...v}=p,y=$p(v);return y.children=l.all(p),y}return $p(p)}return(l.options.unknownHandler||DW)(l,p,f)}function u(p){const f=[];if("children"in p){const d=p.children;let h=-1;for(;++h<d.length;){const g=l.one(d[h],p);if(g){if(h&&d[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=iN(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=iN(b.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function LW(e,t){e.position&&(t.position=wH(e))}function OW(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,$p(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function DW(e,t){const n=t.data||{},r="value"in t&&!(sx.call(n,"hProperties")||sx.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 FW(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 iN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function oN(e,t){const n=$W(e,t),r=n.one(e,void 0),s=NW(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 zW(e,t){return e&&"run"in e?async function(n,r){const s=oN(n,{file:r,...t});await e.run(s,r)}:function(n,r){return oN(n,{file:r,...e||t})}}function aN(e){if(e)throw e}var Gf=Object.prototype.hasOwnProperty,aP=Object.prototype.toString,lN=Object.defineProperty,cN=Object.getOwnPropertyDescriptor,uN=function(t){return typeof Array.isArray=="function"?Array.isArray(t):aP.call(t)==="[object Array]"},dN=function(t){if(!t||aP.call(t)!=="[object Object]")return!1;var n=Gf.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gf.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Gf.call(t,s)},fN=function(t,n){lN&&n.name==="__proto__"?lN(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},pN=function(t,n){if(n==="__proto__")if(Gf.call(t,n)){if(cN)return cN(t,n).value}else return;return t[n]},HW=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,u=arguments.length,p=!1;for(typeof l=="boolean"&&(p=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=pN(l,n),s=pN(t,n),l!==s&&(p&&s&&(dN(s)||(i=uN(s)))?(i?(i=!1,a=r&&uN(r)?r:[]):a=r&&dN(r)?r:{},fN(l,{name:n,newValue:e(p,a,s)})):typeof s<"u"&&fN(l,{name:n,newValue:s}));return l};const ng=bo(HW);function ix(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 BW(){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,...u){const p=e[++i];let f=-1;if(c){a(c);return}for(;++f<s.length;)(u[f]===null||u[f]===void 0)&&(u[f]=s[f]);s=u,p?WW(p,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function WW(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(u){const p=u;if(l&&n)throw p;return s(p)}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 zs={basename:VW,dirname:KW,extname:UW,join:qW,sep:"/"};function VW(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');sd(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 KW(e){if(sd(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 UW(e){sd(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 qW(...e){let t=-1,n;for(;++t<e.length;)sd(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":YW(n)}function YW(e){sd(e);const t=e.codePointAt(0)===47;let n=GW(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function GW(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 sd(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const JW={cwd:XW};function XW(){return"/"}function ox(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function QW(e){if(typeof e=="string")e=new URL(e);else if(!ox(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 ZW(e)}function ZW(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 rg=["history","path","basename","stem","extname","dirname"];class lP{constructor(t){let n;t?ox(t)?n={path:t}:typeof t=="string"||e8(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":JW.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<rg.length;){const i=rg[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)rg.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?zs.basename(this.path):void 0}set basename(t){ig(t,"basename"),sg(t,"basename"),this.path=zs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?zs.dirname(this.path):void 0}set dirname(t){hN(this.basename,"dirname"),this.path=zs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?zs.extname(this.path):void 0}set extname(t){if(sg(t,"extname"),hN(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=zs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ox(t)&&(t=QW(t)),ig(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?zs.basename(this.path,this.extname):void 0}set stem(t){ig(t,"stem"),sg(t,"stem"),this.path=zs.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 nr(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 sg(e,t){if(e&&e.includes(zs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+zs.sep+"`")}function ig(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hN(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function e8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const t8=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},n8={}.hasOwnProperty;class ib extends t8{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=BW()}copy(){const t=new ib;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ng(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(lg("data",this.frozen),this.namespace[t]=n,this):n8.call(this.namespace,t)&&this.namespace[t]||void 0:t?(lg("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=mf(t),r=this.parser||this.Parser;return og("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),og("process",this.parser||this.Parser),ag("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=mf(t),c=r.parse(l);r.run(c,l,function(p,f,d){if(p||!f||!d)return u(p);const h=f,g=r.stringify(h,d);i8(g)?d.value=g:d.result=g,u(p,d)});function u(p,f){p||!f?a(p):i?i(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),og("processSync",this.parser||this.Parser),ag("processSync",this.compiler||this.Compiler),this.process(t,s),gN("processSync","process",n),r;function s(i,a){n=!0,aN(i),r=a}}run(t,n,r){mN(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=mf(n);s.run(t,c,u);function u(p,f,d){const h=f||t;p?l(p):a?a(h):r(void 0,h,d)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),gN("runSync","run",r),s;function i(a,l){aN(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=mf(n),s=this.compiler||this.Compiler;return ag("stringify",s),mN(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(lg("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(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[p,...f]=u;c(p,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))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(u.plugins),u.settings&&(s.settings=ng(!0,s.settings,u.settings))}function l(u){let p=-1;if(u!=null)if(Array.isArray(u))for(;++p<u.length;){const f=u[p];i(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,p){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===u){d=f;break}if(d===-1)r.push([u,...p]);else if(p.length>0){let[h,...g]=p;const b=r[d][1];ix(b)&&ix(h)&&(h=ng(!0,b,h)),r[d]=[u,h,...g]}}}}const r8=new ib().freeze();function og(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ag(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function lg(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 mN(e){if(!ix(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function gN(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function mf(e){return s8(e)?e:new lP(e)}function s8(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function i8(e){return typeof e=="string"||o8(e)}function o8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const a8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",yN=[],xN={allowDangerousHtml:!0},l8=/^(https?|ircs?|mailto|xmpp)$/i,c8=[{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 cP(e){const t=u8(e),n=d8(e);return f8(t.runSync(t.parse(n),n),e)}function u8(e){const t=e.rehypePlugins||yN,n=e.remarkPlugins||yN,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xN}:xN;return r8().use(K6).use(n).use(zW,r).use(t)}function d8(e){const t=e.children||"",n=new lP;return typeof t=="string"&&(n.value=t),n}function f8(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||p8;for(const p of c8)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+a8+p.id,void 0);return oP(e,u),NH(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function u(p,f,d){if(p.type==="raw"&&d&&typeof f=="number")return a?d.children.splice(f,1):d.children[f]={type:"text",value:p.value},f;if(p.type==="element"){let h;for(h in Zm)if(Object.hasOwn(Zm,h)&&Object.hasOwn(p.properties,h)){const g=p.properties[h],b=Zm[h];(b===null||b.includes(p.tagName))&&(p.properties[h]=c(String(g||""),h,p))}}if(p.type==="element"){let h=n?!n.includes(p.tagName):i?i.includes(p.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(p,f,d)),h&&d&&typeof f=="number")return l&&p.children?d.children.splice(f,1,...p.children):d.children.splice(f,1),f}}}function p8(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||l8.test(e.slice(0,t))?e:""}const h8=new Set(["echarts"]),m8=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),g8=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),y8=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function po(e){return e&&typeof e=="object"&&!Array.isArray(e)}function la(e,t){if(!po(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:po(n[r])&&po(s)&&(n[r]=la(n[r],s));return n}function Th(e,t){return e==null?e:Array.isArray(e)?e.map(n=>po(n)?la(n,t):n):po(e)?la(e,t):e}function x8(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 ax(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)=>ax(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||g8.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);ax(r,`${t}.${n}`)}}}function w8(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(!m8.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function b8(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:la(e,t)}function k8(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(!po(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return la(i,n)}):po(e)?la(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function v8(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Th(e,n)}function wN(e,t="rgba(255, 255, 255, 0.62)"){return Th(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 S8(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Th(e,n)}function N8(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:Th(e,t)}function j8(e,t,n){const r=k8(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>po(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??y8,textStyle:la(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:b8(e.tooltip),legend:v8(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?S8(e.grid,s||i):e.grid,xAxis:wN(e.xAxis),yAxis:wN(e.yAxis),radar:N8(e.radar),series:t}}function C8(e){const t=x8(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(!h8.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");ax(n);const r=w8(n.option.series),s=n.title==null?"":String(n.title),i=j8(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)}}}function xi(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 uP(e){const t=xi(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function dP(e){return xi(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function _8(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function E8(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?i(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function A8({code:e}){const t=m.useMemo(()=>E8(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,i=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((p,f)=>{l.set(p.id,{x:28+(n?f*(r+i):f%3*(r+i)),y:28+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(p=>p.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(p=>p.y+s+28));return o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-md-mermaid-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((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const g=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return o.jsx("path",{className:"af-md-mermaid-edge",d:g,markerEnd:"url(#af-md-mermaid-arrow)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,24)})]},p.id)})]})}function P8(e){const t=String(e||"").split(/\r?\n/).map(i=>i.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],s=(i,a="")=>{const l=String(i||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const i of t){if(/^sequenceDiagram\b/i.test(i))continue;const a=i.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){s(a[2],a[3]||a[2]);continue}const l=i.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){s(l[1]),s(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=i.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:i})}return{participants:Array.from(n,([i,a])=>({id:i,label:a})),rows:r}}function I8({code:e}){const t=m.useMemo(()=>P8(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,i=26,a=44,l=48,c=Math.max(620,s*2+n.length*r),u=Math.max(220,i+a+Math.max(1,t.rows.length)*l+34),p=f=>{const d=Math.max(0,n.findIndex(h=>h.id===f));return s+d*r+r/2};return o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-md-sequence-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"})})}),n.map((f,d)=>{const h=s+d*r+r/2;return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:i,width:"136",height:"34",rx:"8"}),o.jsx("text",{className:"af-md-mermaid-text",x:h,y:i+22,textAnchor:"middle",children:f.label.slice(0,18)}),o.jsx("line",{className:"af-md-sequence-life",x1:h,y1:i+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,d)=>{const h=i+a+d*l+24;if(f.type!=="message")return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:c-s*2,height:"30",rx:"7"}),o.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${d}`);const g=p(f.from),b=p(f.to),v=(g+b)/2;return o.jsxs("g",{children:[o.jsx("line",{className:"af-md-mermaid-edge",x1:g,y1:h,x2:b,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),o.jsx("text",{className:"af-md-sequence-label",x:v,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${d}`)})]})}function fP({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return o.jsx("div",{className:"af-md-mermaid-preview",children:n?o.jsx(I8,{code:t}):o.jsx(A8,{code:t})})}function T8(e){const t=String(e||"").replace(/\r\n/g,`
80
- `).split(`
81
- `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
82
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&c){i();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
83
- `)});continue}if(!s&&_8(l)){i();const u=[];for(;a<t.length;){const p=t[a]||"";if(u.length>0&&(!p.trim()||/^-{3,}\s*$/.test(p)||/^#{1,6}\s+/.test(p)))break;u.push(p),a++}n.push({type:"mermaid",text:u.join(`
84
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&xi(l).length>1&&uP(t[a+1])){i();const u=xi(l),p=dP(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&xi(t[a]).length>1;)f.push(xi(t[a])),a++;n.push({type:"table",headers:u,align:p,rows:f});continue}r.push(l),a++}return i(),n}function bN(e,t=""){const n=String(e||"").trim();if(!n||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n)||n.startsWith("/")||n.startsWith("#")||!t||n.startsWith("outputs/"))return n;const r=String(t||"").split("/").filter(Boolean);r.pop();const s=[...r,...n.split("/")].filter(Boolean),i=[];for(const a of s)if(a!=="."){if(a===".."){if(i.length===0)return n;i.pop();continue}i.push(a)}return i.join("/")}function pP(e){const t=String(e||"").replace(/\r\n/g,`
85
- `).split(`
86
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",i=0,a=!1;for(;i<r.length;){const l=r[i];if(l==="`"){a=!a,s+=l,i+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(i)))){s+=l,i+=1;continue}if((i>0?r[i-1]:"")==="("){s+=l,i+=1;continue}let p=i;for(;p<r.length&&!/\s|<|>/.test(r[p]);)p+=1;let f=r.slice(i,p),d="";for(;/[.,;:!?)}\]]$/.test(f);)d=f.slice(-1)+d,f=f.slice(0,-1);f?s+=`[${f}](${f})${d}`:s+=r.slice(i,p),i=p}return s}).join(`
87
- `)}function hP(e,t=!1,n=""){const r=i=>{const a=String(i||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=bN(a,n);return e?e(l,{kind:"link",download:!0}):l},s=(i,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(i.stopPropagation(),!(i.defaultPrevented||i.button!==0)&&(i.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:i})=>o.jsx(o.Fragment,{children:i})}:{},code:({inline:i,className:a,children:l})=>{var p;const c=((p=String(a||"").match(/language-(\w+)/i))==null?void 0:p[1])||"",u=String(l||"").replace(/\n$/,"");return!i&&/^(mermaid|mmd)$/i.test(c)?o.jsx(fP,{code:u}):i?o.jsx("code",{className:a,children:l}):o.jsx("code",{className:a,children:l})},img:({src:i,alt:a})=>o.jsx("img",{src:e?e(bN(i,n)):i||"",alt:a||"",loading:"lazy"}),a:({href:i,children:a})=>o.jsx("a",{href:r(i),target:"_blank",rel:"noopener noreferrer",onClick:l=>s(l,i),children:a})}}function kN({children:e,resolveSrc:t,basePath:n=""}){return o.jsx(cP,{components:hP(t,!0,n),children:pP(e)})}function ob({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>T8(e),[e]),s=m.useMemo(()=>hP(t,!1,n),[n,t]);return o.jsx(o.Fragment,{children:r.map((i,a)=>i.type==="mermaid"?o.jsx(fP,{code:i.text},`mermaid-${a}`):i.type!=="table"?o.jsx(cP,{components:s,children:pP(i.text)},`md-${a}`):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:i.headers.map((l,c)=>o.jsx("th",{style:{textAlign:i.align[c]||"left"},children:o.jsx(kN,{resolveSrc:t,basePath:n,children:l})},c))})}),o.jsx("tbody",{children:i.rows.map((l,c)=>o.jsx("tr",{children:i.headers.map((u,p)=>o.jsx("td",{style:{textAlign:i.align[p]||"left"},children:o.jsx(kN,{resolveSrc:t,basePath:n,children:l[p]||""})},p))},c))})]})},`table-${a}`))})}function R8(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
88
- `);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(i){c==='"'&&u==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
89
- `?(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 Ds(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 M8(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=>Ds(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>Ds(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)=>Ds(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:Ds(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:Ds(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>Ds(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>Ds(s[a])):s&&typeof s=="object"?r.map(i=>Ds(s[i.key])):r.map((i,a)=>a===0?Ds(s):""))}}function $8(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=M8(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
90
- `).split(`
91
- `).filter(l=>l.trim());if(s.length>=2&&xi(s[0]).length>1&&uP(s[1])){const l=xi(s[0]),c=dP(s[1]);return{columns:l.map((u,p)=>({key:String(p),label:u,align:c[p]||"left"})),rows:s.slice(2).map(u=>xi(u)),error:""}}const i=r.includes(" ")?" ":",",a=R8(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function ab({content:e}){const t=m.useMemo(()=>$8(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:Ds(n[i])},`${s.key}-${i}`))},r))})]})})}function lb({content:e}){const t=m.useRef(null),n=m.useMemo(()=>C8(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:""}),_5(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{i||!t.current||(a=u.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(u=>{i||s({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,p;i=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(p=a==null?void 0:a.dispose)==null||p.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]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function mP(e){return typeof e>"u"||e===null}function L8(e){return typeof e=="object"&&e!==null}function O8(e){return Array.isArray(e)?e:mP(e)?[]:[e]}function D8(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 F8(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function z8(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var H8=mP,B8=L8,W8=O8,V8=F8,K8=z8,U8=D8,cb={isNothing:H8,isObject:B8,toArray:W8,repeat:V8,isNegativeZero:K8,extend:U8};function gP(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+=`
92
-
93
- `+e.mark.snippet),r+" "+n):r}function Mu(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=gP(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Mu.prototype=Object.create(Error.prototype);Mu.prototype.constructor=Mu;Mu.prototype.toString=function(t){return this.name+": "+gP(this,t)};var Do=Mu,q8=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Y8=["scalar","sequence","mapping"];function G8(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function J8(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(q8.indexOf(n)===-1)throw new Do('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=G8(t.styleAliases||null),Y8.indexOf(this.kind)===-1)throw new Do('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Zn=J8;function vN(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 X8(){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 lx(e){return this.extend(e)}lx.prototype.extend=function(t){var n=[],r=[];if(t instanceof Zn)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 Do("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof Zn))throw new Do("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new Do("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 Do("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 Zn))throw new Do("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(lx.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=vN(s,"implicit"),s.compiledExplicit=vN(s,"explicit"),s.compiledTypeMap=X8(s.compiledImplicit,s.compiledExplicit),s};var Q8=lx,Z8=new Zn("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),e9=new Zn("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),t9=new Zn("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),n9=new Q8({explicit:[Z8,e9,t9]});function r9(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function s9(){return null}function i9(e){return e===null}var o9=new Zn("tag:yaml.org,2002:null",{kind:"scalar",resolve:r9,construct:s9,predicate:i9,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function a9(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 l9(e){return e==="true"||e==="True"||e==="TRUE"}function c9(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var u9=new Zn("tag:yaml.org,2002:bool",{kind:"scalar",resolve:a9,construct:l9,predicate:c9,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 d9(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function f9(e){return 48<=e&&e<=55}function p9(e){return 48<=e&&e<=57}function h9(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(!d9(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!f9(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!p9(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function m9(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 g9(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!cb.isNegativeZero(e)}var y9=new Zn("tag:yaml.org,2002:int",{kind:"scalar",resolve:h9,construct:m9,predicate:g9,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"]}}),x9=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function w9(e){return!(e===null||!x9.test(e)||e[e.length-1]==="_")}function b9(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 k9=/^[-+]?[0-9]+e/;function v9(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(cb.isNegativeZero(e))return"-0.0";return n=e.toString(10),k9.test(n)?n.replace("e",".e"):n}function S9(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||cb.isNegativeZero(e))}var N9=new Zn("tag:yaml.org,2002:float",{kind:"scalar",resolve:w9,construct:b9,predicate:S9,represent:v9,defaultStyle:"lowercase"}),j9=n9.extend({implicit:[o9,u9,y9,N9]}),C9=j9,yP=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),xP=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 _9(e){return e===null?!1:yP.exec(e)!==null||xP.exec(e)!==null}function E9(e){var t,n,r,s,i,a,l,c=0,u=null,p,f,d;if(t=yP.exec(e),t===null&&(t=xP.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]&&(p=+t[10],f=+(t[11]||0),u=(p*60+f)*6e4,t[9]==="-"&&(u=-u)),d=new Date(Date.UTC(n,r,s,i,a,l,c)),u&&d.setTime(d.getTime()-u),d}function A9(e){return e.toISOString()}var P9=new Zn("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:_9,construct:E9,instanceOf:Date,represent:A9});function I9(e){return e==="<<"||e===null}var T9=new Zn("tag:yaml.org,2002:merge",{kind:"scalar",resolve:I9}),ub=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
- \r`;function R9(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=ub;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 M9(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=ub,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 $9(e){var t="",n=0,r,s,i=e.length,a=ub;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 L9(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var O9=new Zn("tag:yaml.org,2002:binary",{kind:"scalar",resolve:R9,construct:M9,predicate:L9,represent:$9}),D9=Object.prototype.hasOwnProperty,F9=Object.prototype.toString;function z9(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,F9.call(s)!=="[object Object]")return!1;for(i in s)if(D9.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 H9(e){return e!==null?e:[]}var B9=new Zn("tag:yaml.org,2002:omap",{kind:"sequence",resolve:z9,construct:H9}),W9=Object.prototype.toString;function V9(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],W9.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function K9(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 U9=new Zn("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:V9,construct:K9}),q9=Object.prototype.hasOwnProperty;function Y9(e){if(e===null)return!0;var t,n=e;for(t in n)if(q9.call(n,t)&&n[t]!==null)return!1;return!0}function G9(e){return e!==null?e:{}}var J9=new Zn("tag:yaml.org,2002:set",{kind:"mapping",resolve:Y9,construct:G9});C9.extend({implicit:[P9,T9],explicit:[O9,B9,U9,J9]});function SN(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
95
- `: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":""}var X9=new Array(256),Q9=new Array(256);for(var Fa=0;Fa<256;Fa++)X9[Fa]=SN(Fa)?1:0,Q9[Fa]=SN(Fa);const $u=["requirement","planning","code","test","normal"],NN={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function db(e,t){var s,i,a,l,c,u,p,f,d,h,g,b,v,y;const n=w=>{const x={type:(w==null?void 0:w.type)??"node",name:(w==null?void 0:w.name)??"",value:(w==null?void 0:w.value)??(w==null?void 0:w.default)??""};return(w==null?void 0:w.required)===!0&&(x.required=!0),(w==null?void 0:w.description)!=null&&String(w.description).trim()&&(x.description=String(w.description)),(w==null?void 0:w.showOnNode)!=null&&(x.showOnNode=!!w.showOnNode),x},r={};for(const w of e){if((s=w==null?void 0:w.data)!=null&&s.isWorkspaceGroup)continue;const x=t[w.id]&&typeof t[w.id]=="object"?{...t[w.id]}:{},S=((i=w.data)==null?void 0:i.definitionId)||w.id,C=((a=w.data)==null?void 0:a.inputs)??[],j=((l=w.data)==null?void 0:l.outputs)??[],E=((c=w.data)==null?void 0:c.role)!=null?String(w.data.role).trim():"",P=x.role!=null?String(x.role).trim():"",F=NN[E]||E,V=NN[P]||P,z=$u.includes(F)?F:$u.includes(V)?V:"normal",D=Array.isArray(C)?C.map(n):Array.isArray(x.input)?x.input.map(se=>n(se)):[],R=Array.isArray(j)?j.map(n):Array.isArray(x.output)?x.output.map(se=>n(se)):[],T=((u=w.data)==null?void 0:u.label)!=null?String(w.data.label):x.label!=null?String(x.label):w.id,L=(p=w.data)==null?void 0:p.body,$=L!=null?String(L):x.body!=null?String(x.body):"";let O=((f=w.data)==null?void 0:f.model)!=null&&String(w.data.model).trim()!==""?String(w.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(O===""||O==="default")&&(O=void 0);const A={...x,definitionId:S,label:T,role:z,model:O,input:D,output:R},M=((d=w.data)==null?void 0:d.marketplaceRef)||x.marketplaceRef;M?A.marketplaceRef=String(M):delete A.marketplaceRef;const _=((h=w.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;_?A.marketplacePackageId=String(_):delete A.marketplacePackageId;const U=((g=w.data)==null?void 0:g.marketplaceVersion)||x.marketplaceVersion;U?A.marketplaceVersion=String(U):delete A.marketplaceVersion,S.startsWith("provide_")||$.trim()===""?delete A.body:A.body=$;const q=Array.isArray((b=w.data)==null?void 0:b.images)?w.data.images:Array.isArray(x.images)?x.images:[];q.length>0?A.images=q:delete A.images;const B=(v=w.data)==null?void 0:v.script,Q=B!=null?String(B):x.script!=null?String(x.script):"";Q.trim()===""?delete A.script:A.script=Q;for(const se of["scriptRef","implementationRef","implementationMode"]){const oe=(y=w.data)==null?void 0:y[se],ve=oe!=null?String(oe):x[se]!=null?String(x[se]):"";ve.trim()===""?delete A[se]:A[se]=ve.trim()}delete A.temperature,delete A.maxTokens,delete A.description,r[w.id]=A}return r}function nu(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Z9(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 eV(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=>nu(a)),edges:i.map(a=>nu(a)),instances:db(r,n||{})}}function tV(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(d=>d.id)),l=new Map;for(const d of e.nodes)l.set(d.id,Z9(d.id,a));const c=e.nodes.map(d=>{var g,b;const h=l.get(d.id);return{...nu(d),id:h,selected:!0,dragging:!1,position:{x:Number(((g=d.position)==null?void 0:g.x)||0)+i.x,y:Number(((b=d.position)==null?void 0:b.y)||0)+i.y}}}),u=(e.edges||[]).filter(d=>l.has(d.source)&&l.has(d.target)).map((d,h)=>{const g=l.get(d.source),b=l.get(d.target);return{...nu(d),id:`e-${g}-${b}-${Date.now()}-${h}`,source:g,target:b,selected:!1}}),p={...r||{}};for(const[d,h]of l.entries()){const g=(f=e.instances)==null?void 0:f[d];g&&(p[h]={...nu(g),label:g.label!=null?String(g.label):h})}return{nodes:[...(t||[]).map(d=>({...d,selected:!1})),...c],edges:[...(n||[]).map(d=>({...d,selected:!1})),...u],instances:p,pastedNodeIds:c.map(d=>d.id)}}function gn(e){switch(Lp(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Lp(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 nV(e,t){const n=Lp(e),r=Lp(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const rV=new Set(["workspaceContext","skillsContext","mcpContext"]);function cx(e){const t=Lp(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&rV.has(n)?`${t}+${n}`:t}function sV(e){return cx(e)}function Lu(e,t){if(!e||!t||!nV(e.type,t.type))return!1;const n=cx(e),r=cx(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function iV(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 ux(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=iV(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}const Op=/\[image\s+(\d+)\]/gi;function Pi(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 oV(e){return`image ${Pi(e).length+1}`}function aV(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function lV(e,t){const n=Pi(e),r=String(t||""),s=new Set;Op.lastIndex=0;let i;for(;i=Op.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function cV(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 wP(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 ru(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 bP({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=Pi(n);for(const a of r){const l=await cV(a),c=oV(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=aV(s,c)}return{body:s,images:i}}function qr(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function uV(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 dV(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Ft(e){e.stopPropagation()}function fV(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pV(e,t){const n=`\\[${fV(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
- `).replace(/\n{3,}/g,`
97
-
98
- `).trimEnd()}function cg(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hV(e){const t=String(e||"");let n="",r=0;Op.lastIndex=0;let s;for(;s=Op.exec(t);)n+=cg(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${cg(s[0])}</span>`,r=s.index+s[0].length;return n+=cg(t.slice(r)),n||" "}function mV(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,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+s+i+a+l)}function gV({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u}){var Pr,zt;const{t:p}=pr(),f=(e==null?void 0:e.inputs)??[],d=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=uV(e),b=(e==null?void 0:e.isRunMode)??!1,v=!!(e!=null&&e.readOnly),y=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,x=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",j=C.startsWith("provide_"),E=C==="provide_bool",P=C==="provide_str",F=C==="provide_file",V=C==="provide_password",z=C==="agent_subAgent",D=C==="control_agent_toBool",R=(z||D)&&!b,T=E?dV(d[0]):!1,L=j?String(((Pr=d[0])==null?void 0:Pr.value)??((zt=d[0])==null?void 0:zt.default)??(e==null?void 0:e.body)??""):"",$=String((e==null?void 0:e.body)||""),O=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||p("flow:node.fallbackLabel"),A=!j&&!R&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",M=Pi(e==null?void 0:e.images),_=E||P||F||V||R||!!A,U=m.useRef(!1),q=m.useRef(!1),B=m.useRef(null),Q=m.useRef(null),se=m.useRef(null),oe=m.useRef(null),ve=m.useRef(null),[re,ue]=m.useState(L),[te,ae]=m.useState(!1),[pe,be]=m.useState($),[Fe,Ue]=m.useState(!1),[Me,et]=m.useState({visible:!1,top:0,height:100}),[ht,Ie]=m.useState(!1),tt=m.useCallback(()=>{const ne=Q.current;if(!ne)return;const we=Math.max(1,ne.scrollHeight),Z=Math.max(1,ne.clientHeight),ge=we>Z+1,Ae=ge?Math.max(12,Z/we*100):100,bt=Math.max(0,100-Ae),Ct=ge?Math.min(bt,ne.scrollTop/Math.max(1,we-Z)*bt):0;et({visible:ge,top:Ct,height:Ae})},[]);m.useEffect(()=>{U.current||ue(L)},[n,L]),m.useEffect(()=>{q.current||be($)},[n,$]),m.useEffect(()=>{const ne=Q.current;if(!ne)return;if(R){ne.style.minHeight="",ne.style.height="",se.current&&(se.current.style.minHeight="",se.current.style.height="");return}const we=mV(ne,pe);ne.style.minHeight=`${we}px`,ne.style.height="",se.current&&(se.current.style.minHeight=`${we}px`,se.current.style.height="")},[pe,R]),m.useEffect(()=>{if(!R)return;const ne=window.requestAnimationFrame(tt),we=Q.current;if(!we||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ne);const Z=new ResizeObserver(tt);return Z.observe(we),()=>{window.cancelAnimationFrame(ne),Z.disconnect()}},[pe,R,tt]),m.useEffect(()=>{const ne=B.current,we=e==null?void 0:e.onNodeContentResize;if(!R||!ne||!we||typeof ResizeObserver>"u")return;let Z=0;const ge=()=>{window.cancelAnimationFrame(Z),Z=window.requestAnimationFrame(()=>we(n))},Ae=new ResizeObserver(ge);return Ae.observe(ne),ge(),()=>{window.cancelAnimationFrame(Z),Ae.disconnect()}},[e==null?void 0:e.onNodeContentResize,R,n]),m.useEffect(()=>{if(!ht)return;const ne=window.setTimeout(()=>{const we=ve.current;if(!we)return;we.focus();const Z=we.value.length;we.setSelectionRange(Z,Z)},0);return()=>window.clearTimeout(ne)},[ht]);const Wt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],$e=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],Vt=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Gt=Array.isArray(c==null?void 0:c.codex)?c.codex:[],nt=((e==null?void 0:e.model)??"").trim(),ie=h==="agent"&&!C.startsWith("tool_nodejs"),ke=new Set(Wt.map(qr)),Oe=new Set($e.map(qr)),We=new Set(Vt.map(qr)),Je=new Set(Gt.map(qr)),vt=nt?nt.startsWith("cursor:")||nt.startsWith("opencode:")||nt.startsWith("codex:")||nt.startsWith("claude-code:")?nt:We.has(nt)?`claude-code:${nt}`:Je.has(nt)?`codex:${nt}`:Oe.has(nt)?`opencode:${nt}`:ke.has(nt)?`cursor:${nt}`:nt:"",ee=nt&&!vt.startsWith("cursor:")&&!vt.startsWith("opencode:")&&!vt.startsWith("codex:")&&!vt.startsWith("claude-code:")&&!ke.has(nt)&&!Oe.has(nt)&&!We.has(nt)&&!Je.has(nt),ye=nt.startsWith("cursor:")?nt.slice(7):nt.startsWith("opencode:")?nt.slice(9):nt.startsWith("codex:")?nt.slice(6):nt.startsWith("claude-code:")?nt.slice(12):nt,Ve=ne=>{if(v)return;const we=ne.target.value;u&&u(n,we)},Ce=ne=>{ne.stopPropagation(),!v&&r&&r(n)},at=ne=>{ne.stopPropagation(),s&&s()},mt=ne=>{ne.stopPropagation(),!v&&(i==null||i(n,ne.target.value==="true"?"true":"false"))},Qt=ne=>{if(ne.stopPropagation(),v)return;const we=ne.target.value;ue(we),U.current||i==null||i(n,we)},hr=ne=>{ne.stopPropagation(),U.current=!0},Ln=ne=>{if(ne.stopPropagation(),v)return;U.current=!1;const we=ne.currentTarget.value;ue(we),i==null||i(n,we)},On=()=>{v||i==null||i(n,re)},Nn=ne=>{if(ne.stopPropagation(),v)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,re);return}const we=window.prompt("文件路径",re);we!=null&&(ue(we),i==null||i(n,we))},Zt=ne=>{ne.stopPropagation(),ae(we=>!we)},Kn=ne=>{if(be(ne),a==null||a(n,ne),l){const we=lV(M,ne);(we.length!==M.length||we.some((Z,ge)=>{var Ae;return Z.id!==((Ae=M[ge])==null?void 0:Ae.id)}))&&l(n,we)}},pn=ne=>{if(ne.stopPropagation(),v)return;const we=ne.target.value;q.current?be(we):Kn(we)},Pn=ne=>{ne.stopPropagation(),!v&&(q.current=!0,Ue(!0))},jn=ne=>{if(ne.stopPropagation(),v)return;q.current=!1,Ue(!1);const we=ne.currentTarget.value;Kn(we)},Dn=()=>{v||(q.current=!1,Ue(!1),Kn(pe))},Er=ne=>{ne.stopPropagation(),ne.preventDefault(),!v&&Ie(!0)},Fn=()=>{Ie(!1),Dn()},si=ne=>{ne.stopPropagation(),ne.key==="Escape"&&(ne.preventDefault(),Fn())},mr=m.useCallback(ne=>{const we=Q.current;if(!we)return;const Z=Math.max(0,we.scrollHeight-we.clientHeight);we.scrollTop=Math.min(1,Math.max(0,ne))*Z,tt()},[tt]),Ur=m.useCallback((ne,we=0)=>{const Z=oe.current;if(!Z)return 0;const ge=Z.getBoundingClientRect(),Ae=Me.height/100*ge.height,bt=Math.max(1,ge.height-Ae);return(ne-ge.top-we)/bt},[Me.height]),Ar=m.useCallback(ne=>{var Pe,Ut;if(!Me.visible)return;ne.preventDefault(),ne.stopPropagation();const we=oe.current;if(!we)return;const Z=we.getBoundingClientRect(),ge=Me.top/100*Z.height,Ae=Me.height/100*Z.height,Ct=ne.clientY>=Z.top+ge&&ne.clientY<=Z.top+ge+Ae?ne.clientY-Z.top-ge:Ae/2;mr(Ur(ne.clientY,Ct));const Kt=ne.pointerId;(Ut=(Pe=ne.currentTarget).setPointerCapture)==null||Ut.call(Pe,Kt);const qe=Xe=>{Xe.preventDefault(),mr(Ur(Xe.clientY,Ct))},Ot=()=>{window.removeEventListener("pointermove",qe),window.removeEventListener("pointerup",Ot),window.removeEventListener("pointercancel",Ot)};window.addEventListener("pointermove",qe),window.addEventListener("pointerup",Ot),window.addEventListener("pointercancel",Ot)},[Ur,Me.height,Me.top,Me.visible,mr]),ss=async ne=>{if(v)return;const we=await bP({files:ne,body:pe,images:M});we&&(be(we.body),a==null||a(n,we.body),l==null||l(n,we.images))},In=(ne,we)=>{if(ne.stopPropagation(),v)return;const Z=M.filter(Ae=>Ae.id!==we.id),ge=pV(pe,we.label);be(ge),a==null||a(n,ge),l==null||l(n,Z)},gr=ne=>{if(v)return;const we=wP(ne);we.length!==0&&(ne.preventDefault(),ne.stopPropagation(),ss(we).catch(()=>{}))},rr=ne=>{if(v)return;const we=ru(ne);we.length!==0&&(ne.preventDefault(),ne.stopPropagation(),ss(we).catch(()=>{}))},Ms=()=>{const ne=Q.current,we=se.current;!ne||!we||(we.scrollTop=ne.scrollTop,we.scrollLeft=ne.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(x==="success"?" af-flow-node--done":"")+(x==="failed"?" af-flow-node--failed":"")+(x==="running"&&!y?" af-flow-node--running-disk":"")+(w?" af-flow-node--dim":"")+(R?" af-flow-node--inline-body-editor":"")+(P?" af-flow-node--provide-text":"")+(V?" af-flow-node--provide-password":"")+" 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__title af-flow-node__title--chrome",title:`${O}${n?` (${n})`:""}${g?` · ${g}`:""}`,children:O}),!b&&ie&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:vt,onChange:Ve,onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,"aria-label":p("flow:node.model"),title:ye||p("flow:node.defaultModel"),disabled:v,children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),ee&&o.jsx("option",{value:nt,children:nt}),Wt.length>0&&o.jsx("optgroup",{label:"Cursor",children:Wt.map(ne=>o.jsx("option",{value:`cursor:${qr(ne)}`,children:qr(ne)},`c-${ne}`))}),$e.length>0&&o.jsx("optgroup",{label:"OpenCode",children:$e.map(ne=>o.jsx("option",{value:`opencode:${qr(ne)}`,children:qr(ne)},`o-${ne}`))}),Gt.length>0&&o.jsx("optgroup",{label:"Codex",children:Gt.map(ne=>o.jsx("option",{value:`codex:${qr(ne)}`,children:qr(ne)},`codex-${ne}`))}),Vt.length>0&&o.jsx("optgroup",{label:"Claude Code",children:Vt.map(ne=>o.jsx("option",{value:`claude-code:${qr(ne)}`,children:qr(ne)},`cc-${ne}`))})]}),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"}),x==="running"&&!y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),x==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),x==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&j&&!E&&!P&&!F&&!V&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:at,"aria-label":p("flow:node.expandProvide"),title:p("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:v,onClick:Ce,"aria-label":p("flow:node.deleteNode"),title:p("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((ne,we)=>{if(ne.showOnNode===!1)return null;const Z=p("flow:node.inputTooltip",{name:ne.name||`#${we}`,type:ne.type})+(ne.default!=null&&ne.default!==""?p("flow:node.defaultSuffix",{value:ne.default}):""),ge=ne.name||`#${we+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Z,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[ge,ne.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${we}`,className:"af-flow-node__handle",style:{background:gn(ne.type)},title:Z})]},`in-${we}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[E?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(T?" af-flow-node__bool-select--true":""),value:T?"true":"false",onChange:mt,onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,"aria-label":"Boolean value",title:T?"true":"false",disabled:v,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):P?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:re,onChange:Qt,onCompositionStart:hr,onCompositionEnd:Ln,onBlur:On,onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,placeholder:"输入文本",rows:2,readOnly:v}):F?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:re,onChange:Qt,onCompositionStart:hr,onCompositionEnd:Ln,onBlur:On,placeholder:"选择或输入文件路径",title:re||"选择或输入文件路径",readOnly:v}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:v,onClick:Nn,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):V?o.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,children:[o.jsx("input",{className:"af-flow-node__password-input nodrag",type:te?"text":"password",value:re,onChange:Qt,onCompositionStart:hr,onCompositionEnd:Ln,onBlur:On,placeholder:"输入密码或密钥",title:te?re:"密码已隐藏",autoComplete:"off",readOnly:v}),o.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:v,onClick:Zt,"aria-label":te?"隐藏密码":"预览密码",title:te?"隐藏密码":"预览密码",children:o.jsx("span",{className:"material-symbols-outlined",children:te?"visibility_off":"visibility"})})]}):R?o.jsxs("div",{ref:B,className:"af-flow-node__prompt-stack nodrag"+(Fe?" af-flow-node__prompt-stack--composing":""),children:[o.jsx("pre",{ref:se,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:hV(pe)+`
99
- `}}),o.jsx("textarea",{ref:Q,className:"af-flow-node__prompt-editor nodrag",value:pe,onChange:pn,onCompositionStart:Pn,onCompositionEnd:jn,onBlur:Dn,onPaste:gr,onDrop:rr,onScroll:ne=>{Ms(),tt()},onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,onKeyDown:Ft,onDragOver:ne=>{ru(ne).length>0&&ne.preventDefault()},placeholder:D?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:v}),!v&&o.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:Ft,onMouseDown:Ft,onClick:Er,"aria-label":"放大编辑",title:"放大编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),o.jsx("div",{ref:oe,className:"af-flow-node__prompt-scrollbar"+(Me.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:Ar,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${Me.height}%`,top:`${Me.top}%`}})})]}):null,R&&M.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:M.map((ne,we)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ne.name,children:[o.jsx("img",{src:ne.dataUrl,alt:""}),o.jsxs("span",{children:["[",ne.label||`image ${we+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:v,onClick:Z=>In(Z,ne),onPointerDown:Ft,onMouseDown:Ft,"aria-label":`删除 ${ne.label||`image ${we+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ne.id||we))}):null,A?o.jsx("span",{className:"af-flow-node__prompt-preview",title:A,children:A}):null,_?null:o.jsx("span",{className:"af-flow-node__body-title",title:O,children:O})]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:d.map((ne,we)=>{if(ne.showOnNode===!1)return null;const Z=p("flow:node.outputTooltip",{name:ne.name||`#${we}`,type:ne.type})+(ne.default!=null&&ne.default!==""?p("flow:node.defaultSuffix",{value:ne.default}):""),ge=ne.name||`#${we+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Z,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[ge,ne.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${we}`,className:"af-flow-node__handle",style:{background:gn(ne.type)},title:Z})]},`out-${we}`)})})]}),ht?cr.createPortal(o.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:Ft,onMouseDown:Ft,onClick:Ft,onWheel:Ft,children:o.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[o.jsxs("div",{className:"af-flow-node-full-editor__header",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-flow-node-full-editor__title",children:O}),o.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),o.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:Fn,"aria-label":"关闭",title:"关闭",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("textarea",{ref:ve,className:"af-flow-node-full-editor__textarea",value:pe,onChange:pn,onCompositionStart:Pn,onCompositionEnd:jn,onPaste:gr,onDrop:rr,onKeyDown:si,onDragOver:ne=>{ru(ne).length>0&&ne.preventDefault()},placeholder:D?"输入判断条件 / prompt":"输入 prompt",readOnly:v})]})}),document.body):null]})}const xl="flowNode";function dx(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),e.description!=null&&(r.description=String(e.description)),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const yV={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"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],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_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],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_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_react_app:["React App"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function xV(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(yV[e]||[]).includes(s)?r:s}const wV={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"])},bV={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),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"])},kV=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function vV(e,t){if(!kV.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function SV(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function NV(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function kP(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function jV(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function CV(e){const t=String(e??"").trim();return t?t.includes("${")?t:kP(t):""}function _V(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const r=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),s=r?`${r}/${n}`:`\${flowDir}/${n}`,i=Array.isArray(t.args)?t.args.map(CV).filter(Boolean):[];return[jV(t,n),kP(s),...i].join(" ")}return String(t.command||"").trim()}function jN(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,p;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&&((u=wV[e])==null?void 0:u.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...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"}:{},...!r._showOnNodeExplicit&&vV(e,r)?{showOnNode:!0}:{},...(p=bV[e])!=null&&p.has(r.name)?{showOnNode:!1}:{}}})}function EV(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=dx(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function fx(e,t,n,r,s){var A,M,_,U,q,B,Q,se,oe,ve,re,ue,te,ae,pe,be,Fe,Ue,Me,et,ht;const i=((A=e.data)==null?void 0:A.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ie=>Ie.id===i),l=t[e.id];let c=[],u=[],p=((M=e.data)==null?void 0:M.label)??e.id,f,d,h,g,b;const v=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(dx)),Array.isArray(l.output)&&(u=l.output.map(dx)),l.label&&(p=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(d=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(b=String(l.script)));const y=f??(typeof((_=e.data)==null?void 0:_.role)=="string"?e.data.role:"普通"),w=d??((U=e.data)==null?void 0:U.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",S=x!==""?x:void 0,C=h??((q=e.data)==null?void 0:q.body)??"",j=Array.isArray(g)?g:Array.isArray((B=e.data)==null?void 0:B.images)?e.data.images:[],E=_V(a),P=b!==void 0?b:((Q=e.data)==null?void 0:Q.script)!=null?String(e.data.script):E,F=String(e.id),V=(se=r==null?void 0:r[s])==null?void 0:se[F],z=(oe=V==null?void 0:V.label)==null?void 0:oe.label,D=V==null?void 0:V.body,R=V==null?void 0:V.description;v||(c.length===0&&((ve=a==null?void 0:a.inputs)!=null&&ve.length)&&(c=a.inputs.map(Ie=>({...Ie}))),u.length===0&&((re=a==null?void 0:a.outputs)!=null&&re.length)&&(u=a.outputs.map(Ie=>({...Ie}))));const T=NV(a,(a==null?void 0:a.id)??i),L=(l==null?void 0:l.marketplaceRef)||((ue=e.data)==null?void 0:ue.marketplaceRef)||SV(a);if(T==="agent_subAgent"&&!u.some(Ie=>(Ie==null?void 0:Ie.name)==="result")){const Ie=(te=a==null?void 0:a.outputs)==null?void 0:te.find(tt=>(tt==null?void 0:tt.name)==="result");u=[...u,Ie?{...Ie}:{type:"text",name:"result",default:""}]}if((T==="display_markdown"||T==="display_mermaid"||T==="display_ascii"||T==="display_chart"||T==="display_table")&&!u.some(Ie=>(Ie==null?void 0:Ie.name)==="next")){const Ie=(ae=a==null?void 0:a.outputs)==null?void 0:ae.find(tt=>(tt==null?void 0:tt.name)==="next");u=[...u,Ie?{...Ie}:{type:"node",name:"next",default:""}]}if(T==="workspace_run"){if(!c.some(Ie=>(Ie==null?void 0:Ie.name)==="prev")){const Ie=(pe=a==null?void 0:a.inputs)==null?void 0:pe.find(tt=>(tt==null?void 0:tt.name)==="prev");c=[Ie?{...Ie}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Ie=>(Ie==null?void 0:Ie.name)==="next")){const Ie=(be=a==null?void 0:a.outputs)==null?void 0:be.find(tt=>(tt==null?void 0:tt.name)==="next");u=[...u,Ie?{...Ie}:{type:"node",name:"next",default:""}]}}c=jN(T,c,a==null?void 0:a.inputs),u=jN(T,u,a==null?void 0:a.outputs),T.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(C).trim()!==""&&(u=u.map((Ie,tt)=>tt===0?{...Ie,default:C,value:C}:Ie));const $=xV(T,p,a),O=T==="tool_nodejs"||String(P).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:z||p,displayLabel:$,definitionDisplayName:a==null?void 0:a.displayName,definitionId:T,...L?{marketplaceRef:L}:{},...l!=null&&l.marketplacePackageId||(Fe=e.data)!=null&&Fe.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Ue=e.data)==null?void 0:Ue.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(Me=e.data)!=null&&Me.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((et=e.data)==null?void 0:et.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((ht=e.data)==null?void 0:ht.schemaType)??e.type??"agent",role:y,model:w,body:D||C,images:j,script:P,inputs:c,outputs:u,description:R||S,originalLabel:p,originalBody:C,...O?{script:P}:{}}}}function AV(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var p,f,d,h;const s=n.get(r.source),i=n.get(r.target),a=((f=(p=s==null?void 0:s.data)==null?void 0:p.outputs)==null?void 0:f.length)??0,l=((h=(d=i==null?void 0:i.data)==null?void 0:d.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&c>=0&&c<a&&u>=0&&u<l})}function CN(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 _N(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function ug(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=CN(t==null?void 0:t.sourceHandle,"output"),i=CN(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,p,f,d;if(c.id===n){const h=_N((u=c.data)==null?void 0:u.outputs,s);if(h!==((p=c.data)==null?void 0:p.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=_N((f=c.data)==null?void 0:f.inputs,i);if(h!==((d=c.data)==null?void 0:d.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function PV(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 EN(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function IV(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function TV({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function gs({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(TV,{children:t})]},n))})}function RV({open:e,onClose:t}){const{t:n}=pr(),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=IV()?"⌘":"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(gs,{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(gs,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(gs,{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(gs,{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(gs,{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(gs,{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(gs,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(gs,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(gs,{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(gs,{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(gs,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function MV(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 $V({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=pr(),[i,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var b;return(b=u.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const f=m.useMemo(()=>{const g=(r||[]).map(y=>{var w,x,S;return{id:y.id,label:((w=y.data)==null?void 0:w.label)||"",definitionId:((x=y.data)==null?void 0:x.definitionId)||"",schemaType:((S=y.data)==null?void 0:S.schemaType)||""}}),b=i.trim(),v=g.map(y=>({e:y,s:MV(y,b)})).filter(y=>y.s>0);return v.sort((y,w)=>w.s-y.s||y.e.id.localeCompare(w.e.id)),v.slice(0,50).map(y=>y.e)},[r,i]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var b;const g=(b=p.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const d=g=>{const b=f[g];b&&(n(b.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(b=>Math.min(f.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),d(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:u,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:p,className:"af-jump-panel__list",role:"listbox",children:f.map((g,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(b),onMouseDown:v=>{v.preventDefault(),d(b)},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 AN(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=s=>String(s).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function LV(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),s=n%60;return`${r}m${String(s).padStart(2,"0")}s`}function PN(e){if(!e||typeof e!="object")return"";if(e.line)return String(e.line);if(e.text)return String(e.text);if(e.error)return String(e.error);if(e.message)return String(e.message);if(e.status)return String(e.status);if(e.type==="graph"){const n=Array.isArray(e.displayNodeIds)?e.displayNodeIds.join(", "):"";return n?`graph updated: ${n}`:"graph updated"}const t=JSON.stringify(e);return t.length>4e3?`${t.slice(0,4e3)}
100
- ... [truncated]`:t}function dg(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function IN(e){const t=String(e||"").toLowerCase();return t.includes("success")?"success":t.includes("fail")||t.includes("error")?"failed":t.includes("skip")||t.includes("disabled")?"skipped":t.includes("running")?"running":t.includes("stop")?"stopped":"idle"}function OV({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:i}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[p,f]=m.useState(null),[d,h]=m.useState(!1),[g,b]=m.useState(!1),[v,y]=m.useState(""),[w,x]=m.useState(""),S=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),y("");try{const P=new URLSearchParams;P.set("flowId",e.flowId),P.set("flowSource",e.flowSource||"user"),t?P.set("scheduleNodeId",t):n&&P.set("runNodeId",n),P.set("limit","80");const F=await fetch(`/api/workspace/run-logs?${P.toString()}`),V=await F.json().catch(()=>({}));if(!F.ok)throw new Error(V.error||"读取日志失败");const z=Array.isArray(V.runs)?V.runs:[];l(z),u(D=>{const R=z[0]||null;return R&&String(R.status||"")==="running"&&R.runId!==D?R.runId:D&&z.some(T=>T.runId===D)?D:r&&z.some(T=>T.runId===r)?r:(R==null?void 0:R.runId)||""})}catch(P){y(String(P.message||P)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),C=m.useCallback(async P=>{if(!P){f(null);return}b(!0);try{const F=await fetch(`/api/workspace/run-logs/${encodeURIComponent(P)}`),V=await F.json().catch(()=>({}));if(!F.ok)throw new Error(V.error||"读取日志详情失败");f(V)}catch(F){f({error:String(F.message||F),events:[]})}finally{b(!1)}},[]);m.useEffect(()=>{S()},[S]),m.useEffect(()=>{C(c)},[C,c]),m.useEffect(()=>{const P=a.find(V=>V.runId===c),F=window.setInterval(()=>{S(),(!P||P.status==="running")&&c&&C(c)},2e3);return()=>window.clearInterval(F)},[C,S,a,c]);const j=m.useMemo(()=>{const P=Array.isArray(p==null?void 0:p.events)?p.events:[],F=w.trim().toLowerCase();return F?P.filter(V=>String(V.type||"").toLowerCase().includes(F)||dg(V).toLowerCase().includes(F)||PN(V).toLowerCase().includes(F)):P},[p==null?void 0:p.events,w]),E=(p==null?void 0:p.run)||a.find(P=>P.runId===c)||null;return o.jsxs("div",{className:"af-work-run-logs",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:i,"aria-label":"关闭日志侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-run-logs__meta",children:[o.jsx("span",{children:s||t||n||"Workspace Run"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void S(),title:"刷新日志","aria-label":"刷新日志",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),v?o.jsx("div",{className:"af-work-run-logs__error",children:v}):null,o.jsxs("div",{className:"af-work-run-logs__body",children:[o.jsxs("div",{className:"af-work-run-logs__list",children:[o.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),d?o.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!d&&a.length===0?o.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(P=>o.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(P.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(P.runId),title:P.runId,children:[o.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${IN(P.status)}`,children:P.status||"unknown"}),o.jsx("span",{className:"af-work-run-logs__run-label",children:P.label||P.runNodeId||P.scheduleNodeId||"Workspace Run"}),o.jsx("span",{children:AN(P.startedAt)}),o.jsx("span",{children:LV(P.durationMs)})]},P.runId))]}),o.jsxs("div",{className:"af-work-run-logs__detail",children:[o.jsxs("div",{className:"af-work-run-logs__detail-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),E!=null&&E.label?o.jsx("div",{className:"af-work-run-logs__detail-label",children:E.label}):null,o.jsx("div",{className:"af-work-run-logs__run-id",children:(E==null?void 0:E.runId)||"-"})]}),E?o.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${IN(E.status)}`,children:E.status}):null]}),o.jsxs("label",{className:"af-work-run-logs__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{value:w,onChange:P=>x(P.target.value),placeholder:"搜索事件、节点、错误"})]}),g?o.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,p!=null&&p.error?o.jsx("div",{className:"af-work-run-logs__error",children:p.error}):null,!g&&!j.length?o.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,o.jsx("div",{className:"af-work-run-logs__events",children:j.map((P,F)=>o.jsxs("div",{className:"af-work-run-logs__event",children:[o.jsx("span",{className:"af-work-run-logs__event-time",children:AN(P.ts)}),o.jsx("span",{className:"af-work-run-logs__event-type",children:P.type||"event"}),dg(P)?o.jsx("span",{className:"af-work-run-logs__event-node",children:dg(P)}):null,o.jsx("pre",{children:PN(P)})]},`${P.ts||F}-${F}`))})]})]})]})}function DV(e){let t=String(e||"").trim();const n=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*?)```/i);if(n&&n[1])t=n[1].trim();else{const r=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*)$/i);r&&r[1]&&(t=r[1].trim())}return t.replace(/```\s*$/g,"").trim()}function vP(e){const t=DV(e);if(!t)return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":"export default function App() { return <main><h1>React App</h1><p>No project files yet.</p></main>; }"},inputs:{}};try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.files&&typeof n.files=="object"&&!Array.isArray(n.files)?n.files:{};return{title:String(n.title||n.name||"React App"),entry:String(n.entry||n.main||"src/App.jsx"),files:Object.fromEntries(Object.entries(r).map(([s,i])=>[String(s),String(i??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function FV(e){let t=String(e||"");return t=t.replace(/^\s*import\s+[^;]+;\s*$/gm,""),t=t.replace(/^\s*import\s+["'][^"']+["'];\s*$/gm,""),t=t.replace(/\bexport\s+default\s+function\s+([A-Za-z_$][\w$]*)\s*\(/g,"const __AgentFlowDefault = function $1("),t=t.replace(/\bexport\s+default\s+function\s*\(/g,"const __AgentFlowDefault = function App("),t=t.replace(/\bexport\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends/g,"const __AgentFlowDefault = class $1 extends"),t=t.replace(/\bexport\s+default\s+class\s+extends/g,"const __AgentFlowDefault = class extends"),t=t.replace(/\bexport\s+default\s+(\([^)]*\)\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/g,"const __AgentFlowDefault = $1;"),t=t.replace(/\bexport\s+(const|let|var|function|class)\s+/g,"$1 "),t=t.replace(/^\s*export\s+\{[^}]+\};?\s*$/gm,""),t.trim()}function zV(e){return String(e).replace(/<\/script/gi,"<\\/script")}function Rh(e){const t=vP(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function fb(e,t=""){const n=vP(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(d=>/(?:^|\/)App\.[jt]sx$/i.test(d))||Object.keys(r).find(d=>/\.[jt]sx?$/i.test(d))||n.entry,i=FV(r[s]||""),a=Object.entries(r).filter(([d])=>/\.css$/i.test(d)).map(([,d])=>String(d||"")).join(`
101
-
102
- `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),p=zV(i||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
103
- * { box-sizing: border-box; }
104
- body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
105
- main { min-height: 100vh; padding: 24px; }
106
- button, input, select, textarea { font: inherit; }
107
- `;return`<!doctype html>
108
- <html>
109
- <head>
110
- <meta charset="utf-8" />
111
- <meta name="viewport" content="width=device-width, initial-scale=1" />
112
- <base target="_blank" />
113
- <title>${l.replace(/[<&>]/g,d=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[d])}</title>
114
- <style>${f.replace(/<\/style/gi,"<\\/style")}</style>
115
- </head>
116
- <body>
117
- <div id="root"></div>
118
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
119
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
120
- <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
121
- <script>
122
- window.AGENTFLOW_INPUTS = ${u};
123
- window.addEventListener("error", (event) => {
124
- const root = document.getElementById("root");
125
- if (root && !root.__agentflowRendered) {
126
- root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'&lt;','>':'&gt;','&':'&amp;'}[ch])) + '</pre>';
127
- }
128
- });
129
- document.addEventListener("click", (event) => {
130
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
131
- if (!link) return;
132
- const rawHref = String(link.getAttribute("href") || "").trim();
133
- if (!rawHref || rawHref.startsWith("#")) return;
134
- if (/^javascript:/i.test(rawHref)) {
135
- event.preventDefault();
136
- return;
137
- }
138
- event.preventDefault();
139
- window.open(link.href, "_blank", "noopener,noreferrer");
140
- }, true);
141
- <\/script>
142
- <script type="text/babel">
143
- const { useCallback, useEffect, useMemo, useRef, useState } = React;
144
- ${p}
145
- const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
146
- return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
147
- });
148
- ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
149
- document.getElementById("root").__agentflowRendered = true;
150
- <\/script>
151
- <script>
152
- (() => {
153
- const frameId = ${c};
154
- const postSize = () => {
155
- const doc = document.documentElement;
156
- const body = document.body;
157
- const height = Math.ceil(Math.max(
158
- doc ? doc.scrollHeight : 0,
159
- doc ? doc.offsetHeight : 0,
160
- doc ? doc.clientHeight : 0,
161
- body ? body.scrollHeight : 0,
162
- body ? body.offsetHeight : 0,
163
- body ? body.clientHeight : 0,
164
- window.innerHeight || 0
165
- ));
166
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
167
- };
168
- window.addEventListener("load", postSize);
169
- window.addEventListener("resize", postSize);
170
- requestAnimationFrame(postSize);
171
- setTimeout(postSize, 300);
172
- setTimeout(postSize, 1000);
173
- if (typeof ResizeObserver !== "undefined") {
174
- const resizeObserver = new ResizeObserver(postSize);
175
- resizeObserver.observe(document.documentElement);
176
- if (document.body) resizeObserver.observe(document.body);
177
- }
178
- })();
179
- <\/script>
180
- </body>
181
- </html>`}const SP=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),HV=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function BV(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 WV(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 TN(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 NP(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(SP.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 jP(e){return{inputNames:TN(e==null?void 0:e.inputs),outputNames:TN(e==null?void 0:e.outputs)}}function VV(e,t,n){const r=jP(t),s=WV(e),i=[];for(const a of s)if(!NP(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 KV(e,t){const n=jP(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=NP(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 UV(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function qV(e){return e.map(t=>{const n=UV(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 YV(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 HV)SP.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function GV(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 JV(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),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function gf({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:p}=pr(),f=m.useId(),d=m.useRef(null),h=m.useRef(null),[g,b]=m.useState(0),[v,y]=m.useState(0),[w,x]=m.useState(null),S=m.useMemo(()=>Pi(c),[c]),C=m.useMemo(()=>VV(e,a,p),[e,a,p]),j=C.length>0,E=m.useMemo(()=>KV(e,a),[e,a]),P=m.useMemo(()=>qV(E),[E]),F=m.useMemo(()=>n?null:BV(e,g),[e,g,n]),V=m.useMemo(()=>{if(!F)return[];const $=YV(a,p);return GV($,F.query)},[F,a,p]);m.useEffect(()=>{y($=>{const O=Math.max(0,V.length-1);return Math.min(Math.max(0,$),O)})},[V.length]);const z=m.useCallback(()=>{const $=d.current;if(!$||!F||V.length===0){x(null);return}const O=JV($,g);if(!O){x(null);return}const A=4,M=44,_=13.5*16,U=Math.min(V.length*M+8,_);let q=O.bottom+A;q+U>window.innerHeight-8&&(q=Math.max(8,O.top-U-A));const B=288;let Q=O.left;Q=Math.max(8,Math.min(Q,window.innerWidth-B-8)),x({top:q,left:Q})},[F,V.length,g]);m.useLayoutEffect(()=>{if(!F||V.length===0){x(null);return}const $=requestAnimationFrame(()=>z());return()=>cancelAnimationFrame($)},[F,V.length,g,e,z]),m.useEffect(()=>{if(!F||V.length===0)return;const $=()=>z();return window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[F,V.length,z]);const D=m.useCallback($=>{if(!F)return;const{atIndex:O}=F,A=e.slice(0,O)+"${"+$+"}"+e.slice(g);t(A);const M=O+$.length+3;queueMicrotask(()=>{const _=d.current;_&&(_.focus(),_.setSelectionRange(M,M)),b(M)})},[F,e,g,t]),R=m.useCallback(()=>{const $=d.current,O=h.current;!$||!O||(O.scrollTop=$.scrollTop,O.scrollLeft=$.scrollLeft,F&&V.length>0&&queueMicrotask(()=>z()))},[F,V.length,z]),T=m.useCallback($=>{if(!n&&F&&V.length>0&&($.key==="ArrowDown"||$.key==="ArrowUp"||$.key==="Enter")){if($.key==="ArrowDown")$.preventDefault(),y(O=>(O+1)%V.length);else if($.key==="ArrowUp")$.preventDefault(),y(O=>(O-1+V.length)%V.length);else if($.key==="Enter"&&!$.shiftKey){$.preventDefault();const O=V[v];O&&D(O.insert)}}},[n,F,V,v,D]),L=m.useCallback(async $=>{if(n||typeof u!="function")return!1;const O=await bP({files:$,body:e,images:S});return O?(t(O.body),u(O.images),queueMicrotask(()=>{const A=d.current;if(!A)return;A.focus();const M=O.body.length;A.setSelectionRange(M,M),b(M)}),!0):!1},[n,S,t,u,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(($,O)=>o.jsxs("span",{className:"af-body-image-chip",title:$.name,children:[o.jsx("img",{src:$.dataUrl,alt:""}),o.jsxs("span",{children:["[",$.label||`image ${O+1}`,"]"]})]},$.id||O))}):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:P+`
182
- `}}),o.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?f:void 0,onChange:$=>{t($.target.value),b($.target.selectionStart??$.target.value.length)},onSelect:$=>{const O=$.target;O instanceof HTMLTextAreaElement&&b(O.selectionStart??0)},onClick:$=>{const O=$.target;O instanceof HTMLTextAreaElement&&b(O.selectionStart??0)},onKeyUp:$=>{const O=$.target;O instanceof HTMLTextAreaElement&&b(O.selectionStart??O.value.length)},onKeyDown:T,onPaste:$=>{const O=wP($);O.length!==0&&($.preventDefault(),L(O).catch(()=>{}))},onDragOver:$=>{ru($).length>0&&$.preventDefault()},onDrop:$=>{const O=ru($);O.length!==0&&($.preventDefault(),L(O).catch(()=>{}))},onScroll:R})]}),F&&V.length>0&&w?cr.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:w.top,left:w.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:V.map(($,O)=>o.jsx("li",{role:"option","aria-selected":O===v,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(O===v?" af-composer-mention-item--active":""),onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>y(O),onClick:()=>D($.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${$.insert}}`}),$.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:$.subtitle}):null]})},`${$.section}-${$.insert}`))}),document.body):null,j?o.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:C.map($=>$.message).join(" · ")}):null]})}const XV=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function jc(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function RN({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=pr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((d,h)=>h!==f)),u=(f,d,h)=>{const g=n.map((b,v)=>{if(v!==f)return b;const y={...b,[d]:h};return d==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},p=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:p})}),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.description")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((f,d)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${d}`,children:[p,"-",d]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(d,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),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=>u(d,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(d,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(d,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),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||u(d,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),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=>u(d,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${d}`))]}):null]})}function QV({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:f}){const{t:d}=pr(),[h,g]=m.useState(!1),[b,v]=m.useState(!1),[y,w]=m.useState({status:"idle",message:""}),x=m.useCallback(R=>{t(T=>T&&{...T,...R})},[t]),{cursorList:S,opencodeList:C,claudeCodeList:j,codexList:E,currentNotInLists:P}=m.useMemo(()=>{const R=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],T=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],L=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],$=Array.isArray(s==null?void 0:s.codex)?s.codex:[],O=new Set([...R,...T,...L,...$].map(jc)),A=((e==null?void 0:e.model)??"").trim(),M=A.startsWith("cursor:")?A.slice(7):A.startsWith("opencode:")?A.slice(9):A.startsWith("codex:")?A.slice(6):A.startsWith("claude-code:")?A.slice(12):A,_=A&&!O.has(M)?A:"";return{cursorList:R,opencodeList:T,claudeCodeList:L,codexList:$,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const F=String(e.script??""),V=n==="tool_nodejs"||F.trim()!=="",z=typeof c=="function"&&!i&&(e==null?void 0:e.newId),D=async()=>{if(z){w({status:"running",message:d("flow:nodeProps.publishRunning")});try{const R=await c(e,n);w({status:"success",message:R!=null&&R.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:R.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(R){w({status:"error",message:String((R==null?void 0:R.message)||R)})}}};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:d("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:D,disabled:!z||y.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?o.jsx("p",{className:"af-err af-node-props-err",children:p}):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:d("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:[d("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:R=>x({newId:R.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":d("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:[d("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:R=>x({label:R.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:[d("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:$u.includes(e.role)?e.role:d("flow:roles.normal"),onChange:R=>x({role:R.target.value}),disabled:i,children:$u.map(R=>o.jsx("option",{value:R,children:R},R))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const R=(e.model||"").trim();return R?P||R:""})(),onChange:R=>x({model:R.target.value}),disabled:i,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:d("flow:node.defaultModel")}),P?o.jsxs("option",{value:P,children:[P,d("flow:nodeProps.yamlValueNotInList")]}):null,S.length>0?o.jsx("optgroup",{label:"Cursor",children:S.map(R=>o.jsx("option",{value:jc(R),children:R},`c-${R}`))}):null,C.length>0?o.jsx("optgroup",{label:"OpenCode",children:C.map(R=>o.jsx("option",{value:`opencode:${jc(R)}`,children:R},`o-${R}`))}):null,E.length>0?o.jsx("optgroup",{label:"Codex",children:E.map(R=>o.jsx("option",{value:`codex:${jc(R)}`,children:R},`codex-${R}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map(R=>o.jsx("option",{value:`claude-code:${jc(R)}`,children:R},`cc-${R}`))}):null]})]}),o.jsx(RN,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:R=>x({inputs:R}),disabled:i,requiredReadonly:!u}),o.jsx(RN,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:R=>x({outputs:R}),disabled:i,requiredReadonly:!u}),V?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:[d("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>v(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(gf,{value:F,onChange:R=>x({script:R}),disabled:i,placeholder:d("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("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:R=>x({scriptRef:R.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:R=>x({implementationRef:R.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),o.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:R=>x({implementationMode:R.target.value}),disabled:i,children:[o.jsx("option",{value:"",children:"auto"}),o.jsx("option",{value:"script",children:"script"}),o.jsx("option",{value:"steps",children:"steps"}),o.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),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:d("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(gf,{value:e.body,onChange:R=>x({body:R}),images:e.images,onImagesChange:R=>x({images:R}),disabled:i,placeholder:d("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:d("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:R=>{R.target===R.currentTarget&&v(!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:d("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>v(!1),"aria-label":d("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(gf,{value:F,onChange:R=>x({script:R}),disabled:i,placeholder:d("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":d("flow:nodeProps.editUserPrompt"),onMouseDown:R=>{R.target===R.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:d("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":d("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(gf,{value:e.body,onChange:R=>x({body:R}),images:e.images,onImagesChange:R=>x({images:R}),disabled:i,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function ZV({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=pr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const y=requestAnimationFrame(()=>{var w;return(w=l.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),b=g===n;async function v(y){if(y.preventDefault(),!(!b||p)){f(!0),h("");try{const w=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),x=await w.json().catch(()=>({}));if(!w.ok){h(typeof x.error=="string"?x.error:i("project:archiveModal.archiveFailed"));return}s()}catch(w){h(String((w==null?void 0:w.message)||w))}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:v,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=>u(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),d?o.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||p,children:i(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function e7({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=pr(),l=m.useId(),c=m.useRef(null),[u,p]=m.useState(""),[f,d]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),g(""),d(!1);const w=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(w)},[e,n]),!e)return null;const b=u.trim(),v=b===n;async function y(w){if(w.preventDefault(),!v||f)return;d(!0),g("");let x=null;try{const S=new AbortController;x=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:b,flowArchived:s}),signal:S.signal}),j=await C.json().catch(()=>({}));if(!C.ok){g(typeof j.error=="string"?j.error:a("project:deleteModal.deleteFailed"));return}try{for(let E=localStorage.length-1;E>=0;E--){const P=localStorage.key(E);P&&(P.startsWith(`af:composer-sessions:${n}:${r}`)||P.startsWith(`af:composer-active-session:${n}:${r}`)||P.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(P)}}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{x&&clearTimeout(x),d(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:w=>{w.target===w.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:w=>w.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:u,onChange:w=>p(w.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!v})]}),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:!v||f,children:a(f?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}const MN=80,t7=220;function n7(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 r7(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function yf(e,t,n){const r={nodes:Array.isArray(e)?e.map(n7):[],edges:Array.isArray(t)?t.map(r7):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function fg(e,t){const n=[...e,t];return n.length>MN?n.slice(n.length-MN):n}function s7({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),p=m.useRef(null),f=m.useRef(null),d=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(C=>C+1),[]),b=m.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),v=m.useCallback(()=>{b();const C=p.current,j=f.current;return p.current=null,f.current=null,!C||!j||C.signature===j.signature?(j&&(u.current=j),!1):(l.current=fg(l.current,C),c.current=[],u.current=j,g(),!0)},[g,b]),y=m.useCallback((C=[],j=[],E={})=>{b(),l.current=[],c.current=[],p.current=null,f.current=null,u.current=yf(C,j,E),h.current=!1,g()},[g,b]),w=m.useCallback(C=>{h.current=!0,u.current=C,p.current=null,f.current=null,b(),s==null||s(C.value),g()},[g,b,s]),x=m.useCallback(()=>{v();const C=u.current||yf(e,t,n),j=l.current.pop();return j?(c.current=fg(c.current,C),w(j),!0):(g(),!1)},[g,t,n,v,e,w]),S=m.useCallback(()=>{v();const C=u.current||yf(e,t,n),j=c.current.pop();return j?(l.current=fg(l.current,C),w(j),!0):(g(),!1)},[g,t,n,v,e,w]);return m.useEffect(()=>()=>b(),[b]),m.useEffect(()=>{if(!r)return;const C=yf(e,t,n);if(!u.current){u.current=C;return}if(h.current){h.current=!1,u.current=C;return}C.signature!==u.current.signature&&(p.current||(p.current=u.current),f.current=C,b(),d.current=window.setTimeout(()=>{v()},t7))},[b,t,r,n,v,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:y,undo:x,redo:S,version:i}}const i7="af:workspace-graph:v2",$N="agentflow.workspace.sidebarCollapsed",Ba=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],o7=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),a7={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:""}]},l7={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},c7={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}]},u7={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}]},d7={id:"control_cd_workspace",displayName:"Load Workspace",label:"Load Workspace",description:"Select a configured workspace directory and pass workspaceContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"workspaceContext",default:"",showOnNode:!0},{type:"file",name:"cwd",default:"",showOnNode:!1}]},f7={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},p7=new Set(["png","jpg","jpeg","gif","webp","svg"]),CP=320,_P=180,EP=960,Dp=96,AP=900,px=520,hx=320,xf=52,ca=240,ua=160,mx="display-ref:",Ou="0 9 * * *",h7="Asia/Shanghai",m7="0.1.87";function g7(){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 ys(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 Fp(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return p7.has(n)}function Du(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=ys(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function y7(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 x7(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${$N}:${t}`:$N}function w7(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function LN(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function b7(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function k7(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!b7(e)}function v7(e){const t=String(e||"").trim();if(!t||S7(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(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 S7(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function N7(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function pg(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),i=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===s):null,a=t&&typeof t=="object"?t[s]:null;return String(((c=i==null?void 0:i.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function hg(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function Fo(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function j7(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,i=Number.isFinite(r)&&Number.isFinite(s)?`(+${Fo(r)} / 总 ${Fo(s)})`:"";return`${t+1}. ${n}${i}`}function PP(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Wa(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function C7(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function _7(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function E7(e,t){var s;const n=String(((s=t==null?void 0:t.args)==null?void 0:s.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function A7(e){var i,a,l;const t=PP(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Wa(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=_7(t),u=C7(t),p=Wa(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Wa(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((i=c==null?void 0:c.result)==null?void 0:i.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(p)&&Number.isFinite(f)?Math.max(0,f-p):Wa(d.executionTime,d.localExecutionTimeMs),g=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),b=g?g.split(`
183
- `).find(Boolean)||g:"";return{kind:"tool",label:E7(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:b?b.slice(0,90):""}}if(n==="result"){const c=Wa(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:s,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:s,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:s,detail:""}:null}function ON(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(v=>typeof v=="string"?{text:v}:v).filter(v=>v&&String(v.text||"").trim()),i=Array.isArray(t)?t:[],a=[...i].reverse().find(v=>(v==null?void 0:v.kind)==="total"&&Number.isFinite(Number(v.durationMs))),l=[...s].reverse().find(v=>Number.isFinite(Number(v.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=Wa(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=s.filter(v=>v.kind==="model").reduce((v,y)=>v+(Number(y.stepMs)||0),0),f=i.filter(v=>(v==null?void 0:v.kind)==="tool"),d=f.reduce((v,y)=>v+(Number(y.durationMs)||0),0),h=i.filter(v=>(v==null?void 0:v.kind)==="network").length,g=[...s.filter(v=>Number(v.stepMs)>=1e3).map(v=>({label:v.text,durationMs:Number(v.stepMs),detail:"Activity 间隔"})),...f.filter(v=>Number(v.durationMs)>=1e3).map(v=>({label:v.label,durationMs:Number(v.durationMs),detail:v.detail||"工具实际执行"}))].sort((v,y)=>y.durationMs-v.durationMs).slice(0,6),b=["耗时概览"];return Number.isFinite(u)&&b.push(`- 当前总耗时:${Fo(u)}`),p>0&&b.push(`- 模型相关间隔:约 ${Fo(p)}(按 Activity 间隔估算)`),f.length>0&&b.push(`- 工具实际执行:${Fo(d)}(${f.length} 次完成事件)`),h>0&&b.push(`- 网络/会话恢复事件:${h} 次`),g.length>0&&(b.push(""),b.push("慢步骤"),g.forEach((v,y)=>{const w=v.detail?` · ${v.detail}`:"";b.push(`${y+1}. ${v.label}:${Fo(v.durationMs)}${w}`)})),s.length>0&&(b.push(""),b.push("最近 Activity"),s.slice(-10).forEach((v,y)=>{b.push(j7(v,y))})),f.length>0&&(b.push(""),b.push("最近工具完成"),f.slice(-8).forEach((v,y)=>{const w=Number.isFinite(Number(v.durationMs))?` ${Fo(v.durationMs)}`:"",x=v.detail?` · ${v.detail}`:"";b.push(`${y+1}. ${v.label}${w}${x}`)})),b.join(`
184
- `)}function DN(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=PP(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function IP(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 TP(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function pb(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function RP(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function P7(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function I7(e){const t=String(e??"").trim();return t?t.includes("${")?t:RP(t):""}function MP(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const s=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),i=s?`${s}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(I7).filter(Boolean):[];return[P7(t,n),RP(i),...a].join(" ")}return String(t.command||"").trim()}function Oc(e){const t=String(pb(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function FN(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function zp(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Dc(e){return zp(e)}function gx(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function wf(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 zN(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 HN(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 mg(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=ux(s.get(n),e.sourceHandle||"output-0","source"),a=ux(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Lu(i,a))}function T7(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=ux(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:sV(a)}:null}function R7(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"?Lu(t.slot,a):Lu(a,t.slot)))continue;const c=Oc(n);return{def:n,order:r,category:c,categoryRank:Ba.indexOf(c),slot:a,slotIndex:i,displayLabel:Dc(n),description:gx(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 M7(e,t,n){var i,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const p=Array.isArray(s?(i=u.data)==null?void 0:i.inputs:(a=u.data)==null?void 0:a.outputs)?s?u.data.inputs:u.data.outputs:[];for(let f=0;f<p.length;f+=1){const d=p[f];if((d==null?void 0:d.showOnNode)===!1||!(s?Lu(n.slot,d):Lu(d,n.slot)))continue;const g=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},b=(t||[]).some(v=>v.target===g.target&&v.targetHandle===g.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:d,slotIndex:f,handleId:s?g.targetHandle:g.sourceHandle,connection:g,occupied:b})}}return r.sort((u,p)=>{var b,v,y,w,x,S,C,j;const f=Number(((v=(b=u.node)==null?void 0:b.position)==null?void 0:v.y)||0),d=Number(((w=(y=p.node)==null?void 0:y.position)==null?void 0:w.y)||0),h=Number(((S=(x=u.node)==null?void 0:x.position)==null?void 0:S.x)||0),g=Number(((j=(C=p.node)==null?void 0:C.position)==null?void 0:j.x)||0);return f-d||h-g||u.slotIndex-p.slotIndex||String(u.nodeId).localeCompare(String(p.nodeId))})}function ol(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 $7(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 L7(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function O7(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Ou;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:Ou}function to(e,t=0,n=0,r=59){const s=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(s).padStart(2,"0")}function hb(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${to(t[1],9,0,23)}:${to(t[2],0,0,59)}`:"09:00"}function Fc(e,t,n,r,s){const i=hb(t),[a,l]=i.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(s||"").trim()||Ou:`${l} ${a} * * *`}function D7(e){const n=String(e||Ou).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,i,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(s,10),p=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=p?`${to(u,9,0,23)}:${to(c,0,0,59)}`:"09:00";return p&&i==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:p&&i==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:p&&/^\d+$/.test(i)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(i,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function mb(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=O7(r),i=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=D7(i),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=hb(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),p=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=Fc(l,c,u,p,i);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:p,cron:f,timezone:h7,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function F7(e){const t=mb(JSON.stringify(e||{}));return JSON.stringify(t)}function z7(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function H7(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function BN(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function bf(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:BN(n.nextRunAt),lastAt:BN(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function su(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Hp(e){return e>0?`Group ${e+1}`:"Group"}function B7(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),i=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!s||!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:s,title:String((n==null?void 0:n.title)||Hp(r)).trim()||Hp(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:i,y:a,width:Math.max(ca,Math.round(l)),height:Math.max(ua,Math.round(c))}}).filter(Boolean)}function W7(e){var n;return B7((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:xl,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function yx(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(ca,Math.round(t)),height:Math.max(ua,Math.round(n))}}function zc(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:L7(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),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 $P(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function V7(e){var i,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},s=Mh(t);return[$P(e),hn(t)||"",s?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function kf(e,t){var h,g;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=FP(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(g=e==null?void 0:e.ui)!=null&&g.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const b of s)b!=null&&b.source&&l.add(String(b.source)),b!=null&&b.target&&l.add(String(b.target));const u=Array.from(l).map(b=>{const v=r[b]||{},y=v.definitionId||b,w=t.find(D=>D.id===y),x=pb(w)||y,S=t.find(D=>D.id===x)||w,C=v.marketplaceRef||TP(w),j=MP(w),E=i[b]&&typeof i[b].x=="number"&&typeof i[b].y=="number"?i[b]:{x:320+l.size*20,y:180+l.size*12},P=!!hn({definitionId:x,inputs:v.input,outputs:v.output}),F=a[b]&&typeof a[b].width=="number"&&typeof a[b].height=="number"?{width:a[b].width,height:a[b].height}:null,V=Jo(F,{display:P}),z=V&&!Es(x);return{id:b,type:xl,position:E,...z?{width:V.width,height:V.height}:{},data:{label:v.label||zp(w)||zp(S)||b,definitionId:x,...C?{marketplaceRef:C}:{},...w!=null&&w.packageId?{marketplacePackageId:w.packageId}:{},...w!=null&&w.version?{marketplaceVersion:w.version}:{},schemaType:IP(x,S||w),role:v.role||"normal",model:v.model||void 0,body:v.body||"",script:v.script||j||"",scriptRef:v.scriptRef||"",implementationRef:v.implementationRef||"",implementationMode:v.implementationMode||"",displayReloadKey:v.displayReloadKey||"",...z?{nodeSize:V}:{},...P&&z?{displaySize:V}:{}}}}).map(b=>fx(b,r,t)),p=W7(e),f=s.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).filter(b=>!p.some(v=>v.id===String(b.source)||v.id===String(b.target))).map((b,v)=>({id:b.id||`we-${b.source}-${b.target}-${v}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:Ks.ArrowClosed}})),d=[...p,...u];return{nodes:d,edges:AV(f,d),instances:r}}function WN(e){return`${mx}${e}`}function gg(e){const t=String(e||"");return t.startsWith(mx)?t.slice(mx.length):t}function LP(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function xx(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var d;return da((d=f==null?void 0:f.data)==null?void 0:d.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const f of r){const d=String(f||"").trim();!d||i.has(d)||!n.has(d)||(i.add(d),s.push(d))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,d)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+d*36,y:120+d*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const d=Jo(u[f],{display:!0});d&&(c[f]=d)});const p=LP(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...p?{viewport:p}:{}}}function K7(e,t=[]){return xx(e,t)}const yg=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function xg(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function VN(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function KN(e={}){if(e.permanent)return{expiresMode:"permanent",permanent:!0};const t=Number(e.expiresInDays||30);return{expiresMode:"days",expiresInDays:Number.isFinite(t)?t:30}}function U7(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function UN(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const OP="af:workspace:canvas-clipboard",DP="agentflow.workspace.canvas-clipboard";function q7(e){return JSON.stringify({type:DP,version:1,clipboard:e})}function Y7(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==DP)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function G7(e){try{localStorage.setItem(OP,q7(e))}catch{}}function J7(){try{return Y7(localStorage.getItem(OP))}catch{return null}}function X7(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function qN(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function YN(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Jo(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:YN(n,_P,EP)||CP,height:YN(r,Dp,AP)||Dp}}function Bp(e){const t=Jo(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function Q7(e){const t=String(e||"").trim().toLowerCase();return t==="html"||t==="react"?{width:720,height:520}:t==="table"||t==="chart"?{width:640,height:380}:t==="image"?{width:520,height:360}:{width:px,height:hx}}function Z7(e,t=""){const n=Bp(e==null?void 0:e.displaySize);if(n)return n;const r=Bp(e==null?void 0:e.nodeSize);if(r)return r;const s=da(t)||id(yo((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return Q7(s)}function Va(e){var s,i,a,l,c,u,p,f,d,h,g;if(Es((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!hn(e==null?void 0:e.data),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:f.height)||((h=(d=e==null?void 0:e.data)==null?void 0:d.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return Jo({width:n,height:r},{display:t})}function Cc(e,t,n){var p,f,d,h,g,b,v,y,w,x,S,C,j;const r=(e||[]).filter(E=>!su(E)),s=(e||[]).filter(su),i=FP(db(r,n||{})),a=t.map(E=>({source:E.source,target:E.target,sourceHandle:E.sourceHandle??null,targetHandle:E.targetHandle??null})).filter(E=>!s.some(P=>P.id===E.source||P.id===E.target)),l={},c={},u=[];for(const E of r){l[E.id]={x:((p=E.position)==null?void 0:p.x)||0,y:((f=E.position)==null?void 0:f.y)||0};const P=Va(E);P&&(c[E.id]=P)}for(const E of s){const P=Number(((h=(d=E.data)==null?void 0:d.nodeSize)==null?void 0:h.width)||E.width||((g=E.measured)==null?void 0:g.width)||0),F=Number(((v=(b=E.data)==null?void 0:b.nodeSize)==null?void 0:v.height)||E.height||((y=E.measured)==null?void 0:y.height)||0);u.push({id:E.id,title:String(((w=E.data)==null?void 0:w.title)||((x=E.data)==null?void 0:x.label)||"Group"),color:String(((S=E.data)==null?void 0:S.color)||"purple"),x:Number(((C=E.position)==null?void 0:C.x)||0),y:Number(((j=E.position)==null?void 0:j.y)||0),width:Math.max(ca,Math.round(P||ca)),height:Math.max(ua,Math.round(F||ua))})}return{version:1,instances:i,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function FP(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!da(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 da(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_react_app"?"react":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function hn(e){const t=da(e==null?void 0:e.definitionId);return t||(Es(e==null?void 0:e.definitionId)&&Mh(e)?id(yo((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function ho(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=hn(e),r=Es(e==null?void 0:e.definitionId),s=n==="image"?"src":"content",i=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>i(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===s&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?i(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function fa(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),react:new Set(["json","jsx","tsx","js","txt"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function eK(e){let t=String(e||"").replace(/\r\n/g,`
185
- `).trim();return t.includes(`
186
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
187
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
188
- $2`)),t}function ki(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=eK(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
189
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
190
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function $l(e,t){const n=ys(e);n.set("path",t);const r=await fetch(`/api/workspace/file?${n.toString()}`),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`读取文件失败:${t}`);return String(s.content||"")}async function wx(e,t,n){const r=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,path:t,content:String(n||"")})}),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`写入文件失败:${t}`);return s.path||t}function tK(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(i=>[i.id,i]));return(Array.isArray(n)?n:[]).filter(i=>String((i==null?void 0:i.target)||"")===r).slice(0,4).map(i=>{const a=s.get(String((i==null?void 0:i.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
191
- `)}).filter(Boolean).join(`
192
-
193
- `)}function Vl(e){let t=ki(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 nK(e){const t=Vl(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Vo(e,t){return e==="html"?nK(t):""}function zP(e,t=""){const n=Vl(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
194
- (() => {
195
- const frameId = ${JSON.stringify(String(t||""))};
196
- const postSize = () => {
197
- const doc = document.documentElement;
198
- const body = document.body;
199
- const height = Math.ceil(Math.max(
200
- doc ? doc.scrollHeight : 0,
201
- doc ? doc.offsetHeight : 0,
202
- doc ? doc.clientHeight : 0,
203
- body ? body.scrollHeight : 0,
204
- body ? body.offsetHeight : 0,
205
- body ? body.clientHeight : 0,
206
- window.innerHeight || 0
207
- ));
208
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
209
- };
210
- document.addEventListener("click", (event) => {
211
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
212
- if (!link) return;
213
- const rawHref = String(link.getAttribute("href") || "").trim();
214
- if (!rawHref || rawHref.startsWith("#")) return;
215
- if (/^javascript:/i.test(rawHref)) {
216
- event.preventDefault();
217
- return;
218
- }
219
- event.preventDefault();
220
- window.open(link.href, "_blank", "noopener,noreferrer");
221
- }, true);
222
- window.addEventListener("load", postSize);
223
- window.addEventListener("resize", postSize);
224
- requestAnimationFrame(postSize);
225
- setTimeout(postSize, 60);
226
- setTimeout(postSize, 300);
227
- if (typeof ResizeObserver !== "undefined") {
228
- const resizeObserver = new ResizeObserver(postSize);
229
- resizeObserver.observe(document.documentElement);
230
- if (document.body) resizeObserver.observe(document.body);
231
- }
232
- if (typeof MutationObserver !== "undefined") {
233
- const mutationObserver = new MutationObserver(postSize);
234
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
235
- }
236
- })();
237
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function rK(e,t){const n=String(e).trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-").replace(/^-+|-+$/g,"")||"html-render",r=String(t).replace(/^\.+/,"")||"png";return`${n}.${r}`}function sK(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function iK(e,t){const n=URL.createObjectURL(e);try{sK(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function HP(e){var t;try{return(e==null?void 0:e.contentDocument)||((t=e==null?void 0:e.contentWindow)==null?void 0:t.document)||null}catch{return null}}function oK(e){const t=HP(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
238
- ${t.documentElement.outerHTML}`:""}function wg(e){var n;if(!e)return null;const t=(n=e.getBoundingClientRect)==null?void 0:n.call(e);return{rectWidth:t!=null&&t.width?Math.round(t.width):null,rectHeight:t!=null&&t.height?Math.round(t.height):null,clientWidth:e.clientWidth||null,clientHeight:e.clientHeight||null,scrollWidth:e.scrollWidth||null,scrollHeight:e.scrollHeight||null,offsetWidth:e.offsetWidth||null,offsetHeight:e.offsetHeight||null}}function aK(e,t,n,r={}){var v;const s=(v=e==null?void 0:e.getBoundingClientRect)==null?void 0:v.call(e),i=HP(e),a=i==null?void 0:i.documentElement,l=i==null?void 0:i.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,p=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,d={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((f==null?void 0:f.width)||0)||null,displaySizeHeight:Number((f==null?void 0:f.height)||0)||null,rectWidth:s!=null&&s.width?Math.round(s.width):null,rectHeight:s!=null&&s.height?Math.round(s.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:wg(c),displayBody:wg(u),scroller:wg(p)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((p==null?void 0:p.clientWidth)||0),Number((p==null?void 0:p.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(y=>Math.ceil(y)).filter(y=>y>0),g=Math.max(1,...h.length?h:[960]),b=Math.max(1,Math.round(Number(n)||(s==null?void 0:s.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:g,height:b,debug:d}}async function lK({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:i,filename:a,snapshotElements:l,displaySize:c}){const u=aK(r,s,i,{...l||{},displaySize:c}),p=oK(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:p||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const d=await f.blob();iK(d,a)}function cK(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 BP(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function uK(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?i(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function WP({code:e}){const t=m.useMemo(()=>uK(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((p,f)=>{l.set(p.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(p=>p.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(p=>p.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,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((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const g=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.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)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.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:p.label.slice(0,22)})]},p.id)})]})})}function Os({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 p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,g=h?Math.max(12,d/f*100):100,b=Math.max(0,100-g),v=h?Math.min(b,p.scrollTop/Math.max(1,f-d)*b):0;i({visible:h,top:v,height:g})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),g=s.height/100*h.height,b=Math.max(1,h.height-g);return(p-h.top-f)/b},[s.height]),u=m.useCallback(p=>{var S,C;if(!s.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=s.top/100*d.height,g=s.height/100*d.height,v=p.clientY>=d.top+h&&p.clientY<=d.top+h+g?p.clientY-d.top-h:g/2;l(c(p.clientY,v));const y=p.pointerId;(C=(S=p.currentTarget).setPointerCapture)==null||C.call(S,y);const w=j=>{j.preventDefault(),l(c(j.clientY,v))},x=()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",w),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[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:u,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function VP({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=hn(e),i=ho(e),a=s==="image"?i:ki(i),l=s==="image"?"":fa(a,s),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState(!1);m.useEffect(()=>{let w=!1;return l?(h(!0),f(""),u(""),$l(t,l).then(x=>{w||u(x)}).catch(x=>{w||f(String(x.message||x))}).finally(()=>{w||h(!1)}),()=>{w=!0}):(u(""),f(""),h(!1),()=>{w=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const g=l?c:a,b=s==="html"?Vl(g):s==="react"?Rh(g):ki(g),v=m.useRef("");if(v.current||(v.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const y=Vo(s,b);if(d)return o.jsxs(Os,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(p)return o.jsx(Os,{className:"af-work-display-empty",children:p});if(y)return o.jsx(Os,{className:"af-work-display-empty",children:y});if(!b.trim())return o.jsx(Os,{className:"af-work-display-empty",children:"No display content"});if(s==="html"||s==="react")return o.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(s==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:s==="react"?fb(b,v.current):zP(b,v.current)},r)});if(s==="image"){const w=Du(b,t);return o.jsx(Os,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:w,alt:cK(e),loading:"lazy"})})}return s==="markdown"?o.jsx(Os,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(ob,{content:b,basePath:l,resolveSrc:(w,x)=>Du(w,t,x)})}):s==="chart"?o.jsx(Os,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(lb,{content:b})}):s==="table"?o.jsx(Os,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(ab,{content:b})}):s==="mermaid"?o.jsxs(Os,{className:"af-work-display-body",children:[o.jsx(WP,{code:b}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:b})]}):o.jsx(Os,{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:b})})}function dK({node:e,onClose:t}){var i,a;const n=m.useRef(null),r=hn(e==null?void 0:e.data),s=((i=e==null?void 0:e.data)==null?void 0:i.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览");return m.useEffect(()=>{const l=c=>{c.key==="Escape"&&(t==null||t())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t]),e?cr.createPortal(o.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:o.jsxs("div",{className:"af-display-preview-shell",children:[o.jsxs("div",{className:"af-display-preview-head",children:[o.jsxs("div",{className:"af-display-preview-title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:BP(r)}),o.jsx("strong",{children:s}),o.jsx("span",{children:e.id})]}),o.jsx("button",{type:"button",className:"af-display-preview-close",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsx("div",{className:"af-display-preview-content",children:o.jsx(VP,{data:e.data,flowParams:(a=e.data)==null?void 0:a.flowParams,htmlFrameRef:n})})]})}),document.body):null}function fK({node:e}){var d,h,g,b,v,y,w,x,S,C;const t=hn(e==null?void 0:e.data),n=ho(e==null?void 0:e.data),r=t==="image"?n:ki(n),s=t==="image"?"":fa(r,t),[i,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var E;let j=!1;return s?(c(!0),a(""),$l(((E=e==null?void 0:e.data)==null?void 0:E.flowParams)||{},s).then(P=>{j||a(P)}).catch(()=>{j||a("")}).finally(()=>{j||c(!1)}),()=>{j=!0}):(a(""),c(!1),()=>{j=!0})},[s,(h=(d=e==null?void 0:e.data)==null?void 0:d.flowParams)==null?void 0:h.flowId,(b=(g=e==null?void 0:e.data)==null?void 0:g.flowParams)==null?void 0:b.flowSource,(y=(v=e==null?void 0:e.data)==null?void 0:v.flowParams)==null?void 0:y.archived,(w=e==null?void 0:e.data)==null?void 0:w.displayReloadKey]);const u=s?i:r,p=t==="html"?Vl(u):t==="react"?Rh(u):ki(u),f=Vo(t,p);return l?o.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?o.jsx("div",{className:"af-display-picker-preview__empty",children:f}):p.trim()?t==="html"||t==="react"?o.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?fb(p):zP(p)}):t==="image"?o.jsx("img",{src:Du(p,(S=e==null?void 0:e.data)==null?void 0:S.flowParams),alt:((C=e==null?void 0:e.data)==null?void 0:C.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?o.jsx("div",{className:"af-display-picker-preview__markdown",children:o.jsx(ob,{content:p,basePath:s,resolveSrc:(j,E)=>{var P;return Du(j,(P=e==null?void 0:e.data)==null?void 0:P.flowParams,E)}})}):t==="chart"?o.jsx(lb,{content:p}):t==="table"?o.jsx(ab,{content:p}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(WP,{code:p}),o.jsx("pre",{children:p})]}):o.jsx("pre",{className:"af-display-picker-preview__pre",children:p}):o.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function pK({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,p]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const y=s.current;if(!y)return;const w=Math.max(1,y.scrollHeight),x=Math.max(1,y.clientHeight),S=w>x+1,C=S?Math.max(12,x/w*100):100,j=Math.max(0,100-C),E=S?Math.min(j,y.scrollTop/Math.max(1,w-x)*j):0;p({visible:S,top:E,height:C})},[]);m.useEffect(()=>{const y=requestAnimationFrame(f),w=s.current;if(!w||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(y);const x=new ResizeObserver(f);return x.observe(w),()=>{cancelAnimationFrame(y),x.disconnect()}},[f,e]);const d=m.useCallback(y=>{const w=s.current;if(!w)return;const x=Math.max(0,w.scrollHeight-w.clientHeight);w.scrollTop=Math.min(1,Math.max(0,y))*x,f()},[f]),h=m.useCallback((y,w=0)=>{const x=a.current;if(!x)return 0;const S=x.getBoundingClientRect(),C=u.height/100*S.height,j=Math.max(1,S.height-C);return(y-S.top-w)/j},[u.height]),g=m.useCallback(y=>{if(!u.visible)return;y.preventDefault(),y.stopPropagation();const w=a.current;if(!w)return;const x=w.getBoundingClientRect(),S=u.top/100*x.height,C=u.height/100*x.height,E=y.clientY>=x.top+S&&y.clientY<=x.top+S+C?y.clientY-x.top-S:C/2;d(h(y.clientY,E));const P=V=>{V.preventDefault(),d(h(V.clientY,E))},F=()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",F),window.removeEventListener("pointercancel",F)};window.addEventListener("pointermove",P),window.addEventListener("pointerup",F),window.addEventListener("pointercancel",F)},[h,d,u.height,u.top,u.visible]),b=m.useCallback(y=>{const w=String(e||""),x=s.current,S=Number((x==null?void 0:x.selectionStart)??w.length),C=Number((x==null?void 0:x.selectionEnd)??S),j=w.slice(0,S),E=w.slice(C),P=j&&!j.endsWith(`
239
- `)?`
240
- `:"",F=E&&!E.startsWith(`
241
- `)?`
242
- `:"",V=`${j}${P}${y}${F}${E}`;t==null||t(V),window.requestAnimationFrame(()=>{var D,R;const z=j.length+P.length+y.length;(D=s.current)==null||D.focus(),(R=s.current)==null||R.setSelectionRange(z,z)})},[t,e]),v=m.useCallback(async y=>{if(!r&&!(!y||l)){c(!0);try{const w=await(n==null?void 0:n(y)),x=String(w||"").trim();if(x){const S=String(y.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";b(`![${S}](${x})`)}}finally{c(!1)}}},[b,n,r,l]);return o.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:y=>y.stopPropagation(),onDragOver:y=>{var x;Array.from(((x=y.dataTransfer)==null?void 0:x.items)||[]).some(S=>String((S==null?void 0:S.type)||"").startsWith("image/"))&&(y.preventDefault(),y.dataTransfer.dropEffect="copy")},onDrop:y=>{var x;const w=Array.from(((x=y.dataTransfer)==null?void 0:x.files)||[]).find(Fp);w&&(y.preventDefault(),v(w))},children:[o.jsxs("div",{className:"af-work-display-editor__toolbar",children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var y;return(y=i.current)==null?void 0:y.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),o.jsx("input",{ref:i,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:y=>{var x;const w=(x=y.target.files)==null?void 0:x[0];y.target.value="",w&&v(w)}})]}),o.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:y=>t==null?void 0:t(y.target.value),onScroll:f,onKeyDown:y=>{y.key==="Escape"&&y.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),o.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:g,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function hK({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),u=m.useRef(!1),p=String(s.candidateContent||""),f=!!s.running,d=!!(t!=null&&t.readOnly),h=String(s.error||""),g=i.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:b=>b.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 b;return(b=t==null?void 0:t.onCloseNodeChat)==null?void 0:b.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||f||h||p.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[g.map((b,v)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${b.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:b.role==="assistant"?"AI":"你"}),o.jsx("p",{children:b.text})]},`${b.at||v}-${v}`)),f?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?o.jsx("div",{className:"af-work-node-chat__error",children:h}):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||d,"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||d,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:b=>{var y;u.current=!1;const v=b.currentTarget.value;c(v),(y=t==null?void 0:t.onUpdateNodeChatDraft)==null||y.call(t,e,v)},onChange:b=>{var y;const v=b.target.value;c(v),u.current||(y=t==null?void 0:t.onUpdateNodeChatDraft)==null||y.call(t,e,v)},onKeyDown:b=>{var v,y;b.isComposing||(v=b.nativeEvent)!=null&&v.isComposing||b.keyCode===229||(b.metaKey||b.ctrlKey)&&b.key==="Enter"&&(b.preventDefault(),(y=t==null?void 0:t.onSendNodeChat)==null||y.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||d||!l.trim(),onClick:()=>{var b;return(b=t==null?void 0:t.onSendNodeChat)==null?void 0:b.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||d||!p.trim(),onClick:()=>{var b;return(b=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:b.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:f||d||!p.trim(),onClick:()=>{var b;return(b=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:b.call(t,e,"append")},children:"追加"})]})]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:b=>{var v;b.stopPropagation(),(v=t==null?void 0:t.onToggleNodeChat)==null||v.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 mK(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function gK(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function yK(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function GN(e,t=""){const n=fa(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function xK(e,t){const n=yK(e),r=new Set,s=hn(t)||"";Es(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const i=GN(ho(t),s);return i&&r.add(i),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),p=GN(u,s);return p&&r.add(p),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function JN(e,t){const n=hn(t)||"markdown";return`outputs/${gK((t==null?void 0:t.label)||e||n)}.${mK(n)}`}function KP({id:e,data:t,selected:n,deleteNode:r}){var ve,re,ue;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((te,ae)=>({slot:te,idx:ae})).sort((te,ae)=>{var Me,et,ht,Ie;const pe=String(((Me=te.slot)==null?void 0:Me.name)||"").trim(),be=String(((et=ae.slot)==null?void 0:et.name)||"").trim();if(pe==="next"&&be!=="next")return-1;if(be==="next"&&pe!=="next")return 1;const Fe=String(((ht=te.slot)==null?void 0:ht.type)||"").trim(),Ue=String(((Ie=ae.slot)==null?void 0:Ie.type)||"").trim();return Fe==="node"&&Ue!=="node"?-1:Ue==="node"&&Fe!=="node"?1:te.idx-ae.idx}),l=hn(t),c=m.useRef(null),u=m.useRef(null),[p,f]=m.useState(0),[d,h]=m.useState(!1),[g,b]=m.useState(!1),[v,y]=m.useState(!1),[w,x]=m.useState(""),[S,C]=m.useState(""),[j,E]=m.useState(!1),[P,F]=m.useState(!1),V=m.useRef(null),z=ho(t),D=l==="markdown"?ki(z):"",R=l==="markdown"?fa(D,"markdown"):"",T=l==="markdown"?R?S:D:"",L=!!(t!=null&&t.readOnly),$=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let te=!1;return l!=="markdown"||!R?(C(""),E(!1),()=>{te=!0}):(E(!0),$l((t==null?void 0:t.flowParams)||{},R).then(ae=>{te||C(ae)}).catch(ae=>{var pe;te||(C(""),(pe=t==null?void 0:t.onStatus)==null||pe.call(t,String(ae.message||ae)))}).finally(()=>{te||E(!1)}),()=>{te=!0})},[l,R,(ve=t==null?void 0:t.flowParams)==null?void 0:ve.flowId,(re=t==null?void 0:t.flowParams)==null?void 0:re.flowSource,(ue=t==null?void 0:t.flowParams)==null?void 0:ue.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!g)return;const te=()=>b(!1);return window.addEventListener("pointerup",te,!0),window.addEventListener("pointercancel",te,!0),window.addEventListener("mouseup",te,!0),window.addEventListener("blur",te),()=>{window.removeEventListener("pointerup",te,!0),window.removeEventListener("pointercancel",te,!0),window.removeEventListener("mouseup",te,!0),window.removeEventListener("blur",te)}},[g]),m.useEffect(()=>{v||x(String(T||""))},[T,v]);const O=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),A=String((t==null?void 0:t.sourceNodeId)||e),M=(t==null?void 0:t.sharingDisplayNodeId)===A,_=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,U=m.useCallback(async()=>{var tt,Wt,$e,Vt,Gt,nt,ie,ke,Oe,We;if(l!=="html"||d)return;const te=ho(t),ae=fa(te,l);let pe=te;if(ae)try{pe=await $l((t==null?void 0:t.flowParams)||{},ae)}catch(Je){h(!1),console.warn("Failed to read HTML display file before saving image.",Je);return}const be=Vl(pe);if(!be.trim())return;const Fe=Vo(l,be);if(Fe){console.warn(Fe);return}const Ue=(Wt=(tt=u.current)==null?void 0:tt.getBoundingClientRect)==null?void 0:Wt.call(tt),Me=(Vt=($e=c.current)==null?void 0:$e.querySelector)==null?void 0:Vt.call($e,".af-work-display-body"),et=(nt=(Gt=c.current)==null?void 0:Gt.querySelector)==null?void 0:nt.call(Gt,".af-visible-scroll-frame__scroller"),ht=Math.round(Math.max(Number((Ue==null?void 0:Ue.width)||0),Number((_==null?void 0:_.width)||0),Number(((ie=c.current)==null?void 0:ie.clientWidth)||0),Number((Me==null?void 0:Me.clientWidth)||0),Number((et==null?void 0:et.clientWidth)||0),Math.max(320,Number((_==null?void 0:_.width)||960)-2))),Ie=Math.round(Math.max(Number((Ue==null?void 0:Ue.height)||0),Number((_==null?void 0:_.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((Me==null?void 0:Me.clientHeight)||0),Number((et==null?void 0:et.clientHeight)||0),Math.max(180,Number((_==null?void 0:_.height)||640)-46)));h(!0);try{await lK({flowParams:(t==null?void 0:t.flowParams)||{},content:be,sourceFilePath:ae,iframe:u.current,width:ht,height:Ie,filename:rK((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Me,scroller:et},displaySize:_}),(Oe=t==null?void 0:t.onStatus)==null||Oe.call(t,"已导出 HTML 展示截图")}catch(Je){const vt=String((Je==null?void 0:Je.message)||Je||"截图失败");(We=t==null?void 0:t.onStatus)==null||We.call(t,`HTML 截图失败:${vt}`),console.warn("Failed to save HTML display as PNG.",Je)}finally{h(!1)}},[t,_==null?void 0:_.height,_==null?void 0:_.width,e,l,d]),q=m.useCallback(te=>{var ae;L||!te||l!=="image"||(ae=t==null?void 0:t.onUploadImageToDisplayNode)==null||ae.call(t,e,te)},[t,e,l,L]),B=m.useCallback(te=>{var ae,pe;(ae=te==null?void 0:te.stopPropagation)==null||ae.call(te),!L&&((pe=t==null?void 0:t.onSetDisplayNodeContent)==null||pe.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),y(!1)))},[t,e,l,L]),Q=m.useCallback(te=>{var be,Fe;L||l!=="image"||!(Array.from(((be=te.dataTransfer)==null?void 0:be.files)||[]).some(Fp)||Array.from(((Fe=te.dataTransfer)==null?void 0:Fe.items)||[]).some(Ue=>String((Ue==null?void 0:Ue.type)||"").startsWith("image/")))||(te.preventDefault(),te.stopPropagation(),te.dataTransfer.dropEffect="copy",F(!0))},[l,L]),se=m.useCallback(te=>{l==="image"&&(te.currentTarget.contains(te.relatedTarget)||F(!1))},[l]),oe=m.useCallback(te=>{var pe;if(l!=="image")return;const ae=Array.from(((pe=te.dataTransfer)==null?void 0:pe.files)||[]).find(Fp);ae&&(te.preventDefault(),te.stopPropagation(),F(!1),q(ae))},[l,q]);return o.jsxs("div",{className:"af-work-display-card"+(_?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(g?" af-work-display-card--resizing":"")+(P?" af-work-display-card--image-drop":"")+($?" af-work-display-card--presentation":"")+(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:_?{width:_.width,height:_.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:Q,onDragLeave:se,onDrop:oe,children:[o.jsx(Vw,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>b(!0),onResizeEnd:()=>b(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((te,ae)=>{if(te.showOnNode===!1)return null;const pe=`${4.15+ae*1.75}rem`,be=te.name||`#${ae+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:pe},children:be}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${ae}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:pe,background:gn(te.type)},title:`${be} · ${te.type}`})]},`in-${ae}`)}),a.map(({slot:te,idx:ae},pe)=>{if(te.showOnNode===!1)return null;const be=`${4.15+pe*1.75}rem`,Fe=te.name||`#${ae+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:be},children:Fe}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${ae}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:be,background:gn(te.type)},title:`${Fe} · ${te.type}`})]},`out-${ae}`)}),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:BP(l)}),o.jsx("strong",{children:O}),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:te=>te.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var te,ae,pe,be;try{(be=(pe=(ae=(te=u.current)==null?void 0:te.contentWindow)==null?void 0:ae.history)==null?void 0:pe.back)==null||be.call(pe)}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 te,ae,pe,be;try{(be=(pe=(ae=(te=u.current)==null?void 0:te.contentWindow)==null?void 0:ae.history)==null?void 0:pe.forward)==null||be.call(pe)}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:()=>f(te=>te+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:d,onClick:U,"aria-label":"截图另存为图片",title:"截图另存为图片",children:o.jsx("span",{className:"material-symbols-outlined",children:d?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?v?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:te=>te.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:L||j,onClick:async()=>{var te,ae,pe;if(R){try{const be=await wx((t==null?void 0:t.flowParams)||{},R,w);C(w),(te=t==null?void 0:t.onSetDisplayNodeContent)==null||te.call(t,e,be,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${be}`}),y(!1)}catch(be){(ae=t==null?void 0:t.onStatus)==null||ae.call(t,String(be.message||be))}return}(pe=t==null?void 0:t.onSetDisplayNodeContent)==null||pe.call(t,e,w,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),y(!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:()=>{x(String(T||"")),y(!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",disabled:L||j,onClick:te=>{te.stopPropagation(),x(String(T||"")),y(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:V,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:te=>{var pe;const ae=(pe=te.target.files)==null?void 0:pe[0];te.target.value="",ae&&q(ae)}}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:te=>{var ae;te.stopPropagation(),(ae=V.current)==null||ae.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:te=>{var ae;te.stopPropagation(),(ae=t==null?void 0:t.onOpenDisplayPreview)==null||ae.call(t,A)},"aria-label":"全屏预览",title:"全屏预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:M,onClick:te=>{var ae;te.stopPropagation(),(ae=t==null?void 0:t.onShareDisplayNode)==null||ae.call(t,A)},"aria-label":"分享展示",title:"分享展示",children:o.jsx("span",{className:"material-symbols-outlined",children:M?"hourglass_empty":"ios_share"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:B,"aria-label":"清空内容",title:"清空内容",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:L,onClick:()=>{var te;return(te=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:te.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",disabled:L,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&v?o.jsx(pK,{value:w,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:L}):o.jsx(VP,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:p}),o.jsx(hK,{nodeId:e,data:t})]})}function wK({id:e,data:t,selected:n,deleteNode:r}){var p,f,d;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p.has)==null?void 0:f.call(p,e))||((d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);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":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((h,g)=>{if(h.showOnNode===!1)return null;const b=`${2.25+g*1.75}rem`,v=h.name||`#${g+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:b},children:v}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:b,background:gn(h.type)},title:`${v} · ${h.type}`})]},`in-${g}`)}),i.map((h,g)=>{if(h.showOnNode===!1)return null;const b=`${2.25+g*1.75}rem`,v=h.name||`#${g+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:b},children:v}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:b,background:gn(h.type)},title:`${v} · ${h.type}`})]},`out-${g}`)}),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",disabled:u,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-run-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var g,b;h.stopPropagation(),a?(g=t==null?void 0:t.onStopWorkspaceNode)==null||g.call(t,e):(b=t==null?void 0:t.onRunWorkspaceNode)==null||b.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"})]}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var g;h.stopPropagation(),(g=t==null?void 0:t.onOptimizeWorkspaceRun)==null||g.call(t,e)},children:o.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var g;h.stopPropagation(),(g=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||g.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:o.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function bK({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,workspaces:a}){var nt,ie,ke,Oe,We,Je,vt;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=LK(t),[p,f]=m.useState(u.task),d=m.useRef(!1),h=m.useRef(u.task),g=((ie=(nt=t==null?void 0:t.runningRunNodeIds)==null?void 0:nt.has)==null?void 0:ie.call(nt,e))||((ke=t==null?void 0:t.runningRunNodeIds)==null?void 0:ke[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",b=(t==null?void 0:t.nodeStatus)==="stopped",v=!!(t!=null&&t.readOnly),y=Array.isArray(s)?s:[],w=Array.isArray(i)?i:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(ee=>({id:String((ee==null?void 0:ee.id)||""),label:String((ee==null?void 0:ee.label)||(ee==null?void 0:ee.name)||"Workspace"),kind:(ee==null?void 0:ee.kind)==="git"?"git":"local",path:String((ee==null?void 0:ee.path)||""),repoUrl:String((ee==null?void 0:ee.repoUrl)||""),branch:String((ee==null?void 0:ee.branch)||""),mountPath:String((ee==null?void 0:ee.mountPath)||""),builtin:(ee==null?void 0:ee.builtin)===!0,exists:(ee==null?void 0:ee.exists)!==!1,type:String((ee==null?void 0:ee.type)||"")})).filter(ee=>ee.path),[a]),[S,C]=m.useState(!1),[j,E]=m.useState(""),[P,F]=m.useState(()=>new Set),[V,z]=m.useState(!1),[D,R]=m.useState(""),[T,L]=m.useState("config"),$=Mh(t),O=!!$,A=XP(u.displayType),M=m.useMemo(()=>Z7(t,A),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,A]),_=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:A,displaySize:M,nodeSize:M,body:$,inputs:[{type:"text",name:A==="display_image"?"src":"content",value:$,default:$}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,A,e,$,c,M]),U=Array.isArray((Oe=t==null?void 0:t.modelLists)==null?void 0:Oe.cursor)?t.modelLists.cursor:[],q=Array.isArray((We=t==null?void 0:t.modelLists)==null?void 0:We.opencode)?t.modelLists.opencode:[],B=Array.isArray((Je=t==null?void 0:t.modelLists)==null?void 0:Je.claudeCode)?t.modelLists.claudeCode:[],Q=Array.isArray((vt=t==null?void 0:t.modelLists)==null?void 0:vt.codex)?t.modelLists.codex:[],se=m.useMemo(()=>new Set(U.map(Yr)),[U]),oe=m.useMemo(()=>new Set(q.map(Yr)),[q]),ve=m.useMemo(()=>new Set(B.map(Yr)),[B]),re=m.useMemo(()=>new Set(Q.map(Yr)),[Q]),ue=u.model,te=m.useMemo(()=>ue?ue.startsWith("cursor:")||ue.startsWith("opencode:")||ue.startsWith("codex:")||ue.startsWith("claude-code:")?ue:ve.has(ue)?`claude-code:${ue}`:re.has(ue)?`codex:${ue}`:oe.has(ue)?`opencode:${ue}`:se.has(ue)?`cursor:${ue}`:ue:"",[ve,re,se,oe,ue]),ae=ue.startsWith("cursor:")?ue.slice(7):ue.startsWith("opencode:")?ue.slice(9):ue.startsWith("codex:")?ue.slice(6):ue.startsWith("claude-code:")?ue.slice(12):ue,pe=ae,be=!!ue&&!se.has(pe)&&!oe.has(pe)&&!ve.has(pe)&&!re.has(pe),Fe=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ue=m.useMemo(()=>new Map(y.map(ee=>[ee.key,ee])),[y]),Me=m.useMemo(()=>{const ee=new Set,ye=w.map(Ce=>{const at=ra(Ce,y).map(mt=>Ue.get(mt)).filter(Boolean);for(const mt of at)ee.add(mt.key);return{...Ce,skills:at}}).filter(Ce=>Ce.skills.length>0),Ve=y.filter(Ce=>!ee.has(Ce.key));return{collectionGroups:ye,ungrouped:Ve}},[w,Ue,y]);m.useEffect(()=>{F(ee=>{let ye=!1;const Ve=new Set(ee);for(const Ce of Me.collectionGroups)Ve.has(Ce.id)||(Ve.add(Ce.id),ye=!0);return ye?Ve:ee})},[Me.collectionGroups]);const et=m.useMemo(()=>{const ee=j.trim().toLowerCase();if(!ee)return Me;const ye=Ce=>[Ce==null?void 0:Ce.key,Ce==null?void 0:Ce.name,Ce==null?void 0:Ce.description].map(at=>String(at||"").toLowerCase()).join(" ").includes(ee);return{collectionGroups:Me.collectionGroups.map(Ce=>{const at=[Ce==null?void 0:Ce.id,Ce==null?void 0:Ce.name,Ce==null?void 0:Ce.description].map(mt=>String(mt||"").toLowerCase()).join(" ").includes(ee);return{...Ce,skills:at?Ce.skills:Ce.skills.filter(ye)}}).filter(Ce=>Ce.skills.length>0),ungrouped:Me.ungrouped.filter(ye)}},[Me,j]),ht=m.useMemo(()=>{const ee=D.trim().toLowerCase();return ee?x.filter(ye=>[ye.id,ye.label,ye.path,ye.repoUrl,ye.branch,ye.mountPath,ye.type].join(" ").toLowerCase().includes(ee)):x},[x,D]),Ie=m.useMemo(()=>{var Ve,Ce,at;const ee=String(((Ve=u.workspaceContext)==null?void 0:Ve.cwd)||((Ce=u.workspaceContext)==null?void 0:Ce.workspaceRoot)||"").trim(),ye=String(((at=u.workspaceContext)==null?void 0:at.id)||"").trim();return x.find(mt=>ye&&mt.id===ye||ee&&mt.path===ee)||null},[u.workspaceContext,x]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,d.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!O){L("config");return}g||L("result")},[O,$,g]),m.useEffect(()=>{var ye,Ve;if(!(T==="result"&&O))return;(ye=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||ye.call(t,e,M),(Ve=t==null?void 0:t.onRefreshNodeInternals)==null||Ve.call(t,e);const ee=window.setTimeout(()=>{var Ce;return(Ce=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:Ce.call(t,e)},120);return()=>window.clearTimeout(ee)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,A,O,e,$,M,T]);const tt=ee=>{var ye;(ye=t==null?void 0:t.onChangeContextRunConfig)==null||ye.call(t,e,{...u,task:p,...ee})},Wt=(ee=p)=>{var Ve;const ye=String(ee??"");ye!==u.task&&(h.current=ye,(Ve=t==null?void 0:t.onChangeContextRunConfig)==null||Ve.call(t,e,{...u,task:ye}))},$e=(ee,ye)=>{const Ve=new Set(u.skillKeys);for(const Ce of ee){const at=String(Ce||"").trim();at&&(ye?Ve.add(at):Ve.delete(at))}tt({skillKeys:Array.from(Ve)})},Vt=ee=>{F(ye=>{const Ve=new Set(ye);return Ve.has(ee)?Ve.delete(ee):Ve.add(ee),Ve})},Gt=ee=>{const ye=ee?{version:1,id:ee.id||"",label:ee.label||"Workspace",kind:ee.kind||"local",cwd:ee.path||"",workspaceRoot:ee.path||"",repoUrl:ee.repoUrl||"",branch:ee.branch||"",mountPath:ee.mountPath||"",type:ee.type||""}:null;tt({includeWorkspaceContext:!!ee,workspaceContext:ye}),z(!1)};return T==="result"&&O?o.jsx(KP,{id:e,data:{..._,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):o.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(T==="result"&&O?" af-work-context-run-card--result":"")+(g?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(b?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((ee,ye)=>{if(ee.showOnNode===!1)return null;const Ve=`${2.25+ye*1.75}rem`,Ce=ee.name||`#${ye+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Ve},children:Ce}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${ye}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Ve,background:gn(ee.type)},title:`${Ce} · ${ee.type}`})]},`in-${ye}`)}),c.map((ee,ye)=>{if(ee.showOnNode===!1)return null;const Ve=`${2.25+ye*1.75}rem`,Ce=ee.name||`#${ye+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Ve},children:Ce}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${ye}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Ve,background:gn(ee.type)},title:`${Ce} · ${ee.type}`})]},`out-${ye}`)}),o.jsxs("div",{className:"af-work-context-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"automation"}),o.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),o.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:ee=>ee.stopPropagation(),onMouseDown:ee=>ee.stopPropagation(),onClick:ee=>ee.stopPropagation(),children:[o.jsxs("select",{className:"af-work-context-run-card__model",value:te,disabled:v,"aria-label":"模型",title:ae||"默认模型",onChange:ee=>tt({model:ee.target.value}),children:[o.jsx("option",{value:"",children:"默认"}),be?o.jsx("option",{value:ue,children:ue}):null,U.length?o.jsx("optgroup",{label:"Cursor",children:U.map(ee=>o.jsx("option",{value:`cursor:${Yr(ee)}`,children:Yr(ee)},`context-cursor-${ee}`))}):null,q.length?o.jsx("optgroup",{label:"OpenCode",children:q.map(ee=>o.jsx("option",{value:`opencode:${Yr(ee)}`,children:Yr(ee)},`context-opencode-${ee}`))}):null,Q.length?o.jsx("optgroup",{label:"Codex",children:Q.map(ee=>o.jsx("option",{value:`codex:${Yr(ee)}`,children:Yr(ee)},`context-codex-${ee}`))}):null,B.length?o.jsx("optgroup",{label:"Claude Code",children:B.map(ee=>o.jsx("option",{value:`claude-code:${Yr(ee)}`,children:Yr(ee)},`context-claude-${ee}`))}):null]}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),o.jsx("span",{className:"af-work-context-run-card__kind",children:Es(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),O?o.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:ee=>ee.stopPropagation(),children:[o.jsx("button",{type:"button",className:T==="config"?"is-active":"",onClick:()=>L("config"),"aria-label":"切换到任务配置",children:o.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),o.jsx("button",{type:"button",className:T==="result"?"is-active":"",onClick:()=>L("result"),"aria-label":"切换到展示结果",children:o.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:v,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-context-run-card__body nodrag",children:[o.jsxs(o.Fragment,{children:[o.jsx("textarea",{value:p,disabled:v,placeholder:"输入任务,例如:基于当前 workspace 总结需求并生成展示页",onCompositionStart:()=>{d.current=!0},onCompositionEnd:ee=>{d.current=!1,f(ee.currentTarget.value),Wt(ee.currentTarget.value)},onChange:ee=>{f(ee.target.value)},onBlur:ee=>Wt(ee.currentTarget.value)}),o.jsxs("div",{className:"af-work-context-run-card__grid",children:[o.jsxs("div",{className:"af-work-context-run-card__skills",children:[o.jsxs("button",{type:"button",disabled:v,className:"af-work-context-run-card__select",onClick:ee=>{var ye;ee.stopPropagation(),S||(ye=t==null?void 0:t.onRefreshSkills)==null||ye.call(t),C(Ve=>!Ve)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),S?o.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:ee=>ee.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:j,onChange:ee=>E(ee.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),j?o.jsx("button",{type:"button",onClick:()=>E(""),"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 af-work-context-run-card__menu-scroll",children:[et.collectionGroups.map(ee=>{const ye=ee.skills.map(mt=>mt.key),Ve=ye.filter(mt=>Fe.has(mt)).length,Ce=ye.length>0&&Ve===ye.length,at=P.has(ee.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(at?" 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:Ce,disabled:v,onChange:mt=>$e(ye,mt.target.checked),"aria-label":`选择 ${ee.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>Vt(ee.id),"aria-expanded":!at,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:ee.name}),ee.description?o.jsx("em",{children:ee.description}):null]})}),o.jsxs("small",{children:[Ve,"/",ye.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>Vt(ee.id),"aria-label":at?`展开 ${ee.name}`:`收起 ${ee.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:at?"chevron_right":"expand_more"})})]}),at?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:ee.skills.map(mt=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:Fe.has(mt.key),disabled:v,onChange:Qt=>$e([mt.key],Qt.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:mt.name}),mt.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:mt.description}):null]})]},`${ee.id}:${mt.key}`))})]},ee.id)}),et.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:et.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:et.ungrouped.map(ee=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:Fe.has(ee.key),disabled:v,onChange:ye=>$e([ee.key],ye.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:ee.name}),ee.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:ee.description}):null]})]},`ungrouped:${ee.key}`))})]}):null,et.collectionGroups.length===0&&et.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:()=>tt({skillKeys:[]}),children:"清空"})]})]}):null]}),o.jsxs("div",{className:"af-work-context-run-card__workspace",children:[o.jsxs("button",{type:"button",disabled:v,className:"af-work-context-run-card__select",onClick:ee=>{var ye;ee.stopPropagation(),V||(ye=t==null?void 0:t.onRefreshWorkspaces)==null||ye.call(t),z(Ve=>!Ve)},children:[o.jsx("span",{className:"material-symbols-outlined",children:Ie?"folder_open":"folder_off"}),o.jsx("span",{children:(Ie==null?void 0:Ie.label)||"Workspace"}),o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),V?o.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:ee=>ee.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:D,onChange:ee=>R(ee.target.value),placeholder:"搜索 Workspace...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Workspace"}),D?o.jsx("button",{type:"button",onClick:()=>R(""),"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 af-work-context-run-card__menu-scroll",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:"Workspace"}),o.jsx("small",{children:ht.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:ht.map(ee=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"radio",name:`context-workspace-${e}`,checked:(Ie==null?void 0:Ie.path)===ee.path,disabled:v,onChange:()=>Gt(ee)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:ee.label}),o.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[ee.kind==="git"&&ee.repoUrl?`${ee.repoUrl}${ee.branch?` · ${ee.branch}`:""}${ee.mountPath?` · ${ee.mountPath}`:""}`:ee.path,ee.exists?"":" · 路径未就绪"]})]})]},`${ee.id}:${ee.path}`))})]}),ht.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Workspace"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>Gt(null),children:"不加载 Workspace"})]})]}):null]}),o.jsxs("select",{value:u.displayType,disabled:v,onChange:ee=>tt({displayType:ee.target.value}),children:[o.jsx("option",{value:"markdown",children:"Markdown"}),o.jsx("option",{value:"html",children:"HTML"}),o.jsx("option",{value:"react",children:"React"}),o.jsx("option",{value:"table",children:"Table"}),o.jsx("option",{value:"chart",children:"Chart"}),o.jsx("option",{value:"ascii",children:"ASCII"}),o.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),$?o.jsx("pre",{className:"af-work-context-run-card__preview",children:$.slice(0,520)}):null]}),o.jsxs("div",{className:"af-work-context-run-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(g?" af-work-run-card__button--stop":""),disabled:v,onClick:ee=>{var ye,Ve;ee.stopPropagation(),Wt(),g?(ye=t==null?void 0:t.onStopWorkspaceNode)==null||ye.call(t,e):(Ve=t==null?void 0:t.onRunWorkspaceNode)==null||Ve.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:g?"stop_circle":"play_arrow"}),o.jsx("span",{children:g?"Stop":"Run"})]}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:ee=>{var ye;ee.stopPropagation(),(ye=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||ye.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:o.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function kK({id:e,data:t,selected:n,deleteNode:r}){var S,C,j;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=mb((t==null?void 0:t.body)||""),l=(t==null?void 0:t.scheduledRunState)||{},c=((C=(S=t==null?void 0:t.runningRunNodeIds)==null?void 0:S.has)==null?void 0:C.call(S,e))||((j=t==null?void 0:t.runningRunNodeIds)==null?void 0:j[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",u=(t==null?void 0:t.optimizingRun)===!0,p=(t==null?void 0:t.nodeStatus)==="stopped",f=!!(t!=null&&t.readOnly),d=E=>{var P;(P=t==null?void 0:t.onChangeScheduledRunConfig)==null||P.call(t,e,{...a,...E})},h=E=>{d({scheduleType:E,cron:Fc(E,a.time,a.weekday,a.monthDay,a.cron)})},g=E=>{d({time:E,cron:Fc(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[b,v]=hb(a.time).split(":"),y=(E,P)=>{g(`${to(E,9,0,23)}:${to(P,0,0,59)}`)},w=E=>{d({weekday:E,cron:Fc(a.scheduleType,a.time,E,a.monthDay,a.cron)})},x=E=>{d({monthDay:E,cron:Fc(a.scheduleType,a.time,a.weekday,E,a.cron)})};return o.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(c?" 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":"")+(p?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((E,P)=>{if(E.showOnNode===!1)return null;const F=`${2.25+P*1.75}rem`,V=E.name||`#${P+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:F},children:V}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${P}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:F,background:gn(E.type)},title:`${V} · ${E.type}`})]},`in-${P}`)}),i.map((E,P)=>{if(E.showOnNode===!1)return null;const F=`${2.25+P*1.75}rem`,V=E.name||`#${P+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:F},children:V}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${P}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:F,background:gn(E.type)},title:`${V} · ${E.type}`})]},`out-${P}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:f,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-schedule-card__body nodrag",children:[o.jsxs("label",{className:"af-work-schedule-card__toggle",children:[o.jsx("input",{type:"checkbox",checked:a.enabled,disabled:f,onChange:E=>d({enabled:E.target.checked})}),o.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"频率"}),o.jsxs("select",{value:a.scheduleType,disabled:f,onChange:E=>h(E.target.value),children:[o.jsx("option",{value:"daily",children:"每天"}),o.jsx("option",{value:"weekly",children:"每周"}),o.jsx("option",{value:"monthly",children:"每月"}),o.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"时间"}),o.jsxs("div",{className:"af-work-schedule-time-selects",children:[o.jsx("select",{value:b,disabled:f,"aria-label":"小时",onChange:E=>y(E.target.value,v),children:Array.from({length:24},(E,P)=>to(P,0,0,23)).map(E=>o.jsxs("option",{value:E,children:[E," 时"]},E))}),o.jsx("select",{value:v,disabled:f,"aria-label":"分钟",onChange:E=>y(b,E.target.value),children:Array.from({length:12},(E,P)=>to(P*5,0,0,59)).map(E=>o.jsxs("option",{value:E,children:[E," 分"]},E))})]})]}):null,a.scheduleType==="weekly"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"星期"}),o.jsxs("select",{value:a.weekday,disabled:f,onChange:E=>w(E.target.value),children:[o.jsx("option",{value:1,children:"周一"}),o.jsx("option",{value:2,children:"周二"}),o.jsx("option",{value:3,children:"周三"}),o.jsx("option",{value:4,children:"周四"}),o.jsx("option",{value:5,children:"周五"}),o.jsx("option",{value:6,children:"周六"}),o.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"日期"}),o.jsx("select",{value:a.monthDay,disabled:f,onChange:E=>x(E.target.value),children:Array.from({length:31},(E,P)=>P+1).map(E=>o.jsxs("option",{value:E,children:[E," 日"]},E))})]}):null,a.scheduleType==="custom"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"Cron"}),o.jsx("input",{type:"text",value:a.cron,disabled:f,spellCheck:!1,placeholder:Ou,onChange:E=>d({cron:E.target.value})})]}):null,o.jsxs("div",{className:"af-work-schedule-card__meta",children:[o.jsxs("span",{children:[H7(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),o.jsxs("span",{children:["Next ",z7(l.nextAt)]}),o.jsx("span",{children:c?"running":l.lastStatus||"idle"})]}),l.lastError?o.jsx("div",{className:"af-work-schedule-card__error",children:l.lastError}):null,o.jsxs("div",{className:"af-work-schedule-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(c?" af-work-run-card__button--stop":""),disabled:f||u,onClick:E=>{var P,F;E.stopPropagation(),c?(P=t==null?void 0:t.onStopWorkspaceNode)==null||P.call(t,e):(F=t==null?void 0:t.onRunWorkspaceNode)==null||F.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:c?"stop_circle":"play_arrow"}),o.jsx("span",{children:c?"停止":"立即运行"})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(u?" af-work-schedule-card__optimize--running":""),disabled:f||c||u,title:"为下游节点提前生成 implementation",onClick:E=>{var P;E.stopPropagation(),(P=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||P.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:u?"sync":"auto_fix_high"}),o.jsx("span",{children:u?"优化中":"优化"})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:E=>{var P;E.stopPropagation(),(P=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||P.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:l.targetRunNodeId||e,lastRunId:l.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"article"}),o.jsx("span",{children:"日志"})]})]})]})]})}function vK({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Hl(),i=!!(t!=null&&t.readOnly),a=yx(t==null?void 0:t.nodeSize)||{width:ca,height:ua},l=m.useCallback(c=>{var u,p;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(p=(u=c.target)==null?void 0:u.closest)!=null&&p.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>YP(f,e))},[e,s]);return o.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[i?null:o.jsx(Vw,{className:"af-work-group-node__resize nodrag",minWidth:ca,minHeight:ua,position:"bottom-right",children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),o.jsxs("div",{className:"af-work-group-node__title nodrag",children:[o.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),o.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:i,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function SK(e){var g,b,v,y,w,x,S,C,j,E,P,F,V,z,D,R,T,L,$,O,A,M,_;const{setEdges:t,setNodes:n}=Hl(),r=(g=e.data)==null?void 0:g.onSyncNodePropDraft,s=!!((b=e.data)!=null&&b.readOnly),[i,a]=m.useState(!1),l=(v=e.data)!=null&&v.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(U=>{var Q,se,oe;if(s)return;(se=(Q=e.data)==null?void 0:Q.onCleanupWorkspaceNodeOutputs)==null||se.call(Q,U,e.data);const q=Es((oe=e.data)==null?void 0:oe.definitionId)?QP(U):"",B=new Set([U,q].filter(Boolean));n(ve=>ve.filter(re=>!B.has(re.id))),t(ve=>ve.filter(re=>!B.has(re.source)&&!B.has(re.target)))},[e.data,s,t,n]),u=m.useCallback(U=>{var q,B;U.button!==0||U.metaKey||U.ctrlKey||U.shiftKey||(B=(q=U.target)==null?void 0:q.closest)!=null&&B.call(q,".react-flow__handle, .af-work-display-resize")||(n(Q=>YP(Q,e.id)),t(Q=>CK(Q)))},[e.id,t,n]),p=m.useCallback((U,q)=>{s||(n(B=>B.map(Q=>Q.id===U?{...Q,data:{...Q.data,model:q}}:Q)),r==null||r(U,{model:q}))},[s,n,r]),f=m.useCallback((U,q)=>{s||(n(B=>B.map(Q=>{var oe;if(Q.id!==U)return Q;const se=Array.isArray((oe=Q.data)==null?void 0:oe.outputs)&&Q.data.outputs.length?Q.data.outputs.map((ve,re)=>re===0?{...ve,default:q,value:q}:ve):[{type:"bool",name:"value",default:q,value:q}];return{...Q,data:{...Q.data,body:"",outputs:se}}})),r==null||r(U,B=>({body:"",outputs:Array.isArray(B==null?void 0:B.outputs)&&B.outputs.length?B.outputs.map((se,oe)=>oe===0?{...se,default:q,value:q}:se):[{type:"bool",name:"value",default:q,value:q}]})))},[s,n,r]),d=m.useCallback((U,q)=>{s||(n(B=>B.map(Q=>Q.id===U?{...Q,data:{...Q.data,body:q}}:Q)),r==null||r(U,{body:q}))},[s,n,r]),h=m.useCallback((U,q)=>{if(s)return;const B=Pi(q);n(Q=>Q.map(se=>se.id===U?{...se,data:{...se.data,images:B}}:se)),r==null||r(U,{images:B})},[s,n,r]);return(y=e.data)!=null&&y.isWorkspaceGroup?o.jsx(vK,{...e,deleteNode:c}):da((w=e.data)==null?void 0:w.definitionId)?o.jsx(KP,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?o.jsx(wK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((S=e.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"?o.jsx(kK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):Es((C=e.data)==null?void 0:C.definitionId)?o.jsx(bK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(j=e.data)==null?void 0:j.skills,skillCollections:(E=e.data)==null?void 0:E.skillCollections,workspaces:(P=e.data)==null?void 0:P.workspaceTargets}):((F=e.data)==null?void 0:F.definitionId)==="control_load_skills"?o.jsx(WK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(V=e.data)==null?void 0:V.skills,skillCollections:(z=e.data)==null?void 0:z.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((R=e.data)==null?void 0:R.definitionId)==="control_load_mcp"?o.jsx(VK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(T=e.data)==null?void 0:T.mcpServers,onChangeMcpNames:(L=e.data)==null?void 0:L.onChangeLoadMcpNames}):(($=e.data)==null?void 0:$.definitionId)==="control_cd_workspace"?o.jsx(KK,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(O=e.data)==null?void 0:O.workspaceTargets,onChangeWorkspace:(A=e.data)==null?void 0:A.onChangeLoadWorkspace,onRefreshWorkspaces:(M=e.data)==null?void 0:M.onRefreshWorkspaces}):o.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(i?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:o.jsx(Vw,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:_P,minHeight:Dp,maxWidth:EP,maxHeight:AP,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx(gV,{...e,deleteNode:c,modelLists:(_=e.data)==null?void 0:_.modelLists,onModelChange:p,onProvideValueChange:f,onNodeBodyChange:d,onNodeImagesChange:h})]})}const NK={[xl]:SK};function gb(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&gb(n.children,t);return t}function UP(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const s=Array.isArray(r.children)?UP(r.children,n):null;if(s)return s}return null}function jK(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function qP(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&qP(n.children,t));return t}function vf(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 YP(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(i=>{const a=i.id===n;return i.selected===a?i:(r=!0,{...i,selected:a})});return r?s:e}function CK(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function _K(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function EK(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],u=l?`${l}/${c}`:c,p=a===r.length-1;let f=!1;const d=(Array.isArray(i)?i:[]).map(h=>h.name!==c?h:(f=!0,p?{...h,type:"file",name:c,path:u,icon:ol(c),size:n}:{...h,type:"directory",name:c,path:u,icon:ol(c,!0),children:s(h.children||[],a+1,u)}));return f||d.push(p?{type:"file",name:c,path:u,icon:ol(c),size:n}:{type:"directory",name:c,path:u,icon:ol(c,!0),children:s([],a+1,u)}),_K(d)};return s(e||[],0,"")}function AK(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"":t<1024?`${t} B`:t<1024*1024?`${Math.round(t/102.4)/10} KB`:`${Math.round(t/1024/102.4)/10} MB`}function GP({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:i,onFileDragStart:a,onDelete:l,onDownload:c}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const p=u.type==="directory",f=p&&(r==null?void 0:r.has(u.path)),d=n===u.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--"+u.type+(d?" af-work-file--selected":""),draggable:!p,onDragStart:g=>{p||a==null||a(g,u)},onClick:()=>{i==null||i(u),p&&(s==null||s(u.path))},onDoubleClick:()=>{p||t(u)},title:u.path,children:[p?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:u.icon||ol(u.name,p)}),o.jsx("span",{children:u.name})]}),d?o.jsxs("div",{className:"af-work-file-actions",children:[p?null:o.jsx("button",{type:"button",className:"af-work-file-action",onClick:g=>{g.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:g=>{g.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),p&&!f&&((h=u.children)!=null&&h.length)?o.jsx(GP,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:i,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function PK({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:i}){const a=m.useMemo(()=>gb(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.name}`.toLowerCase().includes(l):!0);return o.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:i,children:o.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:u=>u.stopPropagation(),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",children:"folder_open"}),"选择文件"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:i,"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[o.jsx("input",{value:t,onChange:u=>n(u.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(""),children:[o.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),o.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(u=>o.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[o.jsx("span",{className:"material-symbols-outlined",children:u.icon||ol(u.name)}),o.jsxs("span",{className:"af-work-file-picker-modal__main",children:[o.jsx("strong",{children:u.name}),o.jsx("small",{children:u.path})]}),u.size?o.jsx("em",{children:AK(u.size)}):null]},u.path)),c.length===0?o.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function XN({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 JP(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function IK(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(i=>!JP(i));if(r.length>0)return r;const s=[...n].reverse().find(i=>(i==null?void 0:i.kind)==="result"||(i==null?void 0:i.kind)==="assistant"||(i==null?void 0:i.error));return s?[s]:n.length>0||t?[{role:"assistant",kind:"assistant",text:t?"正在执行,可以在完成后继续追问或要求调整。":"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function TK(e){return(Array.isArray(e)?e:[]).filter(JP)}function Fu(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 RK(e){const t=Fu((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 Fu((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function MK(e){const n=[...Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],...Array.isArray(e==null?void 0:e.outputs)?e.outputs:[]].find(r=>(r==null?void 0:r.name)==="skillKeys"||(r==null?void 0:r.name)==="skillsContext");return Fu((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function QN(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function yo(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(i=>(i==null?void 0:i.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function $K(e,t){const n=yo(e,t,"");if(!n)return null;try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function id(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Yr(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function XP(e){const t=id(e);return t==="html"?"display_html":t==="react"?"display_react_app":t==="table"?"display_table":t==="chart"?"display_chart":t==="ascii"?"display_ascii":t==="mermaid"?"display_mermaid":"display_markdown"}function QP(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function ZP(e){return e==="display_image"?"src":"content"}function ZN(e,t,n){const r=ZP(t),s=zc(e);let i=!1;const a=s.map(l=>(l==null?void 0:l.name)===r?(i=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return i||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function ej(e,t,n=[],r=[]){const s=Array.isArray(e)?e:[],i=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=s.findIndex(u=>l(u)&&i.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=s.findIndex(u=>i.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function tj(e){return(Array.isArray(e)?e:[]).map(t=>(t==null?void 0:t.type)==="node"||(t==null?void 0:t.name)==="next"?t:{...t,default:"",value:""})}function Mh(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=s=>String((s==null?void 0:s.value)??(s==null?void 0:s.default)??"").trim(),r=t.find(s=>((s==null?void 0:s.name)==="content"||(s==null?void 0:s.name)==="result")&&n(s))||t.find(s=>(s==null?void 0:s.name)==="resultFile"&&n(s))||t.find(s=>(s==null?void 0:s.type)!=="node"&&(s==null?void 0:s.name)!=="next"&&(s==null?void 0:s.name)!=="displayType"&&n(s));return r?n(r):""}function LK(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=yo(t,"includeWorkspaceContext","true").toLowerCase();return{task:String((e==null?void 0:e.body)||""),skillKeys:MK(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",workspaceContext:$K(t,"workspaceContext"),displayType:id(yo(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function Es(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function OK(e){const t=Fu((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 Fu((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function DK(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function FK(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[];return{path:yo(t,"path",""),label:yo(t,"label","")}}function nj(e){var r,s,i,a,l,c,u,p,f;if(!e)return null;const{inputs:t,outputs:n}=EV(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:Pi((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((p=e.data)==null?void 0:p.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function rj(e,t,n,r=""){var c,u;const s=String(n||"").trim(),i=(Array.isArray(e)?e:[]).find(p=>String((p==null?void 0:p.id)||"")===s),a=String(((c=i==null?void 0:i.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[s])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function sj(e){return(Array.isArray(e)?e:[]).map(t=>({type:String((t==null?void 0:t.type)??"node").trim()||"node",name:String((t==null?void 0:t.name)??""),default:String((t==null?void 0:t.default)??""),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 zK(e,t,n){var p,f;const r=String(((p=e==null?void 0:e.data)==null?void 0:p.definitionId)??n),s=r.startsWith("provide_"),i=String((t==null?void 0:t.role)||"").trim(),a=$u.includes(i)?i:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:s?"":String((t==null?void 0:t.body)??""),images:s?[]:Pi(t==null?void 0:t.images),inputs:sj(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:sj(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const d of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[d])??"").trim();h?c[d]=h:delete c[d]}return c}function ij({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:i=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=i?l:a;if(i){if(!XV.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(b=>b.id===c&&b.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=zK(r,s,c),p=r.data||{};if(!(c!==a||p.label!==u.label||p.role!==u.role||p.model!==u.model||p.body!==u.body||JSON.stringify(Pi(p.images))!==JSON.stringify(u.images)||(p.script??void 0)!==(u.script??void 0)||(p.scriptRef??void 0)!==(u.scriptRef??void 0)||(p.implementationRef??void 0)!==(u.implementationRef??void 0)||(p.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(p.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(p.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const d=e.map(b=>b.id===a?{...b,id:c,selected:!0,data:u}:b);let h=t,g=n;if(c!==a){g={...n||{}};const b={...g[a]||{}};delete g[a],g[c]=b,h=t.map((v,y)=>({...v,source:v.source===a?c:v.source,target:v.target===a?c:v.target,id:`we-${v.source===a?c:v.source}-${v.target===a?c:v.target}-${y}`}))}return{ok:!0,changed:!0,nextId:c,nodes:d,edges:h,instances:g}}function HK(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function BK(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","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:[],u=Array.isArray(s)?s:[],p=Array.isArray(i)?i:[],[f,d]=m.useState(!1),[h,g]=m.useState(""),[b,v]=m.useState(()=>new Set),y=m.useRef(null),w=m.useRef(null),[x,S]=m.useState({visible:!1,top:0,height:100}),C=m.useMemo(()=>new Set(RK(t)),[t]),j=m.useMemo(()=>new Map(u.map(L=>[L.key,L])),[u]),E=m.useMemo(()=>{const L=new Set,$=p.map(A=>{const M=ra(A,u).map(_=>j.get(_)).filter(Boolean);for(const _ of M)L.add(_.key);return{...A,skills:M}}).filter(A=>A.skills.length>0),O=u.filter(A=>!L.has(A.key));return{collectionGroups:$,ungrouped:O}},[j,p,u]);m.useEffect(()=>{v(L=>{let $=!1;const O=new Set(L);for(const A of E.collectionGroups)O.has(A.id)||(O.add(A.id),$=!0);return $?O:L})},[E.collectionGroups]);const P=m.useMemo(()=>{const L=h.trim().toLowerCase();if(!L)return E;const $=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(_=>String(_||"").toLowerCase()).join(" ").includes(L);return{collectionGroups:E.collectionGroups.map(A=>{const _=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(U=>String(U||"").toLowerCase()).join(" ").includes(L)?A.skills:A.skills.filter($);return{...A,skills:_}}).filter(A=>A.skills.length>0),ungrouped:E.ungrouped.filter($)}},[E,h]),F=m.useCallback((L,$)=>{const O=new Set(C);for(const A of L)$?O.add(A):O.delete(A);a==null||a(e,Array.from(O))},[e,C,a]),V=m.useCallback(L=>{v($=>{const O=new Set($);return O.has(L)?O.delete(L):O.add(L),O})},[]),z=m.useCallback(()=>{const L=y.current;if(!L)return;const $=Math.max(1,L.scrollHeight),O=Math.max(1,L.clientHeight),A=$>O+1,M=A?Math.max(12,O/$*100):100,_=Math.max(0,100-M),U=A?Math.min(_,L.scrollTop/Math.max(1,$-O)*_):0;S({visible:A,top:U,height:M})},[]);m.useEffect(()=>{if(!f)return;const L=requestAnimationFrame(z);return()=>cancelAnimationFrame(L)},[b,P,C.size,f,z]);const D=m.useCallback(L=>{const $=y.current;if(!$)return;const O=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,L))*O,z()},[z]),R=m.useCallback((L,$=0)=>{const O=w.current;if(!O)return 0;const A=O.getBoundingClientRect(),M=x.height/100*A.height,_=Math.max(1,A.height-M);return(L-A.top-$)/_},[x.height]),T=m.useCallback(L=>{var se,oe;if(!x.visible)return;L.preventDefault(),L.stopPropagation();const $=w.current;if(!$)return;const O=$.getBoundingClientRect(),A=x.top/100*O.height,M=x.height/100*O.height,U=L.clientY>=O.top+A&&L.clientY<=O.top+A+M?L.clientY-O.top-A:M/2;D(R(L.clientY,U));const q=L.pointerId;(oe=(se=L.currentTarget).setPointerCapture)==null||oe.call(se,q);const B=ve=>{ve.preventDefault(),D(R(ve.clientY,U))},Q=()=>{window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",Q),window.removeEventListener("pointercancel",Q)};window.addEventListener("pointermove",B),window.addEventListener("pointerup",Q),window.addEventListener("pointercancel",Q)},[R,D,x.height,x.top,x.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((L,$)=>{if(L.showOnNode===!1)return null;const O=`${2.6+$*1.7}rem`,A=L.name||`#${$+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:O},children:A}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:O,background:gn(L.type)},title:`${A} · ${L.type}`})]},`in-${$}`)}),c.map((L,$)=>{if(L.showOnNode===!1)return null;const O=`${2.6+$*1.7}rem`,A=L.name||`#${$+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:O},children:A}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:O,background:gn(L.type)},title:`${A} · ${L.type}`})]},`out-${$}`)}),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:L=>{var $;L.stopPropagation(),f||($=t==null?void 0:t.onRefreshSkills)==null||$.call(t),d(O=>!O)},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:L=>L.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:L=>g(L.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:z,children:[P.collectionGroups.map(L=>{const $=L.skills.map(_=>_.key),O=$.filter(_=>C.has(_)).length,A=$.length>0&&O===$.length,M=b.has(L.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(M?" 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:A,onChange:_=>F($,_.target.checked),"aria-label":`选择 ${L.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>V(L.id),"aria-expanded":!M,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:L.name}),L.description?o.jsx("em",{children:L.description}):null]})}),o.jsxs("small",{children:[O,"/",$.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>V(L.id),"aria-label":M?`展开 ${L.name}`:`收起 ${L.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:M?"chevron_right":"expand_more"})})]}),M?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:L.skills.map(_=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:C.has(_.key),onChange:U=>F([_.key],U.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]})]},`${L.id}:${_.key}`))})]},L.id)}),P.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:P.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:P.ungrouped.map(L=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:C.has(L.key),onChange:$=>F([L.key],$.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:L.name}),L.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:L.description}):null]})]},`ungrouped:${L.key}`))})]}):null,P.collectionGroups.length===0&&P.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:w,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:T,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function VK({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,u]=m.useState(!1),[p,f]=m.useState(""),d=m.useMemo(()=>new Set(OK(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(v=>({name:String((v==null?void 0:v.name)||""),description:String((v==null?void 0:v.description)||""),detail:String((v==null?void 0:v.url)||[v==null?void 0:v.command,...Array.isArray(v==null?void 0:v.args)?v.args:[]].filter(Boolean).join(" ")||""),type:String((v==null?void 0:v.type)||"")})).filter(v=>v.name),[s]),g=m.useMemo(()=>{const v=p.trim().toLowerCase();return v?h.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(v)):h},[p,h]),b=m.useCallback((v,y)=>{const w=new Set(d);for(const x of v)y?w.add(x):w.delete(x);i==null||i(e,Array.from(w))},[e,d,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((v,y)=>{if(v.showOnNode===!1)return null;const w=`${2.6+y*1.7}rem`,x=v.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:w},children:x}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:w,background:gn(v.type)},title:`${x} · ${v.type}`})]},`in-${y}`)}),l.map((v,y)=>{if(v.showOnNode===!1)return null;const w=`${2.6+y*1.7}rem`,x=v.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:w},children:x}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:w,background:gn(v.type)},title:`${x} · ${v.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:v=>{var y;v.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),u(w=>!w)},children:[o.jsx("span",{children:d.size>0?`${d.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:v=>v.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:p,onChange:v=>f(v.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),p?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(v=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:d.has(v.name),onChange:y=>b([v.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:v.name}),v.description||v.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:v.description||v.detail}):null]})]},v.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({id:e,data:t,selected:n,deleteNode:r,workspaces:s=[],onChangeWorkspace:i,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,p]=m.useState(!1),[f,d]=m.useState(""),h=FK(t),g=m.useMemo(()=>(Array.isArray(s)?s:[]).map(w=>({id:String((w==null?void 0:w.id)||""),label:String((w==null?void 0:w.label)||(w==null?void 0:w.name)||"Workspace"),kind:(w==null?void 0:w.kind)==="git"?"git":"local",path:String((w==null?void 0:w.path)||""),repoUrl:String((w==null?void 0:w.repoUrl)||""),branch:String((w==null?void 0:w.branch)||""),mountPath:String((w==null?void 0:w.mountPath)||""),builtin:(w==null?void 0:w.builtin)===!0,exists:(w==null?void 0:w.exists)!==!1})).filter(w=>w.path),[s]),b=m.useMemo(()=>{const w=f.trim().toLowerCase();return w?g.filter(x=>[x.id,x.label,x.path,x.repoUrl,x.branch,x.mountPath].join(" ").toLowerCase().includes(w)):g},[f,g]),v=g.find(w=>w.path===h.path)||null,y=(v==null?void 0:v.label)||h.label||"选择 Workspace";return o.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((w,x)=>{if(w.showOnNode===!1)return null;const S=`${2.6+x*1.7}rem`,C=w.name||`#${x+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:S},children:C}),o.jsx(En,{type:"target",position:Le.Left,id:`input-${x}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:S,background:gn(w.type)},title:`${C} · ${w.type}`})]},`in-${x}`)}),c.map((w,x)=>{if(w.showOnNode===!1)return null;const S=`${2.6+x*1.7}rem`,C=w.name||`#${x+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:S},children:C}),o.jsx(En,{type:"source",position:Le.Right,id:`output-${x}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:S,background:gn(w.type)},title:`${C} · ${w.type}`})]},`out-${x}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load Workspace"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),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:w=>{w.stopPropagation(),u||a==null||a(),p(x=>!x)},children:[o.jsx("span",{children:y}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),h.path?o.jsx("div",{className:"af-work-load-workspace-card__path",children:h.path}):null,u?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:w=>w.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:f,onChange:w=>d(w.target.value),placeholder:"搜索 Workspace...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Workspace"}),f?o.jsx("button",{type:"button",onClick:()=>d(""),"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:"Workspace"}),o.jsx("small",{children:b.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:b.map(w=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"radio",name:`workspace-${e}`,checked:w.path===h.path,onChange:()=>{i==null||i(e,w),p(!1)}}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:w.label}),o.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[w.kind==="git"&&w.repoUrl?`${w.repoUrl}${w.branch?` · ${w.branch}`:""}${w.mountPath?` · ${w.mountPath}`:""}`:w.path,w.exists?"":" · 路径未就绪"]})]})]},`${w.id}:${w.path}`))})]}),b.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Workspace"}):null]})]}):null]})]})}function UK(){var Vk,Kk;const{t:e,i18n:t}=pr(),{navigate:n}=ti(),r=Hl(),s=X4(),i=m.useMemo(g7,[]),[a,l]=m.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[c,u]=m.useState(!1),[p,f]=m.useState(!1),[d,h]=Q4([]),[g,b,v]=Z4([]),y=m.useRef([]),w=m.useRef([]),x=m.useRef(null),[S,C]=m.useState(()=>xx(null,[])),j=m.useRef(S),[E,P]=m.useState(null),F=m.useRef(null),[V,z]=m.useState([]),D=m.useRef(new Map),R=m.useRef(new Map),T=m.useRef(null),L=m.useRef(null),$=m.useRef(null),[O,A]=m.useState(null),[M,_]=m.useState({}),U=m.useRef({}),q=m.useRef(!1),B=m.useRef(null),[Q,se]=m.useState([]),[oe,ve]=m.useState(""),[re,ue]=m.useState("nodes"),[te,ae]=m.useState([]),[pe,be]=m.useState(!1),[Fe,Ue]=m.useState(""),[Me,et]=m.useState(!1),[ht,Ie]=m.useState({name:"",id:"",description:""}),[tt,Wt]=m.useState(!1),[$e,Vt]=m.useState(""),[Gt,nt]=m.useState(""),ie=m.useRef(null),[ke,Oe]=m.useState(!1),[We,Je]=m.useState(!1),[vt,ee]=m.useState(""),[ye,Ve]=m.useState(null),[Ce,at]=m.useState(()=>xg()),[mt,Qt]=m.useState(""),[hr,Ln]=m.useState(!1),[On,Nn]=m.useState(""),[Zt,Kn]=m.useState(!1),[pn,Pn]=m.useState([]),[jn,Dn]=m.useState(!1),[Er,Fn]=m.useState(""),[si,mr]=m.useState(""),[Ur,Ar]=m.useState(""),[ss,In]=m.useState(!1),[gr,rr]=m.useState(""),[Ms,Pr]=m.useState(""),[zt,ne]=m.useState(!1),[we,Z]=m.useState("nodes"),[ge,Ae]=m.useState(""),[bt,Ct]=m.useState(0),[Kt,qe]=m.useState(""),Ot=m.useRef(""),[Pe,Ut]=m.useState(null),Xe=m.useRef(null),[Ir,is]=m.useState(""),[os,jo]=m.useState([]),[ya,Jl]=m.useState(""),[Se,Xl]=m.useState(!0),[Ti,xa]=m.useState(""),[wa,as]=m.useState(()=>new Set),[ls,Ri]=m.useState(""),[W,de]=m.useState({nodeId:"",query:""}),[Te,_e]=m.useState(!1),Qe=m.useRef(null),Jt=m.useRef(null),_t=m.useRef(""),[Tn,cs]=m.useState(()=>{try{const k=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(k)&&k>=160)return k}catch{}return 360}),[Co,Mi]=m.useState(!1),[_o,VI]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[ii,KI]=m.useState(""),[us,UI]=m.useState([]),[Ib,Tb]=m.useState(!1),[ds,Ql]=m.useState([]),[ba,qI]=m.useState([]),[Rb,YI]=m.useState(!1),[Mb,$b]=m.useState([]),[Lb,Ob]=m.useState([]),Db=m.useCallback(k=>{ie.current&&window.clearTimeout(ie.current),nt(k),ie.current=window.setTimeout(()=>{nt(""),ie.current=null},3800)},[]),$i=m.useCallback(k=>{const N=String(k||"").trim();if(!N)return;const I=()=>s(N);window.requestAnimationFrame(I),window.setTimeout(I,80)},[s]),Fb=m.useCallback((k,N)=>{const I=String(k||"").trim(),H=Bp(N);!I||!H||(h(K=>K.map(Y=>{var ce;if(Y.id!==I)return Y;const G=Bp((ce=Y.data)==null?void 0:ce.displaySize),J=G&&G.width===H.width&&G.height===H.height,X=Math.round(Number(Y.width||0))===H.width&&Math.round(Number(Y.height||0))===H.height;return J&&X?Y:{...Y,width:H.width,height:H.height,data:{...Y.data,nodeSize:H,displaySize:H}}})),$i(I))},[$i,h]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Tn)))}catch{}},[Tn]);const Hh=m.useCallback(k=>{const N=Qe.current;if(!N)return;const I=N.getBoundingClientRect(),H=16,K=150,Y=230,G=I.top+H,J=I.bottom-H,X=Math.max(K,J-G-Y),ce=Math.min(Math.max(k-G,K),X);cs(ce)},[]),GI=m.useCallback(k=>{k.preventDefault(),k.stopPropagation(),Mi(!0),Hh(k.clientY);const N=H=>{H.preventDefault(),Hh(H.clientY)},I=()=>{Mi(!1),window.removeEventListener("pointermove",N,!0),window.removeEventListener("pointerup",I,!0),window.removeEventListener("pointercancel",I,!0)};window.addEventListener("pointermove",N,!0),window.addEventListener("pointerup",I,!0),window.addEventListener("pointercancel",I,!0)},[Hh]);m.useEffect(()=>()=>{ie.current&&window.clearTimeout(ie.current)},[]);const[JI,zb]=m.useState(()=>new Set),[dd,Bh]=m.useState(!1),Wh=m.useRef(null),Hb=m.useRef(null),Bb=m.useRef(null),[XI,QI]=m.useState({}),[Eo,Vh]=m.useState(""),[Tr,Wb]=m.useState(!1),[fd,pd]=m.useState([]),[hd,sr]=m.useState([]),[Zl,ka]=m.useState("workspace"),[Kh,va]=m.useState(!1),[ec,Sa]=m.useState(null),[ZI,Uh]=m.useState(!0),[Vb,Kb]=m.useState(""),[Na,ja]=m.useState({}),[ir,Ub]=m.useState(null),[qb,Yb]=m.useState(!1),Ca=m.useMemo(()=>qb?x7(ir):"",[qb,ir]),[tc,md]=m.useState(!0);m.useEffect(()=>{Ca&&md(w7(Ca))},[Ca]),m.useEffect(()=>{if(Ca)try{window.localStorage.setItem(Ca,tc?"true":"false")}catch{}},[tc,Ca]);const[qh,gd]=m.useState(!1),[Yh,Gb]=m.useState(!1),[Gh,Jb]=m.useState("pan"),[Xb,eT]=m.useState({}),nc=m.useRef({}),[Qb,Ao]=m.useState({}),rc=m.useRef(new Map),_a=m.useRef(new Set),[Zb,Ea]=m.useState(()=>new Set),[Jh,Aa]=m.useState({}),[ek,tk]=m.useState(""),[tT,xe]=m.useState(""),oi=m.useMemo(()=>y7(i),[i]),[nk,rk]=m.useState(""),yd=i.flowSource||"user",sk=m.useMemo(()=>new Set(Object.values(Xb||{}).map(k=>String((k==null?void 0:k.runNodeId)||"").trim()).filter(Boolean)),[Xb]),Po=m.useCallback(k=>{const N=nc.current||{},I=typeof k=="function"?k(N):k,H=I&&typeof I=="object"&&!Array.isArray(I)?I:{};return nc.current=H,eT(H),H},[]),ik=!!(i.flowId&&!i.archived&&(yd==="user"||yd==="workspace"));m.useEffect(()=>{i.flowId&&$$(i.flowId,i.flowSource||"user","workspace",!!i.archived)},[i]),m.useEffect(()=>{const k=()=>{l(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",k),()=>window.removeEventListener("popstate",k)},[]),m.useEffect(()=>{pd([]),sr([]),ka("workspace"),Uh(!0)},[i]);const kn=m.useCallback(async()=>{const k=ys(i),N=await fetch(`/api/workspace/files?${k.toString()}`),I=await N.json();if(!N.ok)throw new Error(I.error||"读取 workspace 失败");const H=I.files||[];jo(H),as(new Set(qP(H))),Jl(I.root||"")},[i]),xd=m.useCallback(async()=>{be(!0),Ue("");try{const k=await fetch("/api/marketplace/flow-snippets"),N=await k.json().catch(()=>({}));if(!k.ok)throw new Error(N.error||"读取流程片段失败");ae(Array.isArray(N.snippets)?N.snippets:[])}catch(k){Ue(String(k.message||k)),ae([])}finally{be(!1)}},[]),Dt=m.useCallback(async(k=d,N=g)=>{var Y;if(!q.current)return;if(!Se)throw xe("Readonly workspace"),new Error("Readonly workspace");const I=Cc(k,N,U.current);I.ui={...I.ui||{},...F.current?{viewport:F.current}:{},displayPage:K7(j.current,k)};const H=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:I})}),K=await H.json();if(!H.ok)throw new Error(K.error||"保存 workspace graph 失败");U.current=((Y=K.graph)==null?void 0:Y.instances)||I.instances,_(U.current),Ao(bf(K.workspaceSchedules||[])),xe("Workspace graph saved")},[g,i,d,Se]),nT=m.useCallback(k=>{var I;const N=(I=k==null?void 0:k.extra)!=null&&I.instances&&typeof k.extra.instances=="object"?k.extra.instances:{};U.current=N,_(N),h(Array.isArray(k==null?void 0:k.nodes)?k.nodes:[]),b(Array.isArray(k==null?void 0:k.edges)?k.edges:[]),qe(""),A(null)},[b,h]),rT=m.useMemo(()=>({instances:M}),[M]),sT=s7({nodes:d,edges:g,extra:rT,enabled:q.current,onRestore:nT}),{resetHistory:wd,undo:ok,redo:ak}=sT,Pa=m.useCallback(async()=>{var Re,dt;q.current=!1;const k=ys(i),N=ys(i);N.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[I,H]=await Promise.all([fetch(`/api/nodes?${N.toString()}`),fetch(`/api/workspace/graph?${k.toString()}`),kn()]),K=await I.json(),Y=await H.json();if(!I.ok)throw new Error(K.error||"读取节点定义失败");if(!H.ok)throw new Error(Y.error||"读取 workspace graph 失败");const G=[...(Array.isArray(K)?K:K.nodes||[]).filter(It=>!o7.has(It.id)),f7,d7,c7,u7,a7,l7];se(G);const J=Y.graph||JSON.parse(localStorage.getItem(i7)||"null")||{},X=kf(J,G),ce=xx((Re=J==null?void 0:J.ui)==null?void 0:Re.displayPage,X.nodes),le=LP((dt=J==null?void 0:J.ui)==null?void 0:dt.viewport);U.current=X.instances,_(X.instances),h(X.nodes),b(X.edges),Ao(bf(Y.workspaceSchedules||[])),C(ce),j.current=ce,P(le),F.current=le,z([]),wd(X.nodes,X.edges,{instances:X.instances});const he=Y.writable!==!1;Xl(he),xe(he?"Workspace ready":"Readonly workspace"),q.current=!0},[i,t.language,kn,wd,b,h]),iT=m.useCallback(async(k,N)=>{const I={packageId:(k==null?void 0:k.newId)||(k==null?void 0:k.id)||(k==null?void 0:k.label),label:(k==null?void 0:k.label)||(k==null?void 0:k.newId)||(k==null?void 0:k.id),version:"1.0.0",definitionId:N,body:(k==null?void 0:k.body)||"",script:(k==null?void 0:k.script)||"",scriptRef:(k==null?void 0:k.scriptRef)||"",implementationRef:(k==null?void 0:k.implementationRef)||"",implementationMode:(k==null?void 0:k.implementationMode)||"",inputs:Array.isArray(k==null?void 0:k.inputs)?k.inputs:[],outputs:Array.isArray(k==null?void 0:k.outputs)?k.outputs:[],flowId:i.flowId,flowSource:i.flowSource||"user",archived:!!i.archived},H=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),K=await H.json().catch(()=>({}));if(!H.ok||(K==null?void 0:K.ok)===!1)throw new Error((K==null?void 0:K.error)||"Publish failed");return await Pa(),xe(`Published node ${K.definitionId||K.id||I.packageId}`),K},[i,Pa]);m.useCallback((k="workspace")=>{va(!0),Sa(null),Ut(null),ka(k||"workspace")},[]);const lk=m.useCallback((k={})=>{Sa({scheduleNodeId:String(k.scheduleNodeId||""),runNodeId:String(k.runNodeId||k.nodeId||""),lastRunId:String(k.lastRunId||""),label:String(k.label||"")}),va(!1),Ut(null),qe("")},[]),Xh=m.useCallback(async(k="")=>{const N=String(k||"").trim();if(!(!N||!Se)){tk(N),xe(`Optimizing run: ${N}`);try{await Dt(y.current,w.current);const I=Cc(y.current,w.current,U.current),H=rj(y.current,U.current,N,ii),K=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runNodeId:N,graph:I,model:H})}),Y=await K.json().catch(()=>({}));if(!K.ok||Y.ok===!1)throw new Error(Y.error||"优化失败");const G=Y.graph||I,J=kf(G,Q);U.current=J.instances,_(J.instances),h(J.nodes),b(J.edges),Ao(bf(Y.workspaceSchedules||[])),wd(J.nodes,J.edges,{instances:J.instances});const X=Array.isArray(Y.optimized)?Y.optimized.length:0;xe(X>0?`已生成 ${X} 个 implementation`:"没有需要优化的节点")}catch(I){xe(String(I.message||I))}finally{tk("")}}},[ii,w,i,y,Q,wd,Dt,b,h,Se]),ck=m.useCallback(async(k="")=>{const N=String(k||"").trim(),I=nc.current||{},H=Object.entries(I).find(([ce,le])=>ce===N||String((le==null?void 0:le.runNodeId)||"")===N)||Object.entries(I)[0]||null,K=(H==null?void 0:H[0])||"",Y=(H==null?void 0:H[1])||null,G=String((Y==null?void 0:Y.runNodeId)||N||"").trim(),J=new Set([G,...Array.isArray(Y==null?void 0:Y.plannedNodeIds)?Y.plannedNodeIds:[]].map(ce=>String(ce||"").trim()).filter(Boolean));K&&_a.current.add(K);const X=K?rc.current.get(K):null;X&&(X.abort(),rc.current.delete(K)),K&&Po(ce=>{const le={...ce};return delete le[K],le}),Ea(ce=>{const le=new Set(ce);for(const he of J)le.delete(he);return le}),Aa(ce=>{var he;const le={...ce};for(const Re of J)Re&&(!le[Re]||((he=le[Re])==null?void 0:he.status)==="running")&&(le[Re]={status:"stopped"});return le}),xe(G?`Workspace run stopped: ${G}`:"Workspace run stopped"),sr(ce=>ce.map(le=>(K?le.id===K:!G||le.runNodeId===G)&&le.status==="running"?{...le,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(le.messages)?le.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:le));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runId:K,runNodeId:G})})}catch{}},[i,Po]),uk=m.useCallback(async()=>{if(i.flowId)try{const k=ys(i),N=await fetch(`/api/workspace/run/status?${k.toString()}`),I=await N.json().catch(()=>({}));if(!N.ok||!I.running)return;const H=Array.isArray(I.runs)&&I.runs.length?I.runs:[{runId:`run-restored-${I.startedAt||Date.now()}`,runNodeId:I.runNodeId||"",startedAt:I.startedAt||Date.now(),plannedNodeIds:[]}],K={},Y=[];for(const G of H){const J=String((G==null?void 0:G.runNodeId)||"").trim(),X=String((G==null?void 0:G.runId)||`run-restored-${(G==null?void 0:G.startedAt)||Date.now()}-${J}`).trim();if(!X)continue;const ce=String((G==null?void 0:G.label)||"").trim()||pg(y.current,U.current,J,"Workspace Run");K[X]={id:X,runNodeId:J,label:ce,plannedNodeIds:Array.isArray(G==null?void 0:G.plannedNodeIds)?G.plannedNodeIds:[],startedAt:(G==null?void 0:G.startedAt)||Date.now()},J&&Y.push(J)}if(!Object.keys(K).length)return;Po(G=>({...G,...K})),Ea(G=>{const J=new Set(G);for(const X of Y)J.add(X);return J}),Aa(G=>{const J={...G};for(const X of Y)J[X]={status:"running"};return J}),xe(Y.length?`Workspace run still running: ${Y.join(", ")}`:"Workspace run still running"),sr(G=>{const J=[...G];for(const[X,ce]of Object.entries(K)){if(J.some(Re=>Re.id===X||Re.status==="running"&&Re.runNodeId===ce.runNodeId))continue;const le=String(ce.runNodeId||""),he=String(ce.label||"").trim()||pg(y.current,U.current,le,"Workspace Run");J.push({id:X,label:hg(he,le,"Workspace Run"),alias:he,runNodeId:le,status:"running",startedAt:ce.startedAt||Date.now(),steps:le?[{id:le,label:hg(he,le,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[i,y,Po]),dk=m.useCallback(async k=>{if(!Se){xe("Readonly workspace");return}if(!k)return;if(Object.values(nc.current||{}).find(Ze=>String((Ze==null?void 0:Ze.runNodeId)||"")===String(k||""))){xe(`Workspace run already running: ${k}`);return}let I=d,H=g,K=U.current;const Y=Xe.current;if(Y!=null&&Y.id){const Ze=I.find(Ee=>Ee.id===Y.id),Ke=ij({nodes:I,edges:H,instances:K,selectedNode:Ze,draft:Y,allowRename:!1});if(Ke!=null&&Ke.error){is(Ke.error),xe(Ke.error);return}Ke!=null&&Ke.ok&&Ke.changed&&(I=Ke.nodes,H=Ke.edges,K=Ke.instances,U.current=K,_(K),h(I),b(H),$i(Ke.nextId||Y.id))}const G=Cc(I,H,K),J=`run-${Date.now()}-${String(k).replace(/[^a-z0-9_-]+/gi,"_")}`,X=pg(I,K,k,"Workspace Run"),ce=hg(X,k,"Workspace Run");let le=[k];try{const Ze=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:G,runNodeId:k})}),Ke=await Ze.json().catch(()=>({}));if(!Ze.ok||(Ke==null?void 0:Ke.ok)===!1)throw new Error(Ke.error||"Workspace run plan failed");le=Array.isArray(Ke.plannedNodeIds)&&Ke.plannedNodeIds.length?Ke.plannedNodeIds.map(Tt=>String(Tt||"").trim()).filter(Boolean):[k],le=Array.from(new Set([k,...le].filter(Boolean)));const Ee=Ke.conflict||null;if(Ee!=null&&Ee.runNodeId||Ee!=null&&Ee.runId){const Tt=Array.isArray(Ee.conflictNodeIds)&&Ee.conflictNodeIds.length?`: ${Ee.conflictNodeIds.join(", ")}`:"";xe(`Run ${k} conflicts with running ${Ee.runNodeId||Ee.runId}${Tt}`);return}}catch(Ze){xe(String(Ze.message||Ze));return}const he=new Set(le),Re=Object.values(nc.current||{}).find(Ze=>(Array.isArray(Ze==null?void 0:Ze.plannedNodeIds)?Ze.plannedNodeIds:[]).some(Ke=>he.has(String(Ke||"").trim())));if(Re){const Ze=(Array.isArray(Re.plannedNodeIds)?Re.plannedNodeIds:[]).map(Ke=>String(Ke||"").trim()).filter(Ke=>Ke&&he.has(Ke));xe(`Run ${k} conflicts with running ${Re.runNodeId||"workspace run"}${Ze.length?`: ${Ze.join(", ")}`:""}`);return}const dt=new AbortController;rc.current.set(J,dt),_a.current.delete(J),Po(Ze=>({...Ze,[J]:{id:J,runNodeId:k,label:X,plannedNodeIds:le,startedAt:Date.now()}})),Ea(Ze=>new Set([...Ze,k])),Aa(Ze=>({...Ze,[k]:{status:"running"}})),xe(`Running ${ce}...`),ka(J),sr(Ze=>[...Ze.slice(-7),{id:J,label:ce,alias:X,runNodeId:k,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let It=k;const ft=new Map,Be=()=>_a.current.has(J),St=Ze=>{const Ke=new Set((Ze||[]).map(Ee=>String(Ee||"").trim()).filter(Boolean));Ke.size||Ke.add(String(k||"")),Ea(Ee=>{const Tt=new Set(Ee);for(const Ge of Ke)Tt.delete(Ge);return Tt})},Yt=(Ze,Ke)=>{const Ee=new Set((Ze||[]).map(Tt=>String(Tt||"").trim()).filter(Boolean));Ee.size||Ee.add(String(k||"")),Aa(Tt=>{var ut;const Ge={...Tt};for(const Mt of Ee)Mt&&(!Ge[Mt]||((ut=Ge[Mt])==null?void 0:ut.status)==="running")&&(Ge[Mt]={status:Ke});return Ge})};try{await Dt(I,H);const Ze=rj(I,K,k,ii),Ke=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:dt.signal,body:JSON.stringify({...i,graph:G,runNodeId:k,runAlias:X,runSessionId:J,model:Ze,selectedSkills:ds,stream:!0})});if(!Ke.ok){const fe=await Ke.json().catch(()=>({}));throw new Error(fe.error||"Workspace run failed")}if(!Ke.body)throw new Error("Workspace run stream unavailable");const Ee=Ke.body.getReader(),Tt=new TextDecoder;let Ge="",ut=[],Mt=[];const om=(fe,Ye)=>{var rt,wt;const De=d.find(Et=>Et.id===fe),it=String(((rt=De==null?void 0:De.data)==null?void 0:rt.label)||fe||"").trim(),me=String(Ye||((wt=De==null?void 0:De.data)==null?void 0:wt.definitionId)||"").trim();return me&&me!==it?`${it} (${me})`:it},dc=(fe,Ye,De)=>{const it=String(fe||"").trim();it&&sr(me=>me.map(rt=>{if(rt.id!==J)return rt;const Et=[...Array.isArray(rt.steps)?rt.steps:[]],ot=Et.findIndex(en=>en.id===it),gt={id:it,label:om(it,Ye),status:De};ot>=0?Et[ot]={...Et[ot],...gt}:Et.push(gt);const Xt=Et.map((en,Di)=>{const ci=en.status==="done"?"[done]":en.status==="failed"?"[failed]":"[running]";return`${Di+1}. ${ci} ${en.label}`}).join(`
243
- `),$t=Array.isArray(rt.messages)?rt.messages:[],Ht=$t.findIndex(en=>en.kind==="run-summary"),sn={role:"assistant",kind:"run-summary",text:Xt||"准备运行...",at:Date.now()},At=[...$t];return Ht>=0?At[Ht]=sn:At.unshift(sn),{...rt,steps:Et,messages:At.slice(-160)}}))},am=(fe,Ye)=>{var Xk,Qk,Zk,ev,tv,nv,rv,sv,iv,ov;const De=String(fe||"").trim(),it=String(Ye||"").trim();if(!De||!it)return;const me=(Xk=U.current)==null?void 0:Xk[De];if(!Es(me==null?void 0:me.definitionId))return;const rt=yo(me==null?void 0:me.input,"displayType","markdown"),wt=XP(rt),Et=QP(De),ot=Q.find(ar=>ar.id===wt),gt=ZN(ot==null?void 0:ot.inputs,wt,it),Xt=ZN(ot==null?void 0:ot.outputs,wt,it),$t=String((me==null?void 0:me.label)||De||"一键任务").trim(),Ht={...U.current||{},[De]:{...me||{},output:tj(me==null?void 0:me.output)},[Et]:{...((Qk=U.current)==null?void 0:Qk[Et])||{},definitionId:wt,label:$t,role:"normal",body:it,input:gt,output:Xt,sourceContextRunNodeId:De,displayReloadKey:String(Date.now())}};U.current=Ht,_(Ht);const sn=y.current||[],At=sn.find(ar=>ar.id===De),en=sn.find(ar=>ar.id===Et),Di=Number(((Zk=At==null?void 0:At.measured)==null?void 0:Zk.width)||(At==null?void 0:At.width)||((tv=(ev=At==null?void 0:At.data)==null?void 0:ev.nodeSize)==null?void 0:tv.width)||520),ci=(en==null?void 0:en.position)||{x:Number(((nv=At==null?void 0:At.position)==null?void 0:nv.x)||0)+Di+120,y:Number(((rv=At==null?void 0:At.position)==null?void 0:rv.y)||0)},zn=((sv=en==null?void 0:en.data)==null?void 0:sv.displaySize)||((iv=en==null?void 0:en.data)==null?void 0:iv.nodeSize)||{width:px,height:hx},$s=fx({id:Et,type:xl,position:ci,width:Number(zn.width)||px,height:Number(zn.height)||hx,data:{label:$t,definitionId:wt,role:"normal",body:it,inputs:gt,outputs:Xt,sourceContextRunNodeId:De,displayReloadKey:Ht[Et].displayReloadKey,nodeSize:zn,displaySize:zn}},Ht,Q),Fi=sn.map(ar=>{if(ar.id===De){const{width:fse,height:pse,measured:hse,...nR}=ar,{nodeSize:mse,displaySize:gse,...Od}=ar.data||{};return{...nR,data:{...Od,outputs:tj(Od==null?void 0:Od.outputs),contextRunResultNonce:Date.now()}}}return ar.id===Et?{...$s,selected:ar.selected}:ar});en||Fi.push($s),y.current=Fi,h(Fi);const zi=w.current||[],Ld=ZP(wt),cm=ej((me==null?void 0:me.output)||((ov=At==null?void 0:At.data)==null?void 0:ov.outputs),"output",["content","result"],["text"]),eR=ej(gt,"input",[Ld,"content"],["text"]),tR={id:`we-${De}-${Et}`,source:De,target:Et,sourceHandle:cm,targetHandle:eR,markerEnd:{type:Ks.ArrowClosed}},Jk=[...zi.filter(ar=>!(ar.source===De&&ar.target===Et)),tR];w.current=Jk,b(Jk),window.requestAnimationFrame(()=>{s(De),s(Et)})},Td=(fe,Ye=null)=>{const De=fe!=null&&fe.instances&&typeof fe.instances=="object"?fe.instances:{},it=Ye instanceof Set?Ye:null;for(const[me,rt]of Object.entries(De)){if(it&&!it.has(me)||!Es(rt==null?void 0:rt.definitionId))continue;const wt=Mh({outputs:rt.output});wt&&am(me,wt)}},Uk=fe=>{const Ye=String(fe||"").trim();if(!Ye)return;const De=It;It=Ye,Ea(it=>{const me=new Set(it);return De&&De!==Ye&&De!==k&&me.delete(De),k&&me.add(k),me.add(Ye),me}),Aa(it=>{var me;return{...it,...De&&De!==Ye&&De!==k&&((me=it[De])==null?void 0:me.status)==="running"?{[De]:{status:"success"}}:{},...k?{[k]:{status:"running"}}:{},[Ye]:{status:"running"}}})},qk=fe=>{const Ye=String(fe||"").trim();Ye&&(Ea(De=>{const it=new Set(De);return it.delete(Ye),it}),Aa(De=>({...De,[Ye]:{status:"success"}})))},Yk=(fe,Ye)=>{const De=String(Ye||"");if(!De.trim())return;const it=["assistant","thinking","result","error","prompt"].includes(fe)?fe:"assistant";sr(me=>me.map(rt=>{if(rt.id!==J)return rt;let wt=Array.isArray(rt.messages)?rt.messages:[];if(it==="result"){const gt=[...wt].reverse().find(Xt=>Xt.kind==="assistant");if(String((gt==null?void 0:gt.text)||"").trim()===De.trim())return rt}if(it==="assistant"){const gt=wt.findIndex(Xt=>Xt.kind==="result"&&String(Xt.text||"").trim()===De.trim());gt>=0&&(wt=wt.filter((Xt,$t)=>$t!==gt))}const Et=[...wt],ot=Et[Et.length-1];return ot&&ot.kind===it&&!ot.error?Et[Et.length-1]={...ot,text:`${ot.text||""}${ot.text?`
244
- `:""}${De}`}:Et.push({role:"assistant",kind:it,text:De,...it==="error"?{error:!0}:{},at:Date.now()}),{...rt,messages:Et.slice(-160)}}))},Rd=fe=>{const Ye=String(fe||"");Ye.trim()&&sr(De=>De.map(it=>{var Et;if(it.id!==J)return it;const me=Array.isArray(it.messages)?it.messages:[],rt=me.findIndex(ot=>ot.kind==="thinking"),wt=[...me];if(rt>=0){const ot=String(((Et=wt[rt])==null?void 0:Et.text)||"");wt[rt]={...wt[rt],text:`${ot}${ot&&!ot.endsWith(`
245
- `),""}${Ye}`,at:Date.now()}}else{const ot=wt.findIndex(gt=>gt.kind==="activity");wt.splice(ot>=0?ot+1:wt.length,0,{role:"assistant",kind:"thinking",text:Ye,at:Date.now()})}return{...it,messages:wt.slice(-160)}}))},Oi=(fe,Ye=null)=>{const De=v7(fe);De&&sr(it=>it.map(me=>{if(me.id!==J)return me;const rt=Number(Ye==null?void 0:Ye.ts)||Date.now(),wt=Number(me.startedAt)||rt,Et=Number(me.lastActivityAt)||wt,ot=Math.max(0,rt-Et),gt=Number.isFinite(Number(Ye==null?void 0:Ye.runElapsedMs))?Math.max(0,Number(Ye.runElapsedMs)):Math.max(0,rt-wt),Xt=Array.isArray(me.activities)?me.activities:[],$t=Xt[Xt.length-1],sn=(typeof $t=="string"?$t:String(($t==null?void 0:$t.text)||""))===De?Xt:[...Xt,{text:De,kind:N7(De),stepMs:ot,totalMs:gt,at:rt}].slice(-30),At=Array.isArray(me.timingEntries)?me.timingEntries:[],en=Array.isArray(me.messages)?me.messages:[],Di=en.findIndex($s=>$s.kind==="activity"),ci={role:"assistant",kind:"activity",text:ON(sn,At,wt,rt),at:Date.now()},zn=[...en];if(Di>=0)zn[Di]=ci;else{const $s=zn.findIndex(Fi=>Fi.kind==="run-summary");zn.splice($s>=0?$s+1:0,0,ci)}return{...me,activities:sn,lastActivityAt:rt,messages:zn.slice(-160)}}))},Gk=fe=>{const Ye=String((fe==null?void 0:fe.source)||"runner"),De=String((fe==null?void 0:fe.stream)||""),it=String((fe==null?void 0:fe.eventType)||"event"),me=String((fe==null?void 0:fe.text)||"").trim();if(!me)return;const rt=`[${Ye}${De?`:${De}`:""}] ${it}
246
- ${me}`,wt=A7(fe);sr(Et=>Et.map(ot=>{if(ot.id!==J)return ot;const Xt=[...Array.isArray(ot.rawTrace)?ot.rawTrace:[],rt].slice(-80),$t=Array.isArray(ot.timingEntries)?ot.timingEntries:[],Ht=wt?[...$t,wt].slice(-80):$t,sn=Array.isArray(ot.activities)?ot.activities:[],At=Number(ot.startedAt)||Number(fe==null?void 0:fe.ts)||Date.now(),en=Number(wt==null?void 0:wt.at)||Number(fe==null?void 0:fe.ts)||Date.now(),Di=Array.isArray(ot.messages)?ot.messages:[],ci={role:"assistant",kind:"raw",text:Xt.join(`
247
-
248
- ---
249
-
250
- `),at:Date.now()},zn=[...Di],$s=zn.findIndex(zi=>zi.kind==="activity");if(wt){const zi={role:"assistant",kind:"activity",text:ON(sn,Ht,At,en),at:Date.now()};if($s>=0)zn[$s]=zi;else{const Ld=zn.findIndex(cm=>cm.kind==="run-summary");zn.splice(Ld>=0?Ld+1:0,0,zi)}}const Fi=zn.findIndex(zi=>zi.kind==="raw");return Fi>=0?zn[Fi]=ci:zn.push(ci),{...ot,rawTrace:Xt,timingEntries:Ht,messages:zn.slice(-160)}}))},ZT=fe=>{sr(Ye=>Ye.map(De=>De.id===J?{...De,status:fe,endedAt:Date.now()}:De))},Md=fe=>{const Ye=new Set,De=String((fe==null?void 0:fe.nodeId)||"").trim();De&&Ye.add(De);for(const it of Array.isArray(fe==null?void 0:fe.displayNodeIds)?fe.displayNodeIds:[]){const me=String(it||"").trim();me&&Ye.add(me)}for(const it of Array.isArray(fe==null?void 0:fe.touchedNodeIds)?fe.touchedNodeIds:[]){const me=String(it||"").trim();me&&Ye.add(me)}if(Ye.size===0)for(const it of Array.isArray(fe==null?void 0:fe.order)?fe.order:[]){const me=String(it||"").trim();me&&Ye.add(me)}return Ye},$d=(fe,Ye=null)=>{const De=kf(fe||G,Q),it=new Map(De.nodes.map(ot=>[ot.id,ot])),me=De.instances||{},rt=Ye instanceof Set?Ye:null,wt=(ot,gt)=>{const Xt={...ot||gt};Array.isArray(gt==null?void 0:gt.output)&&(Xt.output=gt.output);for(const $t of["scriptRef","implementationRef","implementationMode"])(gt==null?void 0:gt[$t])!=null&&String(gt[$t]).trim()!==""&&(Xt[$t]=gt[$t]);return Xt},Et=(ot,gt)=>{const Xt={...ot||{}};Array.isArray(gt==null?void 0:gt.outputs)&&(Xt.outputs=gt.outputs);for(const $t of["scriptRef","implementationRef","implementationMode"])(gt==null?void 0:gt[$t])!=null&&String(gt[$t]).trim()!==""&&(Xt[$t]=gt[$t]);return Xt};h(ot=>{const gt=new Set(ot.map(Ht=>Ht.id)),$t={...Cc(ot,w.current,U.current).instances||{}};for(const[Ht,sn]of Object.entries(me)){if(rt&&!rt.has(Ht)||!gt.has(Ht))continue;const At=$t[Ht];da((sn==null?void 0:sn.definitionId)||(At==null?void 0:At.definitionId))?$t[Ht]=sn:Array.isArray(sn==null?void 0:sn.output)&&($t[Ht]=wt(At,sn))}return U.current=$t,_($t),ot.map(Ht=>{var At,en;if(rt&&!rt.has(Ht.id))return Ht;const sn=it.get(Ht.id);return sn?da(((At=sn.data)==null?void 0:At.definitionId)||((en=Ht.data)==null?void 0:en.definitionId))?{...Ht,data:{...Ht.data,...sn.data}}:{...Ht,data:Et(Ht.data,sn.data)}:Ht})})};for(;;){const{value:fe,done:Ye}=await Ee.read();if(Ye)break;Ge+=Tt.decode(fe,{stream:!0});const De=Ge.split(`
251
- `);Ge=De.pop()||"";for(const it of De){if(!it.trim())continue;const me=JSON.parse(it);if(me.type==="error")throw new Error(me.error||"Workspace run failed");if(me.type==="stopped"){_a.current.add(J),ut=Array.isArray(me.order)?me.order:ut,Oi("运行停止",me);continue}if(me.type==="node-start"&&(xe(`Running ${me.nodeId}...`),Uk(me.nodeId),dc(me.nodeId,me.definitionId,"running")),me.type==="node-done"){const rt=ft.get(String(me.nodeId||"").trim());rt&&am(me.nodeId,rt),qk(me.nodeId),dc(me.nodeId,me.definitionId,"done")}if(me.type==="status"&&Oi(me.line||me.message||"",me),me.type==="paused"&&(Mt=Array.isArray(me.nodeIds)?me.nodeIds:[],Oi("运行暂停",me)),me.type==="natural"&&((me.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(me.text||"")))&&me.nodeId&&ft.set(String(me.nodeId||"").trim(),String(me.text||"")),me.kind==="thinking"?Rd(me.text||""):Yk(me.kind,me.text||"")),me.type==="raw"){const rt=DN(me);rt&&Rd(rt),Gk(me)}if(me.type==="graph"&&me.graph){const rt=Md(me);$d(me.graph,rt),Td(me.graph,rt)}if(me.type==="done"){if(me.graph){const rt=Md(me);$d(me.graph,rt),Td(me.graph,rt)}ut=Array.isArray(me.order)?me.order:[],Mt=Array.isArray(me.pauseNodeIds)?me.pauseNodeIds:Mt,Oi(Mt.length?"运行暂停":"运行完成",me)}}}if(Ge.trim()){const fe=JSON.parse(Ge);if(fe.type==="error")throw new Error(fe.error||"Workspace run failed");if(fe.type==="stopped"&&(_a.current.add(J),Oi("运行停止",fe)),fe.type==="node-start"&&(xe(`Running ${fe.nodeId}...`),Uk(fe.nodeId),dc(fe.nodeId,fe.definitionId,"running")),fe.type==="node-done"){const Ye=ft.get(String(fe.nodeId||"").trim());Ye&&am(fe.nodeId,Ye),qk(fe.nodeId),dc(fe.nodeId,fe.definitionId,"done")}if(fe.type==="status"&&Oi(fe.line||fe.message||"",fe),fe.type==="paused"&&(Mt=Array.isArray(fe.nodeIds)?fe.nodeIds:[],Oi("运行暂停",fe)),fe.type==="natural"&&((fe.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(fe.text||"")))&&fe.nodeId&&ft.set(String(fe.nodeId||"").trim(),String(fe.text||"")),fe.kind==="thinking"?Rd(fe.text||""):Yk(fe.kind,fe.text||"")),fe.type==="raw"){const Ye=DN(fe);Ye&&Rd(Ye),Gk(fe)}if(fe.type==="graph"&&fe.graph){const Ye=Md(fe);$d(fe.graph,Ye),Td(fe.graph,Ye)}if(fe.type==="done"){if(fe.graph){const Ye=Md(fe);$d(fe.graph,Ye),Td(fe.graph,Ye)}ut=Array.isArray(fe.order)?fe.order:[],Mt=Array.isArray(fe.pauseNodeIds)?fe.pauseNodeIds:Mt,Oi(Mt.length?"运行暂停":"运行完成",fe)}}Be()&&(St(le),Yt(le,"stopped"));const lm=Be()?`Workspace run stopped: ${k}`:Mt.length?`Workspace run paused at ${Mt.join(", ")}`:`Workspace run done: ${ut.length?ut.join(" -> "):k}`;if(xe(lm),Be()||Yt(le,Mt.length?"paused":"success"),ZT(Be()?"stopped":Mt.length?"paused":"done"),!Be()){try{await Dt(y.current,w.current),xe(lm)}catch(fe){xe(`${lm},但保存结果失败:${String(fe.message||fe)}`)}await kn()}}catch(Ze){if(Be()||(Ze==null?void 0:Ze.name)==="AbortError"){St(le),Yt(le,"stopped"),xe(`Workspace run stopped: ${k}`),sr(Ke=>Ke.map(Ee=>Ee.id===J?{...Ee,status:"stopped",endedAt:Date.now()}:Ee));return}St(le),Yt([k,It].filter(Boolean),"failed"),xe(String(Ze.message||Ze)),sr(Ke=>Ke.map(Ee=>Ee.id===J?{...Ee,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Ee.messages)?Ee.messages:[],{role:"assistant",error:!0,text:String(Ze.message||Ze),at:Date.now()}].slice(-160)}:Ee))}finally{rc.current.get(J)===dt&&rc.current.delete(J),Po(Ze=>{const Ke={...Ze};return delete Ke[J],Ke}),_a.current.delete(J),St(le)}},[ii,g,i,kn,d,Q,$i,Dt,ds,b,h,Po,s,Se]),bd=m.useCallback(async()=>{try{const N=await(await fetch("/api/skills")).json().catch(()=>({})),I=Array.isArray(N.skills)?N.skills.map(H=>({key:String(H.key),name:String(H.name||H.id||H.key),description:H.description?String(H.description):"",sourceLabel:H.sourceLabel?String(H.sourceLabel):""})):[];UI(I),Tb(!0)}catch{Tb(!0)}},[]),kd=m.useCallback(async()=>{try{const N=await(await fetch("/api/mcps")).json().catch(()=>({})),I=Array.isArray(N.servers)?N.servers.map(H=>({name:String((H==null?void 0:H.name)||""),type:String((H==null?void 0:H.type)||""),url:String((H==null?void 0:H.url)||""),command:String((H==null?void 0:H.command)||""),args:Array.isArray(H==null?void 0:H.args)?H.args.map(String):[],description:String((H==null?void 0:H.description)||"")})).filter(H=>H.name):[];$b(I)}catch{$b([])}},[]),vd=m.useCallback(async()=>{try{const k=ys(i),I=await(await fetch(`/api/workspaces?${k.toString()}`)).json().catch(()=>({})),H=Array.isArray(I.workspaces)?I.workspaces.map(K=>({id:String((K==null?void 0:K.id)||""),label:String((K==null?void 0:K.label)||(K==null?void 0:K.name)||"Workspace"),path:String((K==null?void 0:K.path)||""),builtin:(K==null?void 0:K.builtin)===!0,exists:(K==null?void 0:K.exists)!==!1})).filter(K=>K.path):[];Ob(H)}catch{Ob([])}},[i]);m.useEffect(()=>{Pa().catch(k=>xe(String(k.message||k))),xd(),fetch("/api/model-lists").then(k=>k.json()).then(k=>VI({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):[],codex:Array.isArray(k.codex)?k.codex.map(String):[]})).catch(()=>{}),bd(),kd(),vd(),uk(),fetch("/api/skill-collections").then(k=>k.json()).then(k=>{qI(qo(k)),YI(!0)}).catch(()=>{}),fetch("/api/auth/me").then(k=>k.json()).then(k=>{Ub(k.user||null),Yb(!0)}).catch(()=>{Ub(null),Yb(!0)})},[Pa,xd,kd,bd,uk,vd,oi]),m.useEffect(()=>{if(rk(""),!(!Ib||!Rb)){if(!oi){Ql([]);return}Ql(q$(oi,"workspace",us,ba)),rk(oi)}},[ba,Rb,us,Ib,oi]),m.useEffect(()=>{if(!(nk!==oi||!oi))try{localStorage.setItem(oi,JSON.stringify(ds))}catch{}},[ds,oi,nk]),m.useEffect(()=>{U.current=M},[M]),m.useEffect(()=>{y.current=d},[d]),m.useEffect(()=>{const k=D.current,N=new Map,I=[];for(const G of d){const J=$P(G);N.set(G.id,J),k.get(G.id)!==J&&I.push(G.id)}if(D.current=N,I.length===0)return;const H=()=>I.forEach(G=>s(G)),K=window.requestAnimationFrame(H),Y=window.setTimeout(H,80);return()=>{window.cancelAnimationFrame(K),window.clearTimeout(Y)}},[d,s]),m.useEffect(()=>{w.current=g},[g]),m.useEffect(()=>{j.current=S},[S]),m.useEffect(()=>{F.current=E},[E]),m.useEffect(()=>{Xe.current=Pe},[Pe]),m.useEffect(()=>{Ot.current=Kt},[Kt]),m.useEffect(()=>{$.current=O},[O]),m.useEffect(()=>{if(!O)return;const k=I=>{I.key==="Escape"&&A(null)},N=I=>{var H,K;(K=(H=I.target)==null?void 0:H.closest)!=null&&K.call(H,".af-connect-node-menu")||A(null)};return document.addEventListener("keydown",k),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",k),document.removeEventListener("pointerdown",N)}},[O]),m.useEffect(()=>{if(q.current&&Se)return B.current&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{Dt().catch(k=>xe(String(k.message||k)))},650),()=>{B.current&&window.clearTimeout(B.current)}},[d,g,S,Dt,Se]);const sc=m.useMemo(()=>d.filter(k=>{var N;return((N=k==null?void 0:k.data)==null?void 0:N.definitionId)==="workspace_scheduled_run"}).map(k=>{var N;return{id:k.id,config:mb(((N=k.data)==null?void 0:N.body)||"")}}),[d]),oT=m.useMemo(()=>sc.map(k=>`${k.id}:${k.config.enabled?"1":"0"}:${k.config.cron}:${k.config.timezone}`).join("|"),[sc]);m.useEffect(()=>{if(!q.current||a!=="workspace"||!i.flowId){Ao({});return}if(!sc.length){Ao({});return}let k=!1;const N=async()=>{try{const H=ys(i),K=await fetch(`/api/workspace/schedules?${H.toString()}`),Y=await K.json().catch(()=>({}));if(!K.ok)throw new Error(Y.error||"读取 Workspace 定时状态失败");k||Ao(bf(Y.schedules||[]))}catch{k||Ao(H=>{var Y;const K={};for(const G of sc)K[G.id]={...H[G.id]||{},lastStatus:((Y=H[G.id])==null?void 0:Y.lastStatus)||"unknown"};return K})}};N();const I=window.setInterval(N,5e3);return()=>{k=!0,window.clearInterval(I)}},[i,sc,oT,a]);const fk=m.useCallback((k,N)=>{if(!Se){xe("Readonly workspace");return}const I=QN(N),H=X=>Array.isArray(X)?X.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:I,value:I}):[],K=d.map(X=>{var ce;return X.id!==k?X:{...X,data:{...X.data,body:I,inputs:H((ce=X.data)==null?void 0:ce.inputs)}}}),Y=U.current||{},G=Y[k]&&typeof Y[k]=="object"?Y[k]:{},J={...Y,[k]:{...G,body:I,input:H(G.input)}};U.current=J,h(K),_(J),Ut(X=>!X||X.id!==k?X:{...X,body:I,inputs:H(X.inputs)}),Dt(K,g).catch(X=>xe(String(X.message||X)))},[g,d,Dt,h,Se]),pk=m.useCallback((k,N)=>{if(!Se){xe("Readonly workspace");return}const I=DK(N),H=X=>Array.isArray(X)?X.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:I,value:I}):[],K=d.map(X=>{var ce;return X.id!==k?X:{...X,data:{...X.data,body:I,inputs:H((ce=X.data)==null?void 0:ce.inputs)}}}),Y=U.current||{},G=Y[k]&&typeof Y[k]=="object"?Y[k]:{},J={...Y,[k]:{...G,body:I,input:H(G.input)}};U.current=J,h(K),_(J),Ut(X=>!X||X.id!==k?X:{...X,body:I,inputs:H(X.inputs)}),Dt(K,g).catch(X=>xe(String(X.message||X)))},[g,d,Dt,h,Se]),hk=m.useCallback((k,N)=>{if(!Se){xe("Readonly workspace");return}const I=String((N==null?void 0:N.path)||"").trim();if(!I)return;const H=String((N==null?void 0:N.label)||(N==null?void 0:N.id)||"Workspace").trim(),K=JSON.stringify({version:1,id:(N==null?void 0:N.id)||"",label:H,kind:(N==null?void 0:N.kind)||"local",cwd:I,workspaceRoot:I,repoUrl:(N==null?void 0:N.repoUrl)||"",branch:(N==null?void 0:N.branch)||"",mountPath:(N==null?void 0:N.mountPath)||"",type:(N==null?void 0:N.type)||""}),Y=le=>Array.isArray(le)?le.map(he=>(he==null?void 0:he.name)==="path"?{...he,default:I,value:I}:(he==null?void 0:he.name)==="label"?{...he,default:H,value:H}:(he==null?void 0:he.name)==="workspaceContext"?{...he,default:K,value:K}:(he==null?void 0:he.name)==="mode"?{...he,default:"set",value:"set"}:he):[],G=d.map(le=>{var he,Re;return le.id===k?{...le,data:{...le.data,label:((he=le.data)==null?void 0:he.label)||"Load Workspace",inputs:Y((Re=le.data)==null?void 0:Re.inputs)}}:le}),J=U.current||{},X=J[k]&&typeof J[k]=="object"?J[k]:{},ce={...J,[k]:{...X,label:X.label||"Load Workspace",input:Y(X.input)}};U.current=ce,h(G),_(ce),Ut(le=>(le==null?void 0:le.id)===k?{...le,inputs:Y(le.inputs)}:le),Dt(G,g).catch(le=>xe(String(le.message||le)))},[g,d,Dt,h,Se]),mk=m.useCallback((k,N)=>{if(!Se){xe("Readonly workspace");return}const I=String(k||"");if(!I)return;const H=QN((N==null?void 0:N.skillKeys)||[]),K=id((N==null?void 0:N.displayType)||"markdown"),Y=String((N==null?void 0:N.model)||"").trim(),G=(N==null?void 0:N.includeWorkspaceContext)===!1?"false":"true",J=N!=null&&N.workspaceContext&&typeof N.workspaceContext=="object"?JSON.stringify(N.workspaceContext):"",X=ft=>Array.isArray(ft)?ft.map(Be=>(Be==null?void 0:Be.name)==="skillKeys"?{...Be,default:H,value:H}:(Be==null?void 0:Be.name)==="displayType"?{...Be,default:K,value:K}:(Be==null?void 0:Be.name)==="includeWorkspaceContext"?{...Be,default:G,value:G}:(Be==null?void 0:Be.name)==="workspaceContext"?{...Be,default:J,value:J}:Be):[],ce=ft=>Array.isArray(ft)?ft.map(Be=>(Be==null?void 0:Be.name)==="displayType"?{...Be,default:K,value:K}:Be):[],le=String((N==null?void 0:N.task)??""),he=d.map(ft=>{var Be,St;return ft.id===I?{...ft,data:{...ft.data,body:le,model:Y,inputs:X((Be=ft.data)==null?void 0:Be.inputs),outputs:ce((St=ft.data)==null?void 0:St.outputs)}}:ft}),Re=U.current||{},dt=Re[I]&&typeof Re[I]=="object"?Re[I]:{},It={...Re,[I]:{...dt,body:le,model:Y,input:X(dt.input),output:ce(dt.output)}};U.current=It,h(he),_(It),Ut(ft=>(ft==null?void 0:ft.id)===I?{...ft,body:le,model:Y,inputs:X(ft.inputs),outputs:ce(ft.outputs)}:ft),Dt(he,g).catch(ft=>xe(String(ft.message||ft)))},[g,d,Dt,h,Se]),gk=m.useCallback((k,N)=>{if(!Se){xe("Readonly workspace");return}const I=F7(N),H=d.map(J=>J.id===k?{...J,data:{...J.data,body:I}}:J),K=U.current||{},Y=K[k]&&typeof K[k]=="object"?K[k]:{},G={...K,[k]:{...Y,body:I}};U.current=G,h(H),_(G),Ut(J=>(J==null?void 0:J.id)===k?{...J,body:I}:J),Dt(H,g).catch(J=>xe(String(J.message||J)))},[g,d,Dt,h,Se]),yk=m.useCallback(k=>{const N=String(k||"").trim();N&&(Kb(I=>I===N?"":N),ja(I=>({...I,[N]:I[N]||{sessionId:`nodechat_${Date.now()}_${N.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),xk=m.useCallback((k,N)=>{const I=String(k||"").trim();I&&ja(H=>({...H,[I]:{...H[I]||{sessionId:`nodechat_${Date.now()}_${I.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(N||""),error:""}}))},[]),Rr=m.useCallback((k,N,I="replace",H={})=>{var Ze,Ke;if(!Se){xe("Readonly workspace");return}const K=String(k||"").trim();if(!K)return;const Y=y.current.find(Ee=>Ee.id===K),G=hn(Y==null?void 0:Y.data),J=Es((Ze=Y==null?void 0:Y.data)==null?void 0:Ze.definitionId),X=ki(N),ce=G==="html"?Vl(X):G==="react"?Rh(X):String(X||""),le=Y?ho(Y.data):"",he=I==="append"&&String(le||"").trim()?`${String(le).replace(/\s+$/g,"")}
252
-
253
- ${ce.trim()}`:ce,Re=G==="image"?"src":"content",dt=H!=null&&H.reloadDisplay?Date.now():(Ke=Y==null?void 0:Y.data)==null?void 0:Ke.displayReloadKey,It=Ee=>{let Tt=!1;return(Array.isArray(Ee)?Ee:[]).map(ut=>{const Mt=String((ut==null?void 0:ut.name)||""),om=String((ut==null?void 0:ut.type)||"");return(J?Mt===Re||Mt==="result"||Mt==="filePath":Mt===Re||Mt==="filePath"||om==="text")?Tt?{...ut,default:"",value:""}:(Tt=!0,{...ut,default:he,value:he}):ut})},ft=y.current.map(Ee=>{var Tt,Ge;return Ee.id!==K?Ee:{...Ee,data:{...Ee.data,body:J?Ee.data.body:he,...dt?{displayReloadKey:dt}:{},inputs:It((Tt=Ee.data)==null?void 0:Tt.inputs),outputs:It((Ge=Ee.data)==null?void 0:Ge.outputs)}}}),Be=U.current||{},St=Be[K]&&typeof Be[K]=="object"?Be[K]:{},Yt={...Be,[K]:{...St,body:J?St.body:he,input:It(St.input),output:It(St.output)}};U.current=Yt,h(ft),_(Yt),Ut(Ee=>(Ee==null?void 0:Ee.id)===K?{...Ee,...J?{}:{body:he}}:Ee),(H==null?void 0:H.logChat)!==!1&&ja(Ee=>{var Tt;return{...Ee,[K]:{...Ee[K]||{},candidateContent:"",messages:[...(Tt=Ee[K])!=null&&Tt.messages&&Array.isArray(Ee[K].messages)?Ee[K].messages:[],{role:"assistant",text:I==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Dt(ft,w.current).catch(Ee=>xe(String(Ee.message||Ee))),xe(String((H==null?void 0:H.statusMessage)||"")||(I==="append"?"已追加节点内容":"已替换节点内容"))},[Dt,h,Se]),Sd=m.useCallback(async(k,N="")=>{if(!Se)return xe("Readonly workspace"),"";if(!k)return"";try{const I=new FormData;I.set("file",k),I.set("dir",String(N||"")),i.flowId&&I.set("flowId",i.flowId),i.flowSource&&I.set("flowSource",i.flowSource),i.archived&&I.set("archived","1");const H=await fetch("/api/workspace/upload",{method:"POST",body:I}),K=await H.json().catch(()=>({}));if(!H.ok)throw new Error(K.error||"上传文件失败");const Y=String(K.path||"").trim();if(!Y)throw new Error("上传文件失败:未返回路径");return await kn(),as(G=>{const J=new Set(G);for(const X of vf(Y))J.delete(X);return J}),xe(`已上传 ${Y}`),Y}catch(I){return xe(String(I.message||I)),""}},[i,kn,Se]),Nd=m.useCallback(async k=>Fp(k)?Sd(k,"img"):(xe("请选择图片文件"),""),[Sd]),wk=m.useCallback((k="")=>{var N;if(!Se){xe("Readonly workspace");return}_t.current=String(k||""),(N=Jt.current)==null||N.click()},[Se]),aT=m.useCallback(async k=>{const N=Array.from(k.target.files||[]);if(k.target.value="",!N.length)return;const I=_t.current||"";_e(!0);try{let H="";for(const K of N){const Y=await Sd(K,I);Y&&(H=Y)}N.length>1&&xe(`已上传 ${N.length} 个文件${H?`,最后一个:${H}`:""}`)}catch(H){xe(String(H.message||H))}finally{_e(!1)}},[Sd]),bk=m.useCallback(async(k,N)=>{const I=String(k||"").trim();if(!I)return;const H=await Nd(N);H&&Rr(I,H,"replace",{logChat:!1,statusMessage:`已上传图片 ${H}`})},[Rr,Nd]),kk=m.useCallback((k,N="replace")=>{var K;const I=String(k||"").trim(),H=String(((K=Na[I])==null?void 0:K.candidateContent)||"").trim();!I||!H||Rr(I,H,N)},[Na,Rr]),vk=m.useCallback(async(k,N=void 0)=>{var It,ft;if(!Se){xe("Readonly workspace");return}const I=String(k||"").trim();if(!I)return;const H=Na[I]||{},K=String(N!==void 0?N:H.draft||"").trim();if(!K||H.running)return;const Y=y.current.find(Be=>Be.id===I);if(!Y)return;const G=hn(Y.data)||"markdown",J=ho(Y.data);let X=fa(J,G),ce=ki(J);if(X)try{ce=await $l(i,X)}catch(Be){xe(String(Be.message||Be))}else if(G!=="image"&&String(ce||"").trim()){const Be=Vo(G,ce);if(Be){xe(`${Be} 未进入微调。`);return}try{const St=await wx(i,JN(I,Y.data),ce);await kn(),Rr(I,St,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${St}`}),X=St,ce=""}catch(St){xe(String(St.message||St));return}}const le=tK(I,y.current,w.current),he={role:"user",text:K,at:Date.now()},Re=Array.isArray(H.messages)?H.messages:[],dt=H.sessionId||`nodechat_${Date.now()}_${I.replace(/[^a-z0-9_-]+/gi,"_")}`;ja(Be=>({...Be,[I]:{...H,sessionId:dt,messages:[...Re,he],draft:"",running:!0,error:""}}));try{const Be=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,sessionId:dt,node:{id:I,label:((It=Y.data)==null?void 0:It.label)||I,definitionId:((ft=Y.data)==null?void 0:ft.definitionId)||""},nodeKind:G,currentContent:X?"":ce,sourceContext:le,targetFilePath:X,messages:Re,message:K,model:ii})}),St=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(St.error||"节点微调失败");const Yt=String(St.candidateContent||St.reply||"").trim(),Ze=!!St.directFileEdit,Ke=String(St.artifactPath||X||"").trim();if(Ze&&Ke){const Ee=Vo(G,Yt);if(Ee)throw new Error(`${Ee} 文件已由 agent 修改,请检查 ${Ke}。`);await kn(),Rr(I,Ke,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ke}`})}else if(Yt){const Ee=Vo(G,Yt);if(Ee)throw new Error(`${Ee} 已取消写入,避免覆盖当前展示文件。`);if(X){const Tt=await wx(i,X,Yt);await kn(),Rr(I,Tt,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Tt}`})}else Rr(I,Yt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}ja(Ee=>{var Tt;return{...Ee,[I]:{...Ee[I]||{},sessionId:String(St.sessionId||dt),running:!1,candidateContent:"",messages:[...(Tt=Ee[I])!=null&&Tt.messages&&Array.isArray(Ee[I].messages)?Ee[I].messages:[...Re,he],{role:"assistant",text:Yt||Ze?Ke?`已更新文件 ${Ke}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(Be){const St=String(Be.message||Be);ja(Yt=>({...Yt,[I]:{...Yt[I]||{},running:!1,error:St}})),xe(St)}},[ii,i,kn,Na,Rr,Se]),Sk=m.useCallback(async(k,N)=>{if(!Se){xe("Readonly workspace");return}const I=hn(N)||"markdown",H=ho(N),K=fa(H,I);let Y=ki(H);if(K)try{Y=await $l(i,K)}catch(ce){xe(String(ce.message||ce));return}if(!String(Y||"").trim()){xe("展示节点没有可保存内容");return}const G=Vo(I,Y);if(G){xe(`${G} 未保存文件。`);return}const J=JN(k,N),X=window.prompt("保存到 workspace 相对路径",J);if(X)try{const ce=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:X,content:Y})}),le=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(le.error||"保存文件失败");const he=le.path||X,Re=ys(i);Re.set("path",he);const dt=await fetch(`/api/workspace/file?${Re.toString()}`);if(!dt.ok){const It=await dt.json().catch(()=>({}));throw new Error(It.error||`保存后读取失败:${he}`)}await kn(),jo(It=>EK(It,he,String(Y||"").length)),as(It=>{const ft=new Set(It);for(const Be of vf(he))ft.delete(Be);return ft}),Rr(k,he,"replace",{logChat:!1,statusMessage:`已保存并引用 ${he}`}),xe(`已保存 ${he}`)}catch(ce){xe(String(ce.message||ce))}},[i,kn,Rr,Se]),Nk=m.useCallback(k=>{var K,Y;const N=String(k||"").trim();if(!N||mt)return;const I=y.current.find(G=>G.id===N);if(!I||!hn(I==null?void 0:I.data)){xe("展示节点不可用");return}const H=String(((K=I.data)==null?void 0:K.label)||((Y=I.data)==null?void 0:Y.displayName)||N).trim()||"AgentFlow Display";at(xg({title:H,layout:"single",nodeIds:[N],mode:"single-node",sourceNodeId:N})),ee(""),Ve(null),Oe(!0)},[mt]),jd=m.useCallback((k,N)=>{const I=String(k||"");I&&Ut(H=>{if(!H||H.id!==I)return H;const K=typeof N=="function"?N(H):N;return!K||typeof K!="object"?H:{...H,...K}})},[]),jk=m.useCallback((k,N)=>{const I=String(k||"");!I||!Se||(h(H=>H.map(K=>{var G;if(K.id!==I)return K;const Y=Array.isArray((G=K.data)==null?void 0:G.outputs)&&K.data.outputs.length?K.data.outputs.map((J,X)=>X===0?{...J,default:N,value:N}:J):[{type:"file",name:"value",default:N,value:N}];return{...K,data:{...K.data,body:"",outputs:Y}}})),jd(I,H=>({body:"",outputs:Array.isArray(H==null?void 0:H.outputs)&&H.outputs.length?H.outputs.map((Y,G)=>G===0?{...Y,default:N,value:N}:Y):[{type:"file",name:"value",default:N,value:N}]})),xe(`已选择文件 ${N}`))},[h,jd,Se]),Ck=m.useCallback(k=>{de({nodeId:String(k||""),query:""})},[]),Qh=m.useCallback(()=>{de({nodeId:"",query:""})},[]),lT=m.useCallback(k=>{const N=String((k==null?void 0:k.path)||"").trim();!N||!W.nodeId||(jk(W.nodeId,N),Qh())},[Qh,W.nodeId,jk]),_k=m.useCallback(async(k,N)=>{if(!Se)return;const I=xK(k,N);if(I.length===0)return;const H=[];try{for(const K of I){const Y=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:K})});if(Y.status===404)continue;const G=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(G.error||"清理节点输出失败");H.push(G.path||K)}if(H.length===0)return;xe(`已清理 ${H.join(", ")}`),await kn(),Ri(K=>I.some(Y=>K===Y||K.startsWith(`${Y}/`))?"":K)}catch(K){xe(String(K.message||K))}},[i,kn,Se]),fs=m.useMemo(()=>d.map(k=>{var N,I;return{...k,data:{...k.data,selected:k.selected===!0,modelLists:_o,showBodyPreview:!0,isExecuting:Zb.has(k.id),nodeStatus:((N=Jh[k.id])==null?void 0:N.status)??null,nodeElapsed:((I=Jh[k.id])==null?void 0:I.elapsed)??null,flowParams:i,readOnly:!Se,onRunWorkspaceNode:dk,onStopWorkspaceNode:ck,onOpenWorkspaceRunLogs:lk,onOptimizeWorkspaceRun:Xh,onOptimizeWorkspaceSchedule:Xh,optimizingRun:ek===k.id,runningRunNodeIds:sk,scheduledRunState:Qb[k.id]||null,onChangeScheduledRunConfig:gk,onChangeContextRunConfig:mk,skills:us,skillCollections:ba,onChangeLoadSkillKeys:fk,onRefreshSkills:bd,mcpServers:Mb,onChangeLoadMcpNames:pk,onRefreshMcps:kd,workspaceTargets:Lb,onChangeLoadWorkspace:hk,onRefreshWorkspaces:vd,onSaveDisplayNodeToFile:Sk,onShareDisplayNode:Nk,onOpenDisplayPreview:Pr,onRefreshNodeInternals:$i,onEnsureWorkspaceNodeDisplaySize:Fb,sharingDisplayNodeId:mt,onUploadWorkspaceImage:Nd,onUploadImageToDisplayNode:bk,onOpenProvideFilePicker:Ck,onStatus:xe,nodeChatActive:Vb===k.id,nodeChat:Na[k.id]||null,onSetDisplayNodeContent:Rr,onToggleNodeChat:yk,onCloseNodeChat:()=>Kb(""),onUpdateNodeChatDraft:xk,onSendNodeChat:vk,onApplyNodeChatCandidate:kk,onSyncNodePropDraft:jd,onCleanupWorkspaceNodeOutputs:_k}}}),[Vb,kk,mk,pk,fk,hk,gk,_k,Fb,i,Mb,_o,Na,d,Ck,lk,Xh,ek,kd,$i,bd,vd,dk,sk,Sk,Qb,vk,Rr,Nk,mt,ba,us,ck,jd,yk,xk,bk,Nd,Zb,Jh,Lb,Se]),Zh=m.useMemo(()=>new Map(fs.map(k=>[k.id,k])),[fs]),Ek=Ms?Zh.get(Ms):null,ic=m.useMemo(()=>{const k=new Set(V);return S.nodeIds.map((N,I)=>{const H=Zh.get(N);if(!H||!hn(H.data))return null;const K=Va(H)||{width:520,height:320},Y=Jo(S.nodeSizes[N]||K,{display:!0})||K,G=S.nodePositions[N]||{x:180+I*36,y:120+I*28};return{...H,id:WN(N),position:G,selected:k.has(N),width:Y.width,height:Y.height,data:{...H.data,sourceNodeId:N,displayPageMode:!0,readOnly:!0,selected:k.has(N),displaySize:Y,nodeSize:Y}}}).filter(Boolean)},[S,Zh,V]),Ia=m.useMemo(()=>fs.filter(k=>hn(k==null?void 0:k.data)),[fs]),lt=a==="display";m.useEffect(()=>{if(!lt||!S.viewport)return;const k=S.viewport,N=()=>{try{r.setViewport(k,{duration:0})}catch{}},I=window.requestAnimationFrame(()=>window.requestAnimationFrame(N));return()=>window.cancelAnimationFrame(I)},[S.viewport,lt,r]),m.useEffect(()=>{if(lt||!E)return;const k=E,N=()=>{try{r.setViewport(k,{duration:0})}catch{}},I=window.requestAnimationFrame(()=>window.requestAnimationFrame(N));return()=>window.cancelAnimationFrame(I)},[lt,r,E]),m.useEffect(()=>{const k=R.current,N=new Map,I=[];for(const G of[...fs,...ic]){const J=V7(G);N.set(G.id,J),k.get(G.id)!==J&&I.push(G.id)}if(R.current=N,I.length===0)return;const H=()=>I.forEach(G=>s(G)),K=window.requestAnimationFrame(H),Y=window.setTimeout(H,80);return()=>{window.cancelAnimationFrame(K),window.clearTimeout(Y)}},[ic,fs,s]);const qt=m.useMemo(()=>d.find(k=>k.id===Kt)||null,[d,Kt]),em=m.useRef({id:"",draft:null}),cT=m.useMemo(()=>{const k=nj(qt);return k?JSON.stringify(k):""},[qt]);m.useEffect(()=>{if(!qt){em.current={id:"",draft:null},Ut(null),is("");return}const k=nj(qt),N=em.current;em.current={id:qt.id,draft:k},Ut(I=>!I||I.id!==qt.id||N.id!==qt.id||!N.draft?k:BK(I,N.draft,k)),is("")},[qt==null?void 0:qt.id,cT]);const tm=m.useCallback((k=!1)=>{if(!Pe||!qt)return!1;if(!Se)return is("Readonly workspace"),xe("Readonly workspace"),!1;is("");const N=ij({nodes:d,edges:g,instances:U.current,selectedNode:qt,draft:Pe,allowRename:k});return N!=null&&N.error?(is(N.error),!1):(!(N!=null&&N.ok)||!N.changed||(U.current=N.instances,_(N.instances),h(N.nodes),b(N.edges),N.nextId!==qt.id&&qe(N.nextId),$i(N.nextId)),!0)},[g,Pe,d,qt,b,h,$i,Se]);m.useEffect(()=>{if(!Se||!Pe||!qt)return;const k=window.setTimeout(()=>{tm(!1)},350);return()=>window.clearTimeout(k)},[Pe==null?void 0:Pe.label,Pe==null?void 0:Pe.role,Pe==null?void 0:Pe.model,Pe==null?void 0:Pe.body,JSON.stringify((Pe==null?void 0:Pe.images)||[]),Pe==null?void 0:Pe.script,Pe==null?void 0:Pe.scriptRef,Pe==null?void 0:Pe.implementationRef,Pe==null?void 0:Pe.implementationMode,JSON.stringify((Pe==null?void 0:Pe.inputs)||[]),JSON.stringify((Pe==null?void 0:Pe.outputs)||[]),tm,qt==null?void 0:qt.id,Se]);const uT=m.useMemo(()=>{const k=new Map(fs.map(N=>[N.id,N]));return g.map(N=>{var ce,le,he,Re;const I=k.get(N.source),H=k.get(N.target),K=/^output-(\d+)$/.exec(N.sourceHandle||""),Y=/^input-(\d+)$/.exec(N.targetHandle||""),G=I&&K?(le=(ce=I.data)==null?void 0:ce.outputs)==null?void 0:le[parseInt(K[1],10)]:null,J=H&&Y?(Re=(he=H.data)==null?void 0:he.inputs)==null?void 0:Re[parseInt(Y[1],10)]:null,X=G!=null&&G.type?gn(G.type):J!=null&&J.type?gn(J.type):"";return X?{...N,style:{...N.style||{},stroke:X,strokeWidth:2},markerEnd:{type:Ks.ArrowClosed,color:X}}:N})},[g,fs]),dT=lt?ic:fs,fT=lt?[]:uT,pT=m.useMemo(()=>lt?ic.map(k=>({...k,id:gg(k.id)})):fs,[ic,fs,lt]),hT=m.useCallback(k=>{const N=String(k||"").trim();if(!N)return;const I=lt?WN(N):N;lt?z([N]):(h(K=>K.map(Y=>({...Y,selected:Y.id===I}))),b(K=>K.map(Y=>({...Y,selected:!1}))),qe(I));const H=()=>{var ce,le,he;const K=r.getNode(I);if(!K)return;const Y=(ce=r.getInternalNode)==null?void 0:ce.call(r,I),G=((le=Y==null?void 0:Y.measured)==null?void 0:le.width)??(Y==null?void 0:Y.width)??K.width??260,J=((he=Y==null?void 0:Y.measured)==null?void 0:he.height)??(Y==null?void 0:Y.height)??K.height??120,{zoom:X}=r.getViewport();r.setCenter(K.position.x+G/2,K.position.y+J/2,{zoom:X7(X),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(H))},[lt,r,b,h]),Ak=m.useCallback(()=>{const k=r.getViewport(),N={x:Number(k.x)||0,y:Number(k.y)||0,zoom:Math.min(Math.max(Number(k.zoom)||1,.1),4)};if(lt){const I={...j.current,viewport:N};j.current=I,C(I),xe("已固定 Display 进入视角")}else F.current=N,P(N),xe("已固定 Workspace 进入视角");Dt(y.current,w.current).catch(I=>xe(String(I.message||I)))},[lt,r,Dt]),nm=m.useMemo(()=>{const k=oe.trim().toLowerCase(),N={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const I of Q)k&&![I.id,I.label,I.displayName,I.description].some(H=>String(H||"").toLowerCase().includes(k))||N[Oc(I)].push(I);for(const I of Ba)N[I].sort((H,K)=>H.id.localeCompare(K.id));return N},[Q,oe]),oc=m.useMemo(()=>{const k=ge.trim().toLowerCase();return Q.filter(N=>!k||[N.id,N.label,N.displayName,N.description].some(I=>String(I||"").toLowerCase().includes(k))).sort((N,I)=>{const H=Ba.indexOf(Oc(N)),K=Ba.indexOf(Oc(I));return H!==K?H-K:Dc(N).localeCompare(Dc(I))}).slice(0,30)},[Q,ge]),ac=m.useMemo(()=>{const k=ge.trim().toLowerCase();return te.filter(N=>!k||[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].some(I=>String(I||"").toLowerCase().includes(k))).sort((N,I)=>String(N.displayName||N.name||N.id).localeCompare(String(I.displayName||I.name||I.id))).slice(0,30)},[te,ge]);m.useEffect(()=>{Ct(0)},[ge,zt,we]),m.useEffect(()=>{if(!zt)return;const k=window.setTimeout(()=>{var N;return(N=Bb.current)==null?void 0:N.focus()},0);return()=>window.clearTimeout(k)},[zt]);const mT=m.useMemo(()=>{const k=Ti.trim().toLowerCase();return k?gb(os).filter(N=>N.path.toLowerCase().includes(k)):os},[Ti,os]),Io=m.useMemo(()=>UP(os,ls),[os,ls]),ai=(Io==null?void 0:Io.type)==="directory"?Io.path:jK((Io==null?void 0:Io.path)||""),gT=m.useCallback(k=>{var N,I;(I=(N=k.target)==null?void 0:N.closest)!=null&&I.call(N,".af-work-file")||Ri("")},[]),yT=[...(_o.cursor||[]).map(k=>({label:`Cursor · ${k.split(" - ")[0]}`,value:`cursor:${k.split(" - ")[0]}`})),...(_o.opencode||[]).map(k=>({label:`OpenCode · ${k.split(" - ")[0]}`,value:`opencode:${k.split(" - ")[0]}`})),...(_o.claudeCode||[]).map(k=>({label:`Claude · ${k.split(" - ")[0]}`,value:`claude-code:${k.split(" - ")[0]}`})),...(_o.codex||[]).map(k=>({label:`Codex · ${k.split(" - ")[0]}`,value:`codex:${k.split(" - ")[0]}`}))],rm=m.useMemo(()=>new Set(ds),[ds]),Ta=m.useMemo(()=>{const k=new Map(us.map(Y=>[Y.key,Y])),N=new Set,I=new Set,H=ba.map(Y=>{const G=ra(Y,us).map(J=>k.get(J)).filter(Boolean);for(const J of G)N.add(J.key),I.add(String(J.name||J.id||J.key||"").trim());return{...Y,skills:G}}).filter(Y=>Y.skills.length>0),K=us.filter(Y=>{const G=String(Y.name||Y.id||Y.key||"").trim();return!N.has(Y.key)&&!I.has(G)});return{groups:H,ungrouped:K}},[ba,us]);m.useEffect(()=>{zb(k=>{let N=!1;const I=new Set(k);for(const H of Ta.groups)I.has(H.id)||(I.add(H.id),N=!0);return N?I:k})},[Ta.groups]);const Rn=m.useMemo(()=>{const k=d.filter(N=>N.selected);return k.length>0?k:Kt?d.filter(N=>N.id===Kt):[]},[d,Kt]),Cd=m.useMemo(()=>Rn.map(k=>k.id),[Rn]),Pk=m.useCallback(()=>{if(lt)return;if(!Se){xe("Readonly workspace");return}const k=(y.current||[]).filter(J=>(J==null?void 0:J.selected)&&!su(J));if(k.length<2){xe("选择至少两个节点后按 G 创建 Group");return}const N=k.reduce((J,X)=>{var dt,It,ft,Be,St,Yt,Ze,Ke,Ee,Tt,Ge,ut;const ce=Number(((dt=X.position)==null?void 0:dt.x)||0),le=Number(((It=X.position)==null?void 0:It.y)||0),he=Number(((ft=X.measured)==null?void 0:ft.width)||X.width||((St=(Be=X.data)==null?void 0:Be.nodeSize)==null?void 0:St.width)||((Ze=(Yt=X.data)==null?void 0:Yt.displaySize)==null?void 0:Ze.width)||CP),Re=Number(((Ke=X.measured)==null?void 0:Ke.height)||X.height||((Tt=(Ee=X.data)==null?void 0:Ee.nodeSize)==null?void 0:Tt.height)||((ut=(Ge=X.data)==null?void 0:Ge.displaySize)==null?void 0:ut.height)||Dp);return{minX:Math.min(J.minX,ce),minY:Math.min(J.minY,le),maxX:Math.max(J.maxX,ce+he),maxY:Math.max(J.maxY,le+Re)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(N.minX)||!Number.isFinite(N.minY))return;const I=new Set((y.current||[]).map(J=>J.id));let H=1,K=`group_${H}`;for(;I.has(K);)H+=1,K=`group_${H}`;const Y=yx({width:N.maxX-N.minX+xf*2,height:N.maxY-N.minY+xf*2})||{width:ca,height:ua},G={id:K,type:xl,position:{x:N.minX-xf,y:N.minY-xf},width:Y.width,height:Y.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Hp(H-1),title:Hp(H-1),color:"purple",nodeSize:Y}};h(J=>[G,...J.map(X=>({...X,selected:!1}))]),b(J=>J.map(X=>({...X,selected:!1}))),qe(""),xe(`Created group for ${k.length} nodes`)},[lt,b,h,Se]),lc=m.useMemo(()=>d.filter(k=>hn(k==null?void 0:k.data)),[d]),sm=m.useMemo(()=>Rn.filter(k=>hn(k==null?void 0:k.data)).map(k=>k.id),[Rn]),xT=m.useMemo(()=>{const k=String((ir==null?void 0:ir.username)||(ir==null?void 0:ir.userId)||"").trim();return k?k.slice(0,1).toUpperCase():"?"},[ir]),im=m.useMemo(()=>new Set(Cd),[Cd]),_d=m.useMemo(()=>g.filter(k=>im.has(k.source)&&im.has(k.target)),[g,im]),Ik=m.useCallback(k=>{const N=k==="display"?"display":"workspace";l(N),qe(""),z([]),A(null),ne(!1),In(!1);const I=ys(i);N==="display"&&I.set("view","display");const H=`/workspace${I.toString()?`?${I.toString()}`:""}`;window.history.pushState({},"",H)},[i]),Tk=m.useCallback(k=>{const N=String(k||"").trim();if(!N)return;const I=y.current.find(H=>H.id===N);if(!I||!hn(I.data)){xe("展示节点不可用");return}C(H=>{if(H.nodeIds.includes(N))return H;const K=H.nodeIds.length,Y=Va(I);return{nodeIds:[...H.nodeIds,N],nodePositions:{...H.nodePositions,[N]:{x:180+K*36,y:120+K*28}},nodeSizes:{...H.nodeSizes,...Y?{[N]:Y}:{}}}}),z([N])},[]),Rk=m.useCallback(k=>{const N=String(k||"").trim();N&&(C(I=>{const H=I.nodeIds.filter(G=>G!==N),K={...I.nodePositions},Y={...I.nodeSizes};return delete K[N],delete Y[N],{nodeIds:H,nodePositions:K,nodeSizes:Y}}),z(I=>I.filter(H=>H!==N)))},[]),Mk=m.useCallback(k=>{const N=String(k||"").trim();N&&(j.current.nodeIds.includes(N)?Rk(N):Tk(N))},[Tk,Rk]),Ed=m.useMemo(()=>{const k=gr.trim().toLowerCase();return k?Ia.filter(N=>{var I,H;return[N.id,(I=N.data)==null?void 0:I.label,(H=N.data)==null?void 0:H.definitionId].filter(Boolean).some(K=>String(K).toLowerCase().includes(k))}):Ia},[Ia,gr]),$k=m.useMemo(()=>{const k=Ed.length,N=k<=1?1:k<=4?2:3,I=Array.from({length:N},()=>({height:0,nodes:[]}));for(const H of Ed){const K=Va(H)||{width:420,height:260},Y=Math.max(1,Number(K.width)||420),G=Math.max(1,Number(K.height)||260),J=Math.min(26,Math.max(5.5,G/Y*16))+3.2;let X=I[0];for(const ce of I)ce.height<X.height&&(X=ce);X.nodes.push(H),X.height+=J}return I.map(H=>H.nodes)},[Ed]),wT=m.useCallback(k=>{var Y;const N=S.nodeIds.includes(k.id),I=Va(k)||{width:420,height:260},H=Math.max(1,Math.round(Number(I.width)||420)),K=Math.max(1,Math.round(Number(I.height)||260));return o.jsxs("button",{type:"button",className:"af-display-picker-card"+(N?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${H} / ${K}`},onClick:()=>Mk(k.id),children:[o.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:o.jsx("input",{type:"checkbox",checked:N,readOnly:!0,tabIndex:-1})}),o.jsx("span",{className:"af-display-picker-card__preview",children:o.jsx(fK,{node:k})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((Y=k.data)==null?void 0:Y.label)||k.id}),o.jsxs("small",{children:[hn(k.data)," · ",k.id]})]})]},k.id)},[S.nodeIds,Mk]),Lk=m.useMemo(()=>{const k=oe.trim().toLowerCase();return k?te.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(I=>String(I).toLowerCase().includes(k))):te},[te,oe]),Ok=m.useCallback((k,N)=>{const I=String(k||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let H=`${I}_${Date.now().toString(36)}`,K=2;for(;N.has(H);)H=`${I}_${Date.now().toString(36)}_${K}`,K+=1;return N.add(H),H},[]),cc=m.useCallback((k,N)=>{var Ee,Tt;if(!Se){xe("Readonly workspace");return}const I=k!=null&&k.snippet&&typeof k.snippet=="object"?k.snippet:{},H=I.instances&&typeof I.instances=="object"?I.instances:{},K=Object.keys(H);if(K.length===0)return;const Y=new Set(y.current.map(Ge=>Ge.id)),G={};for(const Ge of K)G[Ge]=Ok(Ge,Y);const J=(Ee=I.ui)!=null&&Ee.nodePositions&&typeof I.ui.nodePositions=="object"?I.ui.nodePositions:{},X=(Tt=I.ui)!=null&&Tt.nodeSizes&&typeof I.ui.nodeSizes=="object"?I.ui.nodeSizes:{},ce=K.map(Ge=>{const ut=J[Ge];return{id:Ge,x:typeof(ut==null?void 0:ut.x)=="number"?ut.x:0,y:typeof(ut==null?void 0:ut.y)=="number"?ut.y:0}}),le=Math.min(...ce.map(Ge=>Ge.x)),he=Math.min(...ce.map(Ge=>Ge.y));let Re=N||{x:360+y.current.length*24,y:180+y.current.length*18};if(!N){const Ge=document.querySelector(".af-workspace-canvas .react-flow");if(Ge){const ut=Ge.getBoundingClientRect();Re=r.screenToFlowPosition({x:ut.left+ut.width*.48,y:ut.top+ut.height*.32})}}const dt={},It={},ft={};for(const Ge of ce){const ut=G[Ge.id];dt[ut]={...H[Ge.id]||{}},It[ut]={x:Re.x+(Ge.x-le),y:Re.y+(Ge.y-he)};const Mt=X[Ge.id];typeof(Mt==null?void 0:Mt.width)=="number"&&typeof(Mt==null?void 0:Mt.height)=="number"&&(ft[ut]={width:Mt.width,height:Mt.height})}const Be=new Set(K),St=(Array.isArray(I.edges)?I.edges:[]).filter(Ge=>Be.has(Ge==null?void 0:Ge.source)&&Be.has(Ge==null?void 0:Ge.target)).map(Ge=>({source:G[Ge.source],target:G[Ge.target],sourceHandle:Ge.sourceHandle??null,targetHandle:Ge.targetHandle??null})),Yt=kf({instances:dt,edges:St,ui:{nodePositions:It,nodeSizes:ft}},Q),Ze=Yt.nodes.map(Ge=>Ge.id),Ke=Yt.nodes.map(Ge=>({...Ge,selected:!0}));U.current={...U.current,...Yt.instances},_(U.current),h(Ge=>[...Ge.map(ut=>({...ut,selected:!1})),...Ke]),b(Ge=>[...Ge.map(ut=>({...ut,selected:!1})),...Yt.edges.map(ut=>({...ut,selected:!1}))]),qe(""),z([]),xe(`已添加流程片段:${k.displayName||k.id}(已选中 ${Ze.length} 个节点)`)},[Ok,Q,r,b,h,Se]),bT=m.useCallback(()=>{var I,H;if(Rn.length<2){Ue("请先在 workspace 画布上选择至少两个节点。"),ue("flows");return}const k=Rn[0],N=Rn.length===2?`${((I=k.data)==null?void 0:I.label)||k.id} 片段`:`${((H=k.data)==null?void 0:H.label)||k.id} 等 ${Rn.length} 个节点`;Ie({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Vt(""),et(!0),ue("flows")},[Rn]),kT=m.useCallback(async()=>{var K,Y;if(Rn.length<2)return;const k=ht.name.trim();if(!k){Vt("请填写片段名称。");return}const N={},I={};for(const G of Rn){N[G.id]={x:((K=G.position)==null?void 0:K.x)||0,y:((Y=G.position)==null?void 0:Y.y)||0};const J=Va(G);J&&(I[G.id]=J)}const H=_d.map(G=>({source:G.source,target:G.target,sourceHandle:G.sourceHandle??null,targetHandle:G.targetHandle??null}));Wt(!0),Vt("");try{const G=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:ht.id,name:k,displayName:k,version:"1.0.0",description:ht.description,snippet:{instances:db(Rn,U.current),edges:H,ui:{nodePositions:N,nodeSizes:I}}})}),J=await G.json().catch(()=>({}));if(!G.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");et(!1),xe(`流程片段已发布:${J.id||k}`),Db(`流程片段已发布:${J.id||k}`),await xd(),ue("flows")}catch(G){Vt(String(G.message||G))}finally{Wt(!1)}},[xd,ht,_d,Rn,Db]);m.useCallback(()=>{if(lc.length===0){xe("当前 workspace 没有 display 节点");return}const k=sm.length>0?sm:lc.map(I=>I.id),N=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display";at(xg({title:N,layout:"gallery",nodeIds:k,mode:"multi-node"})),ee(""),Ve(null),Oe(!0)},[i.flowId,sm,lc]);const vT=m.useCallback(k=>{at(N=>{const I=Array.isArray(N.nodeIds)?N.nodeIds:[];return I.includes(k)?{...N,nodeIds:I.filter(H=>H!==k)}:{...N,nodeIds:[...I,k]}})},[]),ps=m.useCallback(async()=>{Dn(!0),Fn("");try{const k=await fetch("/api/display/shares"),N=await k.json().catch(()=>({}));if(!k.ok)throw new Error(N.error||"读取分享列表失败");Pn(Array.isArray(N.shares)?N.shares:[])}catch(k){Fn(String(k.message||k)),Pn([])}finally{Dn(!1)}},[]),ST=m.useCallback(()=>{Kn(!0),Ar(""),ps()},[ps]),NT=m.useCallback(async()=>{var I,H;const k=Ce.title.trim(),N=Array.isArray(Ce.nodeIds)?Ce.nodeIds:[];if(N.length===0){ee("请选择至少一个 display 节点。");return}Je(!0),ee(""),Ve(null);try{await Dt(d,g);const K=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:k,layout:Ce.layout,nodeIds:N,...KN(Ce)})}),Y=await K.json().catch(()=>({}));if(!K.ok||Y.ok===!1)throw new Error(Y.error||"发布展示页失败");const G=new URL(Y.url||`/display/${((I=Y.share)==null?void 0:I.id)||""}`,window.location.origin).href;Ve({...Y,absoluteUrl:G}),xe((H=Y.share)!=null&&H.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Zt&&ps()}catch(K){ee(String(K.message||K))}finally{Je(!1)}},[Ce,Zt,g,i,ps,d,Dt]),jT=m.useCallback(async()=>{var N,I;const k=Array.isArray(S.nodeIds)?S.nodeIds:[];if(k.length===0){ee("请先添加至少一个展示节点。"),xe("请先添加至少一个展示节点"),In(!0);return}Je(!0),ee("");try{await Dt(d,g);const H=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display",K=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:H,layout:"canvas",nodeIds:k,...KN(Ce)})}),Y=await K.json().catch(()=>({}));if(!K.ok||Y.ok===!1)throw new Error(Y.error||"生成展示链接失败");const G=new URL(Y.url||`/display/${((N=Y.share)==null?void 0:N.id)||""}`,window.location.origin).href;Ve({...Y,absoluteUrl:G}),Ln(!0),xe((I=Y.share)!=null&&I.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Zt&&ps()}catch(H){const K=String(H.message||H);ee(K),xe(K)}finally{Je(!1)}},[S.nodeIds,Ce,Zt,g,i,ps,d,Dt]),Dk=m.useCallback(async()=>{const k=ye==null?void 0:ye.absoluteUrl;if(!k)return;const N=await qN(k);Nn(N?"copied":"failed"),window.setTimeout(()=>Nn(""),1600)},[ye==null?void 0:ye.absoluteUrl]),CT=m.useCallback(async k=>{const N=UN(k),I=await qN(N);Ar(I?String((k==null?void 0:k.id)||""):"failed"),window.setTimeout(()=>Ar(""),1600)},[]),_T=m.useCallback(async(k,N)=>{const I=String((k==null?void 0:k.id)||"");if(I){mr(I),Fn("");try{const H=N==="permanent"?{id:I,expiresMode:"permanent",permanent:!0}:{id:I,expiresMode:"days",expiresInDays:Number(N||30)},K=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),Y=await K.json().catch(()=>({}));if(!K.ok||Y.ok===!1)throw new Error(Y.error||"更新分享有效期失败");await ps(),xe("分享有效期已更新")}catch(H){Fn(String(H.message||H))}finally{mr("")}}},[ps]),ET=m.useCallback(async k=>{const N=String((k==null?void 0:k.id)||"");if(N){mr(N),Fn("");try{const I=await fetch(`/api/display/share?id=${encodeURIComponent(N)}`,{method:"DELETE"}),H=await I.json().catch(()=>({}));if(!I.ok||H.ok===!1)throw new Error(H.error||"撤销分享失败");await ps(),xe("分享已撤销")}catch(I){Fn(String(I.message||I))}finally{mr("")}}},[ps]),AT=m.useCallback(k=>{h(N=>N.map(I=>I.id===k?{...I,selected:!1}:I)),qe(N=>N===k?"":N)},[h]),Ra=m.useCallback(()=>{const k=Wh.current;if(!k)return;const N=k.getBoundingClientRect(),I=Math.min(420,Math.max(320,N.width+160)),H=12,K=Math.max(180,N.top-H*2),Y=Math.min(560,K);QI({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-I-12,N.left)),top:Math.max(H,N.top-Y-H),width:I,maxHeight:Y,zIndex:1e4})},[]);m.useEffect(()=>{if(!dd)return;Ra();const k=I=>{var K,Y;const H=I.target;(K=Wh.current)!=null&&K.contains(H)||(Y=Hb.current)!=null&&Y.contains(H)||Bh(!1)},N=I=>{I.key==="Escape"&&Bh(!1)};return window.addEventListener("pointerdown",k),window.addEventListener("keydown",N),window.addEventListener("resize",Ra),window.addEventListener("scroll",Ra,!0),()=>{window.removeEventListener("pointerdown",k),window.removeEventListener("keydown",N),window.removeEventListener("resize",Ra),window.removeEventListener("scroll",Ra,!0)}},[dd,Ra]);const PT=m.useCallback(k=>{var H,K;if(a==="display"){const Y=[];let G=!1;C(J=>{var le,he;const X={...J.nodePositions},ce={...J.nodeSizes};for(const Re of k||[]){const dt=gg(Re==null?void 0:Re.id);if(!(!dt||!J.nodeIds.includes(dt))){if(Re.type==="select"){Re.selected&&Y.push(dt);continue}if(Re.type==="position"&&Re.position){X[dt]={x:Re.position.x,y:Re.position.y},G=!0;continue}if(Re.type==="dimensions"&&((le=Re.dimensions)!=null&&le.width)&&((he=Re.dimensions)!=null&&he.height)){const It=Jo({width:Math.round(Number(Re.dimensions.width)),height:Math.round(Number(Re.dimensions.height))},{display:!0});It&&(ce[dt]=It,G=!0)}}}return G?{...J,nodePositions:X,nodeSizes:ce}:J}),(k||[]).some(J=>(J==null?void 0:J.type)==="select")&&z(Y);return}if(!Se){const Y=(k||[]).filter(G=>(G==null?void 0:G.type)==="select");Y.length>0&&h(G=>Tp(Y,G));return}const N=new Map;for(const Y of k||[])if((Y==null?void 0:Y.type)==="dimensions"&&((H=Y.dimensions)!=null&&H.width)&&((K=Y.dimensions)!=null&&K.height)){const G=d.find(he=>he.id===Y.id),J=su(G),X=!!hn(G==null?void 0:G.data),ce={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},le=J?yx(ce):Jo(ce,{display:X});le&&N.set(Y.id,le)}const I=Array.from(N.keys());if(h(Y=>Tp(k,Y).map(G=>{const J=N.get(G.id);return J?su(G)?{...G,width:J.width,height:J.height,data:{...G.data,nodeSize:J}}:hn(G.data)?{...G,width:J.width,height:J.height,data:{...G.data,nodeSize:J,displaySize:J}}:{...G,width:J.width,height:J.height,data:{...G.data,nodeSize:J}}:G})),I.length>0){const Y=()=>I.forEach(G=>s(G));window.requestAnimationFrame(Y),window.setTimeout(Y,80)}},[d,h,s,a,Se]),IT=m.useCallback(k=>{if(a!=="display"){if(!Se){const N=(k||[]).filter(I=>(I==null?void 0:I.type)==="select");N.length>0&&b(I=>Hw(N,I));return}v(k)}},[v,b,a,Se]),Ma=m.useCallback(()=>{const k=document.querySelector(".af-workspace-canvas .react-flow");if(k){const N=k.getBoundingClientRect();return r.screenToFlowPosition({x:N.left+N.width*.48,y:N.top+N.height*.32})}return{x:360+d.length*36,y:180+d.length*28}},[d.length,r]),Ad=m.useCallback(()=>{var k,N,I;if(qt){const H=Number(((k=qt.measured)==null?void 0:k.width)||qt.width||260);return{x:Number(((N=qt.position)==null?void 0:N.x)||0)+H+140,y:Number(((I=qt.position)==null?void 0:I.y)||0)}}return Ma()},[Ma,qt]),li=m.useCallback((k,N={})=>{if(!Se)return xe("Readonly workspace"),null;if(!k)return null;const I=pb(k)||k.id,H=TP(k),K=MP(k),Y=N.id||$7(I,d),G=zc(k.inputs),J=zc(k.outputs),X={definitionId:I,...H?{marketplaceRef:H}:{},...k.packageId?{marketplacePackageId:k.packageId}:{},...k.version?{marketplaceVersion:k.version}:{},label:N.label||zp(k),role:"normal",body:N.body||"",...N.script||K?{script:N.script||K}:{},...N.scriptRef?{scriptRef:N.scriptRef}:{},...N.implementationRef?{implementationRef:N.implementationRef}:{},...N.implementationMode?{implementationMode:N.implementationMode}:{},input:N.inputs||G,output:N.outputs||J},ce={id:Y,type:xl,position:N.position||Ma(),data:{label:X.label,definitionId:I,...H?{marketplaceRef:H}:{},...k.packageId?{marketplacePackageId:k.packageId}:{},...k.version?{marketplaceVersion:k.version}:{},schemaType:IP(I,k),role:"normal",body:X.body,...X.script?{script:X.script}:{},...X.scriptRef?{scriptRef:X.scriptRef}:{},...X.implementationRef?{implementationRef:X.implementationRef}:{},...X.implementationMode?{implementationMode:X.implementationMode}:{},inputs:X.input,outputs:X.output}},le={...fx(ce,{...U.current,[Y]:X},Q),selected:!0};return h(he=>[...he.map(Re=>({...Re,selected:!1})),le]),N.openProperties&&qe(Y),Y},[Ma,d,Q,h,Se]),TT=m.useCallback(k=>mg(k,y.current),[]),RT=m.useCallback(k=>{if(!Se){xe("Readonly workspace");return}if(!mg(k,y.current)){xe("端口类型不匹配,已取消连线");return}A(null),h(N=>ug(N,k)),b(N=>{const I=N.filter(H=>!(H.target===k.target&&H.targetHandle===k.targetHandle));return qf({...k,markerEnd:{type:Ks.ArrowClosed}},I)})},[b,h,Se]),MT=m.useCallback((k,N)=>{if(!Se)return;const I=T7(N,y.current);L.current=I?{...I,preferExisting:!!(k!=null&&k.shiftKey)}:null,A(null)},[Se]),$T=m.useCallback((k,N)=>{var Be,St,Yt,Ze;if(!Se)return;const I=L.current;if(L.current=null,!I||N!=null&&N.toNode)return;const H=R7(Q,I),K=M7(y.current,w.current,I);if(H.length===0&&K.length===0){xe(`没有匹配 ${I.slotType} 端口的节点`);return}const G=!!(k!=null&&k.shiftKey||I.preferExisting)?K.length>0?"existing":"create":H.length>0?"create":"existing",J=((St=(Be=k==null?void 0:k.changedTouches)==null?void 0:Be[0])==null?void 0:St.clientX)??(k==null?void 0:k.clientX),X=((Ze=(Yt=k==null?void 0:k.changedTouches)==null?void 0:Yt[0])==null?void 0:Ze.clientY)??(k==null?void 0:k.clientY);if(!Number.isFinite(J)||!Number.isFinite(X))return;const ce=document.querySelector(".af-workspace-canvas .react-flow");if(!ce)return;const le=ce.getBoundingClientRect(),he=320,Re=Math.max(H.length,K.length),dt=Math.min(480,150+Re*58),It=Math.max(12,Math.min(J-le.left,le.width-he-12)),ft=Math.max(12,Math.min(X-le.top,le.height-dt-12));A({left:It,top:ft,flowPosition:r.screenToFlowPosition({x:J,y:X}),draft:I,candidates:H,existingCandidates:K,mode:G,query:""})},[Q,r,Se]),LT=m.useCallback(k=>{if(!Se){xe("Readonly workspace"),A(null);return}const N=$.current;if(!N||!(k!=null&&k.def))return;const I=li(k.def,{position:N.flowPosition});if(!I)return;const H=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:I,targetHandle:`input-${k.slotIndex}`}:{source:I,sourceHandle:`output-${k.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};h(K=>ug(K,H)),b(K=>{const Y=K.filter(G=>!(G.target===H.target&&G.targetHandle===H.targetHandle));return qf({...H,markerEnd:{type:Ks.ArrowClosed}},Y)}),A(null)},[li,b,Se]),OT=m.useCallback(k=>{if(!Se){xe("Readonly workspace"),A(null);return}const N=k==null?void 0:k.connection;if(!N||!mg(N,y.current)){xe("端口类型不匹配,已取消连线"),A(null);return}h(I=>ug(I,N)),b(I=>{const H=I.filter(K=>!(K.target===N.target&&K.targetHandle===N.targetHandle));return qf({...N,markerEnd:{type:Ks.ArrowClosed}},H)}),A(null)},[b,h,Se]),Fk=m.useCallback(k=>{k&&(li(k,{position:Ad()}),ne(!1),Ae(""))},[li,Ad]),zk=m.useCallback(k=>{k&&(cc(k,Ad()),ne(!1),Ae(""))},[cc,Ad]),DT=m.useCallback(k=>{var I,H,K;if(lt)return;const N=k==null?void 0:k.target;LN(N)||(I=N==null?void 0:N.closest)!=null&&I.call(N,"button, a, [role='button'], .react-flow__handle")||(K=(H=x.current)==null?void 0:H.focus)==null||K.call(H,{preventScroll:!0})},[lt]);m.useEffect(()=>{const k=N=>{var ce;if(N.defaultPrevented)return;const I=PV(N.target)||LN(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){N.preventDefault(),Dt().catch(le=>xe(String(le.message||le)));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),Gb(le=>!le);return}if(Yh)return;if(qh){(N.key==="Escape"||EN(N))&&(N.preventDefault(),gd(!1));return}const H=N.key.toLowerCase(),K=(N.metaKey||N.ctrlKey)&&H==="c",Y=(N.metaKey||N.ctrlKey)&&H==="v",G=I&&K&&k7(N.target);if(I&&!G)return;const J=(N.metaKey||N.ctrlKey)&&!N.shiftKey&&H==="z",X=(N.metaKey||N.ctrlKey)&&(N.shiftKey&&H==="z"||H==="y");if(J||X){if(lt){N.preventDefault(),N.stopPropagation(),xe("展示页布局会自动保存");return}if(!Se){N.preventDefault(),xe("Readonly workspace");return}N.preventDefault(),N.stopPropagation();const le=J?ok():ak();xe(le?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(K){if(lt)return;const le=Ot.current,he=(y.current||[]).some(dt=>dt==null?void 0:dt.selected)?y.current:(y.current||[]).map(dt=>le&&dt.id===le?{...dt,selected:!0}:dt),Re=eV(he,w.current,U.current);Re&&(N.preventDefault(),N.stopPropagation(),T.current=Re,G7(Re),G&&typeof((ce=N.target)==null?void 0:ce.blur)=="function"&&N.target.blur(),xe(`Copied ${Re.nodes.length} node${Re.nodes.length>1?"s":""}`));return}if(Y){if(lt){N.preventDefault(),N.stopPropagation();return}if(!Se){N.preventDefault(),xe("Readonly workspace");return}const le=T.current||J7();le&&!T.current&&(T.current=le);const he=tV(le,y.current,w.current,U.current);he&&(N.preventDefault(),N.stopPropagation(),U.current=he.instances,_(he.instances),h(he.nodes),b(he.edges),xe(`Pasted ${he.pastedNodeIds.length} node${he.pastedNodeIds.length>1?"s":""}`));return}if(EN(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),gd(!0);return}if(H==="g"&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Pk();return}if(N.key==="a"||N.key==="A"){if(N.metaKey||N.ctrlKey){N.preventDefault(),lt?z(j.current.nodeIds):(h(le=>le.map(he=>({...he,selected:!0}))),b(le=>le.map(he=>({...he,selected:!1}))));return}if(N.altKey)return;if(lt){N.preventDefault(),In(!0);return}if(!Se){N.preventDefault(),xe("Readonly workspace");return}N.preventDefault(),ne(!0);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Jb("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Jb("pan");return}(N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&(N.preventDefault(),Ak())};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[Pk,lt,Yh,Ak,ak,Dt,qh,b,h,ok,Se]);const FT=m.useCallback(k=>{as(N=>{const I=new Set(N);return I.has(k)?I.delete(k):I.add(k),I})},[]),zT=m.useCallback((k,N)=>{k.dataTransfer.effectAllowed="copy",k.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:N.path,name:N.name,type:N.type})),k.dataTransfer.setData("text/plain",N.path)},[]),HT=m.useCallback((k,N)=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("application/agentflow-node",N.id),k.dataTransfer.setData("text/plain",N.id)},[]),Pd=m.useCallback(async(k,N)=>{const I=String((k==null?void 0:k.name)||(k==null?void 0:k.path)||"").toLowerCase(),H=I.split(".").pop(),K=["jsx","tsx","js"].includes(H)?"display_react_app":H==="html"?"display_html":H==="csv"||H==="tsv"||H==="json"&&/\b(table|data|rows|report)\b/i.test(I)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(H)?"display_image":"display_markdown",Y=Q.find(he=>he.id===K);if(!Y){xe("展示节点不可用");return}const G=K==="display_image";let J=String(k.path||"");if(!G){const he=ys(i);he.set("path",k.path);const Re=await fetch(`/api/workspace/file?${he.toString()}`),dt=await Re.json();if(!Re.ok)throw new Error(dt.error||"读取文件失败");J=String(dt.content||"")}const X=K==="display_image"?"src":"content",ce=zc(Y.inputs).map(he=>he.name===X?{...he,default:J,value:J}:he),le=zc(Y.outputs).map(he=>he.name===X?{...he,default:J,value:J}:he);li(Y,{label:k.name||"Display",body:J,inputs:ce,outputs:le,position:N}),xe(`已创建展示:${k.path}`)},[li,i,Q]),BT=m.useCallback(k=>{if(!Se){xe("Readonly workspace");return}Pd(k,Ma()).catch(N=>xe(String(N.message||N)))},[Pd,Ma,Se]),WT=m.useCallback(k=>{if(!Se){k.preventDefault(),xe("Readonly workspace");return}const N=k.dataTransfer.getData("application/x-agentflow-workspace-file");if(N){k.preventDefault();let G;try{G=JSON.parse(N)}catch{return}if(!(G!=null&&G.path))return;const J=r.screenToFlowPosition({x:k.clientX,y:k.clientY});Pd(G,J).catch(X=>xe(String(X.message||X)));return}const I=k.dataTransfer.getData("application/agentflow-snippet");if(I){const G=te.find(X=>`${X.id}@${X.version}`===I);if(!G)return;k.preventDefault();const J=r.screenToFlowPosition({x:k.clientX,y:k.clientY});cc(G,J);return}const H=k.dataTransfer.getData("application/agentflow-node");if(!H)return;const K=Q.find(G=>G.id===H);if(!K)return;k.preventDefault();const Y=r.screenToFlowPosition({x:k.clientX,y:k.clientY});li(K,{position:Y})},[Pd,li,te,cc,Q,r,Se]),VT=m.useCallback(k=>{if(!Se)return;const N=Array.from(k.dataTransfer.types||[]);!N.includes("application/x-agentflow-workspace-file")&&!N.includes("application/agentflow-node")&&!N.includes("application/agentflow-snippet")||(k.preventDefault(),k.dataTransfer.dropEffect=N.includes("application/agentflow-node")||N.includes("application/agentflow-snippet")?"move":"copy")},[Se]),KT=m.useCallback(async(k="")=>{if(!Se){xe("Readonly workspace");return}const N=window.prompt("新文件名",k?`${k}/notes.md`:"notes.md");if(!N)return;const I=k&&!N.includes("/")?`${k}/${N}`:N;try{const H=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:I,content:""})}),K=await H.json();if(!H.ok)throw new Error(K.error||"创建文件失败");await kn(),as(Y=>{const G=new Set(Y);for(const J of vf(K.path||I))G.delete(J);return G}),xe(`已创建 ${K.path}`)}catch(H){xe(String(H.message||H))}},[i,kn,Se]),UT=m.useCallback(async(k="")=>{if(!Se){xe("Readonly workspace");return}const N=window.prompt("新文件夹名",k?`${k}/docs`:"docs");if(!N)return;const I=k&&!N.includes("/")?`${k}/${N}`:N;try{const H=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:I})}),K=await H.json();if(!H.ok)throw new Error(K.error||"创建文件夹失败");await kn(),as(Y=>{const G=new Set(Y);for(const J of vf(K.path||I))G.delete(J);return K.path&&G.delete(K.path),G}),xe(`已创建 ${K.path}`)}catch(H){xe(String(H.message||H))}},[i,kn,Se]),qT=m.useCallback(async k=>{if(!Se){xe("Readonly workspace");return}if(!(!(k!=null&&k.path)||!window.confirm(`删除 ${k.path}?`)))try{const N=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:k.path})}),I=await N.json();if(!N.ok)throw new Error(I.error||"删除失败");xe(`已删除 ${I.path}`),await kn()}catch(N){xe(String(N.message||N))}},[i,kn,Se]),YT=m.useCallback(k=>{if(!(k!=null&&k.path)||k.type==="directory")return;const N=Du(k.path,i,{download:!0});if(!N)return;const I=document.createElement("a");I.href=N,I.download=k.name||k.path.split("/").pop()||"download",I.rel="noopener",document.body.appendChild(I),I.click(),I.remove()},[i]),Id=m.useCallback(async()=>{if(!Se){xe("Readonly workspace");return}const k=Eo.trim(),N=Zl,I=hd.find(G=>G.id===N)||null;if(!k||Tr||(I==null?void 0:I.status)==="running")return;const H=I?Array.isArray(I.messages)?I.messages:[]:fd,K=Cc(d,g,U.current);Vh(""),Wb(!0),va(!0),Sa(null);const Y={role:"user",text:k,at:Date.now()};I?sr(G=>G.map(J=>J.id===N?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],Y].slice(-180)}:J)):(ka("workspace"),pd(G=>[...G,Y]));try{await Dt(d,g);const G=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,prompt:k,outputKind:"markdown",workspaceGraph:K,allowFlowYaml:!1,model:ii,selectedSkills:ds,selectedNodeIds:Cd,messages:H})}),J=await G.json();if(!G.ok)throw new Error(J.error||"生成失败");const ce={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};I?sr(le=>le.map(he=>he.id===N?{...he,status:"done",messages:[...Array.isArray(he.messages)?he.messages:[],ce].slice(-180)}:he)):pd(le=>[...le,ce]),await Pa(),xe("AI 生成完成")}catch(G){const J=String(G.message||G),X={role:"assistant",text:J,error:!0,at:Date.now()};I?sr(ce=>ce.map(le=>le.id===N?{...le,status:"failed",messages:[...Array.isArray(le.messages)?le.messages:[],X].slice(-180)}:le)):pd(ce=>[...ce,X]),xe(J)}finally{Wb(!1)}},[Zl,fd,ii,hd,Tr,Eo,g,i,Pa,d,Dt,Cd,ds,Se]),or=hd.find(k=>k.id===Zl)||null,Hk=or?Array.isArray(or.messages)?or.messages:[]:fd,uc=or&&or.status==="running"||Tr,GT=IK(Hk,uc),Bk=TK(Hk),JT=or?or.status==="running"?`${or.label} running`:or.status==="paused"?`${or.label} paused`:or.status==="failed"?`${or.label} failed`:`${or.label} done`:Tr?"Workspace agent running":fd.length>0?"Workspace conversation":"Ready",XT=String(i.flowId||"").trim()||"Workspace",Li=(Ce==null?void 0:Ce.mode)==="single-node",Wk=Li&&lc.find(k=>{var N;return k.id===Ce.sourceNodeId||((N=Ce.nodeIds)==null?void 0:N.includes(k.id))})||null,QT=Li&&Wk?[Wk]:lc;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:()=>n("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:i.flowId?`${i.flowId} · ${ya}`:ya||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:XT}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",m7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:a==="workspace"?"af-view-switch__active":"",onClick:()=>Ik("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:a==="display"?"af-view-switch__active":"",onClick:()=>Ik("display"),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:tT}),lt?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:We||!(ye!=null&&ye.absoluteUrl)&&S.nodeIds.length===0,onClick:()=>{Nn(""),Ln(!0)},title:ye!=null&&ye.absoluteUrl?"查看展示链接":S.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:We?"hourglass_empty":"ios_share"}),We?"生成中":ye!=null&&ye.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ia.length===0,onClick:()=>In(!0),title:Ia.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:ST,title:"查看我的展示分享",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!ik,onClick:()=>u(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:o.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!ik,onClick:()=>f(!0),"aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>gd(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Kh?" af-composer-topbar-btn--active":"")+(Tr?" af-composer-topbar-btn--running":""),disabled:lt,onClick:()=>{Sa(null),va(k=>!k)},children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Se,onClick:()=>Dt().catch(k=>xe(String(k.message||k))),children:"Save"})]})]}),Gt?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:Gt}),o.jsx("button",{type:"button",onClick:()=>nt(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!lt&&(Kh||Pe)?" af-workspace-body--drawer":"")+(!lt&&tc?" af-workspace-body--sidebar-collapsed":"")+(lt?" af-workspace-body--display-mode":""),children:[!lt&&tc?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:()=>ne(!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:()=>md(!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:()=>md(!1),"aria-label":"展开侧边栏",title:(ir==null?void 0:ir.username)||(ir==null?void 0:ir.userId)||"展开侧边栏",children:xT})]})}):null,lt?null:o.jsxs("aside",{ref:Qe,className:"af-workspace-sidebar"+(Co?" af-workspace-sidebar--resizing":""),"aria-hidden":tc,style:{"--af-work-files-pane-height":`${Math.round(Tn)}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:()=>md(!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",disabled:!Se,onClick:()=>KT(ai),"aria-label":"新增文件",title:ai?`在 ${ai} 新增文件`:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>UT(ai),"aria-label":"新增文件夹",title:ai?`在 ${ai} 新增文件夹`:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se||Te,onClick:()=>wk(ai),"aria-label":"上传文件",title:ai?`上传到 ${ai}`:"上传文件",children:o.jsx("span",{className:"material-symbols-outlined",children:Te?"hourglass_top":"upload_file"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void kn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("input",{ref:Jt,type:"file",multiple:!0,className:"af-visually-hidden",onChange:aT})]})]}),o.jsx("input",{className:"af-workspace-search",value:Ti,onChange:k=>xa(k.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",onClick:gT,children:o.jsx(GP,{items:mT,onOpen:BT,selectedPath:ls,collapsedDirs:wa,onToggleDir:FT,onSelect:k=>Ri(k.path||""),onFileDragStart:zT,onDelete:qT,onDownload:YT})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:GI,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:re==="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:oe,onChange:k=>ve(k.target.value),placeholder:re==="flows"?"搜索流程片段...":"搜索节点...","aria-label":re==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":re==="nodes",className:"af-palette-tab"+(re==="nodes"?" af-palette-tab--active":""),onClick:()=>ue("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":re==="flows",className:"af-palette-tab"+(re==="flows"?" af-palette-tab--active":""),onClick:()=>ue("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:re==="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:bT,disabled:Rn.length<2,title:Rn.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:["已选 ",Rn.length," 节点 / ",_d.length," 连线"]})]})}),Fe?o.jsx("p",{className:"af-err af-palette-list-err",children:Fe}):null,pe?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Lk.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:Lk.map(k=>{const N=`${k.id}@${k.version}`,I=k.displayName||k.name||k.id,H=k.description||`${k.nodeCount||0} 个节点,${k.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:K=>{K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("application/agentflow-snippet",N),K.dataTransfer.setData("text/plain",N)},onClick:()=>cc(k),title:H,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:I}),o.jsxs("span",{className:"af-palette-card-id",children:[k.id,"@",k.version]})]})]}),H?o.jsx("span",{className:"af-palette-card-desc",children:H}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[k.nodeCount||0," nodes"]}),o.jsxs("span",{children:[k.edgeCount||0," edges"]})]})]},N)})})]}):o.jsx("p",{className:"af-palette-empty",children:oe.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Ba.map(k=>{var N;return(N=nm[k])!=null&&N.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${k}`,children:[o.jsx("h3",{className:"af-palette-cat",children:k}),o.jsx("div",{className:"af-palette-cards",children:nm[k].map(I=>{const H=HN(I.inputs,"input"),K=HN(I.outputs,"output"),Y=gx(I),G=Dc(I);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>HT(J,I),onClick:()=>li(I),title:Y||I.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:FN(k)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:G}),G!==I.id?o.jsx("span",{className:"af-palette-card-id",children:I.id}):null]})]}),Y?o.jsx("span",{className:"af-palette-card-desc",children:Y}):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:[H.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[H.shown.map((J,X)=>o.jsxs("span",{className:"af-palette-card-port",title:zN("input",J,X),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:gn(J==null?void 0:J.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:wf(J,X)})]},`in-${X}`)),H.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",H.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((J,X)=>o.jsxs("span",{className:"af-palette-card-port",title:zN("output",J,X),children:[o.jsx("span",{className:"af-palette-card-port-name",children:wf(J,X)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:gn(J==null?void 0:J.type)}})]},`out-${X}`)),K.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",K.hidden]}):null]})]})]})]},I.id)})})]},k):null}),Q.length>0&&oe.trim()&&Ba.every(k=>{var N;return!((N=nm[k])!=null&&N.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{ref:x,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:DT,children:[o.jsx(vA,{className:"af-flow-canvas af-workspace-flow"+(Gh==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(lt?" af-workspace-flow--display-mode":""),nodes:dT,edges:fT,nodeTypes:NK,onNodesChange:PT,onEdgesChange:IT,onConnect:lt?void 0:RT,onConnectStart:lt?void 0:MT,onConnectEnd:lt?void 0:$T,isValidConnection:lt?void 0:TT,onNodeClick:(k,N)=>{var I;if(lt){z([gg(N.id)]);return}if((I=N==null?void 0:N.data)!=null&&I.isWorkspaceGroup){qe("");return}if(k.detail>=3){va(!1),h(H=>H.map(K=>({...K,selected:K.id===N.id}))),b(H=>H.map(K=>({...K,selected:!1}))),qe(N.id);return}Kt&&qe(N.id)},onNodeDoubleClick:k=>{k.preventDefault()},onPaneClick:()=>{lt?z([]):qe("")},onDrop:lt?void 0:WT,onDragOver:lt?void 0:VT,nodesDraggable:lt?!0:Se,nodesConnectable:lt?!1:Se,edgesReconnectable:lt?!1:Se,deleteKeyCode:lt?null:Se?["Backspace","Delete"]:null,selectionOnDrag:Gh==="select",panOnDrag:Gh==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(NA,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!lt&&O?(()=>{var J;const k=String(O.query||"").trim().toLowerCase(),N=O.mode==="create"?"create":"existing",I=Array.isArray(O.candidates)?O.candidates:[],H=Array.isArray(O.existingCandidates)?O.existingCandidates:[],K=k?I.filter(X=>{var ce,le,he;return[(ce=X.def)==null?void 0:ce.id,X.displayLabel,X.description,(le=X.slot)==null?void 0:le.name,(he=X.slot)==null?void 0:he.type].filter(Boolean).some(Re=>String(Re).toLowerCase().includes(k))}):I,Y=k?H.filter(X=>{var ce,le;return[X.nodeId,X.nodeLabel,X.definitionId,(ce=X.slot)==null?void 0:ce.name,(le=X.slot)==null?void 0:le.type].filter(Boolean).some(he=>String(he).toLowerCase().includes(k))}):H,G=O.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:O.left,top:O.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:gn((J=O.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",O.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>A(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[o.jsxs("button",{type:"button",className:N==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:H.length===0,onClick:()=>A(X=>X&&{...X,mode:"existing",query:""}),children:["连接已有 ",o.jsx("span",{children:H.length})]}),o.jsxs("button",{type:"button",className:N==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:I.length===0,onClick:()=>A(X=>X&&{...X,mode:"create",query:""}),children:["新建节点 ",o.jsx("span",{children:I.length})]})]}),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:O.query,onChange:X=>A(ce=>ce&&{...ce,query:X.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N==="create"?K.map(X=>{var he,Re;const ce=X.displayLabel||((he=X.def)==null?void 0:he.id),le=wf(X.slot,X.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>LT(X),title:X.description||X.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:ce}),ce!==X.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:X.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:G}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:gn((Re=X.slot)==null?void 0:Re.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:le})]})]},`${X.def.id}-${X.slotIndex}`)}):Y.map(X=>{var he;const ce=X.nodeLabel||X.nodeId,le=wf(X.slot,X.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>OT(X),title:`${X.definitionId||X.nodeId} · ${le}`,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:ce}),o.jsxs("span",{className:"af-connect-node-menu__item-id",children:[X.definitionId?`${X.definitionId} · `:"",X.nodeId]})]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:G}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:gn((he=X.slot)==null?void 0:he.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:le}),X.occupied?o.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${X.nodeId}-${X.handleId}`)}),(N==="create"?K.length:Y.length)===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!lt&&!ZI?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:()=>Uh(!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:Rn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Rn.map(k=>{var K,Y;const N=String(((K=k.data)==null?void 0:K.label)??k.id),I=(Y=k.data)!=null&&Y.definitionId?String(k.data.definitionId):"",H=I&&I!==N?`${N} · ${k.id} · ${I}`:`${N} · ${k.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:H,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:I||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:N}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>AT(k.id),"aria-label":`取消选择 ${k.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},k.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:Eo,rows:2,onChange:k=>Vh(k.target.value),onKeyDown:k=>{(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),Id())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Se})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Wh,type:"button",className:"af-composer-skills-button"+(ds.length>0?" af-composer-skills-button--active":""),disabled:Tr||!Se,"aria-haspopup":"listbox","aria-expanded":dd,onClick:()=>Bh(k=>!k),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:ds.length>0?`Skills ${ds.length}`:"Skills"})]}),dd&&!Tr?cr.createPortal(o.jsx("div",{ref:Hb,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:XI,children:us.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Ta.groups.map(k=>{const N=ra(k,us),I=K$(k,rm,us),H=JI.has(k.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(H?" 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:I==="all",disabled:N.length===0,onChange:K=>{const Y=K.target.checked;Ql(G=>Y?W$(G,N):V$(G,N))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:k.name}),k.builtin?o.jsx("em",{children:"built-in"}):null,I==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":H?`展开 ${k.name}`:`收起 ${k.name}`,onClick:()=>{zb(K=>{const Y=new Set(K);return Y.has(k.id)?Y.delete(k.id):Y.add(k.id),Y})},children:[o.jsx("span",{children:k.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:H?"expand_more":"expand_less"})]})]}),H?null:o.jsx("div",{className:"af-composer-skill-group-items",children:k.skills.map(K=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:rm.has(K.key),onChange:Y=>{const G=Y.target.checked;Ql(J=>G?J.includes(K.key)?J:[...J,K.key]:J.filter(X=>X!==K.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:K.name}),K.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:K.description}):null]})]},`${k.id}:${K.key}`))})]},k.id)}),Ta.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:Ta.ungrouped.length})]}),Ta.ungrouped.map(k=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:rm.has(k.key),onChange:N=>{const I=N.target.checked;Ql(H=>I?H.includes(k.key)?H:[...H,k.key]:H.filter(K=>K!==k.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:k.name}),k.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:k.description}):null]})]},`ungrouped:${k.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:ii,onChange:k=>KI(k.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),yT.map(k=>o.jsx("option",{value:k.value,children:k.label},k.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(Eo.trim()&&!Tr?" af-composer-send--active":"")+(Tr?" af-composer-send--stop":""),disabled:Tr||!Eo.trim()||!Se,"aria-label":Tr?"Running":"Send",onClick:()=>void Id(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Tr?"sync":"arrow_upward"})})]})]})]})}):lt?null:o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Uh(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!lt&&Kh?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:()=>va(!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"+(Zl==="workspace"?" af-composer-session-tab--active":""),onClick:()=>ka("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),hd.map(k=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(Zl===k.id?" af-composer-session-tab--active":"")+(k.status==="running"?" af-composer-session-tab--running":""),onClick:()=>ka(k.id),title:k.runNodeId||k.label,children:o.jsx("span",{className:"af-composer-session-label",children:k.label})},k.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(uc?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:JT}),o.jsxs("div",{className:"af-composer-sidebar-thread",children:[o.jsx(XN,{messages:GT,running:uc,showRunningIndicator:!or}),Bk.length>0?o.jsxs("details",{className:"af-composer-sidebar-log-details",children:[o.jsx("summary",{children:"执行日志"}),o.jsx(XN,{messages:Bk,running:!1,showRunningIndicator:!1})]}):null]}),o.jsxs("div",{className:"af-composer-sidebar-input",children:[o.jsx("textarea",{className:"af-composer-sidebar-textarea",value:Eo,rows:3,onChange:k=>Vh(k.target.value),onKeyDown:k=>{(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),Id())},placeholder:or?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!Se||uc}),o.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!Se||uc||!Eo.trim(),onClick:()=>void Id(),"aria-label":"发送 AI 对话",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!lt&&Pe&&qt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(QV,{draft:Pe,setDraft:Ut,definitionId:String(((Vk=qt.data)==null?void 0:Vk.definitionId)||qt.id),systemPromptReadonly:String(((Kk=qt.data)==null?void 0:Kk.description)||""),modelLists:_o,disabled:!Se,onIdBlur:()=>tm(!0),onClose:()=>qe(""),onPublishToMarketplace:iT,error:Ir,ioSlots:{inputs:Array.isArray(Pe==null?void 0:Pe.inputs)?Pe.inputs:[],outputs:Array.isArray(Pe==null?void 0:Pe.outputs)?Pe.outputs:[]}})}):null,!lt&&ec?cr.createPortal(o.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>Sa(null),children:o.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:k=>k.stopPropagation(),children:o.jsx(OV,{flowParams:i,scheduleNodeId:ec.scheduleNodeId,runNodeId:ec.runNodeId,lastRunId:ec.lastRunId,label:ec.label,onClose:()=>Sa(null)})})}),document.body):null,o.jsx(RV,{open:qh,onClose:()=>gd(!1)}),o.jsx($V,{open:Yh,onClose:()=>Gb(!1),onJump:hT,nodes:pT}),o.jsx(ZV,{open:c,onClose:()=>u(!1),flowId:i.flowId||"",flowSource:yd,onArchived:()=>{u(!1),n("/projects?tab=archived")}}),o.jsx(e7,{open:p&&!!i.flowId,onClose:()=>f(!1),flowId:i.flowId||"",flowSource:yd,flowArchived:!!i.archived,onDeleted:async()=>{f(!1),n("/projects")}}),Me?cr.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:()=>et(!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:ht.name,onChange:k=>{const N=k.target.value;Ie(I=>({...I,name:N,id:I.id?I.id:N.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:ht.id,onChange:k=>Ie(N=>({...N,id:k.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:ht.description,onChange:k=>Ie(N=>({...N,description:k.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Rn.length," 个节点和 ",_d.length," 条内部连线。"]}),$e?o.jsx("div",{className:"af-flow-snippet-error",children:$e}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>et(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:tt||!ht.name.trim(),onClick:()=>void kT(),children:tt?"发布中...":"发布"})]})]})}),document.body):null,Ek?o.jsx(dK,{node:Ek,onClose:()=>Pr("")}):null,ke?cr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":Li?"新建分享":"发布展示页",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:"present_to_all"}),Li?"新建分享":"发布展示页"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Oe(!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:Ce.title,onChange:k=>at(N=>({...N,title:k.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),Li?null:o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"布局"}),o.jsxs("select",{className:"af-display-share-select",value:Ce.layout,onChange:k=>at(N=>({...N,layout:k.target.value})),children:[o.jsx("option",{value:"gallery",children:"Gallery"}),o.jsx("option",{value:"document",children:"Document"}),o.jsx("option",{value:"slides",children:"Slides"})]})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"有效期"}),o.jsx("select",{className:"af-display-share-select",value:VN(Ce),onChange:k=>{const N=k.target.value;at(I=>({...I,permanent:N==="permanent",expiresInDays:N==="permanent"?I.expiresInDays||30:Number(N)}))},children:yg.map(k=>o.jsx("option",{value:k.value,children:k.label},k.value))})]}),o.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":Li?"分享内容":"选择展示节点",children:[Li?o.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,QT.map(k=>{var I;const N=Array.isArray(Ce.nodeIds)&&Ce.nodeIds.includes(k.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:N,disabled:Li,onChange:()=>vT(k.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((I=k.data)==null?void 0:I.label)||k.id}),o.jsxs("small",{children:[hn(k.data)," · ",k.id]})]})]},k.id)})]}),ye!=null&&ye.absoluteUrl?o.jsxs("div",{className:"af-display-share-result",children:[o.jsx("input",{type:"text",readOnly:!0,value:ye.absoluteUrl,onFocus:k=>k.target.select()}),o.jsx("button",{type:"button",onClick:()=>window.open(ye.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),o.jsx("button",{type:"button",onClick:()=>void Dk(),children:On==="copied"?"已复制":On==="failed"?"复制失败":"复制"})]}):null,vt?o.jsx("div",{className:"af-flow-snippet-error",children:vt}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Oe(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:We||!Array.isArray(Ce.nodeIds)||Ce.nodeIds.length===0,onClick:()=>void NT(),children:We?"生成中...":"生成链接"})]})]})}),document.body):null,hr?cr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-link-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:"link"}),"展示链接"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{Nn(""),Ln(!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:[ye!=null&&ye.absoluteUrl?o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",readOnly:!0,value:ye.absoluteUrl,onFocus:k=>k.target.select(),autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>window.open(ye.absoluteUrl,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void Dk(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:On==="copied"?"check":"content_copy"}),On==="copied"?"已复制":On==="failed"?"复制失败":"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"新链接有效期"}),o.jsx("select",{className:"af-display-share-select",value:VN(Ce),onChange:k=>{const N=k.target.value;at(I=>({...I,permanent:N==="permanent",expiresInDays:N==="permanent"?I.expiresInDays||30:Number(N)}))},children:yg.map(k=>o.jsx("option",{value:k.value,children:k.label},k.value))})]}),vt?o.jsx("div",{className:"af-flow-snippet-error",children:vt}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Nn(""),Ln(!1)},children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:We||S.nodeIds.length===0,onClick:()=>void jT(),children:We?"生成中...":ye!=null&&ye.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,Zt?cr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-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:"folder_shared"}),"我的分享"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Kn(!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("div",{className:"af-display-shares-toolbar",children:[o.jsx("span",{children:pn.length?`${pn.length} 个分享`:"暂无分享"}),o.jsxs("button",{type:"button",onClick:()=>void ps(),disabled:jn,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Er?o.jsx("div",{className:"af-flow-snippet-error",children:Er}):null,jn?o.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!jn&&pn.length===0?o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,o.jsx("div",{className:"af-display-shares-list",children:pn.map(k=>{const N=UN(k),I=si===k.id,H=k.expiresAt?String(k.expiresInDays||30):"permanent";return o.jsxs("article",{className:"af-display-share-item",children:[o.jsxs("div",{className:"af-display-share-item__main",children:[o.jsx("strong",{children:k.title||"AgentFlow Display"}),o.jsxs("span",{children:[k.flowId||"-"," · ",k.layout||"gallery"," · ",Array.isArray(k.nodeIds)?k.nodeIds.length:0," nodes"]}),o.jsx("small",{children:U7(k)})]}),o.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:N,onFocus:K=>K.target.select()}),o.jsx("select",{className:"af-display-share-select",value:H,disabled:I,onChange:K=>void _T(k,K.target.value),"aria-label":"修改分享有效期",children:yg.map(K=>o.jsx("option",{value:K.value,children:K.label},K.value))}),o.jsxs("div",{className:"af-display-share-item__actions",children:[o.jsxs("button",{type:"button",onClick:()=>window.open(N,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void CT(k),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ur===k.id?"check":"content_copy"}),Ur===k.id?"已复制":"复制"]}),o.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:I,onClick:()=>void ET(k),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:I?"hourglass_empty":"link_off"}),"撤销"]})]})]},k.id)})})]})]})}),document.body):null,ss?cr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-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:"add_to_photos"}),"选择展示节点"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>In(!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-display-picker-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:gr,onChange:k=>rr(k.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":$k.length||1},children:Ed.length>0?$k.map((k,N)=>o.jsx("div",{className:"af-display-picker-column",children:k.map(wT)},`display-picker-column-${N}`)):o.jsx("div",{className:"af-display-picker-empty",children:Ia.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>In(!1),children:"完成"})})]})}),document.body):null,W.nodeId?cr.createPortal(o.jsx(PK,{files:os,query:W.query,onQueryChange:k=>de(N=>({...N,query:k})),onSelect:lT,onUpload:wk,onClose:Qh}),document.body):null,!lt&&zt?cr.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>ne(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:k=>k.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":we==="nodes",className:"af-workspace-quick-add__tab"+(we==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Z("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":we==="flows",className:"af-workspace-quick-add__tab"+(we==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Z("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:Bb,value:ge,onChange:k=>Ae(k.target.value),onKeyDown:k=>{if(k.key==="Escape")k.preventDefault(),ne(!1);else if(k.key==="ArrowDown"){k.preventDefault();const N=we==="flows"?ac.length:oc.length;Ct(I=>Math.min(Math.max(0,N-1),I+1))}else k.key==="ArrowUp"?(k.preventDefault(),Ct(N=>Math.max(0,N-1))):k.key==="Tab"?(k.preventDefault(),Z(N=>N==="nodes"?"flows":"nodes")):k.key==="Enter"&&(k.preventDefault(),we==="flows"?zk(ac[bt]||ac[0]):Fk(oc[bt]||oc[0]))},placeholder:we==="flows"?"搜索流程片段...":"搜索节点...","aria-label":we==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:we==="flows"?ac.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:pe?"正在加载流程片段...":Fe||"没有匹配的流程片段"}):ac.map((k,N)=>{const I=k.displayName||k.name||k.id,H=k.snippet&&typeof k.snippet=="object"?k.snippet.instances:null,K=k.snippet&&typeof k.snippet=="object"?k.snippet.edges:null,Y=Number.isFinite(Number(k.nodeCount))?Number(k.nodeCount):Object.keys(H||{}).length,G=Number.isFinite(Number(k.edgeCount))?Number(k.edgeCount):Array.isArray(K)?K.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(N===bt?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ct(N),onClick:()=>zk(k),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:I}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[k.id,k.version?` · v${k.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:k.description||`${Y} 节点 / ${G} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${k.id}@${k.version}`)}):oc.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):oc.map((k,N)=>{const I=Oc(k),H=Dc(k),K=gx(k);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(N===bt?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ct(N),onClick:()=>Fk(k),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:FN(I)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:H}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:k.id}),K?o.jsx("span",{className:"af-workspace-quick-add__desc",children:K}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:I})]},k.id)})})]})}),document.body):null]})]})}function qK(){return o.jsx(Ww,{children:o.jsx(UK,{})})}function YK(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=(e==null?void 0:e.kind)==="image"?"src":"content",r=a=>String((a==null?void 0:a.value)??(a==null?void 0:a.default)??""),s=a=>r(a).trim(),i=t.find(a=>(a==null?void 0:a.name)===n&&s(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&s(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&s(a));return String((e==null?void 0:e.body)||(i?r(i):""))}function GK(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function JK(e){let t=String(e||"").replace(/\r\n/g,`
254
- `).trim();return t.includes(`
255
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
256
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
257
- $2`)),t}function eI(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=JK(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
258
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
259
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function yb(e){let t=eI(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 XK(e){const t=yb(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function QK(e){const t=yb(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
260
- (() => {
261
- document.addEventListener("click", (event) => {
262
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
263
- if (!link) return;
264
- const rawHref = String(link.getAttribute("href") || "").trim();
265
- if (!rawHref || rawHref.startsWith("#")) return;
266
- if (/^javascript:/i.test(rawHref)) {
267
- event.preventDefault();
268
- return;
269
- }
270
- event.preventDefault();
271
- window.open(link.href, "_blank", "noopener,noreferrer");
272
- }, true);
273
- })();
274
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function tI(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=new URLSearchParams;return s.set("id",t),s.set("path",r),n.download&&s.set("download","1"),`/api/display/file/raw?${s.toString()}`}function ZK(e,t,n={}){const r=String(e||"").trim();return r?tI(r,t,n):""}function eU({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 p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,g=h?Math.max(12,d/f*100):100,b=Math.max(0,100-g),v=h?Math.min(b,p.scrollTop/Math.max(1,f-d)*b):0;i({visible:h,top:v,height:g})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),g=s.height/100*h.height,b=Math.max(1,h.height-g);return(p-h.top-f)/b},[s.height]),u=m.useCallback(p=>{if(!s.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=s.top/100*d.height,g=s.height/100*d.height,v=p.clientY>=d.top+h&&p.clientY<=d.top+h+g?p.clientY-d.top-h:g/2;l(c(p.clientY,v));const y=x=>{x.preventDefault(),l(c(x.clientY,v))},w=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[o.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function bx({node:e,shareId:t,style:n,bare:r=!1}){const s=YK(e),i=e.kind==="html"?yb(s):e.kind==="react"?Rh(s):eI(s),a=e.kind==="html"?XK(i):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return o.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}${r?" af-public-display-node--bare":""}`,style:n,children:[r?null:o.jsx("div",{className:"af-public-display-node__head",children:o.jsxs("div",{className:"af-public-display-node__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:GK(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(eU,{className:l,children:a?o.jsx("div",{className:"af-public-display-empty",children:a}):i.trim()?o.jsxs(o.Fragment,{children:[e.kind==="html"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:QK(i)}):null,e.kind==="react"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:fb(i)}):null,e.kind==="image"?o.jsx("img",{src:tI(i,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(ob,{content:i,resolveSrc:(c,u)=>ZK(c,t,u)})}):null,e.kind==="chart"?o.jsx(lb,{content:i}):null,e.kind==="table"?o.jsx(ab,{content:i}):null,e.kind==="mermaid"||e.kind==="ascii"?o.jsx("pre",{children:i}):null]}):o.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function tU({data:e}){return o.jsx(bx,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const nU={publicDisplay:tU};function rU(e){const t=String(e||"").split("/").filter(Boolean);return t[0]==="display"&&t[1]?decodeURIComponent(t[1]):new URLSearchParams(window.location.search).get("id")||""}function nI(){var l,c,u,p;const{path:e}=ti(),t=m.useMemo(()=>rU(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function d(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),g=await h.json().catch(()=>({}));if(!h.ok)throw new Error(g.error||"展示页不存在");f||r({loading:!1,error:"",share:g.share||null,nodes:Array.isArray(g.nodes)?g.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return d(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((d,h)=>{const g=d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"?d.position:{x:120+h*40,y:100+h*32},b=d.size&&typeof d.size.width=="number"&&typeof d.size.height=="number"?d.size:{width:520,height:320};return{id:d.id,type:"publicDisplay",position:g,data:{node:d,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(b.width)||520),height:Math.max(1,Number(b.height)||320)}}}),[t,n.nodes]),i=m.useMemo(()=>{var b;const f=(b=n.share)==null?void 0:b.viewport;if(!f||typeof f!="object")return null;const d=Number(f.x),h=Number(f.y),g=Number(f.zoom);return!Number.isFinite(d)||!Number.isFinite(h)||!Number.isFinite(g)?null:{x:d,y:h,zoom:Math.min(Math.max(g,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return o.jsx("main",{className:"af-public-display-page",children:o.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return o.jsx("main",{className:"af-public-display-page",children:o.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),o.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return o.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:o.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>o.jsx(bx,{node:d,shareId:t,bare:!0},d.id))})});const f=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return o.jsxs("main",{className:`af-public-display-page ${f}`,children:[o.jsxs("header",{className:"af-public-display-hero",children:[o.jsxs("div",{children:[o.jsx("p",{children:"AgentFlow Display"}),o.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),o.jsx("span",{children:(p=n.share)!=null&&p.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),o.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>o.jsx(bx,{node:d,shareId:t},d.id))})]})}return o.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:o.jsx(Ww,{children:o.jsx(vA,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:nU,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:i||void 0,fitView:!i,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:o.jsx(NA,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const pt=e=>typeof e=="string",_c=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},oj=e=>e==null?"":""+e,sU=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},iU=/###/g,aj=e=>e&&e.indexOf("###")>-1?e.replace(iU,"."):e,lj=e=>!e||pt(e),iu=(e,t,n)=>{const r=pt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(lj(e))return{};const i=aj(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return lj(e)?{}:{obj:e,k:aj(r[s])}},cj=(e,t,n)=>{const{obj:r,k:s}=iu(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=iu(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=iu(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},oU=(e,t,n,r)=>{const{obj:s,k:i}=iu(e,t,Object);s[i]=s[i]||[],s[i].push(n)},Wp=(e,t)=>{const{obj:n,k:r}=iu(e,t);if(n)return n[r]},aU=(e,t,n)=>{const r=Wp(e,n);return r!==void 0?r:Wp(t,n)},rI=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?pt(e[r])||e[r]instanceof String||pt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):rI(e[r],t[r],n):e[r]=t[r]);return e},za=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var lU={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const cU=e=>pt(e)?e.replace(/[&<>"'\/]/g,t=>lU[t]):e;class uU{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 dU=[" ",",","?","!",";"],fU=new uU(20),pU=(e,t,n)=>{t=t||"",n=n||"";const r=dU.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=fU.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},kx=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},Vp=e=>e&&e.replace("_","-"),hU={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 Kp{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||hU,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:(pt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Kp(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Kp(this.logger,t)}}var qs=new Kp;class $h{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 u=0;u<c;u++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l.apply(l,[t,...r])})}}class uj extends $h{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):pt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=Wp(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!pt(r)?c:kx(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),cj(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)(pt(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=Wp(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?rI(c,r,i):c={...c,...r},cj(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 sI={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 dj={};class Up extends $h{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),sU(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=qs.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&&!pU(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:pt(i)?[i]:i};const u=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),t=u.join(s)}return{key:t,namespaces:pt(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],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(p){const S=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${S}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${S}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let d=f&&f.res;const h=f&&f.usedKey||a,g=f&&f.exactUsedKey||a,b=Object.prototype.toString.apply(d),v=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!pt(d)&&typeof d!="boolean"&&typeof d!="number";if(w&&d&&x&&v.indexOf(b)<0&&!(pt(y)&&Array.isArray(d))){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,d,{...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(d),C=S?[]:{},j=S?g:h;for(const E in d)if(Object.prototype.hasOwnProperty.call(d,E)){const P=`${j}${i}${E}`;C[E]=this.translate(P,{...n,joinArrays:!1,ns:l}),C[E]===P&&(C[E]=d[E])}d=C}}else if(w&&pt(y)&&Array.isArray(d))d=d.join(y),d&&(d=this.extendTranslation(d,t,n,r));else{let S=!1,C=!1;const j=n.count!==void 0&&!pt(n.count),E=Up.hasDefaultValue(n),P=j?this.pluralResolver.getSuffix(u,n.count,n):"",F=n.ordinal&&j?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",V=j&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),z=V&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${P}`]||n[`defaultValue${F}`]||n.defaultValue;!this.isValidLookup(d)&&E&&(S=!0,d=z),this.isValidLookup(d)||(C=!0,d=a);const R=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:d,T=E&&z!==d&&this.options.updateMissing;if(C||S||T){if(this.logger.log(T?"updateKey":"missingKey",u,c,a,T?z:d),i){const A=this.resolve(a,{...n,keySeparator:!1});A&&A.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 L=[];const $=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&$&&$[0])for(let A=0;A<$.length;A++)L.push($[A]);else this.options.saveMissingTo==="all"?L=this.languageUtils.toResolveHierarchy(n.lng||this.language):L.push(n.lng||this.language);const O=(A,M,_)=>{const U=E&&_!==d?_:R;this.options.missingKeyHandler?this.options.missingKeyHandler(A,c,M,U,T,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(A,c,M,U,T,n),this.emit("missingKey",A,c,M,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&j?L.forEach(A=>{const M=this.pluralResolver.getSuffixes(A,n);V&&n[`defaultValue${this.options.pluralSeparator}zero`]&&M.indexOf(`${this.options.pluralSeparator}zero`)<0&&M.push(`${this.options.pluralSeparator}zero`),M.forEach(_=>{O([A],a+_,n[`defaultValue${_}`]||z)})}):O(L,a,z))}d=this.extendTranslation(d,t,n,f,r),C&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${c}:${a}`),(C||S)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,S?d:void 0):d=this.options.parseMissingKeyHandler(d))}return s?(f.res=d,f.usedParams=this.getUsedParamsDetails(n),f):d}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 u=pt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(u){const d=t.match(this.interpolator.nestingRegexp);p=d&&d.length}let f=r.replace&&!pt(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),u){const d=t.match(this.interpolator.nestingRegexp),h=d&&d.length;p<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 d=arguments.length,h=new Array(d),g=0;g<d;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=pt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=sI.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 pt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),p=u.key;s=p;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const d=n.count!==void 0&&!pt(n.count),h=d&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(pt(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(l=v,!dj[`${b[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(dj[`${b[0]}-${v}`]=!0,this.logger.warn(`key "${s}" for languages "${b.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!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;a=y;const w=[p];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(w,p,y,v,n);else{let S;d&&(S=this.pluralResolver.getSuffix(y,n.count,n));const C=`${this.options.pluralSeparator}zero`,j=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(w.push(p+S),n.ordinal&&S.indexOf(j)===0&&w.push(p+S.replace(j,this.options.pluralSeparator)),h&&w.push(p+C)),g){const E=`${p}${this.options.contextSeparator}${n.context}`;w.push(E),d&&(w.push(E+S),n.ordinal&&S.indexOf(j)===0&&w.push(E+S.replace(j,this.options.pluralSeparator)),h&&w.push(E+C))}}let x;for(;x=w.pop();)this.isValidLookup(r)||(i=x,r=this.getResource(y,v,x,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&&!pt(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 bg=e=>e.charAt(0).toUpperCase()+e.slice(1);class fj{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=qs.create("languageUtils")}getScriptPartFromCode(t){if(t=Vp(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=Vp(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(pt(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]=bg(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]=bg(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=bg(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)),pt(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 pt(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))):pt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let mU=[{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}],gU={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 yU=["v1","v2","v3"],xU=["v4"],pj={zero:0,one:1,two:2,few:3,many:4,other:5},wU=()=>{const e={};return mU.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:gU[t.fc]}})}),e};class bU{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=qs.create("pluralResolver"),(!this.options.compatibilityJSON||xU.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=wU(),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=Vp(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)=>pj[s]-pj[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!yU.includes(this.options.compatibilityJSON)}}const hj=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=aU(e,t,n);return!i&&s&&pt(n)&&(i=kx(e,n,r),i===void 0&&(i=kx(t,n,r))),i},kg=e=>e.replace(/\$/g,"$$$$");class kU{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=qs.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:u,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:d,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:v,maxReplaces:y,alwaysFormat:w}=t.interpolation;this.escape=n!==void 0?n:cU,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?za(i):a||"{{",this.suffix=l?za(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=d?za(d):h||za("$t("),this.nestingSuffix=g?za(g):b||za(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=y||1e3,this.alwaysFormat=w!==void 0?w:!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||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const y=hj(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),b=g.shift().trim(),v=g.join(this.formatSeparator).trim();return this.format(hj(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const p=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=>kg(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?kg(this.escape(h)):kg(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=u(g),a===void 0)if(typeof p=="function"){const v=p(t,i,s);a=pt(v)?v:""}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!pt(a)&&!this.useRawValueToEscape&&(a=oj(a));const b=h.safeValue(a);if(t=t.replace(i[0],b),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,u)=>{const p=this.nestingOptionsSeparator;if(c.indexOf(p)<0)return c;const f=c.split(new RegExp(`${p}[ ]*{`));let d=`{${f[1]}`;c=f[0],d=this.interpolate(d,a);const h=d.match(/'/g),g=d.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(d=d.replace(/'/g,'"'));try{a=JSON.parse(d),u&&(a={...u,...a})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${p}${d}`}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&&!pt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const p=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=p.shift(),c=p,u=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!pt(i))return i;pt(i)||(i=oj(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=c.reduce((p,f)=>this.format(p,f,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const vU=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(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),p=l.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Ha=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(Vp(r),s),t[a]=l),l(n)}};class SU{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=qs.create("formatter"),this.options=t,this.formats={number:Ha((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:Ha((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:Ha((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:Ha((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:Ha((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()]=Ha(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:u,formatOptions:p}=vU(c);if(this.formats[u]){let f=l;try{const d=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=d.locale||d.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...p,...s,...d})}catch(d){this.logger.warn(d)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const NU=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class jU extends $h{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=qs.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(u=>{let p=!0;n.forEach(f=>{const d=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?a[d]===void 0&&(a[d]=!0):(this.state[d]=1,p=!1,a[d]===void 0&&(a[d]=!0),i[d]===void 0&&(i[d]=!0),c[f]===void 0&&(c[f]=!0)))}),p||(l[u]=!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=>{oU(c.loaded,[i],a),NU(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const p=c.loaded[u];p.length&&p.forEach(f=>{l[u][f]===void 0&&(l[u][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=(u,p)=>{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(u&&p&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(u,p)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(p=>l(null,p)).catch(l):l(null,u)}catch(u){l(u)}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();pt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),pt(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},u=this.backend.create.bind(this.backend);if(u.length<6)try{let p;u.length===5?p=u(t,n,r,s,c):p=u(t,n,r,s),p&&typeof p.then=="function"?p.then(f=>l(null,f)).catch(l):l(null,p)}catch(p){l(p)}else u(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]),pt(e[1])&&(t.defaultValue=e[1]),pt(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}}),gj=e=>(pt(e.ns)&&(e.ns=[e.ns]),pt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),pt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Sf=()=>{},CU=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class zu extends $h{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=gj(t),this.services={},this.logger=qs,this.modules={external:[]},CU(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&&(pt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=mj();this.options={...s,...this.options,...gj(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=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?qs.init(i(this.modules.logger),this.options):qs.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:typeof Intl<"u"&&(p=SU);const f=new fj(this.options);this.store=new uj(this.options.resources,this.options);const d=this.services;d.logger=qs,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new bU(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(d.formatter=i(p),d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new kU(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new jU(i(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(h,...b)}),this.modules.languageDetector&&(d.languageDetector=i(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=i(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new Up(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(h,...b)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Sf),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[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(p=>{this[p]=function(){return t.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return t.store[p](...arguments),t}});const c=_c(),u=()=>{const p=(f,d)=>{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(d),r(f,d)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Sf;const s=pt(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(u=>{u!=="cimode"&&i.indexOf(u)<0&&i.push(u)})};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=_c();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=Sf),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"&&sI.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=_c();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,u)=>{u?(i(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):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 u=pt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,p=>{a(p,u)})};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 u=arguments.length,p=new Array(u>2?u-2:0),f=2;f<u;f++)p[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(p))}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 d=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${c.keyPrefix}${d}${g}`):h=c.keyPrefix?`${c.keyPrefix}${d}${a}`:a,s.t(h,c)};return pt(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 u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===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=_c();return this.options.ns?(pt(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=_c();pt(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 fj(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 zu(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Sf;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new zu(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 uj(this.store.data,s),i.services.resourceStore=i.store),i.translator=new Up(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),p=1;p<c;p++)u[p-1]=arguments[p];i.emit(l,...u)}),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 Gn=zu.createInstance();Gn.createInstance=zu.createInstance;Gn.createInstance;Gn.dir;Gn.init;Gn.loadResources;Gn.reloadResources;Gn.use;Gn.changeLanguage;Gn.getFixedT;Gn.t;Gn.exists;Gn.setDefaultNamespace;Gn.hasLoadedNamespace;Gn.loadNamespaces;Gn.loadLanguages;function _U(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Hu(e){"@babel/helpers - typeof";return Hu=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},Hu(e)}function EU(e,t){if(Hu(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Hu(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function AU(e){var t=EU(e,"string");return Hu(t)=="symbol"?t:t+""}function PU(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,AU(r.key),r)}}function IU(e,t,n){return t&&PU(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var iI=[],TU=iI.forEach,RU=iI.slice;function MU(e){return TU.call(RU.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var yj=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,$U=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(!yj.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!yj.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},xj={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=$U(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)}},LU={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=xj.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&xj.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},OU={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}},Ec=null,wj=function(){if(Ec!==null)return Ec;try{Ec=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Ec=!1}return Ec},DU={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&wj()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&wj()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ac=null,bj=function(){if(Ac!==null)return Ac;try{Ac=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ac=!1}return Ac},FU={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)}},zU={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}},HU={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}},BU={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}},WU={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]}},oI=!1;try{document.cookie,oI=!0}catch{}var aI=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];oI||aI.splice(1,1);function VU(){return{order:aI,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var lI=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_U(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return IU(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=MU(r,this.options||{},VU()),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(LU),this.addDetector(OU),this.addDetector(DU),this.addDetector(FU),this.addDetector(zU),this.addDetector(HU),this.addDetector(BU),this.addDetector(WU)}},{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)}))}}])}();lI.type="languageDetector";const KU={name:"AgentFlow",tagline:"AI Workflow Orchestration"},UU={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},qU={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"},YU={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},GU={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},JU={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},XU={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},QU={app:KU,nav:UU,common:qU,status:YU,nodeTypes:GU,engine:JU,links:XU},ZU="Flow Editor",eq="Nodes",tq="Edges",nq="Properties",rq={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"},sq={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",description:"Description / format",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",pinDescriptionAriaLabel:"{{label}} {{index}} format description",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}}"},iq={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},oq={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},aq={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"},lq={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)"},cq={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},uq={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},dq={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},fq={node:"Node",text:"Text",file:"File",bool:"Boolean"},pq={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"},hq={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",saveViewport:"Save current entry view",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},mq={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},gq={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."},yq={mainNav:"Main Navigation"},xq={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'},wq={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):
275
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
276
- 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}}"},bq={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"},kq={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},vq={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}}"},Sq={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"},Nq={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"},jq={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"},Cq={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"},_q={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"},Eq={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},Aq={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},Pq={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"},Iq={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."},Tq={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},Rq={save:"Save",cancel:"Cancel"},Mq={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},$q={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},Lq={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"},Oq={title:ZU,nodes:eq,edges:tq,properties:nq,node:rq,nodeProps:sq,actions:iq,panel:oq,palette:aq,pipeline:lq,status:cq,roles:uq,phases:dq,types:fq,runContext:pq,shortcuts:hq,jumpPalette:mq,emptyCanvas:gq,sidebar:yq,validation:xq,composer:wq,topbar:bq,palette2:kq,run:vq,fileEdit:Sq,settings:Nq,schedule:jq,history:Cq,nodePropsError:_q,placeholder:Eq,time:Aq,userCheck:Pq,userAsk:Iq,toolPrint:Tq,provideEdit:Rq,runParams:Mq,runPreset:$q,runConfig:Lq},Dq="Settings",Fq={engine:"Engine Settings",preferences:"Global Preferences"},zq={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)."},Hq={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..."}},Bq={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."},Wq={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."},Vq={title:"Codex CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Codex model id list",description:"Model list comes from codex debug models --bundled. Run 'codex login' first."},Kq={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",noteAdmin:"Configure personal or global env; personal values override global values",saving:"Saving...",key:"Key",value:"Value",scope:"Scope",personal:"Personal",global:"Global",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)"},Uq={title:"User Allowlist",description:"Only controls which usernames may register or sign in. Users set their own password on first sign-in.",enabled:"Allowlist enabled",open:"Open registration",refreshing:"Refreshing...",saving:"Saving...",file:"File",fileList:"File allowlist",envList:"Environment allowlist",readonly:"Read-only",userCount:"{{count}} users",remove:"Remove {{username}}",emptyFile:"No file allowlist configured. If env allowlist is also empty, every username can register.",emptyEnv:"AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS is not configured",unionHint:"The file allowlist and env allowlist are combined. This only stores usernames, never passwords.",add:"Add"},qq={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},Yq={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},Gq={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},Jq={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."},Xq={title:Dq,crumb:Fq,workspace:zq,cursor:Hq,opencode:Bq,claudeCode:Wq,codex:Vq,env:Kq,allowlist:Uq,system:qq,shortcuts:Yq,language:Gq,onboarding:Jq},Qq={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},Zq={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)"},eY={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},tY={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},nY={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},rY={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},sY={aiLabels:Qq,placeholders:Zq,actions:eY,labels:tY,tooltips:nY,rightPanel:rY},iY="Projects",oY="All",aY="Archived",lY="Nodes",cY="My Nodes",uY="My Flows",dY="Skills",fY="Active Projects",pY="Archived Pipelines",hY="Global Nodes",mY="All Nodes",gY="My Nodes",yY="Manage node versions published to the current workspace marketplace, {{count}} total.",xY="Manage flow snippets published to the current workspace marketplace, {{count}} total.",wY="Global Skills",bY="Create New Project",kY="New Pipeline",vY="SEARCH PIPELINES...",SY="SEARCH NODES...",NY="SEARCH FLOW SNIPPETS...",jY="SEARCH SKILLS...",CY="Refresh Resources",_Y="Loading pipelines...",EY="Loading global resources...",AY="Filter result: {{count}} items (matching title, description, path and tags)",PY="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",IY="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",TY="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",RY="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",MY="Executable building blocks for pipeline runtime",$Y="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.",LY="Published local node packages",OY="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",DY="Published flow snippets",FY="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",zY="Operating guides for Composer and agents",HY="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",BY="No archived projects.",WY="No active pipelines; archived items are in the Archived tab.",VY="No global nodes available.",KY="No marketplace nodes have been published.",UY="No flow snippets have been published. Select multiple canvas nodes and publish them first.",qY="No skills available.",YY="No description.",GY='No node matches "{{query}}".',JY='No flow snippet matches "{{query}}".',XY='No skill matches "{{query}}".',QY="{{inputs}} in / {{outputs}} out",ZY="Flow Snippet",eG="{{nodes}} nodes / {{edges}} edges",tG="Skill",nG="Node detail",rG="Flow snippet detail",sG="Skill detail",iG="Type",oG="Source",aG="Package",lG="Version",cG="Path",uG="Editable",dG="Read only",fG="Editable",pG="Schema",hG="Inputs",mG="Outputs",gG="Runtime",yG="Node Body",xG="Files",wG="Usage",bG="No runtime manifest.",kG="No node body or README.",vG="No previewable files.",SG="Select a file to preview.",NG="Binary file preview is not supported.",jG="Large file; showing the first 256KB only.",CG="No pipelines using this node were found.",_G="Node Management",EG="Delete Node Version",AG="Deleting...",PG="AgentFlow checks all flow references before deleting; installed or used versions are kept.",IG="Delete {{id}}@{{version}}? This cannot be undone.",TG="Deleted {{id}}@{{version}}.",RG="{{count}} flow(s) still use it.",MG="Flow Snippet Management",$G="Delete Flow Snippet",LG="Deleting...",OG="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",DG="Delete {{id}}@{{version}}? This cannot be undone.",FG="Deleted {{id}}@{{version}}.",zG="No slots",HG="Purpose",BG="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",WG="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.",VG="Scale",KG="Flow Preview",UG="Edges",qG="Snippet JSON",YG="{{count}} more edge(s)",GG="No previewable nodes.",JG="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",XG="SKILL.md Preview",QG="No preview content available.",ZG="Select a resource to inspect details.",eJ="Failed to load pipeline list.",tJ="No pipelines in current workspace.",nJ="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.",rJ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',sJ="Recent Activity",iJ="No recent activity",oJ="No recent activity matching the keyword",aJ="Recent Run",lJ="Recent Open",cJ={builtin:"Built-in",workspace:"Workspace",user:"User"},uJ={flow:"Flow",global:"Global",marketplace:"Marketplace"},dJ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},fJ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},pJ="Open to edit this pipeline in the node canvas.",hJ={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>"},mJ={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"},gJ={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"},yJ={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"},xJ={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"},wJ={title:iY,all:oY,archived:aY,nodes:lY,myNodes:cY,myFlows:uY,skills:dY,activeProjects:fY,archivedPipelines:pY,globalNodes:hY,nodeScopeAll:mY,nodeScopeMine:gY,myNodesHint:yY,myFlowsHint:xY,globalSkills:wY,createNew:bY,newPipeline:kY,searchPipelines:vY,searchNodes:SY,searchFlows:NY,searchSkills:jY,refreshResources:CY,loadingPipelines:_Y,loadingResources:EY,filterResult:AY,archivedHint:PY,activeHint:IY,nodesHint:TY,skillsHint:RY,nodesPurposeTitle:MY,nodesPurposeDesc:$Y,myNodesPurposeTitle:LY,myNodesPurposeDesc:OY,myFlowsPurposeTitle:DY,myFlowsPurposeDesc:FY,skillsPurposeTitle:zY,skillsPurposeDesc:HY,noArchived:BY,noActive:WY,noNodes:VY,noMyNodes:KY,noMyFlows:UY,noSkills:qY,noDescription:YY,noNodeMatch:GY,noFlowSnippetMatch:JY,noSkillMatch:XY,nodeSlots:QY,flowSnippet:ZY,flowSnippetNodes:eG,skill:tG,nodeDetail:nG,flowDetail:rG,skillDetail:sG,detailType:iG,detailSource:oG,detailPackage:aG,detailVersion:lG,detailPath:cG,detailEditable:uG,readOnly:dG,editable:fG,nodeSchema:pG,nodeInputs:hG,nodeOutputs:mG,nodeRuntime:gG,nodeBody:yG,nodeFiles:xG,nodeUsage:wG,noRuntimeManifest:bG,noNodeBody:kG,noNodeFiles:vG,selectNodeFile:SG,binaryFile:NG,fileTruncated:jG,noNodeUsage:CG,myNodeManagement:_G,deleteMyNode:EG,deletingMyNode:AG,deleteMyNodeHint:PG,deleteMyNodeConfirm:IG,deleteMyNodeSuccess:TG,deleteMyNodeUsedBy:RG,myFlowManagement:MG,deleteMyFlow:$G,deletingMyFlow:LG,deleteMyFlowHint:OG,deleteMyFlowConfirm:DG,deleteMyFlowSuccess:FG,noSlots:zG,resourceMeaning:HG,nodesMeaning:BG,myFlowsMeaning:WG,flowSnippetScale:VG,flowSnippetPreview:KG,flowSnippetEdges:UG,flowSnippetJson:qG,flowSnippetMoreEdges:YG,noFlowSnippetPreview:GG,skillsMeaning:JG,skillPreview:XG,skillPreviewEmpty:QG,selectResource:ZG,loadFailed:eJ,noPipelines:tJ,emptyHint:nJ,noMatch:rJ,recentActivity:sJ,noRecentActivity:iJ,noMatchRecent:oJ,recentRun:aJ,recentOpen:lJ,sourceBadge:cJ,resourceSource:uJ,resourceFilter:dJ,nodeDetailTabs:fJ,defaultCardDesc:pJ,hubCard:hJ,newPipelineModal:mJ,importModal:gJ,deleteModal:yJ,archiveModal:xJ},bJ="Back",kJ="Next",vJ="Skip",SJ="Done",NJ="Start Creating",jJ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
277
-
278
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
279
-
280
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},CJ={intro:`Now you're in the flow editor.
281
-
282
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
283
-
284
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
285
-
286
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
287
-
288
- The left node panel allows you to freely drag, delete, and adjust connections.`},_J={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"},EJ={back:bJ,next:kJ,skip:vJ,done:SJ,startCreate:NJ,projects:jJ,flow:CJ,newPipeline:_J},AJ={name:"AgentFlow",tagline:"AI 工作流编排"},PJ={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},IJ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},TJ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},RJ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},MJ={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},$J={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},LJ={app:AJ,nav:PJ,common:IJ,status:TJ,nodeTypes:RJ,engine:MJ,links:$J},OJ="流程编辑器",DJ="节点",FJ="连线",zJ="属性",HJ={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:"编辑内容"},BJ={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",description:"描述 / 格式",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",pinDescriptionAriaLabel:"{{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}}"},WJ={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},VJ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},KJ={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},UJ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},qJ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},YJ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},GJ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},JJ={node:"节点",text:"文本",file:"文件",bool:"布尔"},XJ={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:"等待"},QJ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},ZJ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},eX={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},tX={mainNav:"主导航"},nX={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},rX={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}} 步):
289
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
290
- 当前:{{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}}"},sX={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},iX={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},oX={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}} 的分支"},aX={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},lX={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:"已复制"},cX={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:"定时配置已保存"},uX={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},dX={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},fX={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},pX={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},hX={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},mX={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},gX={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},yX={save:"保存",cancel:"取消"},xX={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},wX={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},bX={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},kX={title:OJ,nodes:DJ,edges:FJ,properties:zJ,node:HJ,nodeProps:BJ,actions:WJ,panel:VJ,palette:KJ,pipeline:UJ,status:qJ,roles:YJ,phases:GJ,types:JJ,runContext:XJ,shortcuts:QJ,jumpPalette:ZJ,emptyCanvas:eX,sidebar:tX,validation:nX,composer:rX,topbar:sX,palette2:iX,run:oX,fileEdit:aX,settings:lX,schedule:cX,history:uX,nodePropsError:dX,placeholder:fX,time:pX,userCheck:hX,userAsk:mX,toolPrint:gX,provideEdit:yX,runParams:xX,runPreset:wX,runConfig:bX},vX="设置",SX={engine:"引擎设置",preferences:"全局首选项"},NX={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},jX={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},CX={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},_X={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},EX={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},AX={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},PX={title:"用户白名单",description:"只控制 username 是否允许注册或登录,密码由用户首次登录时自行设置。",enabled:"白名单已启用",open:"开放注册",refreshing:"刷新中...",saving:"保存中...",file:"文件",fileList:"文件白名单",envList:"环境变量白名单",readonly:"只读",userCount:"{{count}} 个用户",remove:"删除 {{username}}",emptyFile:"未配置文件白名单;如果环境变量也为空,则所有用户可注册。",emptyEnv:"未配置 AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS",unionHint:"文件白名单与环境变量白名单取并集;这里只会保存用户名,不保存密码。",add:"添加"},IX={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},TX={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},RX={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},MX={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},$X={title:vX,crumb:SX,workspace:NX,cursor:jX,opencode:CX,claudeCode:_X,codex:EX,env:AX,allowlist:PX,system:IX,shortcuts:TX,language:RX,onboarding:MX},LX={thinking:"思考",result:"结果",reply:"回复",error:"错误"},OX={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},DX={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},FX={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},zX={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},HX={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},BX={aiLabels:LX,placeholders:OX,actions:DX,labels:FX,tooltips:zX,rightPanel:HX},WX="项目",VX="全部",KX="已归档",UX="Nodes",qX="我的 Nodes",YX="我的流程",GX="Skills",JX="活跃项目",XX="已归档流水线",QX="全局 Nodes",ZX="全部 Nodes",eQ="我的 Nodes",tQ="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",nQ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",rQ="全局 Skills",sQ="创建新项目",iQ="新建流水线",oQ="搜索流水线…",aQ="搜索 nodes…",lQ="搜索流程片段…",cQ="搜索 skills…",uQ="刷新资源",dQ="加载流水线列表…",fQ="加载全局资源…",pQ="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",hQ="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",mQ="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",gQ="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",yQ="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",xQ="流程运行时的可执行积木",wQ="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",bQ="已发布的本地节点包",kQ="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",vQ="已发布的流程片段",SQ="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",NQ="Composer/Agent 的操作指南",jQ="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",CQ="暂无归档项目。",_Q="暂无未归档流水线;已归档项在 Archived 标签中查看。",EQ="暂无可用全局 nodes。",AQ="暂无已发布的 marketplace nodes。",PQ="暂无已发布的流程片段。可在画布中选中多个节点后发布。",IQ="暂无可用 skills。",TQ="暂无描述。",RQ="未找到与「{{query}}」匹配的 node。",MQ="未找到与「{{query}}」匹配的流程片段。",$Q="未找到与「{{query}}」匹配的 skill。",LQ="{{inputs}} in / {{outputs}} out",OQ="流程片段",DQ="{{nodes}} 节点 / {{edges}} 连线",FQ="Skill",zQ="Node 详情",HQ="流程片段详情",BQ="Skill 详情",WQ="类型",VQ="来源",KQ="包",UQ="版本",qQ="路径",YQ="可编辑",GQ="只读",JQ="可编辑",XQ="Schema",QQ="输入",ZQ="输出",eZ="Runtime",tZ="节点内容",nZ="Files",rZ="Usage",sZ="暂无 runtime manifest。",iZ="暂无节点正文或 README。",oZ="暂无可预览文件。",aZ="请选择文件查看内容。",lZ="二进制文件暂不支持预览。",cZ="文件较大,仅显示前 256KB。",uZ="暂未发现使用此 node 的流水线。",dZ="节点管理",fZ="删除节点版本",pZ="删除中…",hZ="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",mZ="确定删除 {{id}}@{{version}}?此操作不可撤销。",gZ="已删除 {{id}}@{{version}}。",yZ="仍有 {{count}} 个 Flow 使用它。",xZ="流程片段管理",wZ="删除流程片段",bZ="删除中…",kZ="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",vZ="确定删除 {{id}}@{{version}}?此操作不可撤销。",SZ="已删除 {{id}}@{{version}}。",NZ="无槽位",jZ="作用",CZ="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",_Z="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",EZ="规模",AZ="流程预览",PZ="连线",IZ="片段 JSON",TZ="还有 {{count}} 条连线",RZ="暂无可预览节点。",MZ="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",$Z="SKILL.md 预览",LZ="暂无可预览内容。",OZ="请选择一个资源查看详情。",DZ="未能加载流水线列表。",FZ="当前工作区暂无流水线。",zZ="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",HZ="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",BZ="最近打开或最近运行",WZ="暂无打开或运行记录",VZ="暂无与关键词匹配的最近记录",KZ="最近运行",UZ="最近打开",qZ={builtin:"内置",workspace:"工作区",user:"用户"},YZ={flow:"Flow",global:"Global",marketplace:"Marketplace"},GZ={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},JZ={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},XZ="打开以在节点画布中编辑此流水线。",QZ={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},ZZ={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:"关闭"},eee={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},tee={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},nee={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},ree={title:WX,all:VX,archived:KX,nodes:UX,myNodes:qX,myFlows:YX,skills:GX,activeProjects:JX,archivedPipelines:XX,globalNodes:QX,nodeScopeAll:ZX,nodeScopeMine:eQ,myNodesHint:tQ,myFlowsHint:nQ,globalSkills:rQ,createNew:sQ,newPipeline:iQ,searchPipelines:oQ,searchNodes:aQ,searchFlows:lQ,searchSkills:cQ,refreshResources:uQ,loadingPipelines:dQ,loadingResources:fQ,filterResult:pQ,archivedHint:hQ,activeHint:mQ,nodesHint:gQ,skillsHint:yQ,nodesPurposeTitle:xQ,nodesPurposeDesc:wQ,myNodesPurposeTitle:bQ,myNodesPurposeDesc:kQ,myFlowsPurposeTitle:vQ,myFlowsPurposeDesc:SQ,skillsPurposeTitle:NQ,skillsPurposeDesc:jQ,noArchived:CQ,noActive:_Q,noNodes:EQ,noMyNodes:AQ,noMyFlows:PQ,noSkills:IQ,noDescription:TQ,noNodeMatch:RQ,noFlowSnippetMatch:MQ,noSkillMatch:$Q,nodeSlots:LQ,flowSnippet:OQ,flowSnippetNodes:DQ,skill:FQ,nodeDetail:zQ,flowDetail:HQ,skillDetail:BQ,detailType:WQ,detailSource:VQ,detailPackage:KQ,detailVersion:UQ,detailPath:qQ,detailEditable:YQ,readOnly:GQ,editable:JQ,nodeSchema:XQ,nodeInputs:QQ,nodeOutputs:ZQ,nodeRuntime:eZ,nodeBody:tZ,nodeFiles:nZ,nodeUsage:rZ,noRuntimeManifest:sZ,noNodeBody:iZ,noNodeFiles:oZ,selectNodeFile:aZ,binaryFile:lZ,fileTruncated:cZ,noNodeUsage:uZ,myNodeManagement:dZ,deleteMyNode:fZ,deletingMyNode:pZ,deleteMyNodeHint:hZ,deleteMyNodeConfirm:mZ,deleteMyNodeSuccess:gZ,deleteMyNodeUsedBy:yZ,myFlowManagement:xZ,deleteMyFlow:wZ,deletingMyFlow:bZ,deleteMyFlowHint:kZ,deleteMyFlowConfirm:vZ,deleteMyFlowSuccess:SZ,noSlots:NZ,resourceMeaning:jZ,nodesMeaning:CZ,myFlowsMeaning:_Z,flowSnippetScale:EZ,flowSnippetPreview:AZ,flowSnippetEdges:PZ,flowSnippetJson:IZ,flowSnippetMoreEdges:TZ,noFlowSnippetPreview:RZ,skillsMeaning:MZ,skillPreview:$Z,skillPreviewEmpty:LZ,selectResource:OZ,loadFailed:DZ,noPipelines:FZ,emptyHint:zZ,noMatch:HZ,recentActivity:BZ,noRecentActivity:WZ,noMatchRecent:VZ,recentRun:KZ,recentOpen:UZ,sourceBadge:qZ,resourceSource:YZ,resourceFilter:GZ,nodeDetailTabs:JZ,defaultCardDesc:XZ,hubCard:QZ,newPipelineModal:ZZ,importModal:eee,deleteModal:tee,archiveModal:nee},see="返回",iee="下一步",oee="跳过",aee="完成",lee="开始创建",cee={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
291
-
292
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
293
-
294
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},uee={intro:`现在进入流程编辑器。
295
-
296
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
297
-
298
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
299
-
300
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
301
-
302
- 左侧节点面板可以自由拖拽、删除和调整连接。`},dee={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},fee={back:see,next:iee,skip:oee,done:aee,startCreate:lee,projects:cee,flow:uee,newPipeline:dee},pee={en:{common:QU,flow:Oq,settings:Xq,composer:sY,project:wJ,onboarding:EJ},zh:{common:LJ,flow:kX,settings:$X,composer:BX,project:ree,onboarding:fee}};Gn.use(lI).use(W2).init({resources:pee,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 hee=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function mee(e){return Gn.changeLanguage(e)}const vx="agentflow-settings-opencode-plan-v1";function vg(e){if(!e||typeof e!="object")return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt: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):[],codex:Array.isArray(t.codex)?t.codex.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null,codexFetchedAt:t.codexFetchedAt??null}}function cI(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function gee(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Lo(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const s=String(r.key??"").trim(),i=String(r.value??""),a=String(r.id??"").trim()||cI(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:c})}return n}function kj(e){return Lo(e).map(({key:t,value:n})=>({key:t,value:n}))}function vj(){try{return localStorage.getItem(vx)??""}catch{return""}}function yee(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function xb(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function uI({baseUrl:e="",token:t=""}){return JSON.stringify({mcpServers:{agentflow:{command:"agentflow",args:["mcp"],env:{AGENTFLOW_BASE_URL:String(e||"http://127.0.0.1:8875"),AGENTFLOW_TOKEN:xb(t)}}}},null,2)}function dI({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(xb(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
303
- `)}function xee({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=uI({baseUrl:n,token:t}),s=dI({baseUrl:n,token:t});return["你是一个 AI Coding Agent。请帮我把 AgentFlow 配置成当前开发环境可用的 MCP server。","","这是一项配置任务,不是调用任务:请修改 Cursor 或 Codex 的 MCP 配置文件,让它们能连接本机 AgentFlow。","","AgentFlow MCP server 信息:","- server name: agentflow","- command: agentflow",'- args: ["mcp"]',`- env.AGENTFLOW_BASE_URL: ${n}`,`- env.AGENTFLOW_TOKEN: ${xb(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",s,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 设置页点击“使用当前登录 Token”后重新复制。","","配置后验证:","- 确认 `agentflow` 命令在 PATH 中可用。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
304
- `)}function wee(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 bee({authUser:e}){const{t,i18n:n}=pr(["common","settings"]),r=n.language||"zh",[s,i]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[p,f]=m.useState(""),[d,h]=m.useState(!1),[g,b]=m.useState(!1),[v,y]=m.useState(""),[w,x]=m.useState([]),[S,C]=m.useState(""),[j,E]=m.useState(!1),[P,F]=m.useState(""),[V,z]=m.useState(""),[D,R]=m.useState(!1),[T,L]=m.useState(()=>new Set),[$,O]=m.useState(""),[A,M]=m.useState([]),[_,U]=m.useState([]),[q,B]=m.useState(""),[Q,se]=m.useState(""),[oe,ve]=m.useState(()=>{var Z;return typeof window<"u"&&((Z=window.location)!=null&&Z.origin)?window.location.origin:"http://127.0.0.1:8875"}),[re,ue]=m.useState(""),[te,ae]=m.useState(""),[pe,be]=m.useState(!1),[Fe,Ue]=m.useState(!1),[Me,et]=m.useState(""),[ht,Ie]=m.useState(""),[tt,Wt]=m.useState(""),[$e,Vt]=m.useState(null),[Gt,nt]=m.useState(!1),[ie,ke]=m.useState(!1),[Oe,We]=m.useState(""),Je=m.useRef(null),vt=m.useRef(!1),ee=m.useRef(!1),ye=m.useRef(""),Ve=m.useCallback(async()=>{l("");try{const Z=await fetch("/api/ui-context");if(!Z.ok)throw new Error("HTTP "+Z.status);const ge=await Z.json();i(typeof ge.workspaceRoot=="string"?ge.workspaceRoot:"")}catch(Z){l(String(Z.message||Z)),i("")}},[]),Ce=m.useCallback(async()=>{f(""),h(!0);try{const Z=await fetch("/api/model-lists");if(!Z.ok)throw new Error("HTTP "+Z.status);const ge=await Z.json();u(vg(ge))}catch(Z){f(String(Z.message||Z))}finally{h(!1)}},[]),at=m.useCallback(async()=>{C("");try{const Z=await fetch("/api/user-env"),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);const Ae=Lo(Array.isArray(ge.env)?ge.env:[],"user").map(Kt=>({...Kt,scope:"user"})),Ct=[...e!=null&&e.isAdmin?Lo(Array.isArray(ge.globalEnv)?ge.globalEnv:[],"global").map(Kt=>({...Kt,scope:"global"})):[],...Ae];ye.current=JSON.stringify(Ct),x(Ct)}catch(Z){x([]),C(String(Z.message||Z))}finally{ee.current=!0}},[e==null?void 0:e.isAdmin]),mt=m.useCallback(async()=>{if(e!=null&&e.isAdmin){be(!0),et("");try{const Z=await fetch("/api/admin/user-allowlist"),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);const Ae=ge.allowlist&&typeof ge.allowlist=="object"?ge.allowlist:{};M(Array.isArray(Ae.fileUsers)?Ae.fileUsers.map(String):[]),U(Array.isArray(Ae.envUsers)?Ae.envUsers.map(String):[]),B(typeof Ae.path=="string"?Ae.path:"")}catch(Z){et(String(Z.message||Z))}finally{be(!1)}}},[e==null?void 0:e.isAdmin]),Qt=m.useCallback(async Z=>{if(e!=null&&e.isAdmin){Ue(!0),et("");try{const ge=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:Z})}),Ae=await ge.json().catch(()=>({}));if(!ge.ok)throw new Error(typeof Ae.error=="string"?Ae.error:"HTTP "+ge.status);const bt=Ae.allowlist&&typeof Ae.allowlist=="object"?Ae.allowlist:{};M(Array.isArray(bt.fileUsers)?bt.fileUsers.map(String):[]),U(Array.isArray(bt.envUsers)?bt.envUsers.map(String):[]),B(typeof bt.path=="string"?bt.path:"")}catch(ge){et(String(ge.message||ge))}finally{Ue(!1)}}},[e==null?void 0:e.isAdmin]),hr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){nt(!0),We("");try{const Z=await fetch("/api/admin/storage-config"),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);const Ae=ge.config&&typeof ge.config=="object"?ge.config:{};Vt(Ae),Ie(typeof Ae.dataRoot=="string"?Ae.dataRoot:""),Wt(typeof Ae.skillsRoot=="string"?Ae.skillsRoot:"")}catch(Z){We(String(Z.message||Z))}finally{nt(!1)}}},[e==null?void 0:e.isAdmin]),Ln=m.useCallback(async()=>{if(e!=null&&e.isAdmin){ke(!0),We("");try{const Z=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ht.trim(),skillsRoot:tt.trim(),migrateLegacySkills:!0})}),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);const Ae=ge.config&&typeof ge.config=="object"?ge.config:{};Vt(Ae),Ie(typeof Ae.dataRoot=="string"?Ae.dataRoot:""),Wt(typeof Ae.skillsRoot=="string"?Ae.skillsRoot:"")}catch(Z){We(String(Z.message||Z))}finally{ke(!1)}}},[e==null?void 0:e.isAdmin,ht,tt]),On=m.useCallback(async Z=>{const ge=Lo(Z),Ae=ge.filter(Ct=>Ct.scope!=="global"),bt=ge.filter(Ct=>Ct.scope==="global");E(!0),C("");try{const Ct=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:kj(Ae),...e!=null&&e.isAdmin?{globalEnv:kj(bt)}:{}})}),Kt=await Ct.json().catch(()=>({}));if(!Ct.ok)throw new Error(typeof Kt.error=="string"?Kt.error:"HTTP "+Ct.status);const qe=Lo(Array.isArray(Kt.env)?Kt.env:[],"user").map(Ut=>({...Ut,scope:"user"})),Pe=[...e!=null&&e.isAdmin?Lo(Array.isArray(Kt.globalEnv)?Kt.globalEnv:[],"global").map(Ut=>({...Ut,scope:"global"})):[],...qe];ye.current=JSON.stringify(Pe),x(Pe)}catch(Ct){C(String(Ct.message||Ct))}finally{E(!1)}},[e==null?void 0:e.isAdmin]),Nn=m.useCallback(async()=>{f(""),h(!0);try{const Z=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:$.trim()})}),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);u(vg(ge.modelLists))}catch(Z){f(String(Z.message||Z))}finally{h(!1)}},[$]);m.useEffect(()=>{Ve(),Ce(),at(),e!=null&&e.isAdmin&&(mt(),hr()),(async()=>{try{const Z=await fetch("/api/agentflow-config");if(Z.ok){const ge=await Z.json(),Ae=typeof ge.opencodeProvider=="string"?ge.opencodeProvider:"";O(Ae),Je.current=Ae;try{localStorage.setItem(vx,Ae)}catch{}}else{const ge=vj();O(ge),Je.current=ge}}catch{const Z=vj();O(Z),Je.current=Z}finally{vt.current=!0}})()},[e==null?void 0:e.isAdmin,Ve,Ce,hr,mt,at]),m.useEffect(()=>{if(!ee.current||JSON.stringify(Lo(w))===ye.current)return;const ge=setTimeout(()=>{On(w)},350);return()=>clearTimeout(ge)},[w,On]),m.useEffect(()=>{if(!vt.current)return;const Z=$.trim();if(Z===Je.current)return;const ge=setTimeout(()=>{(async()=>{b(!0),y("");try{const Ae=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z})}),bt=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(typeof bt.error=="string"?bt.error:"HTTP "+Ae.status);Je.current=Z;try{localStorage.setItem(vx,Z)}catch{}bt.modelLists&&u(vg(bt.modelLists))}catch(Ae){y(String(Ae.message||Ae))}finally{b(!1)}})()},450);return()=>clearTimeout(ge)},[$]);const Zt=c.cursor.length>0,Kn=c.opencode.length>0,pn=c.claudeCode.length>0,Pn=c.codex.length>0,jn=A.length>0||_.length>0,Dn=m.useMemo(()=>uI({baseUrl:oe,token:re}),[oe,re]),Er=m.useMemo(()=>dI({baseUrl:oe,token:re}),[oe,re]),Fn=m.useMemo(()=>xee({baseUrl:oe,token:re}),[oe,re]),si=m.useCallback(()=>{var Z;s&&((Z=navigator.clipboard)==null||Z.writeText(s))},[s]),mr=m.useCallback(()=>{var Z;Fn&&((Z=navigator.clipboard)==null||Z.writeText(Fn),ae("prompt"),window.setTimeout(()=>ae(""),1200))},[Fn]),Ur=m.useCallback(()=>{var Z;(Z=navigator.clipboard)==null||Z.writeText(Dn),ae("cursor"),window.setTimeout(()=>ae(""),1200)},[Dn]),Ar=m.useCallback(()=>{var Z;(Z=navigator.clipboard)==null||Z.writeText(Er),ae("codex"),window.setTimeout(()=>ae(""),1200)},[Er]),ss=m.useCallback(async()=>{try{const Z=await fetch("/api/auth/session-token"),ge=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(typeof ge.error=="string"?ge.error:"HTTP "+Z.status);ue(String(ge.token||"")),ae("token"),window.setTimeout(()=>ae(""),1200)}catch(Z){ae(""),l(String(Z.message||Z))}},[]),In=m.useCallback(()=>{const Z=P.trim(),ge=V;if(Z){if(!gee(Z)){C(t("settings:env.invalidKey"));return}x(Ae=>[{id:cI(),key:Z,value:ge,scope:e!=null&&e.isAdmin&&D?"global":"user"},...Ae]),F(""),z("")}},[e==null?void 0:e.isAdmin,D,P,V,t]),gr=m.useCallback(Z=>{x(ge=>ge.filter(Ae=>Ae.id!==Z))},[]),rr=m.useCallback((Z,ge)=>{x(Ae=>Ae.map(bt=>bt.id===Z?{...bt,...ge}:bt))},[]),Ms=m.useCallback(Z=>{L(ge=>{const Ae=new Set(ge);return Ae.has(Z)?Ae.delete(Z):Ae.add(Z),Ae})},[]),Pr=m.useCallback(()=>{const Z=Q.trim();if(!Z)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(Z)){et("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(A.map(Ae=>String(Ae||"").trim().toLowerCase())).has(Z.toLowerCase())){se("");return}se(""),Qt([...A,Z])},[Q,A,Qt]),zt=m.useCallback(Z=>{const ge=String(Z||"").trim().toLowerCase();ge&&Qt(A.filter(Ae=>String(Ae||"").trim().toLowerCase()!==ge))},[A,Qt]),ne=m.useCallback(Z=>{const ge=Z.target.value;mee(ge)},[]),we=Z=>{const ge=wee(Z,r);return ge?t("settings:cursor.modelList.fetchedAt",{time:ge}):t("settings:cursor.modelList.never")};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,p?o.jsx("p",{className:"af-err af-settings-api-hint",children:p}):null,S?o.jsx("p",{className:"af-err af-settings-api-hint",children:S}):null,Oe?o.jsx("p",{className:"af-err af-settings-api-hint",children:Oe}):null]}),o.jsx("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:si,"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:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“工作区”里维护。"})]}),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"+(Zt?" af-set-badge--ok":" af-set-badge--muted"),children:t(Zt?"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:Zt?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(Zt?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Zt?t("settings:cursor.modelList.count",{count:c.cursor.length})+" · "+we(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Zt?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:c.cursor.join(`
305
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Nn(),disabled:d,children:t(d?"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"+(Kn?" af-set-badge--ok":" af-set-badge--err"),children:t(Kn?"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:$,onChange:Z=>O(Z.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,v?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:v}):null]}),Kn?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})+" · "+we(c.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:c.opencode.join(`
306
- `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Nn(),disabled:d,children:t(d?"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"+(pn?" af-set-badge--ok":" af-set-badge--err"),children:t(pn?"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:pn?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(pn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:pn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+" · "+we(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),pn?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:c.claudeCode.join(`
307
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Nn(),disabled:d,children:t(d?"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:codex.title")}),o.jsx("span",{className:"af-set-badge"+(Pn?" af-set-badge--ok":" af-set-badge--err"),children:t(Pn?"settings:codex.status.ready":"settings:codex.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:Pn?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(Pn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Pn?t("settings:cursor.modelList.count",{count:c.codex.length})+" · "+we(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Pn?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:codex.modelPreviewLabel"),children:c.codex.join(`
308
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Nn(),disabled:d,children:t(d?"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-mcp-personal",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:"lan"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"AgentFlow MCP 接入"}),o.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),o.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),o.jsx("p",{className:"af-set-hint",children:"这里不是展示 AgentFlow 已接入的外部 MCP server;那些在 MCP tab 管理。这里生成的是让其他 Agent 连接本平台的配置。"}),o.jsxs("div",{className:"af-set-mcp-connect-grid",children:[o.jsxs("label",{className:"af-set-mcp-field",children:[o.jsx("span",{children:"Base URL"}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:oe,onChange:Z=>ve(Z.target.value),placeholder:"http://127.0.0.1:8875"})]}),o.jsxs("label",{className:"af-set-mcp-field",children:[o.jsx("span",{children:"Token"}),o.jsxs("div",{className:"af-set-mcp-token-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:re,onChange:Z=>ue(Z.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:ss,children:te==="token"?"已填入":"使用当前登录 Token"})]})]})]}),o.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-set-mcp-snippet-head",children:[o.jsx("span",{children:"Cursor mcp.json"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Ur,children:te==="cursor"?"已复制":"复制"})]}),o.jsx("pre",{className:"af-set-mcp-code",children:Dn})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"af-set-mcp-snippet-head",children:[o.jsx("span",{children:"Codex config.toml"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Ar,children:te==="codex"?"已复制":"复制"})]}),o.jsx("pre",{className:"af-set-mcp-code",children:Er})]})]}),o.jsx("div",{className:"af-set-mcp-copy-row",children:o.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:mr,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),te==="prompt"?"已复制 Prompt":"复制 AI 使用 Prompt"]})}),o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),o.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:Fn})]}),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:j?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[o.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[o.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?o.jsx("span",{children:t("settings:env.scope")}):null,o.jsx("span",{children:t("settings:env.value")}),o.jsx("span",{})]}),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:P,onChange:Z=>F(Z.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:D?"":"is-active",onClick:()=>R(!1),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:D?"is-active":"",onClick:()=>R(!0),children:t("settings:env.global")})]})}):null,o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:V,onChange:Z=>z(Z.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:In,disabled:!P.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),w.map(Z=>o.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:Z.key,onChange:ge=>rr(Z.id,{key:ge.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:Z.scope!=="global"?"is-active":"",onClick:()=>rr(Z.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:Z.scope==="global"?"is-active":"",onClick:()=>rr(Z.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:T.has(Z.id)?"text":"password",value:Z.value,onChange:ge=>rr(Z.id,{value:ge.target.value}),placeholder:yee(Z.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>Ms(Z.id),"aria-label":T.has(Z.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:T.has(Z.id)?"visibility_off":"visibility"})})]}),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:Z.key}),onClick:()=>gr(Z.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},Z.id))]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",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:"hard_drive_2"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),o.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),o.jsx("span",{className:"af-set-badge"+($e!=null&&$e.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:$e!=null&&$e.envLocked?"Env locked":"Configurable"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void hr(),disabled:Gt||ie,children:Gt?"刷新中...":"刷新"})]}),Oe?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Oe}):null,o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:ht,onChange:Z=>Ie(Z.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!($e!=null&&$e.envLocked)||ie}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void Ln(),"aria-label":"保存 AgentFlow Data Root",disabled:ie||!!($e!=null&&$e.envLocked),children:o.jsx("span",{className:"material-symbols-outlined",children:ie?"hourglass_empty":"save"})})]}),o.jsxs("p",{className:"af-set-hint",children:["当前目录:",o.jsx("code",{children:($e==null?void 0:$e.dataRoot)||ht||"-"}),$e!=null&&$e.configPath?o.jsxs(o.Fragment,{children:[";配置文件:",o.jsx("code",{children:$e.configPath})]}):null]}),o.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",o.jsx("code",{children:"users/"}),"、",o.jsx("code",{children:"pipelines/"}),"、",o.jsx("code",{children:"runBuild/"}),"、",o.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",$e!=null&&$e.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:tt,onChange:Z=>Wt(Z.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!($e!=null&&$e.skillsEnvLocked)||ie}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void Ln(),"aria-label":"保存 AgentFlow Skills Root",disabled:ie||!!($e!=null&&$e.skillsEnvLocked),children:o.jsx("span",{className:"material-symbols-outlined",children:ie?"hourglass_empty":"save"})})]}),o.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",o.jsx("code",{children:($e==null?void 0:$e.skillsRoot)||tt||"-"}),$e!=null&&$e.legacySkillsRootExists?o.jsxs(o.Fragment,{children:[";保存时会补迁移旧目录 ",o.jsx("code",{children:$e.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),o.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",$e!=null&&$e.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",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:"manage_accounts"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),o.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),o.jsx("span",{className:"af-set-badge"+(jn?" af-set-badge--ok":" af-set-badge--muted"),children:t(jn?"settings:allowlist.enabled":"settings:allowlist.open")}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void mt(),disabled:pe,children:t(pe?"settings:allowlist.refreshing":"common:common.refresh")})]}),Me?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Me}):null,q?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",o.jsx("code",{children:q})]}):null,o.jsxs("div",{className:"af-allowlist-grid",children:[o.jsxs("div",{className:"af-allowlist-main",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.fileList")}),o.jsx("span",{children:Fe?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:A.length})})]}),o.jsx("div",{className:"af-allowlist-list",children:A.length>0?A.map(Z=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:Z}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>zt(Z),"aria-label":t("settings:allowlist.remove",{username:Z}),disabled:Fe,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},Z)):o.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:Q,onChange:Z=>se(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&Pr()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Pr,disabled:Fe||!Q.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.envList")}),o.jsx("span",{children:t("settings:allowlist.readonly")})]}),o.jsx("div",{className:"af-allowlist-env-list",children:_.length>0?_.map(Z=>o.jsx("code",{children:Z},Z)):o.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,o.jsxs("section",{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&&!p?"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.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.codexModels")}),o.jsx("span",{children:c.codex.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.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:ne,"aria-label":t("settings:language.description"),children:hee.map(Z=>o.jsxs("option",{value:Z.code,children:[Z.flag," ",Z.name]},Z.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function yr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Nf(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Sg(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function kee(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Ng(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function vee(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function See(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function Nee({authUser:e}){const[t,n]=m.useState(null),[r,s]=m.useState(!1),[i,a]=m.useState(""),l=m.useCallback(async()=>{if(e!=null&&e.isAdmin){s(!0),a("");try{const h=await fetch("/api/admin/usage-dashboard"),g=await h.json().catch(()=>({}));if(!h.ok)throw new Error(typeof g.error=="string"?g.error:"HTTP "+h.status);n(g)}catch(h){n(null),a(String((h==null?void 0:h.message)||h))}finally{s(!1)}}},[e==null?void 0:e.isAdmin]);m.useEffect(()=>{l()},[l]);const c=Array.isArray(t==null?void 0:t.dailyTrend)?t.dailyTrend:[],u=m.useMemo(()=>{const b={top:20,right:24,bottom:42,left:42},v=980-b.left-b.right,y=250-b.top-b.bottom,w=c.length>0?c:[],x=Math.max(1,...w.map(F=>Number(F.runs||0))),S=Math.max(1,...w.flatMap(F=>[Number(F.users||0),Number(F.pipelines||0)])),C=F=>b.left+(w.length<=1?v/2:F*v/(w.length-1)),j=F=>b.top+y-Math.max(0,Number(F||0))/x*y,E=F=>b.top+y-Math.max(0,Number(F||0))/S*y,P=F=>w.map((V,z)=>`${z===0?"M":"L"} ${C(z)} ${E(V[F])}`).join(" ");return{width:980,height:250,margin:b,innerHeight:y,rows:w,x:C,yRuns:j,yLine:E,lineUsers:P("users"),linePipelines:P("pipelines"),barWidth:Math.min(34,Math.max(12,v/Math.max(1,w.length)*.44))}},[c]),p=(t==null?void 0:t.usage)||{},f=(t==null?void 0:t.totals)||{},d=Array.isArray(t==null?void 0:t.recentRuns)?t.recentRuns:[];return e!=null&&e.isAdmin?o.jsxs("main",{className:"af-admin-usage-page",children:[o.jsxs("section",{className:"af-admin-usage-hero",children:[o.jsxs("div",{children:[o.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),o.jsx("h1",{children:"管理看板"}),o.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),o.jsxs("button",{type:"button",onClick:()=>void l(),disabled:r,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),r?"刷新中":"刷新"]})]}),i?o.jsx("div",{className:"af-project-admin-usage__error",children:i}):null,o.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[o.jsxs("div",{children:[o.jsx("span",{children:"7日活跃用户率"}),o.jsx("strong",{children:Nf(p.activeUserRate)}),o.jsxs("em",{children:[yr(p.activeUsers)," / ",yr(f.users)," users"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日流水线使用率"}),o.jsx("strong",{children:Nf(p.activePipelineRate)}),o.jsxs("em",{children:[yr(p.activePipelines)," / ",yr(f.activePipelines)," active"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日 Run"}),o.jsx("strong",{children:yr(p.runs)}),o.jsxs("em",{children:[yr(p.avgRunsPerDay)," / day"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日成功率"}),o.jsx("strong",{children:Nf(p.successRate)}),o.jsxs("em",{children:["失败率 ",Nf(p.failureRate)," · avg ",Sg(p.avgDurationMs)]})]})]}),o.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"每日趋势"}),o.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),o.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[o.jsxs("div",{className:"af-admin-usage-chart__legend",children:[o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),o.jsx("div",{className:"af-admin-usage-chart__canvas",children:o.jsxs("svg",{viewBox:`0 0 ${u.width} ${u.height}`,preserveAspectRatio:"xMidYMid meet",children:[o.jsx("line",{className:"af-admin-usage-chart__axis",x1:u.margin.left,y1:u.margin.top+u.innerHeight,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight}),[.25,.5,.75,1].map(h=>o.jsx("line",{className:"af-admin-usage-chart__grid",x1:u.margin.left,y1:u.margin.top+u.innerHeight-u.innerHeight*h,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight-u.innerHeight*h},h)),u.rows.map((h,g)=>{const b=u.x(g),v=u.yRuns(h.runs),y=u.margin.top+u.innerHeight,w=Math.max(2,y-v);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:b-u.barWidth/2,y:y-w,width:u.barWidth,height:w,rx:"5",children:o.jsx("title",{children:`${h.date}: ${h.runs} runs`})}),o.jsx("text",{className:"af-admin-usage-chart__value",x:b,y:y+22,children:yr(h.runs)}),o.jsx("text",{className:"af-admin-usage-chart__date",x:b,y:y+42,children:kee(h.date)})]},h.date)}),u.rows.length>0?o.jsxs(o.Fragment,{children:[o.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:u.lineUsers}),o.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:u.linePipelines}),u.rows.map((h,g)=>{const b=u.x(g);return o.jsxs("g",{children:[o.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:b,cy:u.yLine(h.users),r:"3.5"}),o.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:b,cy:u.yLine(h.pipelines),r:"3.5"})]},`${h.date}-points`)})]}):null]})})]}),o.jsx("div",{className:"af-project-admin-usage__table-wrap",children:o.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"用户"}),o.jsx("th",{children:"流水线"}),o.jsx("th",{children:"运行时间"}),o.jsx("th",{children:"状态"}),o.jsx("th",{children:"耗时"}),o.jsx("th",{children:"Run ID"})]})}),o.jsx("tbody",{children:d.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:6,children:"暂无运行明细"})}):d.map(h=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:h.username||h.userId||"-"}),o.jsx("span",{children:h.userId||"-"})]}),o.jsxs("td",{children:[o.jsx("strong",{children:h.flowId||"-"}),o.jsxs("span",{children:[h.runType==="workspace"?"Workspace Run":"Pipeline"," · ",h.flowSource||"user"]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:Ng(h.at)}),h.endedAt?o.jsxs("span",{children:["结束 ",Ng(h.endedAt)]}):o.jsx("span",{children:"未结束"})]}),o.jsx("td",{children:o.jsx("span",{className:"af-project-admin-usage__chips",children:o.jsx("em",{children:See(h.status)})})}),o.jsx("td",{children:Sg(h.durationMs)}),o.jsx("td",{children:o.jsx("code",{className:"af-admin-usage-run-id",children:vee(h.runId)})})]},`${h.userId}:${h.flowSource}:${h.flowId}:${h.runId}:${h.at}`))})]})})]}),o.jsxs("section",{className:"af-project-admin-usage",children:[o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"用户使用明细"}),o.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),o.jsx("div",{className:"af-project-admin-usage__table-wrap",children:o.jsxs("table",{className:"af-project-admin-usage__table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"User"}),o.jsx("th",{children:"Pipeline"}),o.jsx("th",{children:"Runs"}),o.jsx("th",{children:"状态"}),o.jsx("th",{children:"最近运行"})]})}),o.jsx("tbody",{children:r&&!t?o.jsx("tr",{children:o.jsx("td",{colSpan:5,children:"正在加载..."})}):((t==null?void 0:t.users)||[]).length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,children:"暂无用户数据"})}):((t==null?void 0:t.users)||[]).map(h=>{var g,b,v,y,w,x,S,C,j,E,P;return o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:h.username||h.userId}),o.jsxs("span",{children:[h.userId,h.isAdmin?" · admin":""]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:yr((g=h.pipelines)==null?void 0:g.total)}),o.jsxs("span",{children:[yr((b=h.pipelines)==null?void 0:b.active)," active / ",yr((v=h.pipelines)==null?void 0:v.archived)," archived"]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:yr((y=h.runs)==null?void 0:y.total)}),o.jsxs("span",{children:["avg ",Sg((w=h.runs)==null?void 0:w.avgDurationMs)]})]}),o.jsx("td",{children:o.jsxs("span",{className:"af-project-admin-usage__chips",children:[o.jsxs("em",{children:["成功 ",yr((x=h.runs)==null?void 0:x.success)]}),o.jsxs("em",{children:["失败 ",yr((S=h.runs)==null?void 0:S.failed)]}),o.jsxs("em",{children:["运行中 ",yr((C=h.runs)==null?void 0:C.running)]})]})}),o.jsx("td",{children:(j=h.runs)!=null&&j.lastRunAt?o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:((E=h.runs)==null?void 0:E.lastRunFlowId)||"-"}),o.jsxs("span",{children:[((P=h.runs)==null?void 0:P.lastRunStatus)||"unknown"," · ",Ng(h.runs.lastRunAt)]})]}):o.jsx("span",{children:"无运行记录"})})]},h.userId)})})]})})]})]}):o.jsx("main",{className:"af-admin-usage-page",children:o.jsx("section",{className:"af-project-admin-usage",children:o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"管理看板"}),o.jsx("span",{children:"需要管理员权限。"})]})})})})}function jee(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);try{return new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}).format(new Date(t))}catch{return String(e)}}function Cee({authUser:e}){const{navigate:t}=ti(),[n,r]=m.useState(""),[s,i]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState([]),[g,b]=m.useState(!1),[v,y]=m.useState(""),w=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(w){b(!0),y("");try{const C=await fetch("/api/feedback"),j=await C.json().catch(()=>({}));if(!C.ok)throw new Error(j.error||"加载失败");h(Array.isArray(j.feedback)?j.feedback:[])}catch(C){y(String(C.message||C)),h([])}finally{b(!1)}}},[w]);m.useEffect(()=>{x()},[x]);const S=async C=>{if(C.preventDefault(),!a){l(!0),u("");try{const j=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),E=await j.json().catch(()=>({}));if(!j.ok)throw new Error(E.error||"提交失败");f(!0),r(""),i("")}catch(j){u(String(j.message||j))}finally{l(!1)}}};return w?o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",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("div",{className:"af-feedback-admin-actions",children:[o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:g,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:g?"hourglass_empty":"refresh"}),g?"刷新中...":"刷新"]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),v?o.jsx("p",{className:"af-err af-feedback-error",children:v}):null,o.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:d.length>0?d.map(C=>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:C.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:C.username||C.userId||"unknown"}),o.jsx("span",{children:jee(C.createdAt)})]})]}),C.contact?o.jsx("span",{className:"af-feedback-item__contact",children:C.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:C.content}),C.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:C.pageUrl}):null]},C.id)):o.jsx("div",{className:"af-feedback-empty",children:g?"正在加载反馈...":"暂无反馈"})})]})}):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:()=>t("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),p?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:S,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:n,onChange:C=>r(C.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:s,onChange:C=>i(C.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?o.jsx("p",{className:"af-err af-feedback-error",children:c}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!s.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function fI(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Sj(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:fI(),key:r,value:String(s??""),private:n.has(r)}))}function Nj(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 Jf(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(`
309
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:Sj(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:Sj(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 jg(){return Jf({name:"",raw:{command:""}})}function _ee(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=Nj(e.envRows),s=Nj(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 jj(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function Cj(e){return e?e.ok?"ok":"error":"unknown"}function Sx(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function Eee(e,t){return e&&e.label||t}function Aee({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return o.jsx("div",{className:"af-mcp-backends",children:n.map(([r,s])=>o.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${Sx(s==null?void 0:s.status)}`,children:[o.jsxs("div",{className:"af-mcp-backend-head",children:[o.jsx("strong",{children:r}),o.jsx("span",{children:Eee(s,"Unknown")})]}),Array.isArray(s==null?void 0:s.reasons)&&s.reasons.length?o.jsx("ul",{children:s.reasons.map(i=>o.jsx("li",{children:i},i))}):o.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function _j({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));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:fI(),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 Pee(){var D;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,i]=m.useState(jg),[a,l]=m.useState(""),[c,u]=m.useState(!1),[p,f]=m.useState(!1),[d,h]=m.useState(!1),[g,b]=m.useState({}),[v,y]=m.useState(""),[w,x]=m.useState(""),S=m.useMemo(()=>n.find(R=>R.name===a)||null,[a,n]),C=S&&g[S.name]||null,j=m.useCallback(async()=>{u(!0),y("");try{const R=await fetch("/api/mcps"),T=await R.json().catch(()=>({}));if(!R.ok)throw new Error(T.error||"MCP HTTP "+R.status);const L=Array.isArray(T.servers)?T.servers:[];t(String(T.path||"")),r(L),a&&L.some($=>$.name===a)&&i(Jf(L.find($=>$.name===a)))}catch(R){y(String(R.message||R))}finally{u(!1)}},[a]);m.useEffect(()=>{j()},[j]);const E=()=>{l(""),i(jg()),x(""),y("")},P=R=>{l(R.name),i(Jf(R)),x(""),y("")},F=async(R="")=>{h(!0),y(""),x("");try{const T=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R?{name:R}:{})}),L=await T.json().catch(()=>({}));if(!T.ok)throw new Error(L.error||"检测 MCP 失败");const $=Array.isArray(L.results)?L.results:[];b(O=>{const A={...O};for(const M of $)M!=null&&M.name&&(A[M.name]=M);return A}),x(R?`已检测 ${R}。`:"已检测所有 MCP。")}catch(T){y(String(T.message||T))}finally{h(!1)}},V=async()=>{f(!0),y(""),x("");try{const R=_ee(s);if(!R.nextName)throw new Error("请填写 MCP 名称");const T=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),L=await T.json().catch(()=>({}));if(!T.ok)throw new Error(L.error||"保存 MCP 失败");const $=Array.isArray(L.servers)?L.servers:[];r($),t(String(L.path||e)),l(R.nextName),i(Jf($.find(O=>O.name===R.nextName)||null)),b(O=>{const A={...O};return s.originalName&&s.originalName!==R.nextName&&delete A[s.originalName],delete A[R.nextName],A}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(R){y(String(R.message||R))}finally{f(!1)}},z=async R=>{if(R!=null&&R.name&&window.confirm(`删除 MCP "${R.name}"?`)){f(!0),y(""),x("");try{const T=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R.name})}),L=await T.json().catch(()=>({}));if(!T.ok)throw new Error(L.error||"删除 MCP 失败");r(Array.isArray(L.servers)?L.servers:[]),l(""),i(jg()),b($=>{const O={...$};return delete O[R.name],O}),x("已删除。")}catch(T){y(String(T.message||T))}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:j,disabled:c||p,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>F(),disabled:d||c||p||n.length===0,children:d?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:E,disabled:p,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:E,disabled:p,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:E,disabled:p,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(R=>{var T,L,$,O;return o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===R.name?" af-mcp-server-item--active":""),onClick:()=>P(R),children:[o.jsx("span",{className:"material-symbols-outlined",children:R.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:R.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${Cj(g[R.name])}`,children:jj(g[R.name])})]}),o.jsxs("span",{className:"af-mcp-server-backends",children:[o.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Sx((L=(T=R.backends)==null?void 0:T.cursor)==null?void 0:L.status)}`,children:"Cursor"}),o.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Sx((O=($=R.backends)==null?void 0:$.codex)==null?void 0:O.status)}`,children:"Codex"})]}),o.jsx("em",{children:R.url||[R.command,...R.args||[]].filter(Boolean).join(" ")})]})]},R.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:()=>F(S.name),disabled:d||p,children:d?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>z(S),disabled:p,children:"删除"})]}):null]}),v?o.jsx("p",{className:"af-mcp-error",children:v}):null,w?o.jsx("p",{className:"af-mcp-status",children:w}):null,S?o.jsx(Aee,{server:S}):null,C?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${Cj(C)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:jj(C)}),o.jsxs("span",{children:[C.elapsedMs||0,"ms"]})]}),C.error?o.jsx("p",{children:C.error}):null,(D=C.tools)!=null&&D.length?o.jsx("div",{className:"af-mcp-tools-list",children:C.tools.map(R=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:R.name}),R.description?o.jsx("span",{children:R.description}):null]},R.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:R=>i(T=>({...T,name:R.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:R=>i(T=>({...T,type:R.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:R=>i(T=>({...T,url:R.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:R=>i(T=>({...T,command:R.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:R=>i(T=>({...T,argsText:R.target.value})),placeholder:`mcp-server-example
310
- --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:R=>i(T=>({...T,description:R.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(_j,{title:"Headers",rows:s.headerRows,onChange:R=>i(T=>({...T,headerRows:R})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(_j,{title:"Env",rows:s.envRows,onChange:R=>i(T=>({...T,envRows:R})),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:R=>i(T=>({...T,extraJson:R.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:E,disabled:p,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:V,disabled:p,children:p?"保存中...":"保存 MCP"})]})]})]})]})})]})}function Ej(e){if(!e)return"-";const t=typeof e=="number"?e:Date.parse(String(e));return Number.isFinite(t)?new Date(t).toLocaleString():String(e)}function Iee(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function Tee(e){if(e!=null&&e.running)return"运行中";if(!(e!=null&&e.enabled))return"已停用";const t=String((e==null?void 0:e.lastStatus)||"").trim();return!t||t==="armed"||t==="enabled"?"已启用":t==="success"?"上次成功":t==="failed"?"上次失败":t==="invalid"?"配置异常":t.startsWith("skipped")?"已跳过":t}function Ree(){const[e,t]=m.useState([]),[n,r]=m.useState(!1),[s,i]=m.useState(""),[a,l]=m.useState(""),c=m.useCallback(async()=>{r(!0),i("");try{const f=await fetch("/api/schedules"),d=await f.json().catch(()=>({}));if(!f.ok)throw new Error(d.error||"读取定时任务失败");t(Array.isArray(d.schedules)?d.schedules:[])}catch(f){i(String(f.message||f)),t([])}finally{r(!1)}},[]);m.useEffect(()=>{c()},[c]);const u=m.useCallback(async f=>{const d=`${f.kind}:${f.flowSource||"user"}:${f.flowId||""}:${f.scheduleNodeId||""}`;l(d),i("");try{const h=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:f.kind,flowId:f.flowId,flowSource:f.flowSource||"user",scheduleNodeId:f.scheduleNodeId||"",enabled:!f.enabled})}),g=await h.json().catch(()=>({}));if(!h.ok||g.success===!1)throw new Error(g.error||"更新定时任务失败");await c()}catch(h){i(String(h.message||h))}finally{l("")}},[c]),p=m.useMemo(()=>{const f=e.filter(h=>h.enabled).length,d=e.filter(h=>h.kind==="workspace").length;return{total:e.length,enabled:f,workspace:d,pipeline:e.length-d}},[e]);return o.jsxs("div",{className:"af-settings-page af-schedules-page",children:[o.jsxs("div",{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:"定时任务"})]}),o.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void c(),disabled:n,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:n?"hourglass_empty":"refresh"}),"刷新"]})]}),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:"定时任务"}),o.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),o.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[o.jsxs("div",{children:[o.jsx("span",{children:"全部"}),o.jsx("strong",{children:p.total})]}),o.jsxs("div",{children:[o.jsx("span",{children:"启用中"}),o.jsx("strong",{children:p.enabled})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Workspace"}),o.jsx("strong",{children:p.workspace})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Pipeline"}),o.jsx("strong",{children:p.pipeline})]})]}),s?o.jsx("div",{className:"af-schedules-error",children:s}):null,n?o.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!n&&e.length===0?o.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,o.jsx("div",{className:"af-schedules-list",children:e.map(f=>{const d=`${f.kind}:${f.flowSource||"user"}:${f.flowId||""}:${f.scheduleNodeId||""}`,h=a===d;return o.jsxs("article",{className:"af-schedule-card",children:[o.jsxs("div",{className:"af-schedule-card__main",children:[o.jsxs("div",{className:"af-schedule-card__title-row",children:[o.jsx("strong",{children:f.label||f.flowId||"-"}),o.jsx("span",{className:`af-schedule-badge af-schedule-badge--${f.kind||"pipeline"}`,children:Iee(f)}),o.jsx("span",{className:`af-schedule-state ${f.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:Tee(f)})]}),o.jsxs("div",{className:"af-schedule-card__meta",children:[o.jsx("span",{children:f.flowId||"-"}),o.jsx("span",{children:f.flowSource||"user"}),f.scheduleNodeId?o.jsx("span",{children:f.scheduleNodeId}):null]}),o.jsxs("div",{className:"af-schedule-card__grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Cron"}),o.jsx("strong",{children:f.cron||"-"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"时区"}),o.jsx("strong",{children:f.timezone||"Asia/Shanghai"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"下次执行"}),o.jsx("strong",{children:Ej(f.nextRunAt)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"最近执行"}),o.jsx("strong",{children:Ej(f.lastTriggeredAt)})]})]}),f.lastError?o.jsx("p",{className:"af-schedule-card__error",children:f.lastError}):null]}),o.jsx("div",{className:"af-schedule-card__actions",children:o.jsxs("button",{type:"button",className:f.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:h,"aria-pressed":f.enabled,title:f.enabled?"点击停用":"点击启用",onClick:()=>void u(f),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:h?"hourglass_empty":f.enabled?"toggle_on":"toggle_off"}),f.enabled?"已启用":"已停用"]})})]},d)})})]})})]})}const Aj={id:"",title:"Untitled Node",definitionId:"",agentMessages:[],promptDraft:"",manifest:{id:"",version:"1.0.0",name:"",runtime:{type:"agent_subAgent"},inputs:[],outputs:[],configSchema:{fields:[]},ui:{card:{icon:"extension",variant:"default",actions:[]}}},config:{},files:{},test:{inputs:{},log:[],status:"not run"}};function Pj(e){const t=(e==null?void 0:e.manifest)||{};return(e==null?void 0:e.definitionId)||`marketplace:${t.id||(e==null?void 0:e.id)||"node"}@${t.version||"1.0.0"}`}function Mee(e){var c,u,p,f,d,h,g,b,v,y,w,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],i=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((p=(u=t.ui)==null?void 0:u.card)==null?void 0:p.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(S=>[`input.${S.name||"-"}`,`${S.type||"text"}${S.required?" · required":""}${S.default?` · default: ${S.default}`:""}`]),...s.map(S=>[`output.${S.name||"-"}`,S.type||"text"]),...i.map(S=>[`config.${S.key||"-"}`,S.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((d=t.runtime)==null?void 0:d.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((b=(g=t.ui)==null?void 0:g.card)==null?void 0:b.variant)||"default"],["card.icon",((y=(v=t.ui)==null?void 0:v.card)==null?void 0:y.icon)||"extension"],...a.map(S=>[`action.${S.id||S.label||"-"}`,S.variant||S.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([S,C])=>[`sample.${S}`,String(C)]),["last run",`${((w=e==null?void 0:e.test)==null?void 0:w.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function $ee(){var R,T,L,$,O,A,M;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,i]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState(""),g=e||Aj,b=m.useMemo(()=>Mee(g),[g]),v=m.useMemo(()=>b.find(_=>_.id===n)||b[1],[n,b]),y=(g==null?void 0:g.manifest)||{},w=(g==null?void 0:g.config)||{},x=((R=g==null?void 0:g.test)==null?void 0:R.inputs)||{},S=Array.isArray((T=g==null?void 0:g.test)==null?void 0:T.log)?g.test.log:[],C=(($=(L=y.ui)==null?void 0:L.card)==null?void 0:$.icon)||"event_repeat",j=((A=(O=y.ui)==null?void 0:O.card)==null?void 0:A.variant)||"default",E=w.enabled===!0,P=m.useCallback(async()=>{var _;l(!0),u("");try{const U=await fetch("/api/node-studio/drafts"),q=await U.json().catch(()=>({}));if(!U.ok)throw new Error(q.error||"读取节点草稿失败");const B=Array.isArray(q.drafts)?q.drafts[0]:null;if(!(B!=null&&B.id)){t(null),h("");return}const Q=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(B.id)}`),se=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(se.error||"读取节点草稿失败");t(se.draft||null),h(String(((_=se.draft)==null?void 0:_.promptDraft)||""))}catch(U){u(String(U.message||U))}finally{l(!1)}},[]);m.useEffect(()=>{P()},[P]);const F=m.useCallback(async(_={})=>{var U;f(!0),u("");try{const q=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",..._})}),B=await q.json().catch(()=>({}));if(!q.ok||B.ok===!1)throw new Error(B.error||"保存节点草稿失败");t(B.draft||e),h(String(((U=B.draft||e)==null?void 0:U.promptDraft)||""))}catch(q){u(String(q.message||q))}finally{f(!1)}},[e]),V=()=>{i(!0),window.setTimeout(()=>i(!1),900)},z=_=>{const U={...w,enabled:_};t(q=>({...q||Aj,config:U})),F({config:{enabled:_}})},D=()=>{F({promptDraft:d,appendUserMessage:!0})};return o.jsxs("div",{className:"af-node-studio-page",children:[o.jsxs("header",{className:"af-node-studio-top",children:[o.jsxs("div",{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:"Node Studio"})]}),o.jsx("h1",{children:"节点编辑器"})]}),o.jsxs("div",{className:"af-node-studio-actions",children:[o.jsxs("button",{type:"button",onClick:()=>void P(),disabled:a,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),o.jsxs("button",{type:"button",onClick:V,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),o.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),o.jsxs("main",{className:"af-node-studio-shell",children:[o.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),o.jsx("strong",{children:"AI Agent"})]}),c?o.jsx("div",{className:"af-node-studio-error",children:c}):null,o.jsxs("div",{className:"af-node-studio-thread",children:[e?null:o.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(g==null?void 0:g.agentMessages)?g.agentMessages:[]).map((_,U)=>o.jsx("div",{className:_.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:_.text||""},`${_.role||"message"}-${U}`)),o.jsxs("div",{className:"af-node-studio-agent-tools",children:[o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),o.jsxs("label",{className:"af-node-studio-prompt",children:[o.jsx("span",{children:"需求"}),o.jsx("textarea",{value:d,onChange:_=>h(_.target.value)})]}),o.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:p,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:p?"sync":"send"}),p?"Saving":"Send"]})]}),o.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),o.jsx("strong",{children:"Preview / Test"})]}),o.jsxs("div",{className:"af-node-studio-preview-grid",children:[o.jsx("div",{className:"af-node-studio-preview-stage",children:e?j==="schedule"?o.jsxs("div",{className:"af-node-preview-card",children:[o.jsxs("div",{className:"af-node-preview-card__head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C}),o.jsx("strong",{children:g.title||y.name||"Untitled Node"}),o.jsx("code",{children:Pj(g)})]}),o.jsxs("label",{className:"af-node-preview-toggle",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:_=>z(_.target.checked)}),o.jsx("span",{children:E?"定时开启":"定时关闭"})]}),o.jsxs("div",{className:"af-node-preview-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"频率"}),o.jsxs("select",{value:w.scheduleType||"daily",onChange:_=>F({config:{scheduleType:_.target.value}}),children:[o.jsx("option",{value:"daily",children:"每天"}),o.jsx("option",{value:"weekly",children:"每周"})]})]}),o.jsxs("label",{children:[o.jsx("span",{children:"时间"}),o.jsxs("div",{children:[o.jsxs("select",{value:w.hour||"09",onChange:_=>F({config:{hour:_.target.value}}),children:[o.jsx("option",{children:"09"}),o.jsx("option",{children:"10"})]}),o.jsxs("select",{value:w.minute||"00",onChange:_=>F({config:{minute:_.target.value}}),children:[o.jsx("option",{children:"00"}),o.jsx("option",{children:"30"})]})]})]})]}),o.jsxs("div",{className:"af-node-preview-meta",children:[o.jsxs("span",{children:[w.scheduleType==="weekly"?"每周":"每天"," ",w.hour||"09",":",w.minute||"00"]}),o.jsx("span",{children:"Next -"}),o.jsx("span",{children:E?"enabled":"disabled"})]}),o.jsxs("div",{className:"af-node-preview-actions",children:[o.jsxs("button",{type:"button",className:"af-node-preview-run",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):o.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[o.jsxs("div",{className:"af-node-preview-card__head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C}),o.jsx("strong",{children:g.title||y.name||"Untitled Node"}),o.jsx("code",{children:Pj(g)})]}),o.jsxs("div",{className:"af-node-preview-default-body",children:[o.jsx("p",{children:y.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),o.jsxs("div",{children:[o.jsxs("span",{children:[Array.isArray(y.inputs)?y.inputs.length:0," inputs"]}),o.jsxs("span",{children:[Array.isArray(y.outputs)?y.outputs.length:0," outputs"]}),o.jsx("span",{children:((M=y.runtime)==null?void 0:M.type)||y.baseDefinitionId||"agent_subAgent"})]})]})]}):o.jsxs("div",{className:"af-node-preview-empty",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),o.jsx("strong",{children:"暂无预览"}),o.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),o.jsxs("div",{className:"af-node-studio-test",children:[o.jsxs("div",{className:"af-node-studio-subhead",children:[o.jsx("strong",{children:"Test Inputs"}),o.jsxs("button",{type:"button",onClick:V,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"play_arrow"}),"Run"]})]}),o.jsxs("div",{className:"af-node-studio-inputs",children:[o.jsxs("label",{children:[o.jsx("span",{children:"project"}),o.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"date"}),o.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),o.jsx("div",{className:"af-node-studio-log",children:(s?["running..."]:S.length?S:["No test run yet."]).map((_,U)=>o.jsx("span",{children:_},`${_}-${U}`))})]})]})]}),o.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),o.jsx("strong",{children:"Internals"})]}),o.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:b.map(_=>o.jsxs("button",{type:"button",className:_.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(_.id),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_.icon}),_.label]},_.id))}),o.jsx("div",{className:"af-node-studio-internal-list",children:v.rows.map(([_,U])=>o.jsxs("div",{className:"af-node-studio-internal-row",children:[o.jsx("span",{children:_}),o.jsx("strong",{children:U})]},_))}),o.jsx("pre",{className:"af-node-studio-code",children:v.id==="ui"?JSON.stringify(y.ui||{},null,2):v.id==="contract"?JSON.stringify({inputs:y.inputs||[],outputs:y.outputs||[],configSchema:y.configSchema||{}},null,2):v.id==="tests"?JSON.stringify((g==null?void 0:g.test)||{},null,2):JSON.stringify({runtime:y.runtime||{},files:(g==null?void 0:g.files)||{}},null,2)})]})]})]})}function Lee(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Oee(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Dee(e={},t={}){return`${String(e.mountPath||t.mountPath||e.label||t.label||e.id||t.id||"workspace").trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"WORKSPACE"}_GIT_TOKEN`}function Cg(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function _g(e={}){return{id:String((e==null?void 0:e.id)||""),label:String((e==null?void 0:e.label)||(e==null?void 0:e.name)||""),kind:(e==null?void 0:e.kind)==="local"?"local":"git",path:String((e==null?void 0:e.path)||""),repoUrl:String((e==null?void 0:e.repoUrl)||""),branch:String((e==null?void 0:e.branch)||"master"),mountPath:String((e==null?void 0:e.mountPath)||""),credentialRef:String((e==null?void 0:e.credentialRef)||""),type:String((e==null?void 0:e.type)||((e==null?void 0:e.kind)==="local"?"local":"code")),description:String((e==null?void 0:e.description)||""),enabled:(e==null?void 0:e.enabled)!==!1}}function Fee(e){const t=e.kind==="local"?"local":"git";return{id:String(e.id||"").trim(),label:String(e.label||"").trim(),kind:t,path:String(e.path||"").trim(),repoUrl:t==="git"?String(e.repoUrl||"").trim():"",branch:t==="git"?String(e.branch||"master").trim()||"master":"",mountPath:t==="git"?String(e.mountPath||"").trim():"",credentialRef:t==="git"?String(e.credentialRef||"").trim():"",type:String(e.type||(t==="local"?"local":"code")).trim(),description:String(e.description||"").trim(),enabled:e.enabled!==!1}}function di(e,t=0){return(e==null?void 0:e.id)||(e==null?void 0:e.path)||(e==null?void 0:e.repoUrl)||`workspace-${t}`}function zee({ok:e}){return o.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function Ij({item:e,selected:t,onClick:n,readOnly:r}){return o.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[o.jsxs("div",{className:"af-workspaces-card__head",children:[o.jsx("strong",{children:e.label||"Workspace"}),o.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),o.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),o.jsxs("div",{className:"af-workspaces-card__meta",children:[o.jsx(zee,{ok:e.exists!==!1}),o.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?o.jsx("em",{children:"内置"}):e.enabled===!1?o.jsx("em",{children:"disabled"}):null]})]})}function Hee(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,i]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState([]),[d,h]=m.useState([]),[g,b]=m.useState(Cg),[v,y]=m.useState(""),[w,x]=m.useState([]),[S,C]=m.useState(""),j=m.useMemo(()=>d.findIndex((M,_)=>di(M,_)===S),[d,S]),P=!!m.useMemo(()=>p.find((M,_)=>di(M,_)===S)||null,[p,S]),F=m.useMemo(()=>{const M=String(g.credentialRef||"").trim();return M?w.some(_=>String((_==null?void 0:_.key)||"").trim()===M&&String((_==null?void 0:_.value)??"")!==""):!1},[g.credentialRef,w]),V=m.useCallback(async()=>{t(!0),i("");try{const[M,_]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),U=await M.json().catch(()=>({})),q=await _.json().catch(()=>({}));if(!_.ok)throw new Error(typeof q.error=="string"?q.error:"ENV HTTP "+_.status);if(!M.ok)throw new Error(typeof U.error=="string"?U.error:"HTTP "+M.status);const B=Array.isArray(U.workspaces)?U.workspaces:[],Q=Array.isArray(U.customWorkspaces)?U.customWorkspaces:[];u(String(U.path||"")),f(B.filter(se=>se==null?void 0:se.builtin)),h(Q),x(Array.isArray(q.env)?q.env.map(se=>({key:String((se==null?void 0:se.key)||""),value:String((se==null?void 0:se.value)??"")})):[])}catch(M){i(String(M.message||M))}finally{t(!1)}},[]);m.useEffect(()=>{V()},[V]);const z=m.useCallback(async(M,_="")=>{r(!0),i(""),l("");try{const U=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:M})}),q=await U.json().catch(()=>({}));if(!U.ok)throw new Error(typeof q.error=="string"?q.error:"HTTP "+U.status);const B=Array.isArray(q.customWorkspaces)?q.customWorkspaces:M;h(B),f((Array.isArray(q.workspaces)?q.workspaces:[]).filter(Q=>Q==null?void 0:Q.builtin)),u(String(q.path||c)),_&&C(_),l("已保存")}catch(U){i(String(U.message||U))}finally{r(!1)}},[c]),D=m.useCallback(()=>{C(""),b(Cg()),y(""),l(""),i("")},[]),R=m.useCallback((M,_)=>{C(di(M,_)),b(_g(M)),y(""),l("")},[]),T=m.useCallback((M,_)=>{C(di(M,_)),b(_g(M)),y(""),l("")},[]),L=m.useCallback(async(M,_)=>{const U=String(M||"").trim(),q=String(_??"");if(!U||!q)return;const B=w.filter(oe=>String((oe==null?void 0:oe.key)||"").trim()!==U);B.push({key:U,value:q});const Q=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:B})}),se=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(typeof se.error=="string"?se.error:"ENV HTTP "+Q.status);x(Array.isArray(se.env)?se.env.map(oe=>({key:String((oe==null?void 0:oe.key)||""),value:String((oe==null?void 0:oe.value)??"")})):B)},[w]),$=m.useCallback(()=>{const M=Fee({...g,id:g.id||Lee()}),_=v.trim();if(M.kind==="git"&&_&&!M.credentialRef&&(M.credentialRef=Dee(g,M)),M.kind==="local"&&!M.path){i("本地工作区需要填写路径");return}if(M.kind==="git"&&!M.repoUrl){i("Git 工作区需要填写 repoUrl");return}if(!M.label){i("请填写名称");return}if(M.kind==="git"&&M.credentialRef&&!Oee(M.credentialRef)){i("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const U=j>=0?d.map((q,B)=>B===j?M:q):[M,...d];b(_g(M)),(async()=>{r(!0);try{_&&await L(M.credentialRef,_),y(""),await z(U,di(M))}catch(q){i(String(q.message||q)),r(!1)}})()},[d,g,z,L,j,v]),O=m.useCallback(()=>{if(j<0)return;const M=d.filter((_,U)=>U!==j);b(Cg()),C(""),z(M)},[d,z,j]),A=m.useCallback(M=>{b(_=>({..._,...M}))},[]);return o.jsxs("div",{className:"af-workspaces-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb","aria-label":"工作区",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"工作区"})]}),o.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:V,disabled:e,children:[o.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),o.jsx("main",{className:"af-settings-body",children:o.jsxs("div",{className:"af-workspaces-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"工作区"}),o.jsx("p",{className:"af-settings-lead",children:"维护可被 Load Workspace、一键任务和后续 Agent 运行使用的上下文目录。Git 字段与 mengmai 的资源配置保持一致。"}),c?o.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",c]}):null,s?o.jsx("p",{className:"af-err af-settings-api-hint",children:s}):null,a?o.jsx("p",{className:"af-workspaces-status",children:a}):null]}),o.jsxs("section",{className:"af-workspaces-summary",children:[o.jsxs("div",{children:[o.jsx("span",{children:"内置"}),o.jsx("strong",{children:p.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"自定义"}),o.jsx("strong",{children:d.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Git"}),o.jsx("strong",{children:d.filter(M=>M.kind==="git").length})]})]}),o.jsxs("div",{className:"af-workspaces-layout",children:[o.jsxs("section",{className:"af-workspaces-list",children:[o.jsxs("div",{className:"af-workspaces-section-head",children:[o.jsx("h2",{children:"自定义工作区"}),o.jsxs("button",{type:"button",onClick:D,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),d.length?d.map((M,_)=>o.jsx(Ij,{item:M,selected:di(M,_)===S,onClick:()=>R(M,_)},di(M,_))):o.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义工作区。新增 Git 或本地目录后,画布里的 Load Workspace 就可以选择它。"}),o.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:o.jsx("h2",{children:"内置工作区"})}),p.map((M,_)=>o.jsx(Ij,{item:M,selected:di(M,_)===S,onClick:()=>T(M,_),readOnly:!0},di(M,_)))]}),o.jsxs("section",{className:"af-workspaces-editor",children:[o.jsxs("div",{className:"af-workspaces-editor__head",children:[o.jsxs("div",{children:[o.jsx("h2",{children:P?"查看内置工作区":j>=0?"编辑工作区":"新增工作区"}),o.jsx("p",{children:P?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于执行,Git 字段用于后续同步和上下文挂载。"})]}),o.jsxs("label",{className:"af-workspaces-switch",children:[o.jsx("input",{type:"checkbox",checked:g.enabled!==!1,disabled:P,onChange:M=>A({enabled:M.target.checked})}),o.jsx("span",{children:"启用"})]})]}),o.jsxs("div",{className:"af-workspaces-kind",children:[o.jsxs("button",{type:"button",className:g.kind==="git"?"active":"",disabled:P,onClick:()=>A({kind:"git",type:g.type==="local"?"code":g.type}),children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),o.jsxs("button",{type:"button",className:g.kind==="local"?"active":"",disabled:P,onClick:()=>A({kind:"local",type:"local"}),children:[o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),o.jsxs("div",{className:"af-workspaces-form",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:g.label,disabled:P,onChange:M=>A({label:M.target.value}),placeholder:"Likee Android"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型"}),o.jsxs("select",{value:g.type,disabled:P,onChange:M=>A({type:M.target.value}),children:[o.jsx("option",{value:"code",children:"code"}),o.jsx("option",{value:"docs",children:"docs"}),o.jsx("option",{value:"analytics",children:"analytics"}),o.jsx("option",{value:"config",children:"config"}),o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"other",children:"other"})]})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"本地路径"}),o.jsx("input",{value:g.path,disabled:P,onChange:M=>A({path:M.target.value}),placeholder:g.kind==="git"?"可空,默认保存到用户数据目录/workspaces/repos/<id>":"/Users/.../project"})]}),g.kind==="git"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"Git URL"}),o.jsx("input",{value:g.repoUrl,disabled:P,onChange:M=>A({repoUrl:M.target.value}),placeholder:"https://git.example.com/group/repo.git"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"分支"}),o.jsx("input",{value:g.branch,disabled:P,onChange:M=>A({branch:M.target.value}),placeholder:"master"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"挂载目录"}),o.jsx("input",{value:g.mountPath,disabled:P,onChange:M=>A({mountPath:M.target.value}),placeholder:"likee_android"})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"凭证环境变量"}),o.jsx("input",{value:g.credentialRef,disabled:P,onChange:M=>A({credentialRef:M.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"Token"}),o.jsx("input",{type:"password",value:v,disabled:P,onChange:M=>y(M.target.value),placeholder:F?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),o.jsx("small",{children:"保存后只在 workspace 配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:g.description,disabled:P,onChange:M=>A({description:M.target.value}),placeholder:"这个工作区包含哪些代码、文档或需求上下文"})]})]}),o.jsxs("div",{className:"af-workspaces-actions",children:[!P&&j>=0?o.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:O,disabled:n,children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):o.jsx("span",{}),o.jsxs("div",{children:[o.jsx("button",{type:"button",onClick:D,disabled:n,children:"重置"}),o.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:$,disabled:P||n,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const Bee=[{icon:"campaign",title:"首页 Feed 想加一个广告引导",question:"先判断入口、展示位、用户影响面,再决定弹框、浮层还是页面内引导。",context:["查客户端展示位逻辑","查历史需求与配置","查 m09 / Feed PV"],result:"原型 + PRD + TAPD 更新",tone:"pink"},{icon:"manage_search",title:"接到需求但不知道现有逻辑",question:"不用先找研发问一圈,直接从 Likee 代码、知识库、历史文档里拿上下文。",context:["客户端 / 后台 / 前端知识库","接口与配置链路","相关 Git 文档"],result:"背景结论 + 影响范围",tone:"cyan"},{icon:"query_stats",title:"运营要评估活动或入口价值",question:"先查人群规模、页面访问、历史转化,避免凭经验拍优先级。",context:["CK / Hive 查数","自动生成 SQL","指标口径解释"],result:"数据表 + 图表 + 结论",tone:"green"},{icon:"draw",title:"想快速把方案画给团队看",question:"把一句需求变成客户端或 H5 原型,让评审时先讨论体验,不只讨论文字。",context:["Likee 客户端样式","前端页面结构","交互状态与文案"],result:"HTML 原型 + Display 面板",tone:"amber"},{icon:"sync_alt",title:"需求写完后需要同步多个地方",question:"PRD、TAPD、Git 仓库和评审展示保持一致,减少重复复制和漏改。",context:["需求正文","变更记录","MR / 仓库路径"],result:"TAPD 更新 + Git 提交",tone:"violet"},{icon:"monitoring",title:"上线后要看效果和复盘",question:"沿用需求阶段的口径继续查数,把结果沉淀回下一轮需求线索。",context:["上线后 CK / Hive","分页面 / 分人群指标","实验和版本信息"],result:"复盘结论 + 后续建议",tone:"blue"}],Wee=[{label:"Use Case 01",title:"Likee 客户端知识库查询(如广告占位)",images:["/likee-context/usecase-ad-query.png"],trigger:"产品或运营想确认客户端已有逻辑,例如 Likee Android 里有哪些广告占位,以及相关常量和代码位置。",steps:["在「我的流程」加载 Likee Android 流程片段","在子 Agent 节点输入客户端逻辑问题","点击 Run Line,只执行当前链路","在右侧 Markdown Display 查看知识库查询结果"],outputs:["SETTING_ID / PAGE_ID 表格","客户端代码路径与口径说明","可继续用于 PRD 的背景材料"]},{label:"Use Case 02",title:"客户端原型设计",images:["/likee-context/usecase-prototype.png"],trigger:"业务已经明确要在 Likee 首页加入广告引导,需要先把弹框体验画出来给产品、设计、研发评审。",steps:["在 Workspace 打开原型生成流程","加载客户端原型 Skill","在子 Agent 中说明生成一个首页 dialog 弹框","查看 HTML Display 中的手机预览稿"],outputs:["Likee 风格手机原型","弹框文案与按钮状态","可直接用于评审的 Display 面板"]},{label:"Use Case 03",title:"前端 H5 原型设计",images:["/likee-context/usecase-h5-prototype.png"],trigger:"运营活动需要快速产出 Likee 风格 H5 页面,例如幸运转盘、积分排行榜、活动首页或结果页。",steps:["在 Workspace 打开 H5 原型生成流程","加载前端 H5 原型相关 Skill","在子 Agent 中说明活动结构、页面模块和运营规则","查看 HTML Display 中的可交互 H5 原型"],outputs:["Likee 风格 H5 页面","抽奖转盘与排行榜布局","活动规则和状态页","可用于评审的 HTML Display"]},{label:"Use Case 04",title:"CK / Hive 查数与 SQL 生成",images:["/likee-context/usecase-data-query.png"],trigger:"运营或产品需要快速验证一个数据问题,例如找出典型 UID、对比不同日期的视频上传分辨率占比,并保留可复用 SQL。",steps:["在 Workspace 打开查数流程","加载查数相关 Skill","在子 Agent 中说明数据口径、日期和筛选条件","查看 Markdown Display 中的数据结果和查询 SQL"],outputs:["查询结果表格","SQL 语句","口径说明","可继续接入 PRD 或复盘面板的数据结论"]},{label:"Use Case 05",title:"需求文档生成、数据补齐与同步",images:["/likee-context/usecase-prd.png","/likee-context/usecase-sync.png"],trigger:"需求进入评审和落库阶段,需要把 TAPD 信息、Hive 数据、原型内容组织成 PRD,并同步到 TAPD 和 Git 仓库。",steps:["先运行 TAPD / 数据查询节点,拿到迭代、页面 PV 和业务背景","把查询结果和原型 Display 内容接入 PRD 生成子 Agent","在 Markdown Display 查看完整需求文档","把 PRD content 接入 TAPD 更新节点和 Git 仓库提交节点"],outputs:["完整 PRD 文档","项目背景与 Top 页面数据","TAPD 需求更新成功","Git MR 链接"]},{label:"Use Case 06",title:"Display 模式做需求评审面板",images:["/likee-context/usecase-display.png"],trigger:"流程跑完后,需要把 PRD、原型、数据图表、展示位表格放在一个页面里给产品、运营、研发一起看。",steps:["在 Workspace 中完成查数、原型、PRD、同步节点执行","确认 Markdown / HTML / 图表 / 表格展示节点都有结果","切换顶部 DISPLAY 模式","使用生成链接把评审面板发给相关同学"],outputs:["PRD 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Vee=[{name:"likee-client-ui",namespace:"智能助手 / 客户端原型",icon:"phone_iphone",mode:"客户端原型设计",usage:"生成 Likee 客户端风格页面、弹框、Feed 引导、个人页、活动入口等原型,适合产品评审前快速对齐体验。",examples:["首页 dialog 弹框","Feed 内引导","客户端红色主品牌视觉","移动端交互态"],tone:"pink"},{name:"tapd-likee",namespace:"智能助手 / TAPD",icon:"sync",mode:"需求系统交互",usage:"和 TAPD 交互,支持创建、同步、更新需求,把工作区生成的 PRD 或 Markdown 内容回写到需求系统。",examples:["创建 TAPD 需求","更新需求正文","同步处理人和链接","把结果回显到 Display"],tone:"green"},{name:"plain-language-response",namespace:"智能助手 / 回答风格",icon:"record_voice_over",mode:"业务化回答",usage:"用于把回答收敛成产品、运营更容易阅读的解释,避免直接把客户端代码库细节、函数调用链和实现细节暴露太多。",examples:["需求背景解释","代码结论转业务语言","评审材料摘要","减少实现细节噪音"],tone:"cyan"},{name:"create-likee-h5-style-html",namespace:"智能助手 / 前端 H5",icon:"language",mode:"H5 原型设计",usage:"创建 Likee H5 风格原型,适合运营活动、抽奖、排行榜、报告页、反馈表单、创作者认证页、订单列表等页面。",examples:["幸运转盘活动","积分排行榜","活动规则页","结果页和空状态"],tone:"amber"},{name:"analytics",namespace:"数据 / CK & Hive",icon:"query_stats",mode:"查数和 SQL 生成",usage:"面向 CK、Hive 的指标查询和 SQL 生成,适合 PV、UV、转化、分国家、分实验组、典型 UID 等数据问题。",examples:["自动生成 SQL","输出查询结果表","解释指标口径","沉淀复盘数据"],tone:"green"}],Kee=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function jf({icon:e,title:t,label:n,tone:r="violet"}){return o.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[o.jsx("span",{className:"material-symbols-outlined",children:e}),o.jsxs("div",{children:[o.jsx("strong",{children:t}),o.jsx("small",{children:n})]})]})}function Uee(){return o.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[o.jsx("div",{className:"likee-scene-grid"}),o.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[o.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),o.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),o.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),o.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),o.jsx("div",{className:"likee-node-pos likee-node-a",children:o.jsx(jf,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),o.jsx("div",{className:"likee-node-pos likee-node-b",children:o.jsx(jf,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),o.jsx("div",{className:"likee-node-pos likee-node-c",children:o.jsx(jf,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),o.jsx("div",{className:"likee-node-pos likee-node-d",children:o.jsx(jf,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),o.jsxs("div",{className:"likee-phone-preview",children:[o.jsxs("div",{className:"likee-phone-top",children:[o.jsx("span",{children:"关注"}),o.jsx("strong",{children:"推荐"}),o.jsx("span",{children:"直播"})]}),o.jsxs("div",{className:"likee-phone-card",children:[o.jsx("div",{className:"likee-gift",children:"AD"}),o.jsx("h4",{children:"广告个性化引导弹框"}),o.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),o.jsx("button",{children:"继续"}),o.jsx("button",{className:"secondary",children:"稍后"})]})]}),o.jsxs("div",{className:"likee-display-panel",children:[o.jsxs("div",{className:"likee-panel-header",children:[o.jsx("span",{children:"DISPLAY"}),o.jsx("strong",{children:"需求资产面板"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"需求"}),o.jsx("strong",{children:"首页广告个性化引导"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"数据"}),o.jsx("strong",{children:"m09 PV Top 1"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"同步"}),o.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function Xf({kicker:e,title:t,children:n}){return o.jsxs("div",{className:"likee-section-copy",children:[o.jsx("p",{className:"likee-section-kicker",children:e}),o.jsx("h2",{children:t}),o.jsx("p",{children:n})]})}function qee(){return o.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[o.jsx(Xf,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),o.jsx("div",{className:"likee-skill-grid",children:Vee.map(e=>o.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[o.jsxs("div",{className:"likee-skill-head",children:[o.jsx("div",{className:"likee-skill-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.name}),o.jsx("span",{children:e.namespace})]})]}),o.jsx("div",{className:"likee-skill-mode",children:e.mode}),o.jsx("p",{children:e.usage}),o.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>o.jsx("strong",{children:t},t))})]},e.name))})]})})}function pI(){return o.jsxs("div",{className:"likee-page",children:[o.jsx("div",{className:"likee-top-actions",children:o.jsxs("a",{href:"/projects",className:"likee-home-link",children:[o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),o.jsxs("section",{className:"likee-hero",children:[o.jsx(Uee,{}),o.jsxs("div",{className:"likee-hero-content",children:[o.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),o.jsx("h1",{children:"Likee Agent 工作台"}),o.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),o.jsxs("div",{className:"likee-signal-row",children:[o.jsx("span",{children:"查业务逻辑"}),o.jsx("span",{children:"查 CK / Hive"}),o.jsx("span",{children:"生成原型"}),o.jsx("span",{children:"生成 PRD"}),o.jsx("span",{children:"同步 TAPD / Git"})]}),o.jsxs("div",{className:"likee-hero-actions",children:[o.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),o.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),o.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),o.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),o.jsx("section",{id:"likee-scenarios",className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner",children:[o.jsx(Xf,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),o.jsx("div",{className:"likee-scenario-grid",children:Bee.map(e=>o.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[o.jsx("div",{className:"likee-scenario-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.question})]}),o.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>o.jsx("span",{children:t},t))}),o.jsxs("div",{className:"likee-scenario-result",children:[o.jsx("span",{children:"产出"}),o.jsx("strong",{children:e.result})]})]},e.title))})]})}),o.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[o.jsx(Xf,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),o.jsx("div",{className:"likee-usecase-stack",children:Wee.map(e=>o.jsxs("article",{className:"likee-usecase-card",children:[o.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>o.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),o.jsxs("div",{className:"likee-usecase-body",children:[o.jsx("div",{className:"likee-usecase-label",children:e.label}),o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.trigger}),o.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>o.jsx("li",{children:t},t))}),o.jsxs("div",{className:"likee-usecase-output",children:[o.jsx("span",{children:"实际产物"}),o.jsx("div",{children:e.outputs.map(t=>o.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),o.jsx(qee,{}),o.jsx("section",{className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[o.jsx(Xf,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),o.jsx("div",{className:"likee-capability-table",children:Kee.map(([e,t,n])=>o.jsxs("div",{className:"likee-capability-row",children:[o.jsx("span",{children:e}),o.jsx("strong",{children:t}),o.jsx("p",{children:n})]},e))})]})})]})}function hI(e){return t=>typeof t===e}var Yee=hI("function"),Gee=e=>e===null,Tj=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",Rj=e=>!Jee(e)&&!Gee(e)&&(Yee(e)||typeof e=="object"),Jee=hI("undefined");function Xee(e,t,n){return ste(n,e,t)?!0:(ite(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Qee(e,t,n):e instanceof Map&&t instanceof Map?tte(e,t,n):e instanceof Set&&t instanceof Set?rte(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Zee(e,t):Tj(e)&&Tj(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?ete(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():nte(e,t,n))}function od(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!Rj(e)||!t||!Rj(t)?!1:Xee(e,t,n)}function Qee(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!od(e[s],t[s],n))return!1;return!0}function Zee(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 ete(e,t,n){return e.message===t.message&&e.name===t.name&&od(e.cause,t.cause,n)}function tte(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(!od(r[1],t.get(r[0]),n))return!1;return!0}function nte(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)&&!od(e[i],t[i],n))return!1}return!0}function rte(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 ste(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function ite(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function wb(e,t){return od(e,t,new WeakMap)}function Eg(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function ote(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function ate(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function lte(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function cte(e,t){const n=lte();m.useEffect(()=>{if(!n)return e()},t)}function mI(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function ute(e,t){const n=m.useRef(t);return wb(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function dte(e){m.useEffect(()=>{e()},[])}function fte(e=0){const[t,n]=m.useState({height:Eg()?window.innerHeight:0,width:Eg()?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(!Eg())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),ate(window,"resize",i),()=>{ote(window,"resize",i)}},[]),t}var pte=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],hte=["bigint","boolean","null","number","string","symbol","undefined"];function ad(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(mte(t))return t}function Rs(e){return t=>ad(t)===e}function mte(e){return pte.includes(e)}function Kl(e){return t=>typeof t===e}function gte(e){return hte.includes(e)}var yte=["innerHTML","ownerDocument","style","attributes","nodeValue"],ld=e=>Array.isArray(e),xte=e=>ad(e)==="AsyncGeneratorFunction",wte=Rs("AsyncFunction"),bte=Kl("bigint"),kte=e=>e===!0||e===!1,vte=Rs("Date"),Ste=Rs("Error"),xo=Kl("function"),Nte=Rs("GeneratorFunction"),jte=e=>typeof e=="number"&&Number.isInteger(e),Nx=Rs("Map"),gI=e=>Number.isNaN(e),bb=e=>e===null,yI=Rs("Function"),Cte=Rs("Promise"),_te=Rs("RegExp"),jx=Rs("Set"),cd=Kl("string"),Ete=Kl("symbol"),kb=Kl("undefined"),Ate=Rs("WeakMap"),Pte=Rs("WeakSet"),vb=e=>bb(e)||kb(e),xI=e=>!kb(e),Ite=e=>Kl("number")(e)&&!gI(e),Tte=e=>cd(e)&&e.trim().length>0,Rte=e=>{if(!cd(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},Lh=e=>!vb(e)&&(xo(e)||typeof e=="object"),wI=e=>{if(ad(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Mte=e=>bb(e)||gte(typeof e),$te=e=>ad(e)==="URL",bI=e=>!vb(e)&&xo(e[Symbol.iterator]),Lte=e=>bI(e)&&xo(e.next)&&xo(e.throw),Ote=e=>xo(e)&&/^class\s/.test(e.toString()),Dte=(e,t)=>!ld(e)||!xo(t)?!1:e.every(n=>t(n)),Fte=e=>Lh(e)&&!wI(e)&&e.nodeType===1&&cd(e.nodeName)&&yte.every(t=>t in e),zte=e=>cd(e)&&e.length===0||ld(e)&&e.length===0||Lh(e)&&!Nx(e)&&!jx(e)&&Object.keys(e).length===0||jx(e)&&e.size===0||Nx(e)&&e.size===0,Hte=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Bte=(e,t)=>ld(e)?e.indexOf(t)>-1:!1,Wte=(e,t,n)=>{if(!Lh(e)||!t)return!1;const r=e[t];return xo(n)?n(r):xI(r)};function xt(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(ld(e))return"Array";if(yI(e))return"Function";const t=ad(e);return t||"Object"}xt.array=ld;xt.arrayOf=Dte;xt.asyncGeneratorFunction=xte;xt.asyncFunction=wte;xt.bigint=bte;xt.boolean=kte;xt.class=Ote;xt.date=vte;xt.defined=xI;xt.domElement=Fte;xt.empty=zte;xt.error=Ste;xt.function=xo;xt.generator=Lte;xt.generatorFunction=Nte;xt.instanceOf=Hte;xt.integer=jte;xt.iterable=bI;xt.map=Nx;xt.nan=gI;xt.null=bb;xt.nullOrUndefined=vb;xt.nonEmptyString=Tte;xt.number=Ite;xt.numericString=Rte;xt.object=Lh;xt.oneOf=Bte;xt.plainFunction=yI;xt.plainObject=wI;xt.primitive=Mte;xt.promise=Cte;xt.propertyOf=Wte;xt.regexp=_te;xt.set=jx;xt.string=cd;xt.symbol=Ete;xt.undefined=kb;xt.url=$te;xt.weakMap=Ate;xt.weakSet=Pte;var er=xt;/* v8 ignore next -- @preserve */var Vte=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Kte=function(e,t){return e+Bu(t)},Bu=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(Kte,""):Vte(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Bu(e.props.children):""};Bu.default=Bu;var Ute=Bu;const Ag=bo(Ute);var kI={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 j=0;const E=C.length,P=new Array(E);for(j;j<E;++j)P[j]=y(C[j]);return P}function l(C){const j={};if(d&&Object.getPrototypeOf(C)!==t)return d(C);const E=f(C);let P,F,V;for(P=0,F=E.length;P<F;++P)i(V=E[P])&&(j[V]=y(C[V]));return j}function c(C,j){const E=C.length,P=j.length;let F=0;const V=new Array(E+P);for(F;F<E;++F)V[F]=y(C[F]);for(F=0;F<P;++F)V[F+E]=y(j[F]);return V}const u=Object.prototype.propertyIsEnumerable;function p(C){const j=Object.keys(C),E=Object.getOwnPropertySymbols(C);for(let P=0,F=E.length;P<F;++P)u.call(C,E[P])&&j.push(E[P]);return j}const f=s!=null&&s.symbols?p:Object.keys,d=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 b(C){return typeof C!="object"||C===null}const v=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function y(C){return h(C)?Array.isArray(C)?a(C):l(C):C}function w(C,j){const E={},P=f(C),F=f(j);let V,z,D;for(V=0,z=P.length;V<z;++V)i(D=P[V])&&F.indexOf(D)===-1&&(E[D]=y(C[D]));for(V=0,z=F.length;V<z;++V)if(i(D=F[V]))if(D in C)P.indexOf(D)!==-1&&(d&&h(j[D])&&Object.getPrototypeOf(j[D])!==t?E[D]=d(j[D]):E[D]=x(C[D],j[D]));else{if(g&&typeof j[D]>"u")continue;E[D]=y(j[D])}return E}function x(C,j){if(g&&typeof j>"u")return y(C);const E=Array.isArray(j),P=Array.isArray(C);return b(j)?j:h(C)?E&&P?v(C,j):E!==P?y(j):w(C,j):y(j)}function S(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return x(arguments[0],arguments[1])}let C;for(let j=0,E=arguments.length;j<E;++j)C=x(C,arguments[j]);return C}return s!=null&&s.all?S:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(kI);var qte=kI.exports;const Yte=bo(qte);var Gte=new Error("Element already at target scroll position"),Jte=new Error("Scroll cancelled"),Xte=Math.min,Mj=Date.now,Qte={left:$j("scrollLeft"),top:$j("scrollTop")};function $j(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=ene);var a=Mj(),l=n[e],c=s.ease||Zte,u=isNaN(s.duration)?350:+s.duration,p=!1;return l===r?i(Gte,n[e]):requestAnimationFrame(d),f;function f(){p=!0}function d(h){if(p)return i(Jte,n[e]);var g=Mj(),b=Xte(1,(g-a)/u),v=c(b);n[e]=v*(r-l)+l,b<1?requestAnimationFrame(d):requestAnimationFrame(function(){i(null,n[e])})}}}function Zte(e){return .5*(1-Math.cos(Math.PI*e))}function ene(){}const tne=bo(Qte);var vI={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(ou,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})})(vI);var nne=vI.exports;const SI=bo(nne),rne=["top","right","bottom","left"],Lj=["start","end"],Oj=rne.reduce((e,t)=>e.concat(t,t+"-"+Lj[0],t+"-"+Lj[1]),[]),Ll=Math.min,Xo=Math.max,qp=Math.round,Cf=Math.floor,Xs=e=>({x:e,y:e}),sne={left:"right",right:"left",bottom:"top",top:"bottom"};function Cx(e,t,n){return Xo(e,Ll(t,n))}function Ul(e,t){return typeof e=="function"?e(t):e}function _i(e){return e.split("-")[0]}function Qs(e){return e.split("-")[1]}function NI(e){return e==="x"?"y":"x"}function Sb(e){return e==="y"?"height":"width"}function no(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Nb(e){return NI(no(e))}function jI(e,t,n){n===void 0&&(n=!1);const r=Qs(e),s=Nb(e),i=Sb(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Gp(a)),[a,Gp(a)]}function ine(e){const t=Gp(e);return[Yp(e),t,Yp(t)]}function Yp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Dj=["left","right"],Fj=["right","left"],one=["top","bottom"],ane=["bottom","top"];function lne(e,t,n){switch(e){case"top":case"bottom":return n?t?Fj:Dj:t?Dj:Fj;case"left":case"right":return t?one:ane;default:return[]}}function cne(e,t,n,r){const s=Qs(e);let i=lne(_i(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(Yp)))),i}function Gp(e){const t=_i(e);return sne[t]+e.slice(t.length)}function une(e){return{top:0,right:0,bottom:0,left:0,...e}}function CI(e){return typeof e!="number"?une(e):{top:e,right:e,bottom:e,left:e}}function Jp(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 zj(e,t,n){let{reference:r,floating:s}=e;const i=no(t),a=Nb(t),l=Sb(a),c=_i(t),u=i==="y",p=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:p,y:r.y-s.height};break;case"bottom":h={x:p,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(Qs(t)){case"start":h[a]-=d*(n&&u?-1:1);break;case"end":h[a]+=d*(n&&u?-1:1);break}return h}async function dne(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=Ul(t,e),g=CI(h),v=l[d?f==="floating"?"reference":"floating":f],y=Jp(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:p,strategy:c})),w=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},C=Jp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:c}):w);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 fne=50,pne=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:dne},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:f}=zj(u,r,c),d=r,h=0;const g={};for(let b=0;b<i.length;b++){const v=i[b];if(!v)continue;const{name:y,fn:w}=v,{x,y:S,data:C,reset:j}=await w({x:p,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:g,rects:u,platform:l,elements:{reference:e,floating:t}});p=x??p,f=S??f,g[y]={...g[y],...C},j&&h<fne&&(h++,typeof j=="object"&&(j.placement&&(d=j.placement),j.rects&&(u=j.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):j.rects),{x:p,y:f}=zj(u,d,c)),b=-1)}return{x:p,y:f,placement:d,strategy:s,middlewareData:g}},hne=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:u,padding:p=0}=Ul(e,t)||{};if(u==null)return{};const f=CI(p),d={x:n,y:r},h=Nb(s),g=Sb(h),b=await a.getDimensions(u),v=h==="y",y=v?"top":"left",w=v?"bottom":"right",x=v?"clientHeight":"clientWidth",S=i.reference[g]+i.reference[h]-d[h]-i.floating[g],C=d[h]-i.reference[h],j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let E=j?j[x]:0;(!E||!await(a.isElement==null?void 0:a.isElement(j)))&&(E=l.floating[x]||i.floating[g]);const P=S/2-C/2,F=E/2-b[g]/2-1,V=Ll(f[y],F),z=Ll(f[w],F),D=V,R=E-b[g]-z,T=E/2-b[g]/2+P,L=Cx(D,T,R),$=!c.arrow&&Qs(s)!=null&&T!==L&&i.reference[g]/2-(T<D?V:z)-b[g]/2<0,O=$?T<D?T-D:T-R:0;return{[h]:d[h]+O,data:{[h]:L,centerOffset:T-L-O,...$&&{alignmentOffset:O}},reset:$}}});function mne(e,t,n){return(e?[...n.filter(s=>Qs(s)===e),...n.filter(s=>Qs(s)!==e)]:n.filter(s=>_i(s)===s)).filter(s=>e?Qs(s)===e||(t?Yp(s)!==s:!1):!0)}const gne=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:u}=t,{crossAxis:p=!1,alignment:f,allowedPlacements:d=Oj,autoAlignment:h=!0,...g}=Ul(e,t),b=f!==void 0||d===Oj?mne(f||null,h,d):d,v=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,w=b[y];if(w==null)return{};const x=jI(w,i,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==w)return{reset:{placement:b[0]}};const S=[v[_i(w)],v[x[0]],v[x[1]]],C=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:S}],j=b[y+1];if(j)return{data:{index:y+1,overflows:C},reset:{placement:j}};const E=C.map(V=>{const z=Qs(V.placement);return[V.placement,z&&p?V.overflows.slice(0,2).reduce((D,R)=>D+R,0):V.overflows[0],V.overflows]}).sort((V,z)=>V[1]-z[1]),F=((s=E.filter(V=>V[2].slice(0,Qs(V[0])?2:3).every(z=>z<=0))[0])==null?void 0:s[0])||E[0][0];return F!==l?{data:{index:y+1,overflows:C},reset:{placement:F}}:{}}}},yne=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:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=Ul(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=_i(s),w=no(l),x=_i(l)===l,S=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=d||(x||!b?[Gp(l)]:ine(l)),j=g!=="none";!d&&j&&C.push(...cne(l,b,g,S));const E=[l,...C],P=await c.detectOverflow(t,v),F=[];let V=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&F.push(P[y]),f){const T=jI(s,a,S);F.push(P[T[0]],P[T[1]])}if(V=[...V,{placement:s,overflows:F}],!F.every(T=>T<=0)){var z,D;const T=(((z=i.flip)==null?void 0:z.index)||0)+1,L=E[T];if(L&&(!(f==="alignment"?w!==no(L):!1)||V.every(A=>no(A.placement)===w?A.overflows[0]>0:!0)))return{data:{index:T,overflows:V},reset:{placement:L}};let $=(D=V.filter(O=>O.overflows[0]<=0).sort((O,A)=>O.overflows[1]-A.overflows[1])[0])==null?void 0:D.placement;if(!$)switch(h){case"bestFit":{var R;const O=(R=V.filter(A=>{if(j){const M=no(A.placement);return M===w||M==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(M=>M>0).reduce((M,_)=>M+_,0)]).sort((A,M)=>A[1]-M[1])[0])==null?void 0:R[0];O&&($=O);break}case"initialPlacement":$=l;break}if(s!==$)return{reset:{placement:$}}}return{}}}},xne=new Set(["left","top"]);async function wne(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=_i(n),l=Qs(n),c=no(n)==="y",u=xne.has(a)?-1:1,p=i&&c?-1:1,f=Ul(t,e);let{mainAxis:d,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*p,y:d*u}:{x:d*u,y:h*p}}const bne=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 wne(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}}}}},kne=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:w,y:x}=y;return{x:w,y:x}}},...u}=Ul(e,t),p={x:n,y:r},f=await i.detectOverflow(t,u),d=no(_i(s)),h=NI(d);let g=p[h],b=p[d];if(a){const y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",x=g+f[y],S=g-f[w];g=Cx(x,g,S)}if(l){const y=d==="y"?"top":"left",w=d==="y"?"bottom":"right",x=b+f[y],S=b-f[w];b=Cx(x,b,S)}const v=c.fn({...t,[h]:g,[d]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:a,[d]:l}}}}}};function Oh(){return typeof window<"u"}function ql(e){return _I(e)?(e.nodeName||"").toLowerCase():"#document"}function Hr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ri(e){var t;return(t=(_I(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _I(e){return Oh()?e instanceof Node||e instanceof Hr(e).Node:!1}function Ps(e){return Oh()?e instanceof Element||e instanceof Hr(e).Element:!1}function Ii(e){return Oh()?e instanceof HTMLElement||e instanceof Hr(e).HTMLElement:!1}function Hj(e){return!Oh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Hr(e).ShadowRoot}function ud(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Is(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function vne(e){return/^(table|td|th)$/.test(ql(e))}function Dh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Sne=/transform|translate|scale|rotate|perspective|filter/,Nne=/paint|layout|strict|content/,To=e=>!!e&&e!=="none";let Pg;function jb(e){const t=Ps(e)?Is(e):e;return To(t.transform)||To(t.translate)||To(t.scale)||To(t.rotate)||To(t.perspective)||!Cb()&&(To(t.backdropFilter)||To(t.filter))||Sne.test(t.willChange||"")||Nne.test(t.contain||"")}function jne(e){let t=wo(e);for(;Ii(t)&&!Ol(t);){if(jb(t))return t;if(Dh(t))return null;t=wo(t)}return null}function Cb(){return Pg==null&&(Pg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Pg}function Ol(e){return/^(html|body|#document)$/.test(ql(e))}function Is(e){return Hr(e).getComputedStyle(e)}function Fh(e){return Ps(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wo(e){if(ql(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Hj(e)&&e.host||ri(e);return Hj(t)?t.host:t}function EI(e){const t=wo(e);return Ol(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ii(t)&&ud(t)?t:EI(t)}function Wu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=EI(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=Hr(s);if(i){const l=_x(a);return t.concat(a,a.visualViewport||[],ud(s)?s:[],l&&n?Wu(l):[])}else return t.concat(s,Wu(s,[],n))}function _x(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function AI(e){const t=Is(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ii(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=qp(n)!==i||qp(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function _b(e){return Ps(e)?e:e.contextElement}function wl(e){const t=_b(e);if(!Ii(t))return Xs(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=AI(t);let a=(i?qp(n.width):n.width)/r,l=(i?qp(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Cne=Xs(0);function PI(e){const t=Hr(e);return!Cb()||!t.visualViewport?Cne:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _ne(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Hr(e)?!1:t}function pa(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=_b(e);let a=Xs(1);t&&(r?Ps(r)&&(a=wl(r)):a=wl(e));const l=_ne(i,n,r)?PI(i):Xs(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,p=s.width/a.x,f=s.height/a.y;if(i){const d=Hr(i),h=r&&Ps(r)?Hr(r):r;let g=d,b=_x(g);for(;b&&r&&h!==g;){const v=wl(b),y=b.getBoundingClientRect(),w=Is(b),x=y.left+(b.clientLeft+parseFloat(w.paddingLeft))*v.x,S=y.top+(b.clientTop+parseFloat(w.paddingTop))*v.y;c*=v.x,u*=v.y,p*=v.x,f*=v.y,c+=x,u+=S,g=Hr(b),b=_x(g)}}return Jp({width:p,height:f,x:c,y:u})}function zh(e,t){const n=Fh(e).scrollLeft;return t?t.left+n:pa(ri(e)).left+n}function II(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zh(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Ene(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=ri(r),l=t?Dh(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Xs(1);const p=Xs(0),f=Ii(r);if((f||!f&&!i)&&((ql(r)!=="body"||ud(a))&&(c=Fh(r)),f)){const h=pa(r);u=wl(r),p.x=h.x+r.clientLeft,p.y=h.y+r.clientTop}const d=a&&!f&&!i?II(a,c):Xs(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+d.x,y:n.y*u.y-c.scrollTop*u.y+p.y+d.y}}function Ane(e){return Array.from(e.getClientRects())}function Pne(e){const t=ri(e),n=Fh(e),r=e.ownerDocument.body,s=Xo(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Xo(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+zh(e);const l=-n.scrollTop;return Is(r).direction==="rtl"&&(a+=Xo(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const Bj=25;function Ine(e,t){const n=Hr(e),r=ri(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const p=Cb();(!p||p&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=zh(r);if(u<=0){const p=r.ownerDocument,f=p.body,d=getComputedStyle(f),h=p.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-h);g<=Bj&&(i-=g)}else u<=Bj&&(i+=u);return{width:i,height:a,x:l,y:c}}function Tne(e,t){const n=pa(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=Ii(e)?wl(e):Xs(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,u=r*i.y;return{width:a,height:l,x:c,y:u}}function Wj(e,t,n){let r;if(t==="viewport")r=Ine(e,n);else if(t==="document")r=Pne(ri(e));else if(Ps(t))r=Tne(t,n);else{const s=PI(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Jp(r)}function TI(e,t){const n=wo(e);return n===t||!Ps(n)||Ol(n)?!1:Is(n).position==="fixed"||TI(n,t)}function Rne(e,t){const n=t.get(e);if(n)return n;let r=Wu(e,[],!1).filter(l=>Ps(l)&&ql(l)!=="body"),s=null;const i=Is(e).position==="fixed";let a=i?wo(e):e;for(;Ps(a)&&!Ol(a);){const l=Is(a),c=jb(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ud(a)&&!c&&TI(e,a))?r=r.filter(p=>p!==a):s=l,a=wo(a)}return t.set(e,r),r}function Mne(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Dh(t)?[]:Rne(t,this._c):[].concat(n),r],l=Wj(t,a[0],s);let c=l.top,u=l.right,p=l.bottom,f=l.left;for(let d=1;d<a.length;d++){const h=Wj(t,a[d],s);c=Xo(h.top,c),u=Ll(h.right,u),p=Ll(h.bottom,p),f=Xo(h.left,f)}return{width:u-f,height:p-c,x:f,y:c}}function $ne(e){const{width:t,height:n}=AI(e);return{width:t,height:n}}function Lne(e,t,n){const r=Ii(t),s=ri(t),i=n==="fixed",a=pa(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Xs(0);function u(){c.x=zh(s)}if(r||!r&&!i)if((ql(t)!=="body"||ud(s))&&(l=Fh(t)),r){const h=pa(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();i&&!r&&s&&u();const p=s&&!r&&!i?II(s,l):Xs(0),f=a.left+l.scrollLeft-c.x-p.x,d=a.top+l.scrollTop-c.y-p.y;return{x:f,y:d,width:a.width,height:a.height}}function Ig(e){return Is(e).position==="static"}function Vj(e,t){if(!Ii(e)||Is(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ri(e)===n&&(n=n.ownerDocument.body),n}function RI(e,t){const n=Hr(e);if(Dh(e))return n;if(!Ii(e)){let s=wo(e);for(;s&&!Ol(s);){if(Ps(s)&&!Ig(s))return s;s=wo(s)}return n}let r=Vj(e,t);for(;r&&vne(r)&&Ig(r);)r=Vj(r,t);return r&&Ol(r)&&Ig(r)&&!jb(r)?n:r||jne(e)||n}const One=async function(e){const t=this.getOffsetParent||RI,n=this.getDimensions,r=await n(e.floating);return{reference:Lne(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Dne(e){return Is(e).direction==="rtl"}const Fne={convertOffsetParentRelativeRectToViewportRelativeRect:Ene,getDocumentElement:ri,getClippingRect:Mne,getOffsetParent:RI,getElementRects:One,getClientRects:Ane,getDimensions:$ne,getScale:wl,isElement:Ps,isRTL:Dne};function MI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zne(e,t){let n=null,r;const s=ri(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 u=e.getBoundingClientRect(),{left:p,top:f,width:d,height:h}=u;if(l||t(),!d||!h)return;const g=Cf(f),b=Cf(s.clientWidth-(p+d)),v=Cf(s.clientHeight-(f+h)),y=Cf(p),x={rootMargin:-g+"px "+-b+"px "+-v+"px "+-y+"px",threshold:Xo(0,Ll(1,c))||1};let S=!0;function C(j){const E=j[0].intersectionRatio;if(E!==c){if(!S)return a();E?a(!1,E):r=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!MI(u,e.getBoundingClientRect())&&a(),S=!1}try{n=new IntersectionObserver(C,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return a(!0),i}function Kj(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,u=_b(e),p=s||i?[...u?Wu(u):[],...t?Wu(t):[]]:[];p.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const f=u&&l?zne(u,n):null;let d=-1,h=null;a&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let g,b=c?pa(e):null;c&&v();function v(){const y=pa(e);b&&!MI(b,y)&&n(),b=y,g=requestAnimationFrame(v)}return n(),()=>{var y;p.forEach(w=>{s&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const Hne=bne,Bne=gne,Wne=kne,Vne=yne,Uj=hne,Kne=(e,t,n)=>{const r=new Map,s={platform:Fne,...n},i={...s.platform,_c:r};return pne(e,t,{...s,platform:i})};var Une=typeof document<"u",qne=function(){},Qf=Une?m.useLayoutEffect:qne;function Xp(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(!Xp(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)&&!Xp(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function $I(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qj(e,t){const n=$I(e);return Math.round(t*n)/n}function Tg(e){const t=m.useRef(e);return Qf(()=>{t.current=e}),t}function Yj(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:u}=e,[p,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);Xp(d,r)||h(r);const[g,b]=m.useState(null),[v,y]=m.useState(null),w=m.useCallback(A=>{A!==j.current&&(j.current=A,b(A))},[]),x=m.useCallback(A=>{A!==E.current&&(E.current=A,y(A))},[]),S=i||g,C=a||v,j=m.useRef(null),E=m.useRef(null),P=m.useRef(p),F=c!=null,V=Tg(c),z=Tg(s),D=Tg(u),R=m.useCallback(()=>{if(!j.current||!E.current)return;const A={placement:t,strategy:n,middleware:d};z.current&&(A.platform=z.current),Kne(j.current,E.current,A).then(M=>{const _={...M,isPositioned:D.current!==!1};T.current&&!Xp(P.current,_)&&(P.current=_,cr.flushSync(()=>{f(_)}))})},[d,t,n,z,D]);Qf(()=>{u===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(A=>({...A,isPositioned:!1})))},[u]);const T=m.useRef(!1);Qf(()=>(T.current=!0,()=>{T.current=!1}),[]),Qf(()=>{if(S&&(j.current=S),C&&(E.current=C),S&&C){if(V.current)return V.current(S,C,R);R()}},[S,C,R,V,F]);const L=m.useMemo(()=>({reference:j,floating:E,setReference:w,setFloating:x}),[w,x]),$=m.useMemo(()=>({reference:S,floating:C}),[S,C]),O=m.useMemo(()=>{const A={position:n,left:0,top:0};if(!$.floating)return A;const M=qj($.floating,p.x),_=qj($.floating,p.y);return l?{...A,transform:"translate("+M+"px, "+_+"px)",...$I($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:_}},[n,l,$.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:R,refs:L,elements:$,floatingStyles:O}),[p,R,L,$,O])}const Yne=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?Uj({element:r.current,padding:s}).fn(n):{}:r?Uj({element:r,padding:s}).fn(n):{}}}},Gj=(e,t)=>{const n=Hne(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gne=(e,t)=>{const n=Wne(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jne=(e,t)=>{const n=Vne(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xne=(e,t)=>{const n=Bne(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qne=(e,t)=>{const n=Yne(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zne={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},ere={beaconOptions:{offset:-18}},LI={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},tre={isFixed:!1,locale:LI,placement:"bottom"},nre={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},jt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},Hn={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"},ze={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Bs={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},kt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},rre="react-joyride-portal";function sre(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function al(...e){return Yte({all:!0,isMergeableObject:t=>!(!er.plainObject(t)||m.isValidElement(t))})(...e)}function OI(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function hi(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=Ag(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&&OI(e.type)==="function")try{i=hi(e.type({}),t)}catch{i=Ag(n)}else i=Ag(n);return i}function Wn(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 ire(e,t){const n=sre(t);return{...e,...n}}function Vu(){}function ore(e){return Object.keys(e)}function Qp(e,...t){if(!er.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 Jj(e,...t){if(!er.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 Ex(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(OI(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(er.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):Ex(i,t,n))});if(er.function(e.type)&&!Object.values(e.props).length)try{return Ex(e.type({}),t,n)}catch{return e}return e}function Xj(e){return ore(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Eb(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function Qj(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 Ab(e){return e?e.getBoundingClientRect():null}function are(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 Zr(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 lre(e,t,n){const r=Ab(e),s=Yl(e),i=s?!s.isSameNode(vr()):!1,a=n??Gl(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(vr())||(c+=vr().scrollTop)),Math.floor(c-t)}function Yl(e,t){if(!e)return vr();const n=SI(e);if(n){if(n.isSameNode(vr()))return t?document:vr();if(!(n.scrollHeight>n.offsetHeight))return vr()}return n}function cre(e){const t=e.getBoundingClientRect(),n=vr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function ure(e,t){if(!e)return 0;const n=SI(e)??vr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Ab(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(DI(e)||dre(e))){const p=e.getBoundingClientRect(),f=p.top-((s==null?void 0:s.top)??0),d=f+p.height,h=n.clientHeight,g=h*.2;f>=g&&d<=h-g?c=i:c=f+i}const u=Math.floor(c-t-r);return u<0?0:u}function dre(e){return e.offsetParent!==document.body}function DI(e){if(!e)return!1;const t=Yl(e);return t?!t.isSameNode(vr()):!1}function Gl(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?Gl(e.parentNode,t):!1}function _f(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 Zj(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==ze.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Yl(s):vr(),l=a?!a.isSameNode(vr()):!1;return(r.isFixed||Gl(s))&&!l?!1:a.scrollHeight>a.clientHeight}function vr(){return document.scrollingElement??document.documentElement}function e1(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=tne.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function fre(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 FI={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Ef={...FI,borderRadius:4,padding:8};function pre(e,t){const{styles:n}=e,r=al(n??{},t.styles??{});let{width:s}=t;Eb()&&(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 al({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...FI,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(${fre(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:{...Ef,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Ef,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Ef,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Ef,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 hre=["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 Pb(e,t){if(!t)return null;const n=al(tre,Jj(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=al(Zne,e.options??{},Jj(t,...hre)),s=pre(e,{...n,...r}),i=al(ere,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:al(LI,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:mre(r.spotlightPadding),styles:s}}function mre(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 gre(e,t,n){const{action:r}=t,s=n&&[jt.PREV,jt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function zI(e,t=!1){return er.plainObject(e)?e.target?!0:(Wn(t,"tour","target is missing from the step"),!1):(Wn(t,"tour","step must be an object"),!1)}function HI(e,t=!1){return er.array(e)?e.every(n=>zI(n,t)):(Wn(t,"tour","steps must be an array"),!1)}var yre=class{constructor(e){wn(this,"beaconPosition",null);wn(this,"debug");wn(this,"eventListeners",new Map);wn(this,"listeners",new Set);wn(this,"props");wn(this,"snapshot");wn(this,"state");wn(this,"steps");wn(this,"tooltipPosition",null);wn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});wn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);wn(this,"getServerSnapshot",()=>this.snapshot);wn(this,"getSnapshot",()=>this.snapshot);wn(this,"getEventState",()=>Qp(this.snapshot,"positioned"));wn(this,"getState",()=>Qp(this.snapshot,"positioned"));wn(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Wn(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===ze.BEACON_BEFORE||this.state.lifecycle===ze.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)});wn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});wn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});wn(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)}});wn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));wn(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,!wb(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=er.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,er.number(t)&&Wn(this.debug,"tour","initialStepIndex is ignored in controlled mode")):er.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&Wn(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:jt.INIT,controlled:s,index:i,lifecycle:ze.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?kt.READY:kt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===kt.WAITING&&e.size>0?{...e,status:kt.RUNNING}:e}getStep(e){return Pb(this.props,this.steps[e??this.state.index])}};function xre(e){return new yre(e)}function t1(e,t){return Math.min(Math.max(e,0),t)}function wre(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:(v=null)=>{const{index:y,status:w}=i();w===kt.RUNNING&&e.current.updateState({action:jt.CLOSE,index:y+1,origin:v,lifecycle:ze.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:v=>{const{controlled:y,size:w,status:x}=i();if(y){Wn(r.current,"tour","go() is not supported in controlled mode");return}x===kt.RUNNING&&e.current.updateState({action:jt.GO,index:v,lifecycle:ze.COMPLETE,positioned:!1,scrolling:!1,status:v<w?x:kt.FINISHED,waiting:!1})},info:()=>Qp(e.current.getSnapshot(),"positioned"),next:v=>{const{index:y,size:w,status:x}=i();x===kt.RUNNING&&e.current.updateState({action:jt.NEXT,index:t1(y+1,w),lifecycle:ze.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:v}=i();v===kt.RUNNING&&e.current.updateState({action:jt.UPDATE,lifecycle:ze.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:v=>{const{index:y,size:w,status:x}=i();x===kt.RUNNING&&e.current.updateState({action:jt.PREV,index:t1(y-1,w),lifecycle:ze.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},reset:(v=!1)=>{const{controlled:y}=i();if(y){Wn(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:jt.RESET,index:0,lifecycle:ze.INIT,positioned:!1,scrolling:!1,status:v?kt.RUNNING:kt.READY,waiting:!1})},skip:v=>{const{status:y}=i();y===kt.RUNNING&&e.current.updateState({action:jt.SKIP,lifecycle:ze.COMPLETE,origin:v,positioned:!1,scrolling:!1,status:kt.SKIPPED,waiting:!1})},start:v=>{const{index:y,size:w}=i();s.current(),e.current.updateState({action:jt.START,index:er.number(v)?v:y,lifecycle:ze.INIT,positioned:!1,scrolling:!1,status:w?kt.RUNNING:kt.WAITING,waiting:!1},!0)},stop:(v=!1)=>{const{index:y,status:w}=i();[kt.FINISHED,kt.SKIPPED].includes(w)||e.current.updateState({action:jt.STOP,index:y+(v?1:0),lifecycle:ze.COMPLETE,positioned:!1,scrolling:!1,status:kt.PAUSED,waiting:!1})}}},[e])}const bre=new Set(["origin","positioned"]);function kre(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Wn(!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]&&!bre.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||Wn(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function vre(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 u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(u=r.current)==null||u.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Gi(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 Sre(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:u,index:p,lifecycle:f,positioned:d,scrolling:h,size:g,status:b}=a,v=mI(l)??null,y=m.useRef(null),w=m.useRef(i),x=m.useRef(a),S=m.useRef(s),C=m.useRef(l),j=m.useRef(v),E=m.useRef(n),P=m.useRef(null),F=m.useRef(null),V=m.useRef(null);w.current=i,x.current=a,S.current=s,C.current=l,j.current=v,E.current=n;const z=()=>{P.current&&(clearInterval(P.current),P.current=null),F.current=null,V.current&&(V.current.cancel(),V.current=null)};m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:D}=Gi(x.current,S.current);(D("action",[jt.NEXT,jt.PREV,jt.SKIP,jt.CLOSE])||y.current===jt.CLOSE&&u===jt.START)&&(y.current=u)},[u]),m.useEffect(()=>{if(!S.current)return()=>{z()};const{hasChanged:D}=Gi(x.current,S.current),R=C.current;if(D("index")&&z(),b!==kt.RUNNING||!R||f!==ze.INIT)return()=>{z()};const{hasChangedTo:T}=Gi(x.current,S.current);T("status",kt.RUNNING)&&[kt.IDLE,kt.READY,kt.PAUSED].includes(S.current.status)&&r(Hn.TOUR_START,R),c.current.cleanupPositionData();const{debug:L}=w.current;if(R.before&&!V.current){Wn(L,`step:${p}`,"before()",R),V.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(Hn.STEP_BEFORE_HOOK,R,{action:y.current??x.current.action});const $=()=>{V.current=null,c.current.updateState({action:y.current??x.current.action,waiting:!1,lifecycle:ze.READY})},O=new AbortController,A=R.beforeTimeout;V.current={cancel:()=>O.abort()};const M=A?setTimeout(()=>{O.signal.aborted||(Wn(L,`step:${p}`,"before()","timed out",`${A}ms`),O.abort(),t(R,"before_hook"),r(Hn.ERROR,R,{error:new Error("Step before hook timed out")}),$())},A):null;R.before({...c.current.getState(),action:y.current??c.current.getState().action,step:R}).then(()=>{O.signal.aborted||(M&&clearTimeout(M),$())}).catch(_=>{O.signal.aborted||(M&&clearTimeout(M),t(R,"before_hook"),r(Hn.ERROR,R,{error:_ instanceof Error?_:new Error(String(_))}),$())})}else if(!V.current){P.current&&F.current!==R.target&&z();const $=Zr(R.target);if($&&_f($))z(),c.current.updateState({action:y.current??jt.UPDATE,lifecycle:ze.READY,waiting:!1});else if(R.targetWaitTimeout===0)c.current.updateState({action:y.current??jt.UPDATE,lifecycle:ze.READY,waiting:!1});else if(!P.current){const{targetWaitTimeout:O}=R,A=Date.now();F.current=R.target,Wn(L,`step:${p}`,"polling","started",`${O}ms`),c.current.updateState({waiting:!0}),P.current=setInterval(()=>{const M=Zr(R.target),_=Date.now()-A,U=_>=O;(M&&_f(M)||U)&&(Wn(L,`step:${p}`,"polling",M&&_f(M)?"found":"timed out",`${_}ms`),z(),c.current.updateState({action:y.current??jt.UPDATE,lifecycle:ze.READY,waiting:!1}))},100)}}return()=>{z()}},[t,r,p,f,b,c]),m.useEffect(()=>{if(!S.current)return;const{hasChanged:D,hasChangedTo:R,previous:T}=Gi(x.current,S.current),L=C.current;if(!L)return;const $=Zr(L.target),O=!!$;if(O&&_f($)){if(R("lifecycle",ze.READY)&&T.lifecycle===ze.INIT&&r(Hn.STEP_BEFORE,L,{action:y.current??x.current.action}),R("lifecycle",ze.READY)){const A=x.current,M=gre(L,A,w.current.continuous)?ze.TOOLTIP:ze.BEACON,_=Zr(L.scrollTarget??L.spotlightTarget??L.target),U=Zj({isFirstStep:A.index===0,scrollToFirstStep:w.current.scrollToFirstStep,step:L,target:_,targetLifecycle:M}),q=M===ze.TOOLTIP?ze.TOOLTIP_BEFORE:ze.BEACON_BEFORE;Wn(w.current.debug,`step:${p}`,"scroll",U?"needed":"skipped"),c.current.updateState({action:jt.UPDATE,lifecycle:q,scrolling:U})}}else if(x.current.status===kt.RUNNING&&f!==ze.INIT&&f!==ze.COMPLETE&&D("lifecycle")){Wn(w.current.debug,`step:${p}`,O?"Target not visible":"Target not mounted",L),t(L,"target_not_found"),r(Hn.TARGET_NOT_FOUND,L);const A=x.current;A.controlled||c.current.updateState({action:jt.UPDATE,index:A.index+(A.action===jt.PREV?-1:1),lifecycle:ze.INIT})}},[t,r,p,f,c]),m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:D,previous:R}=Gi(x.current,S.current),T=C.current,L=j.current;if(T&&D("lifecycle",ze.TOOLTIP_BEFORE)&&R.lifecycle===ze.BEACON){const A=Zr(T.scrollTarget??T.spotlightTarget??T.target);if(Zj({isFirstStep:x.current.index===0,scrollToFirstStep:w.current.scrollToFirstStep,step:T,target:A,targetLifecycle:ze.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const $=f===ze.BEACON_BEFORE||f===ze.TOOLTIP_BEFORE;if(T&&$&&!h){const A=f===ze.TOOLTIP_BEFORE?ze.TOOLTIP:ze.BEACON;c.current.updateState({action:jt.UPDATE,lifecycle:A})}T&&D("lifecycle",ze.BEACON)&&r(Hn.BEACON,T),T&&D("lifecycle",ze.TOOLTIP)&&r(Hn.TOOLTIP,T);const O=x.current;if((O.status===kt.RUNNING||O.controlled&&O.status===kt.PAUSED&&T)&&L&&D("lifecycle",ze.COMPLETE)&&R.lifecycle===ze.TOOLTIP&&(r(Hn.STEP_AFTER,L,{action:y.current??jt.UPDATE,index:R.index??O.index,lifecycle:O.lifecycle}),L.after)){r(Hn.STEP_AFTER_HOOK,L,{action:y.current??jt.UPDATE,index:R.index??O.index,lifecycle:O.lifecycle});try{L.after({...c.current.getState(),action:y.current??jt.UPDATE,index:R.index??O.index,lifecycle:O.lifecycle,step:L})}catch{}}},[r,f,d,h,c]),m.useEffect(()=>{if(!S.current)return;const{hasChangedTo:D,previous:R}=Gi(x.current,S.current),T=C.current,L=j.current;g&&!T&&f===ze.INIT&&c.current.updateState({action:jt.UPDATE,lifecycle:ze.COMPLETE,status:kt.FINISHED}),!x.current.controlled&&b===kt.RUNNING&&D("lifecycle",ze.COMPLETE)&&p<g&&c.current.updateState({action:jt.UPDATE,lifecycle:ze.INIT}),D("lifecycle",ze.COMPLETE)&&p>=g&&c.current.updateState({action:jt.UPDATE,lifecycle:ze.COMPLETE,status:kt.FINISHED});const $=T??L??Pb(w.current,w.current.steps[p-1]);if($&&D("status",[kt.FINISHED,kt.SKIPPED])){let O;T?O=p:L?O=R.index??p:O=p-1,r(Hn.TOUR_END,$,{index:O}),x.current.controlled||E.current.reset(),y.current=null}T&&D("action",jt.STOP)&&(y.current=null,r(Hn.TOUR_STATUS,T)),T&&D("action",jt.RESET)&&(r(Hn.TOUR_STATUS,T),y.current=null)},[u,r,p,f,g,b,c])}function Nre({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,p=m.useRef(void 0),f=m.useRef(r),d=m.useRef(e);f.current=r,d.current=e,m.useEffect(()=>{const h=p.current;if(p.current=n,!h||n===h)return;const{hasChanged:g}=Gi(n,h);if(wb(h.steps,u)||(HI(u,i)?s.current.setSteps(u):(Wn(i,"tour","Steps are not valid",u),t(Hn.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&d.current.start(c??a):d.current.stop();else if(er.number(c)&&g("stepIndex")){const b=er.number(h.stepIndex)&&h.stepIndex<c?jt.NEXT:jt.PREV;[kt.FINISHED,kt.SKIPPED].includes(f.current.status)||s.current.updateState({action:b,index:c,lifecycle:ze.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,u,s])}function jre(e,t){var l,c,u,p;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===ze.BEACON_BEFORE&&(n!=null&&n.placement)){const f=Cre(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===ze.TOOLTIP_BEFORE){const{placement:f}=i;if(f==="top"){const d=((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-=d+g}else if(f==="left"||f==="right"){const d=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((p=Zr(i.target))==null?void 0:p.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+h/2-d/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Cre(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:u,status:p}=r,f=m.useRef(null),d=m.useRef(r),h=m.useRef(t),g=m.useRef(n),b=m.useRef(s);d.current=r,h.current=t,g.current=n,b.current=s,m.useEffect(()=>()=>{var v;(v=f.current)==null||v.call(f)},[]),m.useEffect(()=>{var C;if(!h.current||!b.current)return;const{hasChangedTo:v}=Gi(d.current,h.current),y=b.current,{debug:w}=g.current,{scrollDuration:x}=y,S=l===ze.BEACON_BEFORE||l===ze.TOOLTIP_BEFORE;if(p===kt.RUNNING&&S&&u&&v("positioned",!0)){const j=Zr(y.scrollTarget??y.spotlightTarget??y.target),E=i.current.getPositionData("beacon"),P=Yl(j),F=P?!P.isSameNode(vr()):!1;(C=f.current)==null||C.call(f),(async()=>{if(F&&!Gl(P)){const O=vr(),A=cre(P),M={initial:O.scrollTop,target:A,element:O,duration:x};e(Hn.SCROLL_START,y,{scroll:M});const{cancel:_,promise:U}=e1(A,{element:O,duration:x});f.current=_,await U,e(Hn.SCROLL_END,y,{scroll:M})}const z=Math.floor(ure(j,y.scrollOffset))||0,D=F?z:jre(z,{beaconPosition:E,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Wn(w,`step:${a}`,"scroll",F?"custom":"document",`${z} → ${D}`);const R=P,T={initial:R.scrollTop,target:D,element:R,duration:x};e(Hn.SCROLL_START,y,{scroll:T});const{cancel:L,promise:$}=e1(D,{element:R,duration:x});f.current=L,await $,e(Hn.SCROLL_END,y,{scroll:T}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,u,p,i])}function Ere(e){const t=ute(()=>ire(nre,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=m.useRef(xre(t)),u=KE.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[p,f]=m.useState([]),d=m.useCallback((C,j)=>{f(E=>[...E,{reason:j,step:C}])},[]),h=m.useCallback(()=>{f([])},[]);kre(c,n);const g=wre(c,n,h),b=vre(s,g,c),{index:v,size:y,status:w}=u,x=mI(u),S=m.useMemo(()=>Pb(t,l[v]),[v,t,l]);return dte(()=>{i&&y&&HI(l,n)&&g.start(a??r)}),cte(()=>{i&&y&&w===kt.IDLE&&c.current.updateState({status:kt.READY})},[i,y,w]),Nre({controls:g,emitEvent:b,props:t,state:u,store:c}),Sre({addFailure:d,controls:g,emitEvent:b,previousState:x,props:t,state:u,step:S,store:c}),_re({emitEvent:b,previousState:x,props:t,state:u,step:S,store:c}),{controls:g,failures:p,mergedProps:t,state:u,step:S,store:c}}function Are(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(er.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=rre,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Pre={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Ire({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Vu;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
311
- @keyframes joyride-loader-spin {
312
- to { transform: rotate(360deg); }
313
- }
314
- `)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const c=n;l=st.createElement(c,{step:t})}else l=st.createElement("div",{style:{...Pre,height:s,width:i,borderTopColor:t.primaryColor}});return st.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Tre={height:0,isFixed:!1,left:0,top:0,width:0};function Pc(e,t){const n=Zr(e);if(!n)return Tre;const r=Ab(n),s=Gl(n),i=lre(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 Rre(e,t,n){const[r,s]=m.useState(()=>Pc(e,t)),i=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(f=>{const d=Pc(e,t);return f.top===d.top&&f.left===d.left&&f.width===d.width&&f.height===d.height&&f.isFixed===d.isFixed?f:d})},100)},[e,t]);m.useEffect(()=>{let f=null;const d=g=>{a.current=Yl(g,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(g)),s(Pc(e,t))},h=Zr(e);return h?d(h):(f=new MutationObserver(()=>{const g=Zr(e);g&&(f==null||f.disconnect(),f=null,d(g))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(g=c.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&s(Pc(e,t)),l.current=n},[n,e,t]);let p=r;return l.current&&!n&&(p=Pc(e,t)),p}function Mre(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function n1(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 $re=[ze.BEACON_BEFORE,ze.BEACON];function Lre(e){var $,O;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:p,spotlightRadius:f,spotlightTarget:d,styles:h,target:g,waiting:b}=e,v=fte(),y=Rre(d??g,p,u||b),w=m.useRef(null),x=(s===ze.TOOLTIP||s===ze.TOOLTIP_BEFORE)&&l!=="center",[S,C]=m.useState(!1),j=c?($=w.current)==null?void 0:$.offsetParent:null,E=(j==null?void 0:j.clientWidth)??v.width,P=(j==null?void 0:j.clientHeight)??are()??v.height,F=((O=h.overlay)==null?void 0:O.backgroundColor)??"rgba(0, 0, 0, 0.5)",V=m.useMemo(()=>{const{backgroundColor:A,mixBlendMode:M,..._}=h.overlay;return{height:P,pointerEvents:"none",..._}},[P,h.overlay]),z=x&&!u&&!b;m.useEffect(()=>{z?requestAnimationFrame(()=>C(!0)):C(!1)},[z]);const D=n&&$re.includes(s),R=!n&&s!==ze.TOOLTIP;if(r||!b&&(D||R))return null;let T="";if(z)if(c&&j){const A=Zr(d??g);if(A){const M=Qj(A),_=Qj(j);T=n1(M.left-_.left-p.left,M.top-_.top-p.top,A.offsetWidth+p.left+p.right,A.offsetHeight+p.top+p.bottom,f)}}else T=n1(y.left,y.top,y.width,y.height,f);const L=Mre(E,P,T);return st.createElement("div",{ref:w,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:V},st.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:P,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:E}},st.createElement("path",{d:L,fill:F,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),T&&st.createElement("path",{d:T,fill:F,style:{opacity:S?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),T&&Object.keys(h.spotlight).length>0&&st.createElement("path",{d:T,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function BI(e){const{children:t,element:n}=e;return n?cr.createPortal(t,n):null}const Ore='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Dre(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return Vu;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(Ore)],{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 wi(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 Fre(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...wi(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...wi(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...wi(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...wi(e,t,n)};default:return null}}function zre(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...wi(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...wi(e,r,n)};case"left":return{right:-n,top:t.y??0,...wi(e,r,n)};case"right":return{left:-n,top:t.y??0,...wi(e,r,n)};default:return{}}}function Hre({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!wi(r,n,i))return null;c=st.createElement("span",{style:{flexShrink:0}},st.createElement(l,{base:n,placement:r,size:i}))}else{const u=Fre(r,n,i);if(!u)return null;c=st.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},st.createElement("polygon",{fill:"currentColor",points:u.points}))}return st.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...zre(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function Bre(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:u,step:p,styles:f}=e,d=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return Vu;const v=document.createElement("style");v.id="joyride-beacon-animation",a&&v.setAttribute("nonce",a),v.appendChild(document.createTextNode(`
315
- @keyframes joyride-beacon-inner {
316
- 20% {
317
- opacity: 0.9;
318
- }
319
-
320
- 90% {
321
- opacity: 0.7;
322
- }
323
- }
324
-
325
- @keyframes joyride-beacon-outer {
326
- 0% {
327
- transform: scale(1);
328
- }
329
-
330
- 45% {
331
- opacity: 0.7;
332
- transform: scale(0.75);
333
- }
334
-
335
- 100% {
336
- opacity: 0.9;
337
- transform: scale(1);
338
- }
339
- }
340
- `)),document.head.appendChild(v);const y=setTimeout(()=>{er.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(y);const w=document.getElementById("joyride-beacon-animation");w!=null&&w.parentNode&&w.parentNode.removeChild(w)}},[h,a,c]);const g=hi(i.open);let b;if(t){const v=t;b=st.createElement(v,{continuous:n,index:r,isLastStep:s,size:u,step:p})}else b=st.createElement("span",{style:f.beacon},st.createElement("span",{style:f.beaconOuter}),st.createElement("span",{style:f.beaconInner}));return st.createElement("button",{ref:d,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:g,type:"button"},b)}function Wre({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return st.createElement("button",{style:i,type:"button",...t},st.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"},st.createElement("g",null,st.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 Vre(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:p,styles:f,title:d}=l,h={};u.includes("primary")&&(h.primary=st.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...i})),u.includes("skip")&&!s&&(h.skip=st.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=st.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&st.createElement(Wre,{"data-testid":"button-close",styles:f.buttonClose,...n});const g=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":hi(p),"aria-describedby":"joyride-tooltip-content"};return st.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...g},st.createElement("div",{style:f.tooltipContainer},d&&st.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},d),st.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},p)),u.some(b=>b==="back"||b==="primary"||b==="skip")&&st.createElement("div",{style:f.tooltipFooter},st.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Kre(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(Bs.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(Bs.BUTTON_CLOSE):n.close(Bs.BUTTON_CLOSE)},u=y=>{if(y.preventDefault(),!t){n.close(Bs.BUTTON_PRIMARY);return}n.next(Bs.BUTTON_PRIMARY)},p=y=>{y.preventDefault(),n.skip(Bs.BUTTON_SKIP)},f=()=>{const{back:y,close:w,last:x,next:S,nextWithProgress:C,skip:j}=a.locale,E=hi(y),P=hi(w),F=hi(x),V=hi(S),z=hi(j);let D=w,R=P;if(t){if(D=S,R=V,a.showProgress&&!s){const T=hi(C,{step:r+1,steps:i});D=Ex(C,r+1,i),R=T}s&&(D=x,R=F)}return{backProps:{"aria-label":E,children:y,"data-action":"back",onClick:l,role:"button",title:E},closeProps:{"aria-label":P,children:w,"data-action":"close",onClick:c,role:"button",title:P},primaryProps:{"aria-label":R,children:D,"data-action":"primary",onClick:u,role:"button",title:R},skipProps:{"aria-label":z,children:j,"data-action":"skip",onClick:p,role:"button",title:z},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:h,tooltipComponent:g,...b}=a;let v;if(g){const y=g;v=st.createElement(y,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b})}else v=st.createElement(Vre,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return v}function Ure(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function qre(e,t,n){var r,s;return e?[Xne()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Jne({crossAxis:!1,fallbackPlacements:Ure(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Yre(e){var M,_,U,q,B;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:p,size:f,step:d,target:h,updateState:g}=e,b=m.useRef(null),v=m.useRef({}),y=m.useRef({}),w=d.placement==="center",x=d.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(()=>DI(h)?Yl(h):void 0,[h]),j=m.useMemo(()=>Gl(h),[h]),E=m.useMemo(()=>C?{boundary:C,rootBoundary:"viewport"}:{},[C]),P=w||x?"bottom":d.placement,F=w?"fixed":((M=d.floatingOptions)==null?void 0:M.strategy)??(d.isFixed||j?"fixed":"absolute"),V=m.useMemo(()=>{var Q,se,oe,ve;return w?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[Gj(({placement:re})=>{var ae;let ue="right";re.startsWith("top")?ue="top":re.startsWith("bottom")?ue="bottom":re.startsWith("left")&&(ue="left");const te=d.spotlightTarget?0:d.spotlightPadding[ue];return d.offset+te+((ae=d.floatingOptions)!=null&&ae.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(Q=d.floatingOptions)==null?void 0:Q.hideArrow]),...qre(x,d,P),Gne({padding:10,...E,...(se=d.floatingOptions)==null?void 0:se.shiftOptions}),...(oe=d.floatingOptions)!=null&&oe.hideArrow?[]:[Qne({element:b,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((ve=d.floatingOptions)==null?void 0:ve.middleware)??[]]},[w,d,x,P,E]),z=Yj({...w?{elements:{reference:S}}:{},placement:P,strategy:F,middleware:V}),D=Yj({strategy:F,placement:d.beaconPlacement??(x||w?"bottom":d.placement),middleware:m.useMemo(()=>{var Q,se;return[Gj(((se=(Q=d.floatingOptions)==null?void 0:Q.beaconOptions)==null?void 0:se.offset)??-18)]},[(U=(_=d.floatingOptions)==null?void 0:_.beaconOptions)==null?void 0:U.offset]),whileElementsMounted:Kj});y.current=z.middlewareData,v.current=D.middlewareData,m.useEffect(()=>{var oe;const{floating:Q,reference:se}=z.elements;if(!(!se||!Q||s!==ze.TOOLTIP))return Kj(se,Q,z.update,(oe=d.floatingOptions)==null?void 0:oe.autoUpdate)},[s,z.update,(q=d.floatingOptions)==null?void 0:q.autoUpdate,d.target,z.elements]),m.useEffect(()=>{!w&&h&&z.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,w,h,z.refs]),m.useEffect(()=>{z.isPositioned&&c("tooltip",{placement:z.placement,x:z.x??0,y:z.y??0,middlewareData:y.current})},[c,z.isPositioned,z.placement,z.x,z.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:v.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const R=d.zIndex+100,T=m.useCallback(Q=>{Q.type==="mouseenter"&&d.beaconTrigger!=="hover"||g({lifecycle:ze.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,g]),L=m.useCallback(Q=>{Q&&(z.refs.setFloating(Q),u(Q))},[z.refs,u]),{arrow:$,floater:O}=d.styles;let A=null;if(s===ze.TOOLTIP||s===ze.TOOLTIP_BEFORE){const Q=Xj({...O,...z.floatingStyles,zIndex:R,opacity:a&&z.isPositioned?1:0,...!a&&{transition:"none"}});A=st.createElement("div",{ref:L,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:Q},st.createElement(Kre,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:d}),!w&&!((B=d.floatingOptions)!=null&&B.hideArrow)&&st.createElement(Hre,{arrowComponent:d.arrowComponent,arrowRef:b,base:d.arrowBase,placement:z.placement,position:z.middlewareData.arrow,size:d.arrowSize,styles:$}))}else(s===ze.BEACON||s===ze.BEACON_BEFORE)&&(A=st.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:Xj({...D.floatingStyles,zIndex:R})},st.createElement(Bre,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:d.locale,nonce:i,onInteract:T,shouldFocus:p,size:f,step:d,styles:d.styles})));return st.createElement(BI,{element:l},A)}function Gre(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:p,updateState:f}=e,[d,h]=m.useState(null);Dre(p.disableFocusTrap?null:d,"[data-action=primary]");const g=Zr(p.target),b=s===ze.TOOLTIP;return!zI(p)||!er.domElement(g)?null:st.createElement(Yre,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:b,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:p,target:g,updateState:f})}function Jre({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,p=Are(c),{index:f,lifecycle:d,status:h}=n,g=h===kt.RUNNING,[b,v]=m.useState(!1),y=m.useRef(null),w=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?w===0?v(!0):y.current=setTimeout(()=>{v(!0)},w):v(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[w,n.waiting]),m.useEffect(()=>{if(!g)return;const C=j=>{!r||d!==ze.TOOLTIP||j.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Bs.KEYBOARD):e.close(Bs.KEYBOARD))};return document.body.addEventListener("keydown",C,{passive:!0}),()=>{document.body.removeEventListener("keydown",C)}},[e,g,d,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Bs.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Bs.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const S=n.action===jt.START&&!r.skipBeacon&&r.placement!=="center";return st.createElement(st.Fragment,null,d!==ze.INIT&&st.createElement(Gre,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),st.createElement(BI,{element:p},st.createElement(st.Fragment,null,b&&st.createElement(Ire,{nonce:l,step:r}),!S&&st.createElement(Lre,{...r,continuous:i,lifecycle:d,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Xre(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=Ere(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Qp(s,"positioned"),[s]),step:i,Tour:Eb()?st.createElement(Jre,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function Qre(e){const{Tour:t}=Xre(e);return t}function Zre(e){return Eb()?st.createElement(Qre,e):null}function ese(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 tse(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function nse(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Af="af:onboarding";function rse({page:e,hasNodes:t=!1}){const{t:n}=pr(),[r,s]=m.useState(!1),[i,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?ese(n):t?tse(n):nse(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(Af),p=u?JSON.parse(u):{};if(p.completed||p[e]){s(!1),a([]);return}localStorage.setItem(Af,JSON.stringify({...p,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=p=>{var g;const f=p.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 b=localStorage.getItem(Af)||"{}",v=JSON.parse(b);h===n("onboarding:skip")?(v.projects=!0,v.flow=!0,v.completed=!0):v[e]=!0,localStorage.setItem(Af,JSON.stringify(v)),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",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(Zre,{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 sse(){const{navigate:e,path:t}=ti(),[n,r]=m.useState([]),[s,i]=m.useState(!1);if(m.useEffect(()=>{let p=!1;const f=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const g=await h.json();if(p)return;const b=Array.isArray(g.runs)?g.runs:[];r(b.filter(v=>v&&v.status==="running"))}catch{}};f();const d=window.setInterval(f,3e3);return()=>{p=!0,window.clearInterval(d)}},[]),n.length===0)return null;const a=p=>{const f=new URLSearchParams({flowId:p.flowId,flowSource:p.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"))||"",u=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!u&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(p=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(p.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(p),title:`${p.flowId} · ${p.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:p.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:p.runId.slice(0,12)})]},`${p.flowId}:${p.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>u?a(n[0]):i(p=>!p),title:u?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:u?n[0].flowId:`${n.length} running`})]})]})}function WI(e){return e==="/likee-context"||e==="/likee_context"}function ise(){const{navigate:e}=ti();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class ose 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 ase({authUser:e}){const{path:t}=ti();return t==="/projects"||t==="/"?o.jsx(La,{authUser:e}):t==="/nodes"?o.jsx(La,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(La,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(La,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(La,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?o.jsx(Hee,{authUser:e}):t==="/mcps"?o.jsx(Pee,{}):t==="/schedules"?o.jsx(Ree,{}):t==="/node-studio"?o.jsx($ee,{}):t==="/flow"?o.jsx(ise,{}):t==="/workspace"?o.jsx(qK,{}):t.startsWith("/display")?o.jsx(nI,{}):t==="/settings"?o.jsx(bee,{authUser:e}):t==="/admin/usage"?o.jsx(Nee,{authUser:e}):t==="/feedback"?o.jsx(Cee,{authUser:e}):WI(t)?o.jsx(pI,{}):o.jsx(La,{})}function lse({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),[u,p]=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}),p(g.error?String(g.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(h.message||h))}};m.useEffect(()=>{f()},[]);const d=async h=>{h.preventDefault(),c(!0),p("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),b=await g.json().catch(()=>({}));if(!g.ok)throw new Error(b.error||"登录失败");n({loading:!1,authenticated:!0,user:b.user||null,setupRequired:!1})}catch(g){p(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:d,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"})]}),u?o.jsx("p",{className:"af-auth-error",children:u}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function cse({authUser:e,onLogout:t}){const{path:n}=ti(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(rse,{page:r?"flow":"projects"}):null,r?null:o.jsx(J2,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(ase,{authUser:e})}),o.jsx(sse,{})]})}function use(){return o.jsx(ose,{children:o.jsx(I2,{children:o.jsx(dse,{})})})}function dse(){const{path:e}=ti();return e.startsWith("/display")?o.jsx(nI,{}):WI(e)?o.jsx(pI,{}):o.jsx(lse,{children:({user:t,onLogout:n})=>o.jsx(cse,{authUser:t,onLogout:n})})}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 r1=document.querySelector('link[rel="icon"]');r1&&(r1.href=w_);Rg.createRoot(document.getElementById("root")).render(o.jsx(st.StrictMode,{children:o.jsx(use,{})}));